Repository navigation
feat: minimal build v3 API cleanup, literal ImportType, README restructure - #240
Merged
Merged
Conversation
Drops the always-null `at` field from minimal import records, makes
`ImportType` a type-only const enum with no runtime export, and reports the
imported name of `export { a as b } from 'c'` in the minimal build's
`ln` / `ls` / `le` rather than erasing it, matching the full build's
importName fields.
guybedford
force-pushed
the
minimal-v3-api
branch
from
September 7, 2026 05:17
74e3002 to
6ac8bd2
Compare
* README: package exports table carries footprint and cold / warm parse speed per MB; environment support, CSP and usage move to the top with the minimal build documented before the full build; the WASI build steps are removed in favour of the two emsdk checkouts the build installs itself. * `chomp bench` runs all four builds in one process and prints the per-MB table the README uses. * The generated `types/` declarations are tracked so the README can link to them. * `initSync` is internal only: `parse` initializes on first use and `init` covers browser main threads, so nothing needs to call it. The asm.js builds export `init` so all four entry points share one API.
guybedford
force-pushed
the
minimal-v3-api
branch
from
September 7, 2026 05:18
6ac8bd2 to
f0d245e
Compare
Each test lane builds only its own dist, so the export parity test now checks the module under test rather than importing all four. The README no longer claims the minimal build tags `export * from` with `t === 8`; it reports the plain static `1`.
`ImportType` is a union of named numeric literal type aliases (`StaticImportType = 1`, `DynamicImportType = 2`, ...) rather than an ambient const enum, so nothing is importable at runtime by mistake under single-file transpilers and type stripping. Dynamic import records type `attributes` as `null`: the options argument is not parsed, only located by `attributesStart`. README footprints match `chomp footprint`.
Merged
guybedford
added a commit
that referenced
this pull request
Sep 7, 2026
## Breaking * **Full build records are tagged unions** discriminated by `type` (`static` | `reexport-star` | `dynamic` | `import-meta`; `direct` | `reexport` | `reexport-all`) with descriptive fields (`specifier`, `importStart`/`importEnd`, `attributes`, `phase`, `name`, `localName`, `from`, `importIndex`, `exportStart`) replacing the terse v2 names and numeric type tags. (#233) * **`es-module-lexer/minimal`** is a new entry point holding the v2-shaped API: `parse` returns `[imports, exports]` only; `at` is dropped (read attributes via `source.slice(a, se - 1)`); `export { a as b } from 'c'` reports the imported name in `ln`/`ls`/`le`. (#211, #240) * **`ImportType`** is a type-only union of named numeric literal aliases (`StaticImportType = 1`, `DynamicImportType = 2`, …); no runtime enum is exported. `initSync` is no longer exported — `parse` initializes on first use. (#240) * **`es-module-lexer/js`** is the asm.js build; the unmaintained pure-JS port is removed. (#204) * Invalid escape sequences in static specifiers throw a parse error instead of yielding `undefined`. (#238) * Node.js 18+ is required. (#232) ## Features * **TypeScript**: type-only imports, exports, aliases, interfaces and ambient declarations are lexed as accepted by Node.js type stripping; type-only edges carry `typeOnly`, dynamic imports carry a best-effort `probablyTypeOnly`, and erased declaration bodies never leak nested `import()` types. Full builds only. (#220, #241) * **Export origin analysis**: reexports resolve to their originating import (`importName`, `from`, `importIndex`) regardless of statement order; `export * from` appears in `exports` as `reexport-all` and its import as `reexport-star`. (#229) * **Template globs**: a dynamic import whose argument is a single template literal reports a glob specifier with each `${…}` collapsed to `*` (`./locales/*.js`), disambiguated by the parser so regex/division inside substitutions is handled. (#205) * Dynamic import `attributes` is typed `null`; the options argument is located by `attributesStart`. (#240) * `parse` initializes the Wasm synchronously on first call; `await init` is only required on browser main threads, and all four entry points export the same `parse` / `init` API. (#237, #240) ## Performance * SIMD scanning for long line comments and templates in the full Wasm build (the minimal build stays Wasm MVP). (#231, #235) * Identifier and number runs are skipped in bulk: ~15% faster sweeps across Wasm and asm.js. (#227) * Module strings decode without `eval`: one-import parse 354 → 238 ns, and the Wasm builds now work under `--disallow-code-generation-from-strings`. (#239) * Short sources (< 64 chars) copy via the typed-array loop rather than `Buffer`. (#242) * Strict specifier decoding avoids V8's sloppy/strict cache mismatch. (#220) ## Fixes * Bounds checks on the open-token and dynamic-import stacks; nesting past 1024 brackets or 512 dynamic imports is a parse error rather than memory corruption. (#243) * Unannotated `declare let`/`var` and shorthand `declare module 'm'` no longer erase the following statement; `export default interface Foo {}` reports `Foo` as its local name. (#241) * Typed export binding lists collect every declarator; `export { type as }` / `type as as` follow TypeScript's specifier table; U+00A0 is whitespace around import/export names. (#220) * Minimal build enforces Wasm MVP (no post-MVP features) and is tested in Firefox 67. (#234) ## Docs & tooling * README restructured: package exports table with Brotli footprint and cold/warm parse speed per MB, environment/CSP/usage up front, minimal-build "Upgrading from v2" section, WASI build steps replaced by the emsdk checkouts the build installs itself. (#240) * `chomp bench` runs all four builds in one process and prints the README table; generated `types/` are tracked in the repo. (#240) * TypeScript differential fuzzer against `stripTypeScriptTypes` in CI; no-eval lanes for minimal and CommonJS. (#220, #239)
guybedford
added a commit
that referenced
this pull request
Sep 7, 2026
…cture (#240) * feat: minimal build v3 API cleanup Drops the always-null `at` field from minimal import records, makes `ImportType` a type-only const enum with no runtime export, and reports the imported name of `export { a as b } from 'c'` in the minimal build's `ln` / `ls` / `le` rather than erasing it, matching the full build's importName fields. * docs: minimal build upgrading from v2 * docs: restructure the README, track types, drop initSync * README: package exports table carries footprint and cold / warm parse speed per MB; environment support, CSP and usage move to the top with the minimal build documented before the full build; the WASI build steps are removed in favour of the two emsdk checkouts the build installs itself. * `chomp bench` runs all four builds in one process and prints the per-MB table the README uses. * The generated `types/` declarations are tracked so the README can link to them. * `initSync` is internal only: `parse` initializes on first use and `init` covers browser main threads, so nothing needs to call it. The asm.js builds export `init` so all four entry points share one API. * test: check the lane's own entry point exports Each test lane builds only its own dist, so the export parity test now checks the module under test rather than importing all four. The README no longer claims the minimal build tags `export * from` with `t === 8`; it reports the plain static `1`. * feat: literal ImportType aliases, null dynamic attributes, README sizes `ImportType` is a union of named numeric literal type aliases (`StaticImportType = 1`, `DynamicImportType = 2`, ...) rather than an ambient const enum, so nothing is importable at runtime by mistake under single-file transpilers and type stripping. Dynamic import records type `attributes` as `null`: the options argument is not parsed, only located by `attributesStart`. README footprints match `chomp footprint`. * fix: import the shared types the minimal declarations use
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.
This applies the v3 minimal build API changes that mirror the full build record changes at zero footprint cost, and lands the v3 README restructure and the remaining public API cleanups that came out of reviewing it.
Minimal build (
es-module-lexer/minimal):atis dropped from import records. It was alwaysnull; attributes are read viasource.slice(a, se - 1)as before.export { a as b } from 'c'reportsln: 'a'withls/lespanning the imported name instead of erasing them toundefined/-1, matching the full build'simportNamefields. The minimal wasm drops its erasure branch. Namespace reexports andexport *are unchanged.Shared API:
ImportTypeis a union of named numeric literal type aliases (StaticImportType = 1,DynamicImportType = 2, ...) rather than a runtime enum, so nothing is importable at runtime by mistake under single-file transpilers or type stripping. This removes the enum object from the wasm bundles.initSyncis internal only:parseinitializes on first use andinitcovers browser main threads. The asm.js builds exportinitso all four entry points share the sameparse/initAPI, with a test asserting it per lane.attributesasnull: the options argument is not parsed, only located byattributesStart.README and tooling:
chomp footprint) and cold / warm parse speed per MB; environment support, CSP and usage move to the top, with the minimal build documented before the full build; the WASI build steps are replaced by the two emsdk checkouts the build installs itself.chomp benchruns all four builds in one process and prints the per-MB table the README uses.types/declarations are tracked so the README can link to them.Brotli sizes:
lexer.minimal.js7522 → 7351 B,lexer.min.wasm4536 → 4523 B,lexer.js15168 → 15076 B (before the README size figures were refreshed againstchomp footprint).Test coverage: the shared suites assert the imported name for every reexport in both builds (the full build
im/ims/imefields mapped through the export assertion helper), minimal records are asserted to have noat, each lane checks its entry point exports exactlyparseandinit, and the type test coversImportTypenarrowing, the rejected literal9, and the absent minimalat.