Skip to content

feat(minify): close more oxc and swc gaps, keep with bodies free of flattened names - #22919

Merged
alexander-akait merged 7 commits into
mainfrom
feat/minify-more-gaps
Oct 26, 2026
Merged

alexander-akait merged 7 commits into
mainfrom
feat/minify-more-gaps

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes more of the size gaps between webpack's JS minifier and swc/oxc, and fixes a wrong output terser shares.

  • Fix (correct phase): a function called inside a with body was flattened into it, so its vars and parameters became names the with object could hold:

    // in: prints 3, then 5
    function f(o){with(o){(function(){var q=1;q+=o.n;console.log(q)})()}return o.q}console.log(f({q:5,n:2}))
    // main: prints 3, then 3
    function f(o){with(o)q=1,q+=o.n,console.log(q);var q;return o.q}…
    // this PR: prints 3, then 5
    function f(o){with(o)!function(){var n=1;n+=o.n,console.log(n)}();return o.q}…
  • New improve rewrites:

    • (a,0)&&b → (a,0), (a,1)&&b → (a,b) (|| alike).
    • In strict code, an arrow called in place to run eval is the call it makes.
    • A bare var moves into a later for…in/for…of head, and a var with a value joins a following for(var …) head.
    • Imported and exported names stay unmangled where that is at least 2 bytes shorter.
    • typeof of a function or class declaration nothing writes is "function", and a short constant read in a template is written into its text.
    • Literal arguments replace an in-place function's parameters, and […] is !1 after its effects.
    • asm.js statements made only of a constant or a function are dropped.
    • Names in a scope a with reaches, which no with body spells, are mangled.
  • correct phase: names whose values are numeric expressions are now known to hold numbers, so unread arithmetic on them is dropped.

Gap lists: swcSmaller.js −7, oxcSmaller.js −14, nothing added. Two IMPROVED_YET_BIGGER entries, each 3 or fewer bytes of gzip.

Input (compress: { passes: 2 }, mangle: true) main (raw/gzip) This PR (raw/gzip)
var k; if (o) for (k in o) … var o;if(f)for(o in f)…: 60/77 if(f)for(var o in f)…: 58/75

What kind of change does this PR introduce?

feat

Did you add tests for your changes?

Yes: test/unitCases/javascript/printer.unittest.js covers each rewrite and the cases that must stay unchanged. It also has a regression test for the with fix. The gap lists and IMPROVED_YET_BIGGER live in test/specCases/minify-corpora.spectest.js.

Does this PR introduce a breaking change?

No.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

docs/syntax.md (the syntax-printer.js bullet) describes the new rewrites.

Use of AI

Claude Code wrote the changes and tests. Four agents each triaged one family of gap-list entries. The results were merged and then checked with the printer unit tests, the full corpus suite, the minifier config cases, the fuzz seeds and yarn lint.


Generated by Claude Code

Summary by CodeRabbit

  • Improvements
    • Improved JavaScript minification across more expressions, function calls, template substitutions, and loop declarations. These optimizations can produce smaller output while preserving program behavior.
    • Improved handling of name mangling and variable references in with scopes, and expanded safe simplifications for typeof and asm.js code.
  • Documentation
    • Clarified the minifier options and the cases where these optimizations apply.

terser flattened such a call into the body, so its `var`s and parameters became names the `with` object could hold.

Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD
@changeset-bot

changeset-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2da6c6b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the area: parser JavaScript parsing and dependency analysis (lib/javascript, lib/dependencies) label Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR is packaged and the instant preview of its latest commit is available.

Install it locally:

  • npm
npm i -D webpack@https://pkg.pr.new/webpack@22919
  • yarn
yarn add -D webpack@https://pkg.pr.new/webpack@22919
  • pnpm
pnpm add -D webpack@https://pkg.pr.new/webpack@22919

@github-actions

Copy link
Copy Markdown
Contributor

Types Coverage

Coverage after merging feat/minify-more-gaps into main will be
99.27%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
bin
   webpack.js98.84%100%100%98.84%113
declarations
   WebpackOptions.ts99.94%100%100%99.94%4266
examples
   build-common.js100%100%100%100%
   buildAll.js100%100%100%100%
   examples.js100%100%100%100%
   template-common.js98.21%100%100%98.21%72
