Repository navigation
Conversation
* build(deps-dev): update dev dependencies to latest The TypeScript and mocha majors each break a build step unless paired with a change here: 1. `build:types` errored on `Buffer` — TypeScript 6 no longer auto-includes @types/node for a file passed on the tsc command line, so the call now passes `--types node`. 2. The unit suite threw `ReferenceError: beforeEach is not defined` at load — mocha 11's tdd UI dropped the bdd `beforeEach`, so its two hooks use the tdd `setup` alias. * fix(bench): update kleur to v4 function-call chaining API --------- Co-authored-by: Guy Bedford <guybedford@gmail.com>
…d#201) * fix: report n for no-substitution template dynamic imports A dynamic import whose specifier is a no-substitution template literal (import(`./x.js`)) returned n: undefined, while the quoted forms returned the specifier. A template with no ${...} is a constant string, so it now records a safe specifier the same as a quoted one; an interpolated template has no constant value and still returns undefined. This surfaces with minified Rolldown bundles, which rewrite dynamic-import specifiers to template literals. readString tolerates raw line breaks for a backtick quote, since template literals permit them and string literals do not. Drive-by fix: * The JS fallback recorded the specifier start before skipping leading whitespace/comments, so import(/* c */ "x") mis-decoded n; it now records the start after, matching the C lexer. Fixes guybedford#198 * fix: tolerate template line breaks in asm.js specifier decoder The asm.js wrapper decodes the dynamic-import specifier with its own readString copy, which still rejected raw line breaks. A multi-line no-substitution template threw a parse error on the asm.js build while WASM and the JS fallback decoded it. Apply the same backtick exception. --------- Co-authored-by: Guy Bedford <guybedford@gmail.com>
The export lexer stopped at the first `= initializer`, so later declarators
were dropped (`export const a = 1, b = 2` reported only `a`), and the
destructuring path reported property keys instead of bound names
(`export const { a: b } = x` reported `a`) and dropped defaults, nested
patterns, rest elements and trailing declarators.
Initializers and defaults are now skipped expression-aware, so a comma inside
one never splits the binding list, and the list ends at `;`, EOF or an ASI
line break — the statement after an automatic semicolon is never read as
another binding.
A binding list that reaches EOF mid-declaration (`export const`,
`export let a,`) no longer scans past the source terminator into the analysis
heap and reports a phantom export: the var/let/const loop now stops at `end`,
matching the destructuring-pattern loop.
Drive-by fix:
* The JS fallback matched char code 109 (`m`) for the `let` keyword instead of
108 (`l`), so `export let` parsed no names there; the C lexer was correct.
The tracked lib/ artifacts last matched src/lexer.c at cc29c5b (guybedford#195). Two later commits changed the C source without rebuilding them, leaving the committed artifacts inconsistent with the sources they are generated from: 1. 0259739 (guybedford#201) — no-substitution template dynamic-import specifiers. 2. e139948 — export var/let/const binding detection. Regenerate with the pinned wasi-sdk 12 + emscripten 1.40.1-fastcomp toolchain.
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.Test plan
chomp testgreen on both shipped builds (wasm + asm.js), 141 passing each.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.Notes
WIP / draft: based on
origin/main, so the PR currently also carries three sibling commits not yet inmain— guybedford#200 (dev-deps), guybedford#201 (no-substitution template specifiers), and the export binding-detection fix — which this work depends on. Thelib/artifact rebuild is a separatechorecommit.Fixes: guybedford#137