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 — perf(javascript): skip compress work on code the minifier drops by alexander-akait · Pull Request #23492 · webpack/webpack

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Nov 20, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Summary

Follows #23483. Cuts per-node compress work in webpack's JavaScript minifier. Output is byte-identical.

  • Skip printing what a dropped declaration holds. The print walk ran the compress logic on every node, including the insides of declarations findDropped had already dropped. A dropped function, class or declarator now marks what it holds (goneNodes, 1 byte per node), and a marked node under a marked parent prints "" at once. Declarations whose text still prints elsewhere stay unmarked: moved ones, ones kept for their effect, inlined constants, defaults, ones holding comments, and ones holding a function an inlined object's call prints. This skips 8,407 of about 85,800 printer calls per pass over the app chunks (9.8%).
  • Ask whether a call is pure only where its value may go. unreadArgumentsOf ran isPureCall for nearly every printed call, twice under an unread list. It now first checks whether the value is unread or the parent can hold unread parts (holdsParts), and runs isPureCall at most once: 11,660 → 7,540 calls per pass.
// before
if (!(valueUnread(node, parent) || returnedUnread(node, parent, level) ||
	(isPureCall(node) && isUnreadPart(node, parent, level))) || !isPureCall(node)) return null;

// after
const unread = valueUnread(node, parent) || returnedUnread(node, parent, level);
if ((!unread && !holdsParts(parent)) || !isPureCall(node) ||
	(!unread && !isUnreadPart(node, parent, level))) return null;

Instructions per minify pass (cachegrind, --predictable):

Input Mode Before After Change
16 app chunks, 1.14 MB --no-opt (CodSpeed's mode) 13,868M 13,198M −4.8%
16 app chunks, 1.14 MB JIT, pass 1 14,749M 14,400M −2.4%
16 app chunks, 1.14 MB JIT, pass 3 3,136M 3,101M −1.1%
lodash, three.js and 2 large chunks, 3.9 MB --no-opt 54,690M 51,362M −6.1%
lodash, three.js and 2 large chunks, 3.9 MB JIT, pass 3 8,408M 8,127M −3.4%

JIT passes 2–3 move ±2–3% with any code change as V8's tiering shifts; the --no-opt column is the stable one. The in-build minify stage was measured on a loaded machine and shows no gain beyond noise; peak RSS is unchanged.

Checked: minify output matches the base over 161,472 runs (test262 and the app chunks, 3 option sets) and the large inputs. An earlier version passed that comparison yet crashed on the one-pass-object-function-call invariants fixture (a function inside a dropped inlined object prints at a call elsewhere); that case is now excluded and the fixture passes.

What kind of change does this PR introduce?

perf

Did you add tests for your changes?

No new tests: behavior is unchanged. The unitCases/javascript printer and invariants fixtures (27,929 tests, including one-pass-object-function-call) and the minify config cases (363) cover the new branches.

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?

n/a. Adds the changeset 130-faster-javascript-minification.md, which also covers #23468 and #23483 now that the release consumed the earlier one.

Use of AI

Claude Code profiled the minifier, counted calls per node, wrote the changes, measured instruction counts and checked the output against the base. The changes were reviewed before opening.


Generated by Claude Code

Summary by CodeRabbit

  • Performance
    • JavaScript minification is faster, reducing the time required to process JavaScript during builds.

Sorry, something went wrong.

Uh oh!

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

All reactions
alexander-akait added 3 commits November 20, 2026 05:07
@alexander-akait
perf(javascript): skip printing what a dropped declaration holds
e624b1c
A function, class or list declarator that `findDropped` drops whole
has its reads discounted: its text prints nowhere. The print walk still
ran the compress logic on every node below it. Those nodes now print
as empty text.

A declaration stays unmarked where its text still prints elsewhere: a
function an inlined object's call reads, a constant whose reads print
its value, a default printing among parameters, a moved function, or
one holding comments.

Claude-Session: https://claude.ai/code/session_013FhutSZRZTvPgiMbi5LcCs
@alexander-akait
perf(javascript): ask whether a call is pure only where its value may go
a9890f6
`unreadArgumentsOf` runs for nearly every call printed. It asked
`isPureCall` before every other test, and twice for a call among the
parts of an unread list. A call whose value is read, held by no spread,
array, property or call, now returns before `isPureCall` runs, and no
call asks it twice: 35% fewer `isPureCall` calls over the app chunks.

Claude-Session: https://claude.ai/code/session_013FhutSZRZTvPgiMbi5LcCs
@alexander-akait
chore: add a changeset for faster JavaScript minification
d3dcb49
Claude-Session: https://claude.ai/code/session_013FhutSZRZTvPgiMbi5LcCs
@changeset-bot

changeset-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d3dcb49

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

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

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

All reactions

Sorry, something went wrong.

Uh oh!

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

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

github-actions Bot commented Nov 20, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Reports for d3dcb49, computed by this pull request's own code. Each section updates when its workflow finishes.


Preview package

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

From Preview package run #13754.


Generated code size

Comparing base (c5f31ab) to head (d3dcb49). 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 — 10872 — — —

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.17 KiB — 150.55 KiB —
react-1k 73.34 KiB — 907.38 KiB —
react-1k-esm 72.54 KiB — 906.44 KiB —
react-5k 191.49 KiB — 4.08 MiB —
webworker 36.60 KiB — 95.02 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/): 2502 test(s), 10872 asset(s), 112 emitted nothing.

