feat: minimal build variant for es-module-shims#211
Merged
Conversation
Adds a LEXER_MIN build variant that drops the metadata es-module-shims never reads, exposed as two new package entry points alongside the existing full builds: - es-module-lexer/minimal -> dist/lexer.minimal.js (wasm) - es-module-lexer/minimal/js -> dist/lexer.minimal.asm.js (asm.js) Gated behind -DLEXER_MIN in the C source and a build-time MINIMAL flag in the readers (folded out by terser). Dropped: - the parsed import attribute list `at` (Attribute struct + ra/aks/ake/ avs/ave getters); assertions remain recoverable via source.slice(a, se-1) - export statement_start `ss` / ess() - the facade f() / hasModuleSyntax ms() flags (+ the bool) - the module-only facade fast path Imports keep n,s,e,ss,se,d,t,a; exports keep n,s,e,ls,le,ln. parse() returns a 2-tuple in the minimal build. Footprint (brotli): wasm 7,113 -> 6,648B, asm 6,865 -> 6,486B. Shared build steps extracted to build/*.mjs; the full build is unchanged (byte-for-byte). The test suite runs against both variants (MINIMAL=1) with min-only-field assertions gated; bench and footprint cover the full 2x2 matrix.
3 tasks
guybedford
added a commit
that referenced
this pull request
Jul 2, 2026
…e readme (#219) The minimal wasm build added in #211 predates the #217 memory growth fix and was missing -s ALLOW_MEMORY_GROWTH=1, so parse() on sources over ~4M chars threw "Maximum memory size exceeded" (the Large source test from #217 catches this under test:minimal:wasm). Also documents the es-module-lexer/minimal build in the readme, and corrects the stale comments claiming dynamic-import n / ip() are dropped in the minimal build: _ip is exported and read, only at/ss/f/ms go.
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
Adds a stripped
LEXER_MINbuild variant tuned for es-module-shims, which only consumes a subset of the lexer's output. Two new package entry points sit alongside the existing full builds:es-module-lexer/minimaldist/lexer.minimal.jses-module-lexer/minimal/jsdist/lexer.minimal.asm.jsWhat it drops
Verified against the es-module-shims core — the minimal build removes only what shims never reads, gated behind
-DLEXER_MINin C and a build-timeMINIMALflag in the readers (folded out by terser):at(theAttributestruct +ra/aks/ake/avs/avegetters) — assertions stay recoverable viasource.slice(a, se - 1)statement_start(ss) /ess()facade(f()) /hasModuleSyntax(ms()) flags and the underlying boolf()is gone)Imports keep
n, s, e, ss, se, d, t, a; exports keepn, s, e, ls, le, ln.parse()returns a 2-tuple in the minimal build.Footprint (brotli)
dist/lexer.js)dist/lexer.asm.js)lib/lexer.wasm(raw)Build / tooling
build/*.mjs(asm prelude, asm combine, wasm embed, minimal d.ts); the full build is unchanged byte-for-byte.types/lexer.minimal.d.ts(re-exports the shared types, overridesExportSpecifierminusssand the 2-tupleparse).MINIMAL=1), with min-only-field assertions gated behind!min.benchandfootprintcover the full 2×2 (full/minimal × wasm/asm) matrix.Test plan
chomp buildproduces all 6 dist files + both d.tschomp test— 147 passing across all four suites (full/minimal × wasm/asm)tsc --strictslice(a, se-1)in the minimal build🤖 Generated with Claude Code