Relationships
#4882 Investigate replacing @babel/parser with oxc for parsing extension source
Opened by zack · 11/18/2026
Why
Every reader of extension source parses it with @babel/parser through parseExtensionModule in packages/extension-scoring/source/parse.ts: the shared import scan, the safety rules, the quality-ignore directive reader, the CLI's push and quality gates, and swamp-club's scorecard analysis. Babel parsing is now the dominant cost of the scan.
On @swamp/aws/ec2@2026.11.18.1 (253 code files, 142M characters, mostly esbuild bundles), swamp-club#4874 brings the scorecard import scan from 15.1s to 6.5s by parsing each module once and pruning the AST walk. Almost all of the remaining 6.5s is Babel parse time. A sound text pre-check cannot skip parses on this archive: every bundle contains .md text (runtimeConfig.md5) and regex escapes, so the parse cannot be avoided, only made faster.
What to investigate
Whether oxc (oxc-parser, Rust with Node/WASM bindings) can replace Babel as the extension source parser, and what it would cost.
- Speed. Benchmark oxc against Babel on the ec2 archive and a few typical extensions: parse alone, and parse plus the import scan. Compare the native binding with the WASM build. The compiled
swampbinary and swamp-club's server need whichever one runs under Deno (npm:specifiers,deno compile). - Syntax parity.
parseExtensionModulesets a specific configuration: legacy decorators with a TC39 retry,explicitResourceManagement,decoratorAutoAccessors, import attributes, source and defer phase imports, JSX by extension, CommonJS (.cjs,.cts) parsed as a sloppy script, error recovery for bundles, and the allow-everywhere flags. Check that oxc accepts and refuses the same modules. A module one parser refuses and the other accepts changes thesource-syntaxgate and the dependency audit's unreadable-module handling. - AST shape. oxc produces ESTree/TS-ESTree, not Babel's AST:
ImportExpressionagainstCallExpression(Import),TSImportTypeshape,StringLiteralagainstLiteral, and UTF-8 against UTF-16 offsets. List every consumer ofSyntaxNode(import scan, safety rules, directive reader,extension_source_ast.ts, the bare-import rewrite plan) and estimate the port. - Result parity. All shared vectors under
packages/extension-scoring/vectors/, the import property tests and swamp-club'stests/integration/extension_scoring_vectors_test.tsmust give identical results. Any difference moves scores, so it needs aRUBRIC_VERSIONdecision. - Supply chain. A native binding is a new kind of dependency for the CLI and the registry (prebuilt binaries per platform, deps audit). Weigh that against the speedup.
Outcome
A recommendation, with benchmark numbers and a parity report, to adopt oxc, adopt it only for the import scan, or stay on Babel.
Open
No activity in this phase yet.
Sign in to post a ripple.