examples/custom-javascript-parser
   test.filter.js100%100%100%100%
examples/custom-javascript-parser/internals
   acorn-parse.js100%100%100%100%
   meriyah-parse.js100%100%100%100%
   oxc-parse.js100%100%100%100%
examples/markdown
   webpack.config.mjs100%100%100%100%
examples/module-federation
   test.filter.js100%100%100%100%
examples/reexport-components
   test.filter.js100%100%100%100%
examples/ssr
   test.filter.js100%100%100%100%
examples/typescript
   test.filter.js100%100%100%100%
examples/typescript-non-erasable
   test.filter.js50%100%100%50%5
examples/virtual-modules
   test.filter.js100%100%100%100%
examples/wasm-bindgen-esm
   test.filter.js100%100%100%100%
examples/wasm-complex
   test.filter.js100%100%100%100%
examples/wasm-emscripten
   test.filter.js100%100%100%100%
examples/wasm-simple
   test.filter.js100%100%100%100%
examples/wasm-simple-source-phase
   test.filter.js100%100%100%100%
lib
   Chunk.js100%100%100%100%
   Compilation.js98.74%100%100%98.74%1823, 2135, 2142, 2150, 2172, 2175, 3161, 3720, 3763, 4358, 4362, 4488, 4509, 4634, 4671, 4678, 4731–4732, 4736, 4741, 4757–4758, 4772–4773, 4778–4779, 5307, 5333, 6254, 6271, 6289, 6305, 6320, 6345, 6348, 6760, 6763–6764, 6769, 6784, 6867, 6891, 883–884
   Compiler.js98.81%100%100%98.81%1107, 1144, 1147, 1323–1324, 1332, 848, 932, 972
   Dependency.js100%100%100%100%
   DependencyTemplate.js100%100%100%100%
   EntryPlugin.js100%100%100%100%
   Entrypoint.js100%100%100%100%
   ExternalsPlugin.js100%100%100%100%
   FileSystemInfo.js100%100%100%100%
   InitFragment.js100%100%100%100%
   LibraryTemplatePlugin.js100%100%100%100%
   ModuleFilenameHelpers.js100%100%100%100%
   ModuleNotFoundError.js100%100%100%100%
   MultiCompiler.js98.91%100%100%98.91%489, 561, 748, 813
   NormalModule.js100%100%100%100%
   NullFactory.js100%100%100%100%
   ProgressPlugin.js100%100%100%100%
   RawModule.js100%100%100%100%
   RequestShortener.js100%100%100%100%
   SingleEntryPlugin.js100%100%100%100%
   WebpackError.js100%100%100%100%
   index.js100%100%100%100%
   webpack.js98.59%100%100%98.59%306, 308
lib/asset
   AssetBytesGenerator.js100%100%100%100%
   AssetBytesParser.js91.67%100%100%91.67%27
   AssetGenerator.js100%100%100%100%
   AssetModule.js100%100%100%100%
   AssetModulesPlugin.js98.45%100%100%98.45%334, 360, 363, 493, 58
   AssetParser.js96.15%100%100%96.15%47
   AssetSourceGenerator.js100%100%100%100%
   AssetSourceParser.js91.67%100%100%91.67%27
   RawDataUrlModule.js100%100%100%100%
   WebManifestGenerator.js100%100%100%100%
   WebManifestParser.js100%100%100%100%
lib/async-modules
   AsyncModuleHelpers.js100%100%100%100%
   AwaitDependenciesInitFragment.js100%100%100%100%
   InferAsyncModulesPlugin.js100%100%100%100%
   isGeneratorLowered.js100%100%100%100%
lib/bun
   BunTargetPlugin.js100%100%100%100%
lib/cache
   AddBuildDependenciesPlugin.js100%100%100%100%
   AddManagedPathsPlugin.js100%100%100%100%
   Cache.js98.25%100%100%98.25%104
   CacheFacade.js100%100%100%100%
   IdleFileCachePlugin.js97.92%100%100%97.92%75, 87, 95
   MemoryCachePlugin.js92%100%100%92%33, 42
   MemoryWithGcCachePlugin.js93.42%100%100%93.42%106, 120–121, 130, 88
   PackFileCacheStrategy.js96.54%100%100%96.54%1304, 1404, 1408, 1470, 1716, 1796, 1819, 1849, 684, 703, 713–715, 717, 733–734, 739, 742, 744, 749, 754, 779, 785, 819, 825, 831, 836, 847, 856, 861–862, 864, 881, 887–888, 890
   ResolverCachePlugin.js100%100%100%100%
   getLazyHashedEtag.js100%100%100%100%
   mergeEtags.js100%100%100%100%
lib/config
   OptionsApply.js100%100%100%100%
   PlatformPlugin.js100%100%100%100%
   WebpackOptionsApply.js100%100%100%100%
   WebpackOptionsDefaulter.js100%100%100%100%
   browserslistTargetHandler.js100%100%100%100%
   cli.js98.89%100%100%98.89%114, 549, 581, 631
   defaults.js99.59%100%100%99.59%1633–1635, 1643, 288, 548
   defineConfig.js100%100%100%100%
   getClaimedAssetTypes.js100%100%100%100%
   normalization.js99.14%100%100%99.14%285–286, 356, 371
   target.js100%100%100%100%
   validateSchema.js94.67%100%100%94.67%100, 87, 89, 98
lib/container
   ContainerEntryDependency.js100%100%100%100%
   ContainerEntryModule.js100%100%100%100%
   ContainerEntryModuleFactory.js100%100%100%100%
   ContainerExposedDependency.js100%100%100%100%
   ContainerPlugin.js100%100%100%100%
   ContainerReferencePlugin.js100%100%100%100%
   FallbackDependency.js100%100%100%100%
   FallbackItemDependency.js100%100%100%100%
   FallbackModule.js100%100%100%100%
   FallbackModuleFactory.js100%100%100%100%
   HoistContainerReferencesPlugin.js100%100%100%100%
   ModuleFederationPlugin.js100%100%100%100%
   RemoteModule.js100%100%100%100%
   RemoteRuntimeModule.js100%100%100%100%
   RemoteToExternalDependency.js100%100%100%100%
   declaredRemotes.js100%100%100%100%
   moduleFederationHooks.js100%100%100%100%
   options.js100%100%100%100%
lib/context
   ContextExclusionPlugin.js100%100%100%100%
   ContextModule.js99.88%100%100%99.88%1495
   ContextModuleFactory.js95.70%100%100%95.70%230, 257, 276, 280–281, 289, 466, 487, 492, 534, 543, 545, 549, 552, 558–559
   ContextReplacementPlugin.js100%100%100%100%
lib/css
   CssGenerator.js99.29%100%100%99.29%1085, 129, 305, 837
   CssInjectStyleRuntimeModule.js100%100%100%100%
   CssLoadingRuntimeModule.js100%100%100%100%
   CssModule.js100%100%100%100%
   CssModulesPlugin.js98.72%100%100%98.72%217, 418, 432, 445, 458, 481, 494, 507, 520
   CssParser.js99.76%100%100%99.76%1122, 2457, 3104, 3107, 3113, 3545, 975
   CssServerStylesRuntimeModule.js100%100%100%100%
   conventions.js100%100%100%100%
   cssMinify.js100%100%100%100%
   data.js99.84%100%100%99.84%229, 5605
   syntax-parser.js99.71%100%100%99.71%11104–11105, 11657–11658, 11695, 11905, 11954, 14388, 14449–14452, 14557–14558, 14656–14657, 15430, 15726, 15728, 16283, 16675, 16717, 19107, 3066, 3068, 3073, 3086, 3837, 3843
   syntax-printer.js99.33%100%100%99.33%2611–2612, 2614–2615, 2617–2618, 2623, 2893–2896, 2989, 356, 3690, 4115, 4251, 4928, 5242, 6134, 730
   syntax.js100%100%100%100%
   topologicalSort.js100%100%100%100%
lib/debug
   ProfilingPlugin.js100%100%100%100%
lib/define
   DefinePlugin.js99.42%100%100%99.42%1488, 936, 938, 943, 967
   DotenvPlugin.js97.61%100%100%97.61%276, 395, 443, 456–457
   EnvironmentPlugin.js100%100%100%100%
lib/deno
   DenoTargetPlugin.js100%100%100%100%
lib/dependencies
   ConstDependency.js100%100%100%100%
   ContextElementDependency.js100%100%100%100%
   NullDependency.js100%100%100%100%
lib/dependencies/amd
   AMDDefineDependency.js100%100%100%100%
   AMDDefineDependencyParserPlugin.js100%100%100%100%
   AMDPlugin.js99.31%100%100%99.31%54
   AMDRequireArrayDependency.js100%100%100%100%
   AMDRequireContextDependency.js100%100%100%100%
   AMDRequireDependenciesBlock.js100%100%100%100%
   AMDRequireDependenciesBlockParserPlugin.js100%100%100%100%
   AMDRequireDependency.js100%100%100%100%
   AMDRequireItemDependency.js100%100%100%100%
   AMDRuntimeModules.js95.45%100%100%95.45%65
   LocalModule.js100%100%100%100%
   LocalModuleDependency.js100%100%100%100%
   LocalModulesHelpers.js100%100%100%100%
   RequireJsStuffPlugin.js100%100%100%100%
   UnsupportedDependency.js100%100%100%100%
lib/dependencies/commonjs
   CommonJsDependencyHelpers.js98.63%100%100%98.63%43
   CommonJsExportRequireDependency.js99.21%100%100%99.21%413, 415, 417
   

@github-actions

Copy link
Copy Markdown
Contributor

Generated code size

Comparing base (11a1ebd) to head (2da6c6b). Merging this pull request changes the size of 3 asset(s) whose tests it leaves untouched.

What moved Tests Assets Gzip Raw Test edit
Changed, test untouched 1 3 🟢 ↓ -2 B 🟢 ↓ -6 B —
Changed, test edited 0 0 — — —
New 0 0 — — —
Deleted 0 0 — — —
Unchanged — 9252 — — —

Read Changed, test untouched first: the test is byte-identical on both sides, so webpack generated the difference. Changed, test edited moved partly because the test did — Test edit is how many bytes the test gained, and a bundle that grew by less is not a regression. New and Deleted are whole files, not deltas — a new asset was created, not grown, so it reads gray (⚪ added) — and adding tests cannot bury a real change. Gzip decides, because that is what users download; raw is the tiebreak, and brotli and zstd are per asset below.

3 asset(s) changed size, test untouched
Asset Before After Change Gzip (9) Brotli (11) Zstd (19)
🟢 ↓ optimization/minify-oxc-syntax-gaps 1/bundle1.js 1.74 KiB 1.74 KiB -2 B (-0.11%) -1 B (-0.13%) +9 B (+1.27%) -3 B (-0.38%)
🟢 ↓ optimization/minify-oxc-syntax-gaps 2/bundle2.js 1.76 KiB 1.76 KiB -2 B (-0.11%) -1 B (-0.13%) -2 B (-0.28%) —
🟢 ↓ optimization/minify-oxc-syntax-gaps 3/bundle3.js 1.84 KiB 1.84 KiB -2 B (-0.11%) — -2 B (-0.27%) +3 B (+0.37%)

No runtime gained or lost a runtime module.

Built test/configCases with the defaults a user gets: 2296 test(s), 9255 asset(s), 102 emitted nothing.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 11a1ebd and 2da6c6b.

Files ignored due to path filters: 1
  • test/unitCases/javascript/__snapshots__/printer.unittest.js.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
Files selected for processing: 8
  • .changeset/067-minify-more-gaps.md
  • docs/syntax.md
  • lib/javascript/ScopeAnalyzer.js
  • lib/javascript/syntax-printer.js
  • test/helpers/oxcSmaller.js
  • test/helpers/swcSmaller.js
  • test/specCases/minify-corpora.spectest.js
  • test/unitCases/javascript/printer.unittest.js
Files with no reviewable changes: 1
  • test/helpers/swcSmaller.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The compressor adds expression-folding, call-inlining, and loop-declaration optimizations. Scope analysis and mangling now track names referenced in with bodies. Tests, comparison records, documentation, and a Changeset describe or cover these changes.

Changes: JavaScript minification

Layer / File(s) Summary
Expression evaluation and folding
lib/javascript/syntax-printer.js, test/unitCases/javascript/printer.unittest.js, test/helpers/oxcSmaller.js, test/helpers/swcSmaller.js, test/specCases/minify-corpora.spectest.js, docs/syntax.md, .changeset/067-minify-more-gaps.md
Primitive classification and expression optimization cover additional constant, template, typeof, and logical-expression cases. Tests and comparison records cover the changed cases. The documentation and Changeset describe minification behavior and release changes.
Name handling in with scopes
lib/javascript/ScopeAnalyzer.js, lib/javascript/syntax-printer.js, test/unitCases/javascript/printer.unittest.js, test/helpers/oxcSmaller.js, test/helpers/swcSmaller.js
Both scope analyzers can collect names referenced in with bodies. Mangling uses the collected names, and inlining avoids moving certain functions into with bodies. Tests cover name resolution and mangling behavior.
Call inlining and asm.js statements
lib/javascript/syntax-printer.js, test/unitCases/javascript/printer.unittest.js, test/helpers/oxcSmaller.js, test/helpers/swcSmaller.js
Eligible calls support literal-argument substitution and strict-mode direct-eval handling. The compressor removes eligible constant and function expression statements in asm.js scopes.
Loop declaration placement
lib/javascript/syntax-printer.js, test/unitCases/javascript/printer.unittest.js, test/helpers/oxcSmaller.js, docs/syntax.md
Declaration movement covers eligible for…in/for…of loops and following for initializers. Tests cover cases where declarations remain outside loop heads.

Possibly related PRs

Suggested labels: area: parser

Suggested reviewers: aryanraj45

Priority: Normal

Change: Feature

Merge Risk: Minimal · up to 2da6c

The minification changes have no established merge-blocking issue and are mergeable subject to normal checks.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Inconclusive The title uses the required Conventional Commit form and describes the minification changes. The branch prefix is not provided, so the required type-to-branch-prefix match cannot be verified. Provide the branch name or confirm that its prefix is feat. If confirmed, the title passes this check.
Passed Passed checks: 3 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 ast-grep (0.45.3)
test/unitCases/javascript/printer.unittest.js

ast-grep timed out on this file

lib/javascript/syntax-printer.js

ast-grep timed out on this file

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codspeed

codspeed Bot commented Oct 26, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 33.44%

2 warnings, 1 note

⚠️ 117 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

ℹ️ 46 benchmarks have no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 2 improved benchmarks
✅ 349 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Memory benchmark "no-concatenation", scenario '{"name":"mode-production","mode":"production"}' 1,218.8 KB 833 KB +46.32%
⚡ Memory benchmark "realistic-app", scenario '{"name":"mode-production","mode":"production"}' 2.5 MB 2.1 MB +21.7%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/minify-more-gaps (2da6c6b) with main (11a1ebd)

Open in CodSpeed

