Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[AssetMapper] Rewrite relative paths in export ... from statements#64208

Open
ousamabenyounes wants to merge 1 commit into
symfony:6.4from
ousamabenyounes:fix/issue-64183
Open

[AssetMapper] Rewrite relative paths in export ... from statements#64208
ousamabenyounes wants to merge 1 commit into
symfony:6.4from
ousamabenyounes:fix/issue-64183

Conversation

@ousamabenyounes
Copy link
Copy Markdown
Contributor

@ousamabenyounes ousamabenyounes commented May 14, 2026

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #64183
License MIT

JavaScriptImportPathCompiler's IMPORT_PATTERN only matches import /
import(...) statements. export * from './x.js' and export { foo } from './x.js'
re-exports are not captured, so the browser receives the original relative path
(unhashed) and 404s on the asset.

Reproduces with

Plain regex test (no PHPUnit needed) on the current 6.4 HEAD pattern:

input: "export * from './other.js';"
preg_match_all(IMPORT_PATTERN, input, $m)  -> 1 raw match, no capture group ($m[1] empty)
=> compile() early-returns, path stays "./other.js"

With the patch, $m[1] captures ./other.js, the path is rewritten through
findAssetForRelativeImport() and emitted as the versioned public path.

Fix

Extend the alternation block in IMPORT_PATTERN with an export branch that
requires a from clause (so plain export const x = 1; is correctly skipped):

export\s+
    (?:\*(?:\s*as\s+\w+)?|[\w\s{},*]+)
    \s*from\s*

This mirrors the existing import\s*(...)?\s*from\s* structure and reuses the
same trailing path-capture group.

Tests

5 new data-provider entries in provideCompileTests():

Case Input
static_export_star_from export * from './other.js';
static_export_named_from export { myFunction } from './other.js';
static_export_multiple_named_from export { myFunction, myOtherFunction } from './other.js';
static_export_star_as_namespace_from export * as myModule from './other.js';
export_const_without_from_is_ignored export const foo = 1;\nexport { bar } from './other.js'; (only the second matches)

Verified locally via docker run php:8.4-cli: 5/5 RED on the upstream/6.4
regex, 5/5 GREEN with the patch; plain export const x = 1; stays 0/0 on both.

Fixes #64183.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants