GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(javascript): read the minifier's comments and tokens off arrays, not terser's objects by alexander-akait · Pull Request #23039 · webpack/webpack

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Oct 31, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Summary

First step of moving the JavaScript printer off terser's shapes and onto arrays like the CSS and HTML ones:

  1. Nodes are typed as the SyntaxTree numbers they are. The ESTree-shaped Print* typedefs, which every use cast a number to, are gone, along with the mangling recording that only the deleted patchRecording read.
  2. Comments and tokens are read off per-parse arrays. Before, each comment was a ParsedToken object, comments came in arrays shared between tokens, and SourceToken objects were built for readers. Now:
    • a comment is a number;
    • a gap's or a parenthesis's comments are a list number;
    • the stream marks what it printed in two byte arrays instead of a Set of objects;
    • a comments callback is still handed terser's comment shape (type, value, pos, line, col, nlb, file), built when it is called.

Output is byte-identical: code, source maps and every comments callback call (arguments included) match before and after. That covers 14,308 runs: 511 sources holding comments × 7 comment settings × print-only/full minify × script/module.

lodash.js, every comment kept before after
heap a parse retains 563–708 KB 355–371 KB

CPU is unchanged within noise.

What kind of change does this PR introduce?

refactor

Did you add tests for your changes?

No new tests: behavior is unchanged, and the existing printer tests cover the comment paths. The syntax coverage baseline drops (tooling/syntax-coverage.json: 112 → 101 statements, 230 → 215 branches).

Does this PR introduce a breaking change?

No. Only types of the experimental javascript.syntax.printer internals change in types.d.ts.

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

n/a

Use of AI

Claude Code wrote the change, checked byte-identical output against the previous commit and measured memory and CPU. A maintainer directed the work and reviews it.


Generated by Claude Code

Summary by CodeRabbit

  • Refactor
    • Updated internal handling of JavaScript syntax, comments, and source-map positions. Comment matching and extraction behavior remain unchanged, so this update does not introduce a change to those user-visible behaviors.
  • Tests
    • Updated recorded syntax-printer coverage totals.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
alexander-akait added 2 commits October 31, 2026 14:15
@alexander-akait
refactor(javascript): type the printer's nodes as the numbers they are
bcb563c
Drop the ESTree-shaped `Print*` node typedefs, which every use cast a
`SyntaxTree` node number to, and the mangling recording only the deleted
`patchRecording` read.

Claude-Session: https://claude.ai/code/session_01Tgxgyb4N35ndP6cC4KcrXC
@alexander-akait
refactor(javascript): read the minifier's comments and tokens off arrays
570e564
Comments are numbers into per-parse arrays, and a gap's or parenthesis's
comments a list number, instead of terser's `ParsedToken` and
`SourceToken` objects; the stream marks what it printed in two byte
arrays. A `comments` callback is still handed terser's comment shape.
Output is byte-identical; a parse of lodash keeping every comment retains
about 45% less heap.

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

changeset-bot Bot commented Oct 31, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4920bbd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added area: parser JavaScript parsing and dependency analysis (lib/javascript, lib/dependencies) area: types types.d.ts, JSDoc annotations, hand-maintained declarations area: tooling Repo tooling, codegen, CLI entry (tooling/, bin/) labels Oct 31, 2026
@github-actions

github-actions Bot commented Oct 31, 2026

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@23039
  • yarn
yarn add -D webpack@https://pkg.pr.new/webpack@23039
  • pnpm
pnpm add -D webpack@https://pkg.pr.new/webpack@23039
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Oct 31, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Types Coverage

Typed lines: 99.49% (164407 of 165253)

Escape hatch Base Head Change
EXPECTED_ANY 66 64 🟢 −2
EXPECTED_OBJECT 45 45 —
EXPECTED_FUNCTION 3 3 —
unknown 129 128 🟢 −1
inferred any 62 62 —

Inferred any counts the identifiers whose type TypeScript infers as any though no JSDoc names it, such as const map = new Map().

Changed by this pull request

File Typed lines EXPECTED_ANY EXPECTED_OBJECT EXPECTED_FUNCTION unknown inferred any
lib/javascript/syntax-printer.js 99.92% 4 (🟢 −2) 8 2 (🟢 −1) 7
119 file(s) in lib/ and hot/ still use an escape hatch, infer `any` or have untyped lines
File Typed lines EXPECTED_ANY EXPECTED_OBJECT EXPECTED_FUNCTION unknown inferred any
lib/javascript/syntax-parser.js 99.96% 1 37
lib/Compilation.js 99.63% 6 2 19
lib/javascript/syntax-printer.js 99.92% 4 (🟢 −2) 8 2 (🟢 −1) 7
lib/Compiler.js 100.00% 5 2 6
lib/stats/StatsFactory.js 96.99% 4 1 6
lib/cache/PackFileCacheStrategy.js 99.23% 10
lib/hmr/JavascriptHotModuleReplacement.runtime.js 100.00% 1 7
lib/module/Module.js 98.77% 7
lib/module/NormalModule.js 99.45% 4 1 2
lib/util/cleverMerge.js 100.00% 1 6
lib/util/terminalColors.js 98.73% 1 6
lib/module/NormalModuleFactory.js 98.21% 2 4
lib/resolve/getResolveOptionsKey.js 100.00% 1 1 4
lib/serialization/SerializerMiddleware.js 100.00% 3 3
lib/debug/ProfilingPlugin.js 100.00% 1 4
lib/define/DefinePlugin.js 100.00% 1 4
lib/hmr/HotModuleReplacement.runtime.js 100.00% 5
lib/loaders/LoaderOptionsPlugin.js 90.63% 5
lib/serialization/ObjectMiddleware.js 99.79% 1 4
lib/cache/MemoryWithGcCachePlugin.js 100.00% 4
lib/config/cli.js 99.73% 1 1 2
lib/config/normalization.js 99.14% 4
lib/graph/ModuleGraph.js 100.00% 3 1
lib/loaders/LoaderPlugin.js 99.41% 4
lib/performance/HotspotsPlugin.js 100.00% 4
lib/util/SortableSet.js 98.98% 4
lib/cache/MemoryCachePlugin.js 100.00% 3
lib/errors/WebpackError.js 97.14% 1 2
lib/util/WeakTupleMap.js 100.00% 3
lib/util/deprecation.js 99.24% 1 1 1
lib/asset/AssetModulesPlugin.js 99.38% 2
lib/cache/Cache.js 100.00% 2
lib/cache/IdleFileCachePlugin.js 100.00% 2
lib/config/defineConfig.js 100.00% 2
lib/css/syntax-parser.js 99.89% 2
lib/html/syntax-parser.js 99.95% 2
lib/javascript/JavascriptModulesPlugin.js 100.00% 2
lib/loaders/LoaderRunner.js 97.55% 2
lib/module/Parser.js 100.00% 2
lib/node/nodeConsole.js 100.00% 2
lib/stats/DefaultStatsFactoryPlugin.js 99.87% 1 1
lib/stats/DefaultStatsPrinterPlugin.js 99.88% 2
lib/util/SourceProcessor.js 100.00% 2
lib/util/comparators.js 100.00% 2
lib/util/serialization.js 98.68% 2
lib/util/validateSchema.js 100.00% 2
lib/MultiCompiler.js 99.74% 1
lib/context/ContextModuleFactory.js 100.00% 1
lib/css/CssModulesPlugin.js 100.00% 1
lib/dependencies/import/ImportParserPlugin.js 100.00% 1
lib/devtool/ModuleFilenameHelpers.js 99.47% 1
lib/dll/DllReferencePlugin.js 100.00% 1
lib/errors/NonErrorEmittedError.js 100.00% 1
lib/hmr/HotModuleReplacementPlugin.js 100.00% 1
lib/html/HtmlModulesPlugin.js 99.51% 1
lib/index.js 100.00% 1
lib/javascript/JavascriptParser.js 100.00% 1
lib/logging/Logger.js 100.00% 1
lib/logging/ProgressPlugin.js 99.80% 1
lib/module/ModuleSourceTypeConstants.js 100.00% 1
lib/optimize/ConcatenatedModule.js 99.89% 1
lib/optimize/TupleQueue.js 100.00% 1
lib/output/CopyPlugin.js 100.00% 1
lib/output/ManifestPlugin.js 100.00% 1
lib/performance/UnusedExternalsPlugin.js 95.35% 1
lib/rules/BasicEffectRulePlugin.js 100.00% 1
lib/rules/RuleSetCompiler.js 99.72% 1
lib/serialization/PlainObjectSerializer.js 100.00% 1
lib/serialization/SingleItemMiddleware.js 100.00% 1
lib/serialization/types.js 100.00% 1
lib/stats/DefaultStatsPresetPlugin.js 100.00% 1
lib/stats/StatsPrinter.js 99.11% 1
lib/template/Template.js 100.00% 1
lib/util/TupleSet.js 100.00% 1
lib/util/identifier.js 100.00% 1
lib/util/magicComment.js 100.00% 1
lib/util/makeSerializable.js 100.00% 1
lib/asset/AssetBytesParser.js 91.67%
lib/asset/AssetParser.js 96.15%
lib/asset/AssetSourceParser.js 91.67%
lib/config/validateSchema.js 94.67%
lib/css/CssGenerator.js 99.65%
lib/css/conventions.js 98.68%
lib/css/syntax-printer.js 99.73%
lib/dependencies/amd/AMDPlugin.js 99.31%
lib/dependencies/amd/AMDRuntimeModules.js 95.45%
lib/dependencies/commonjs/CommonJsExportsParserPlugin.js 99.79%
lib/dependencies/esm/ESMExportInitFragment.js 99.35%
lib/dependencies/helpers/processExportInfo.js 96.97%
lib/dependencies/html/HtmlEntryDependency.js 99.83%
lib/dependencies/import-meta/ImportMetaPlugin.js 99.63%
lib/devtool/SourceMapDevToolPlugin.js 99.78%
lib/errors/CacheEffectivenessWarning.js 93.75%
lib/externals/ExternalModule.js 99.87%
lib/fs/FileSystemInfo.js 99.92%
lib/graph/buildChunkGraph.js 99.88%
lib/hmr/HotModuleReplacementChunkVersionCheckRuntimeModule.js 87.50%
lib/hmr/HotModuleReplacementRuntimeModule.js 77.78%
lib/hmr/JavascriptHotModuleReplacementHelper.js 91.30%
lib/hmr/lazyCompilationBackend.js 99.07%
lib/html/HtmlGenerator.js 99.87%
lib/javascript/JavascriptMetaInfoPlugin.js 98.08%
lib/json/JsonParser.js 96.88%
lib/optimize/LazyBucketSortedSet.js 96.85%
lib/optimize/SideEffectsFlagPlugin.js 99.78%
lib/performance/UnusedDefinesPlugin.js 96.97%
lib/runtime/MakeDeferredNamespaceObjectRuntime.js 99.65%
lib/schemes/HttpUriPlugin.js 99.87%
lib/serialization/BinaryMiddleware.js 99.27%
lib/sharing/semver.js 99.54%
lib/template/RuntimeTemplate.js 99.95%
lib/util/async.js 97.62%
lib/util/binarySearchBounds.js 94.74%
lib/util/createMappings.js 98.45%
lib/util/globUtils.js 99.83%
lib/util/registerExternalSerializer.js 96.85%
lib/wasm-sync/WebAssemblyParser.js 98.94%
lib/wasm/AsyncWebAssemblyParser.js 97.83%
lib/webpack.js 98.62%
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coderabbitai coderabbitai Bot added the area: build-perf Build time and memory of webpack itself label Oct 31, 2026
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Files selected but had no reviewable changes: 1
  • lib/javascript/syntax-printer.js
Files ignored due to path filters: 1
  • types.d.ts is excluded by !types.d.ts
Run configuration
  • Source mode: Auto
  • Repository: webpack/webpack
  • Branch: refactor/javascript-printer-soa-comments
  • File: .coderabbit.yaml
  • Commit: 4920bbd
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a24ecc4a-a7d1-4485-89f1-e2f4a9151f78
Commits

Reviewing files that changed from the base of the PR and between 570e564 and 4920bbd.

Files ignored due to path filters: 1
  • types.d.ts is excluded by !types.d.ts
Files selected for processing: 1
  • lib/javascript/syntax-printer.js

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: webpack/webpack
  • Branch: refactor/javascript-printer-soa-comments
  • File: .coderabbit.yaml
  • Commit: 570e564
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a97e69d7-f9c4-4b3a-b450-124be970e588
Commits

Reviewing files that changed from the base of the PR and between b12ad4d and 570e564.

Files ignored due to path filters: 1
  • types.d.ts is excluded by !types.d.ts
Files selected for processing: 4
  • lib/javascript/ScopeAnalyzer.js
  • lib/javascript/jsMinify.js
  • lib/javascript/syntax-printer.js
  • tooling/syntax-coverage.json

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

Walkthrough

The minifier and syntax printer now use numeric node, token, and comment references. TokenTable stores and exposes token and comment metadata by index. Printer comment filtering and output use these indexed records.

Changes: Syntax indexing and printing

Layer / File(s) Summary
Numeric node references
lib/javascript/ScopeAnalyzer.js, lib/javascript/jsMinify.js, lib/javascript/syntax-printer.js
Scope analysis and minification callbacks use numeric node IDs. Scope name records pair identifier names with resolved definitions. Printer interfaces and token reads also use numeric node and token references.
Indexed token and comment storage
lib/javascript/syntax-printer.js
TokenTable stores token positions and comment metadata in indexed arrays. It provides lookups for comment lists, token positions, gaps, and parenthesis data used by parser integration.
Comment filtering and printing
lib/javascript/syntax-printer.js, tooling/syntax-coverage.json
Comment filtering, claiming, deduplication, and output use indexed metadata. Related comment queries use TokenTable, and the syntax-printer coverage counts are updated.