From Generated code size run #8389.


Types Coverage

Typed lines: 99.66% (201097 of 201793)

Kind Base Head Change
any 41 41 —
unknown 18 18 —
object 18 18 —
Function 0 0 —
untyped 0 0 —

any counts EXPECTED_ANY, a written any and JSDoc's * and ? for any type. unknown counts a written unknown; ThrownValue, the unknown a throw or a rejected promise hands on, is left out. object counts EXPECTED_OBJECT and Object, Function counts EXPECTED_FUNCTION. Untyped counts the any TypeScript infers where no type is written: a type argument a call leaves to inference that comes out any, whether a lib signature defaults it, as in const map = new Map() and Array(5), or a generic call infers it from an any argument; and const list = []. An identifier that only holds an any written in the project's files is not counted again, as the any row counts it where it is written; an any a lib signature returns, such as JSON.parse's, is counted in neither row.

This pull request adds or removes no escape hatch, any or untyped identifier.

33 file(s) in lib/, hot/, declarations/ and bin/ still have an escape hatch, `any` or untyped identifiers
File Typed lines any unknown object Function untyped
declarations/WebpackOptions.ts 100.00% 7
lib/Compilation.js 99.97% 5 2
lib/javascript/syntax-printer.js 100.00% 5
lib/module/NormalModule.js 100.00% 4 1
lib/loaders/LoaderOptionsPlugin.js 100.00% 4
lib/serialization/ObjectMiddleware.js 100.00% 4
lib/util/SortableSet.js 100.00% 4
lib/hmr/HotModuleReplacement.runtime.js 100.00% 2 1
lib/module/NormalModuleFactory.js 100.00% 3
lib/stats/StatsFactory.js 100.00% 2 1
lib/Compiler.js 100.00% 2
lib/config/defineConfig.js 100.00% 2
lib/hmr/JavascriptHotModuleReplacement.runtime.js 100.00% 2
lib/index.js 100.00% 2
lib/loaders/LoaderRunner.js 100.00% 2
lib/module/Module.js 100.00% 2
lib/module/Parser.js 100.00% 2
lib/node/nodeConsole.js 100.00% 2
lib/util/cleverMerge.js 100.00% 2
lib/config/cli.js 100.00% 1
lib/dll/DllReferencePlugin.js 100.00% 1
lib/graph/ModuleGraph.js 100.00% 1
lib/hmr/HotModuleReplacementPlugin.js 100.00% 1
lib/javascript/JavascriptParser.js 100.00% 1
lib/javascript/syntax-parser.js 100.00% 1
lib/logging/Logger.js 100.00% 1
lib/logging/createConsoleLogger.js 100.00% 1
lib/output/ManifestPlugin.js 100.00% 1
lib/serialization/types.js 100.00% 1
lib/stats/DefaultStatsFactoryPlugin.js 100.00% 1
lib/stats/StatsPrinter.js 100.00% 1
lib/util/makeSerializable.js 100.00% 1
lib/util/terminalColors.js 100.00% 1

