[AssetMapper] Rewrite relative paths in export ... from statements#64208
Open
ousamabenyounes wants to merge 1 commit into
Open
[AssetMapper] Rewrite relative paths in export ... from statements#64208ousamabenyounes wants to merge 1 commit into
export ... from statements#64208ousamabenyounes wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JavaScriptImportPathCompiler'sIMPORT_PATTERNonly matchesimport/import(...)statements.export * from './x.js'andexport { 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:
With the patch,
$m[1]captures./other.js, the path is rewritten throughfindAssetForRelativeImport()and emitted as the versioned public path.Fix
Extend the alternation block in
IMPORT_PATTERNwith anexportbranch thatrequires a
fromclause (so plainexport const x = 1;is correctly skipped):This mirrors the existing
import\s*(...)?\s*from\s*structure and reuses thesame trailing path-capture group.
Tests
5 new data-provider entries in
provideCompileTests():static_export_star_fromexport * from './other.js';static_export_named_fromexport { myFunction } from './other.js';static_export_multiple_named_fromexport { myFunction, myOtherFunction } from './other.js';static_export_star_as_namespace_fromexport * as myModule from './other.js';export_const_without_from_is_ignoredexport 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.4regex, 5/5 GREEN with the patch; plain
export const x = 1;stays 0/0 on both.Fixes #64183.