Possibly related PRs

  • webpack/webpack#23021: Adds PrintNode annotations to the same asCondition callbacks whose node types change here.
  • webpack/webpack#23037: Changes token reads and comment-retention queries in the same TokenTable and syntax-printer code.
  • webpack/webpack#22892: Adds comment claiming and printing in the node printer, which this change refactors to use indexed comment and token references.

Suggested labels: area: parser, area: types, area: tooling, area: build-perf

Suggested reviewers: aryanraj45

Change: Refactor

Merge Risk: Minimal · previous review 570e5

This internal refactor of the JavaScript printer's comment and token storage reports no change in minified output, source maps or comments callback behavior. I found no concrete regression risk, and no merge-blocking concern remains beyond 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 valid Conventional Commit syntax and accurately describes the refactor. The branch prefix is not provided, so the required type-prefix match cannot be verified. Provide the branch name or confirm that its prefix is refactor.
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

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
  • X
  • Mastodon
  • Reddit
  • LinkedIn
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Oct 31, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Generated code size

Comparing base (855b052) to head (4920bbd). Merging this pull request will not change the code webpack generates.

What moved Tests Assets Gzip Raw Test edit
Changed, test untouched 0 0 — — —
Changed, test edited 0 0 — — —
New 0 0 — — —
Deleted 0 0 — — —
Unchanged — 9869 — — —

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.

Sample apps

No sample app changed size.

26 unchanged app(s)
App Gzip Gzip change Raw Raw change
library amd 1.38 KiB — 2.68 KiB —
library amd-require 1.38 KiB — 2.67 KiB —
library assign 1.38 KiB — 2.67 KiB —
library assign-properties 1.42 KiB — 2.80 KiB —
library commonjs 1.38 KiB — 2.66 KiB —
library commonjs-module 1.38 KiB — 2.67 KiB —
library commonjs-static 1.55 KiB — 3.54 KiB —
library commonjs2 1.38 KiB — 2.67 KiB —
library global 1.38 KiB — 2.66 KiB —
library jsonp 1.37 KiB — 2.66 KiB —
library module 1.21 KiB — 2.35 KiB —
library self 1.38 KiB — 2.66 KiB —
library system 1.41 KiB — 2.73 KiB —
library this 1.38 KiB — 2.66 KiB —
library umd 1.44 KiB — 2.86 KiB —
library umd2 1.44 KiB — 2.86 KiB —
library var 1.38 KiB — 2.67 KiB —
library window 1.38 KiB — 2.66 KiB —
node-ssr 96.36 KiB — 371.30 KiB —
node-ssr-esm 96.61 KiB — 372.00 KiB —
react-100 32.06 KiB — 150.15 KiB —
react-1k 73.05 KiB — 906.51 KiB —
react-1k-esm 72.54 KiB — 906.44 KiB —
react-5k 190.87 KiB — 4.08 MiB —
webworker 36.15 KiB — 93.71 KiB —
webworker-esm 35.67 KiB — 94.21 KiB —

No asset changed size.

No runtime gained or lost a runtime module.

Built test/configCases with the defaults a user gets, and the apps in test/sizeCoreReports (apps/): 2336 test(s), 9869 asset(s), 103 emitted nothing.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait
refactor(javascript): drop terser's node shapes and module bag from t…
4920bbd
…he printer

The printer's types no longer describe terser's AST: `NodeShape`,
`NodeFields`, `Node`, `CompressorShape`, `PureCallView` and the generic
`NodeAccess<N>`/`OutputStream<N>` over ESTree nodes are gone, and the
`TerserModules` bag the phases installed into is built from explicit
pieces, its unread `quotesKept` dropped.

Claude-Session: https://claude.ai/code/session_01Tgxgyb4N35ndP6cC4KcrXC
@codspeed

codspeed Bot commented Oct 31, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning, 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

ℹ️ 39 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

✅ 351 untouched benchmarks


Comparing refactor/javascript-printer-soa-comments (4920bbd) with main (855b052)

Open in CodSpeed
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait
alexander-akait merged commit 353202a into main Oct 31, 2026
53 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait
alexander-akait deleted the refactor/javascript-printer-soa-comments branch October 31, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

area: build-perf Build time and memory of webpack itself area: parser JavaScript parsing and dependency analysis (lib/javascript, lib/dependencies) area: tooling Repo tooling, codegen, CLI entry (tooling/, bin/) area: types types.d.ts, JSDoc annotations, hand-maintained declarations

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@alexander-akait
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.