From Types Coverage run #4443.


Module loading

How many files a fresh Node.js process loads (require or import) to do each thing below; a change from the pull request's base is marked 🔴 when it grew and 🟢 when it shrank. Every file is startup time, so fewer is better. webpack files are this package's own (lib/, hot/); node_modules files are its dependencies'.

What the process does webpack files node_modules files
require("webpack") 2 0
import "webpack" 2 0
JavaScript syntax 12 0
CSS syntax 12 0
HTML syntax 11 0
XML syntax 11 0
JavaScript minifier 13 0
CSS minifier 14 0
HTML minifier 19 0
XML minifier 14 0
JSON minifier 1 0
development build 422 103
production build 430 133
watch with HMR, one rebuild 446 110

From Module loading run #1687.

All reactions

Sorry, something went wrong.

Uh oh!

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

@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The syntax printer now tracks declarations and declarators marked for whole-node removal. It marks and clears descendant state during removal analysis, handles moved-function retention, and skips text generation for nodes marked as gone. A changeset declares a webpack patch release.

Changes: JavaScript minification

Layer / File(s) Summary
Removal candidate tracking
lib/javascript/syntax-printer.js
The printer adds per-node tracking for whole-node removal and marks eligible declarators as candidates. It initializes and resets this state alongside existing per-node state.
Subtree removal analysis
lib/javascript/syntax-printer.js
Removal analysis marks eligible subtrees and handles moved-function retention. Call analysis now checks unread values and unread parts separately, with holdsParts identifying supported parent nodes.
Mark cleanup and text generation
lib/javascript/syntax-printer.js, .changeset/130-faster-javascript-minification.md
The printer clears descendant marks for retained roots and skips text generation when a node and its immediate ancestor are marked as gone. The changeset declares a webpack patch release and documents faster JavaScript minification.

Suggested labels: area: parser

Suggested reviewers: aryanraj45

Change: Refactor

Merge Risk: Minimal · up to d3dcb

This change reduces minifier work without altering output, and the reported byte-identical results and existing fixtures support that. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Inconclusive The title uses the conventional-commit form perf(javascript): with a valid type from the allowed list. It names the main change: the minifier skips compress work on code that findDropped removes, whic… Confirm the source branch name carries the 'perf' prefix so the type matches the branch prefix as the title requirements specify. If the branch uses a different prefix, rename the branch or change the title type to match.
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.
Full details: Title check

Explanation

The title uses the conventional-commit form perf(javascript): with a valid type from the allowed list. It names the main change: the minifier skips compress work on code that findDropped removes, which matches the objectives and the syntax-printer changes. The title does not match the branch prefix check, but no branch name was provided in the context, so the type-to-branch match cannot be confirmed.

Resolution

Confirm the source branch name carries the 'perf' prefix so the type matches the branch prefix as the title requirements specify. If the branch uses a different prefix, rename the branch or change the title type to match.

  • 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.51.1)

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

  • X
  • Mastodon
  • Reddit
  • LinkedIn
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: webpack/webpack
  • Branch: perf/javascript-printer-compress
  • File: .coderabbit.yaml
  • Commit: d3dcb49
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f54a3577-1e1e-440c-8aa0-cfa443d90cff
Commits

Reviewing files that changed from the base of the PR and between c5f31ab and d3dcb49.

Files selected for processing: 2

  • .changeset/130-faster-javascript-minification.md
  • lib/javascript/syntax-printer.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.

All reactions

Sorry, something went wrong.

Uh oh!

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

@codspeed

codspeed Bot commented Nov 20, 2026

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

ℹ️ 38 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 perf/javascript-printer-compress (d3dcb49) with main (c5f31ab)

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 6b8240f into main Nov 20, 2026
89 of 90 checks passed

Uh oh!

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

@alexander-akait
alexander-akait deleted the perf/javascript-printer-compress branch November 20, 2026 08:08
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
chore(release): new release #23490
Open
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: parser JavaScript parsing and dependency analysis (lib/javascript, lib/dependencies)

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.