WIP: feat(lexer): report glob n for interpolated template dynamic imports#205
Draft
BridgeAR wants to merge 1 commit into
Draft
Conversation
A dynamic import whose entire argument is a template literal with substitutions
returned n: undefined, so a consumer resolving the specifier (a bundler or glob
importer) had nothing to work with. It now reports the static skeleton as a
glob with each ${...} collapsed to a single "*": import(`./locales/${x}.js`)
yields "./locales/*.js".
Only a lone template literal qualifies. A template concatenated with anything
else (import(`a` + b)) has no static skeleton and still returns undefined.
Fixes: guybedford#137
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.
Summary
A dynamic import whose entire argument is a template literal with substitutions returned
n: undefined, so a consumer resolving the specifier (a bundler or glob importer) had nothing to work with. It now reports the static skeleton as a glob with each${...}collapsed to a single*:import(`./locales/${locale}.js`)yields./locales/*.js. Only a lone template literal qualifies — a template concatenated with anything else (import(`a` + b)) has no static skeleton and still returnsundefined.The change lives entirely in the three decoders (WASM
src/lexer.ts, asm.jssrc/lexer.asm.js, pure-JSlexer.js);src/lexer.cis untouched, since the parser already produces the correct specifier range and still descends into${ ... }for nested-import detection. Source-only — the generatedlib/artifacts are left for the build.Test plan
Dynamic import interpolated template specifier globtest covers multi-substitution, leading/trailing/whole substitution, escapes, string/comment/nested-template interpolation bodies, attribute-following, and the concatenation negatives.WIP / draft: opening early for CI and review feedback.
Fixes: #137