Skip to content

WIP: feat(lexer): report glob n for interpolated template dynamic imports#205

Draft
BridgeAR wants to merge 1 commit into
guybedford:mainfrom
BridgeAR:BridgeAR/2026-06-22-dynamic-import-template-glob
Draft

WIP: feat(lexer): report glob n for interpolated template dynamic imports#205
BridgeAR wants to merge 1 commit into
guybedford:mainfrom
BridgeAR:BridgeAR/2026-06-22-dynamic-import-template-glob

Conversation

@BridgeAR

Copy link
Copy Markdown
Contributor

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 returns undefined.

The change lives entirely in the three decoders (WASM src/lexer.ts, asm.js src/lexer.asm.js, pure-JS lexer.js); src/lexer.c is untouched, since the parser already produces the correct specifier range and still descends into ${ ... } for nested-import detection. Source-only — the generated lib/ artifacts are left for the build.

Test plan

WIP / draft: opening early for CI and review feedback.

Fixes: #137

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Glob imports don't parse

1 participant