@alexander-akait
alexander-akait merged commit 55be23a into main Oct 26, 2026
70 checks passed
@alexander-akait
alexander-akait deleted the feat/minify-more-gaps branch October 26, 2026 06:49
alexander-akait added a commit that referenced this pull request Oct 26, 2026
…und (#22903)

* fix(html): cover the printer from its own tests and fix what that found

Prints that re-parsed to a different tree, now each printed so the tree
comes back the same:
- content after a `<plaintext>` no longer gets end tags that read as
  text; a script left double-escaped at EOF gets no `</script>`;
- a `<?pi>` keeps the shell tags around it, as a comment does;
- `<body>` stays before a head element, a `<noscript>`, a template or
  whitespace collapsing removes; `<html>` in foreign content keeps its
  start tag; `<tbody>`/`<colgroup>` in template content and `</caption>`
  before a script are kept;
- nested forms, text fostered out of a table and merged into earlier
  text, and fragment prints (whitespace under the root, a stray `<html>`,
  non-body contexts) are re-parsed and fall back to the source.
A streamed walk starting after a `</form>` no longer visits out of
order, `skipChildren()` while printing no longer writes `undefined`, and
`<tr> <table><tr><option><li>` no longer throws.

The printer tests now reach every statement and branch of the HTML
printer and minifier; checks no input could fail are folded away.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* fix(html): cover the insertion modes from the parser tests too

The parser tests' earlier reach left out the insertion modes (`modes.*`),
which are assigned after `const modes = {}`; they now reach every
statement and branch of those too, and two trees were wrong:
- an `<a>` start tag ran the adoption agency, then removed the first
  `a` anywhere in the active formatting list, which can be one below a
  marker: in `<a>1<marquee><a>2<a>3</marquee>4` the outer link was lost.
- in a head `<noscript>` with scripting off, the whitespace before other
  text went to the head after it; the mode now splits it off first, as
  in head and after head do.
Checks the stack and list invariants rule out (an `<html>` at the bottom
of every scope, a formatting element still listed after the inner loop,
a detached node always among its parent's children, …) are folded away.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* fix(css): cover the printer from its own tests and fix what that found

Prints that changed what a sheet means, or threw:
- `background-position` with an empty layer printed `undefined` and
  turned a value the browser drops into one it applies;
- a `url()` holding two strings was rebuilt as one valid url;
- `@supports ((display:grid) {…}` cut short lost its outer `(`, so the
  block opened and the rule applied;
- box longhands holding a word the longhand does not read were merged
  into a shorthand the browser drops whole (and the shorthand lowered
  into partly valid longhands);
- `escapeIdentifier` wrote U+0001–U+001F/U+007F raw and a lone `-` bare;
  `normalizeUrl` decoded `\1F600` as U+F600 and `\110000` as U+0000;
- nesting lowered inside a block big enough to stream lost the hoisted
  rules (an empty sheet for a 4000-rule block);
- `skipChildren()` while printing, `color-mix()` with an empty argument
  and `as: "block-contents"` with a nested or streamed block threw.

The printer tests now reach every statement and branch of
syntax-printer.js and every printer function in syntax-parser.js; checks
no input could fail are folded away.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* fix(css): cover the rest of the printer and fix what that found

Ordered and deduplicated layer gathers, empty @layer blocks no longer
stop later joins, value-less grid longhands no longer merge, and an
unquoted url no longer reads as a comment when scanning layer text.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* fix(javascript): cover the printer from its own tests and fix what that found

Nested IIFE run-in-place crash, uncompilable RegExp() under unsafe,
folding patched builtins, global_defs on an exported binding,
RegExp.$1 under unsafe, ESTree shorthand __proto__, and spidermonkey
directive values.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* fix(javascript): reach more of the printer and fix what that found

A join of one hole, hoist_vars across a block with let, a computed
__proto__ key under unsafe, and new RegExp(/a/g) losing its flags.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* chore: add the printer changeset and fix the type check

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* fix(css): lower an inset of a lone CSS-wide keyword again

The box-slot check refused `inset:inherit`, which every longhand reads;
a keyword beside another value still stays, as the target drops it.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* fix(javascript): keep the literal a built-in method is called on

A computed read like `[1]['concat']` rewritten to a dot read lost its
receiver's elements, as the call guard compared the rewritten read with
the one its parent calls.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* test(javascript): read a duplicate-named regular expression by the runtime

Duplicate group names in alternatives compile on newer runtimes only, so
whether its `source` folds follows the runtime the test runs on.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* fix(css): tell a quoted url from an unquoted one past leading whitespace

The lookahead backtracked into the whitespace, so `url( "a)b")` read
as unquoted.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* fix(javascript): read the global object as handed on only where it may be, and run the printer tests on Bun

A binding nothing reads, a literal's method and a module's function leak
no global object, which kept swc's corpus bigger. The printer tests
compare runtime output only where the engine compiles the source, read
engine errors by type, and skip what a small stack stops.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* perf(html): read back only the fragments a body does not read alike

Every fragment's print was parsed again to check it, which doubled the
cost of one in a `tr`; foreign, `select` and raw-text contexts still are.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* test(javascript): leave acorn's deepest program out where Bun's stack is small

Bun runs a test in a worker whose stack no parser gets 2000 levels deep
in, which every corpus test now reads from one list.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* fix(javascript): keep a nested index map's section that ends past the outer one

A section's stop clamped the outer stop's column to the next section's
even where that one started on a later line, which cut a nested map's
first source to nothing; terser's source-map reader does the same.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* test(css): read a visitor's replace and remove through the printer's own tests

#22906's edits are written out by the printer, which its own tests now
read, a replaced node holding a replaced one included.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* test(javascript): take the printer's snapshots as main's new passes write them

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* fix(css): read past the comments after a visitor stops the walk

stop() drops the comment bucket while the node it is in still tokenizes,
so on a walk that prints nothing the next comment read a bucket it no
longer had and threw. The guard folded as dead is back, with its tests.

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP

* test(javascript): take the printer's snapshots as #22919's passes write them

Claude-Session: https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: parser JavaScript parsing and dependency analysis (lib/javascript, lib/dependencies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant