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(css): cut what the minifier allocates, and name the output with mode alone by alexander-akait · Pull Request #21681 · webpack/webpack

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Aug 11, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Summary

Four allocation-shaped changes to the CSS minifier, measured with a deterministic scavenge count under --predictable --max-semi-space-size=1 (each figure reproduces exactly on repeat) and byte-identical output throughout:

fixture main this PR
Semantic UI 2 (734 KB) 212 145 −31.6%
Bootstrap 5 (274 KB) 70 58 −17.1%
Tailwind 4 wide (2414 KB) 406 349 −14.0%
HTML document, 12k inline style="" 720 676 −6.1%

What each one does: the print store is keyed by dense integer node handles and never holds more than a few dozen entries, yet a 1.9 MiB stylesheet drove ~600k hash operations through a Map — two columns and an epoch counter replace it, printNode falling 12.2% → 5.0% of printer self time. _wouldFuseTokens read the last character off the text _join accumulates, and indexing a rope flattens it, once per fragment over text that grows with every fragment. Reaching an rgb()'s arguments built a replaced copy, a split array and a filtered copy of that, for every colour in the sheet. And process built a source map on every printing call, including the thousands an HTML document makes for its inline CSS, none of which name an input or read the map back.

Two changes come with it. minimize: true was a second spelling of mode: "minify", so a caller had two ways to ask for one thing and the processor had to decide which won — mode names the output and is now the only thing that does. And the minifier comparison tools warmed nothing before timing, so they reported the JIT-compiled tools' warm-up rather than their throughput; webpack's own minifier takes ~5x its steady-state time on the first call and settles by the sixth.

What kind of change does this PR introduce?

perf

Did you add tests for your changes?

Yes — test/SourceProcessor.unittest.js is new (27 cases over both languages: how mode resolves, that a source map is built only for a caller that names its input, visitor dispatch, reuse across calls, degenerate input). The transforms themselves are already covered by test/CssSyntax.unittest.js and the configCases/css and configCases/html snapshots, which are unchanged — every change here is byte-identical by design.

Does this PR introduce a breaking change?

Yes, for SourceProcessor, which is @experimental and documented as an unstable API: minimize: true is gone. Pass mode: "minify" instead — every caller in the repo moved with it, and the overloads make the mistake a type error rather than a silent walk.

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

n/a — SourceProcessor is experimental and undocumented outside its own JSDoc, which is updated here.

Use of AI

Claude Code was used throughout, driven by me. It profiled the minifiers, proposed and implemented the changes, and ran the measurements and suites. Every candidate was accepted or rejected on measured evidence: of fifteen tried, eleven were reverted for showing no effect or a regression (a duplicate-declaration scan cost 4.7x on token-heavy blocks, a hand-written whitespace scan lost to V8's regex engine, and several removed large object counts that turned out to be a rounding error in bytes). I reviewed the diff and the numbers before opening this.


Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • CSS and HTML minification now use the explicit mode: "minify" option.
    • Source-map generation is more clearly separated from standard output processing.
  • Performance
    • Improved minification speed and reduced overhead during repeated processing.
  • Bug Fixes
    • Improved consistency across repeated minification operations while preserving environment-specific behavior and source maps.
  • Tests
    • Expanded coverage for formatting, source maps, repeatability, traversal, and edge cases.

Sorry, something went wrong.

Uh oh!

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

All reactions
alexander-akait added 8 commits August 11, 2026 14:27
@alexander-akait
perf(css): keep printed node text in columns rather than a map
f431fe4
The print store is keyed by dense integer node handles and never holds more
than a few dozen entries, yet a 1.9 MiB stylesheet drives 304,464 sets and
295,789 gets through it — `printNode` alone was 12.2% of printer self time.

Two columns replace the map, and `dropStore` bumps an epoch instead of
clearing, which matters because it runs per node: clearing a column by
length would make it quadratic. The columns start empty and grow on demand,
because the HTML minifier builds one of these per inline `style=""` — sizing
them up front cost that document 4.4x its allocation.

Allocation falls 13.5% on a stylesheet (635 -> 549 scavenges under
`--predictable`, reproduced exactly) and `printNode` to 5.0%. HTML is
unchanged without inline CSS and slightly better with it. Output is
byte-identical.
@alexander-akait
perf(css): cut an rgb()'s arguments in one pass
852fba8
Reaching the three or four numbers in an `rgb()` built a copy of the argument
text with the `/` replaced, a split array, and a filtered copy of that — three
allocations and two regex passes for every color in the stylesheet, which on a
framework sheet is thousands.

One scan over the text produces the same strings. The whitespace test is
written as a comparison rather than a call to `_isWhiteSpace`: a call per
character loses to the regex engine outright, which an earlier attempt
measured.

`_minifyColorFunction` falls 23% (42.2 -> 32.6 ms of printer self time) and
allocation 2.4% (549 -> 536 scavenges under `--predictable`). Output is
byte-identical over the whole `configCases` corpus.
@alexander-akait
build: warm the minifier comparisons before timing them
df1c2bd
Half of the tools compared are native binaries, at full speed on their first
call; the other half are JavaScript, still being compiled on it. Timing from
cold reported the JavaScript ones' warm-up rather than their throughput —
webpack's CSS minifier takes ~5x its steady-state time on the first call and
settles by the sixth — while a build minifies many assets in one process, so
steady state is what a user gets.

Eight warm-up passes bounded by a 500ms budget, so a slow tool on a large
fixture is not multiplied while a fast one still reaches steady state. Every
JavaScript tool's numbers improve and the native ones barely move, which is
the bias being removed: on the inlined-Bootstrap document webpack reads
30ms/37cpu rather than 45ms/115cpu, and htmlnano 345ms rather than 434ms,
while minify-html goes 2ms to 1ms.
@alexander-akait
refactor(css): resolve the target's spelling limits once per run
e52251e
The four `output.environment` predicates were called per color rather than
per stylesheet — 58,153 of the 58,441 calls on a 1.9 MiB sheet are the
hex-alpha one. They become per-run values beside `_convertLengthUnits`,
which `grammar` already resolves this way.

Not a speed claim: their cost sits under a sampling profiler's resolution,
which caught nothing in them in two runs of three, and neither CPU nor heap
separates the two arms. What this buys is the shape. Output is byte-identical
over 610 stylesheets under both a permissive target and one that refuses all
four spellings.
@alexander-akait
chore: fold the minifier speed-ups into one changeset
6c29455
@alexander-akait
perf(css): ask the joiner for the character it already knows
8e83006
`_wouldFuseTokens` read the last character off the text joined so far, which
is a rope: indexing one forces it flat, once per fragment, over text that
grows with every fragment. `_join` already tracks that character.

The full text stays a parameter for the one branch that needs more than the
character — a digit meeting a `.` asks whether what precedes it is a number.

535 -> 530 scavenges under `--predictable`. Output is byte-identical.
@alexander-akait
perf: build a source map only for a caller that asked for one
8fcce31
`process` built one on every printing call, including the thousands an HTML
document makes to minify its inline `style=""` attributes and its `<style>`
blocks — none of which name an input or read the map back. Building one walks
the whole output looking for line breaks, which is the walk `_emit` documents
itself as avoiding when no map is wanted.

The overloads now say it: naming a `source` returns a map, printing without
one returns `undefined` in its place. `cssMinify` names the asset, so a real
CSS asset is unaffected.

A document of 12,000 inline styles falls 717 -> 676 scavenges (-5.7%), a
stylesheet minified without a source name 150 -> 145 (-3.3%), and one minified
with a map is unchanged. Output is byte-identical.
@alexander-akait
test: pin how mode and minimize resolve, in both languages
35f1932
`mode` names the output a caller wants and `minimize: true` is shorthand for
the `"minify"` one of them, so `mode` decides when the two disagree. That
resolution lives in the shared `SourceProcessor` and nothing asserted it, in
either language — a grammar reading `minimize` itself would part them silently.
@changeset-bot

changeset-bot Bot commented Aug 11, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ba899a7

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 changesets to release 1 package
Name Type
webpack Patch

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: css CSS support (lib/css) area: html Experimental HTML support (lib/html) area: types types.d.ts, JSDoc annotations, hand-maintained declarations area: build-perf Build time and memory of webpack itself area: tooling Repo tooling, codegen, CLI entry (tooling/, bin/) labels Aug 11, 2026
@github-actions

github-actions Bot commented Aug 11, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

This PR is packaged and the instant preview is available (eb88274).

Install it locally:

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

Sorry, something went wrong.

Uh oh!

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

@codecov

codecov Bot commented Aug 11, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.51%. Comparing base (4410afe) to head (ba899a7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21681      +/-   ##
==========================================
- Coverage   94.54%   94.51%   -0.03%     
==========================================
  Files         631      631              
  Lines       82294    82402     +108     
  Branches    24376    24422      +46     
==========================================
+ Hits        77806    77886      +80     
- Misses       4488     4516      +28     
Flag Coverage Δ
css-parsing 26.59% <25.33%> (-0.03%) ⬇️
html5lib 30.98% <4.00%> (-0.05%) ⬇️
integration 88.21% <89.33%> (-0.06%) ⬇️
test262 51.70% <ø> (-0.04%) ⬇️
unit 54.51% <100.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

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

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@alexander-akait, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 7 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f646662-27c3-42cd-bb02-5827b1f8b49f

📥 Commits

Reviewing files that changed from the base of the PR and between 9e0c12c and ba899a7.

📒 Files selected for processing (2)
  • AGENTS.md
  • test/SourceProcessor.unittest.js

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key: "tools"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

Changes

Minification processing

Layer / File(s) Summary
SourceProcessor storage and mode contract
lib/util/SourceProcessor.js, test/SourceProcessor.unittest.js
PrintContext now uses dense generation-based storage. SourceProcessor.process requires an explicit mode and separates mapped and unmapped output. Tests cover modes, source maps, visitors, state isolation, and edge cases.
CSS capability and token-printing paths
lib/css/cssMinify.js, lib/css/syntax.js, test/CssSyntax.unittest.js, test/CssValueSyntax.unittest.js
CSS printing caches environment capabilities, scans rgb() arguments directly, and passes the previous character to token-fusion checks. CSS tests use mode: "minify" and validate RGB whitespace handling.
HTML and inline CSS mode migration
lib/html/htmlMinify.js, lib/html/syntax.js, test/HtmlSyntax.unittest.js, test/SyntaxBrowserEquivalence.unittest.js, test/configCases/html/minimize-round-trip/test.config.js
HTML and inline CSS processing now select minification with mode: "minify". Related tests and configuration use the updated option.
Benchmark configuration and warm-up
tooling/compare-css-minifiers.js, tooling/compare-html-minifiers.js, test/benchmarkCases/*, .changeset/072-css-html-minify-hot-paths.md, AGENTS.md
Minifier comparisons add bounded warm-up runs before timing. Benchmark callers use the explicit mode. The changeset and contributor guidance describe the updated process.

Possibly related PRs

  • webpack/webpack#21663: Directly relates to SourceProcessor minification APIs and CSS/HTML callers.
  • webpack/webpack#21664: Directly relates to CSS syntax minification and token-fusion handling.
  • webpack/webpack#21628: Directly relates to CSS traversal, printing, and PrintContext.

Suggested labels: breaking-change

Suggested reviewers: xiaoxiaojx

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title follows the required conventional-commit format and describes the minifier performance and mode changes, but the branch prefix is not provided. Provide the branch name or prefix to verify that the perf type matches it.
✅ 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.

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions

github-actions Bot commented Aug 11, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Generated code size

Comparing ba899a7 merged into 638ce71 against 638ce71. Merging this PR will not change the code webpack generates.

Changed New Deleted Unchanged Raw change
Cases 0 0 0 1571 —
Assets 0 0 0 6157 —
Runtimes 0 0 0 1933 —

No asset changed size.

No runtime gained or lost a runtime module.

Built test/configCases with the defaults a user gets: 1571 case(s), 6157 asset(s), 40 emitted nothing.

All reactions

Sorry, something went wrong.

Uh oh!

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

coderabbitai[bot]
coderabbitai Bot reviewed Aug 11, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (2)
lib/util/SourceProcessor.js (1)

139-141: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Shorten newly added comments.

The changed comments exceed the repository limit of two short lines. Keep only non-obvious rationale.

  • lib/util/SourceProcessor.js#L139-L141: reduce the storage rationale to at most two short lines.
  • lib/util/SourceProcessor.js#L291-L300: reduce the generation-invalidation explanation to at most two short lines.
  • lib/util/SourceProcessor.js#L757-L763: reduce the source-map allocation explanation to at most two short lines.
  • lib/css/syntax.js#L4967-L4975: reduce the token-fusion rationale to at most two short lines.
  • lib/css/syntax.js#L5784-L5811: reduce the RGB scanner rationale to at most two short lines.
  • test/SourceProcessor.unittest.js#L24-L26: reduce the mode-resolution rationale to at most two short lines.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/util/SourceProcessor.js` around lines 139 - 141, Shorten only the newly
added comments to at most two short lines, retaining non-obvious rationale and
removing implementation-detail verbosity: in lib/util/SourceProcessor.js lines
139-141, 291-300, and 757-763; lib/css/syntax.js lines 4967-4975 and 5784-5811;
and test/SourceProcessor.unittest.js lines 24-26. Update the comments near their
associated storage, generation-invalidation, source-map allocation,
token-fusion, RGB-scanning, and mode-resolution logic without changing the
implementation.

Sources: Coding guidelines, Path instructions

tooling/compare-html-minifiers.js (1)

474-481: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a two-line warm-up rationale in both tooling workers.

Both changed comment blocks use eight lines. Keep only the non-obvious reason and the two warm-up bounds.

  • tooling/compare-html-minifiers.js#L474-L481: replace the eight-line comment with the two-line rationale.
  • tooling/compare-css-minifiers.js#L388-L395: apply the same replacement.
Suggested replacement
- // Half of these tools are native binaries, at full speed on their first
- // call; the other half are JavaScript, which is still being compiled on it.
- // Timing from cold reports the JavaScript ones' warm-up rather than their
- // throughput — webpack's own minifier takes ~5x its steady-state time on
- // the first call and settles by the sixth — and a build minifies many
- // assets in one process, so steady state is what a user gets. Bounded by
- // time as well as by count, so a slow tool on a large document is not
- // multiplied while a fast one still reaches it.
+ // Warm minifiers before timing steady-state throughput.
+ // Stop after eight runs or 500 ms of warm-up.

As per coding guidelines, comments in {lib,hot,tooling,test}/**/*.{js,mjs} must be at most two short lines.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tooling/compare-html-minifiers.js` around lines 474 - 481, Shorten the
warm-up comments in both tooling/compare-html-minifiers.js lines 474-481 and
tooling/compare-css-minifiers.js lines 388-395 to the same two short lines:
retain only the non-obvious steady-state rationale and the count/time warm-up
bounds, removing the detailed explanation while preserving the behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.changeset/072-css-html-minify-hot-paths.md:
- Line 5: Replace the changeset sentence with one concise, capitalized
imperative sentence of no more than 80 characters that summarizes the
minification speedup and includes the SourceProcessor migration, ending with a
period.

In `@lib/css/cssMinify.js`:
- Line 76: Update the adjacent API comments for the callers in
lib/css/cssMinify.js lines 70-73 and lib/html/htmlMinify.js lines 59-61 to
document mode: "minify" instead of the removed minimize selector; no
implementation changes are needed at the referenced call sites.

In `@lib/css/syntax.js`:
- Around line 5797-5806: Update the argument-separator condition in the visible
color-scanning logic to recognize only CSS whitespace characters (tab, line
feed, form feed, carriage return, and space), while retaining comma, solidus,
and end-of-input handling. Add a regression test for input containing U+0001
between numeric components, ensuring it remains invalid and is not rewritten as
a valid color.

In `@lib/util/SourceProcessor.js`:
- Around line 703-704: Update the source-map contract documentation near the
printer description to state that map is undefined unless the caller provides
source, matching the undefined return path in the surrounding source-processing
logic. Keep the existing behavior unchanged.

In `@test/SourceProcessor.unittest.js`:
- Around line 30-33: Extend the “walks without printing when none is asked for”
test to call Processor.process with { minimize: true } and assert it returns
undefined. Keep the existing missing-options and empty-options cases, verifying
that minimize does not select an output mode.
- Around line 54-62: Update the two Processor.process calls in the “beautifies
to something that still parses to the same output” test to use mode: "beautify"
instead of mode: "minify", preserving the existing idempotence assertion between
once and twice.

---

Nitpick comments:
In `@lib/util/SourceProcessor.js`:
- Around line 139-141: Shorten only the newly added comments to at most two
short lines, retaining non-obvious rationale and removing implementation-detail
verbosity: in lib/util/SourceProcessor.js lines 139-141, 291-300, and 757-763;
lib/css/syntax.js lines 4967-4975 and 5784-5811; and
test/SourceProcessor.unittest.js lines 24-26. Update the comments near their
associated storage, generation-invalidation, source-map allocation,
token-fusion, RGB-scanning, and mode-resolution logic without changing the
implementation.

In `@tooling/compare-html-minifiers.js`:
- Around line 474-481: Shorten the warm-up comments in both
tooling/compare-html-minifiers.js lines 474-481 and
tooling/compare-css-minifiers.js lines 388-395 to the same two short lines:
retain only the non-obvious steady-state rationale and the count/time warm-up
bounds, removing the detailed explanation while preserving the behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7ecce383-ad00-404f-9f48-7c0675128ef4

📥 Commits

Reviewing files that changed from the base of the PR and between 4410afe and cc86349.

⛔ Files ignored due to path filters (1)
  • types.d.ts is excluded by !types.d.ts
📒 Files selected for processing (16)
  • .changeset/072-css-html-minify-hot-paths.md
  • lib/css/cssMinify.js
  • lib/css/syntax.js
  • lib/html/htmlMinify.js
  • lib/html/syntax.js
  • lib/util/SourceProcessor.js
  • test/CssSyntax.unittest.js
  • test/CssValueSyntax.unittest.js
  • test/HtmlSyntax.unittest.js
  • test/SourceProcessor.unittest.js
  • test/SyntaxBrowserEquivalence.unittest.js
  • test/benchmarkCases/css-printer-tailwind-unit/index.bench.mjs
  • test/benchmarkCases/html-printer-document-unit/index.bench.mjs
  • test/configCases/html/minimize-round-trip/test.config.js
  • tooling/compare-css-minifiers.js
  • tooling/compare-html-minifiers.js
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • webpack/schema-utils (auto-detected)
  • webpack/tapable (auto-detected)

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread .changeset/072-css-html-minify-hot-paths.md Outdated
---

Speed up CSS and HTML minification: value printing, tag printing and rule merging.
Speed up CSS and HTML minification: value and tag printing, rule merging, the printed-node store and `rgb()` arguments.

@coderabbitai coderabbitai Bot Aug 11, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Shorten the changeset sentence.

Line 5 exceeds 80 characters and lists implementation details. Replace it with one concise imperative sentence that also covers the SourceProcessor migration.

Suggested changeset text
-Speed up CSS and HTML minification: value and tag printing, rule merging, the printed-node store and `rgb()` arguments.
+Select SourceProcessor output with `mode` and optimize minification.

As per coding guidelines, changesets require one concise imperative sentence of no more than 80 characters. As per path instructions, the sentence must be capitalized and end with a period.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Speed up CSS and HTML minification: value and tag printing, rule merging, the printed-node store and `rgb()` arguments.
Select SourceProcessor output with `mode` and optimize minification.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.changeset/072-css-html-minify-hot-paths.md at line 5, Replace the changeset
sentence with one concise, capitalized imperative sentence of no more than 80
characters that summarizes the minification speedup and includes the
SourceProcessor migration, ending with a period.

Sources: Coding guidelines, Path instructions

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread lib/css/cssMinify.js Resolved

Uh oh!

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

Comment thread lib/css/syntax.js Resolved

Uh oh!

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

Comment thread lib/util/SourceProcessor.js Resolved

Uh oh!

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

Comment thread test/SourceProcessor.unittest.js Resolved

Uh oh!

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

Comment thread test/SourceProcessor.unittest.js Resolved

Uh oh!

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

@codspeed

codspeed Bot commented Aug 11, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Merging this PR will degrade performance by 20.65%

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 308 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory benchmark "many-modules-esm", scenario '{"name":"mode-development","mode":"development"}' 882.6 KB 2,297.9 KB -61.59%
⚡ Memory benchmark "css-modules", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 1,233.4 KB 752.4 KB +63.93%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing perf/css-minifier-speed (ba899a7) with main (638ce71)

Open in CodSpeed
All reactions

Sorry, something went wrong.

Uh oh!

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

@alexander-akait
refactor: name the output with mode alone
5adae77
`minimize: true` was a second spelling of `mode: "minify"`, so a caller had two
ways to ask for one thing and the processor had to decide which won when they
disagreed. `mode` names the output, and now it is the only thing that does.

The one caller that read `.code` off a call the removal turns into a walk —
`compare-html-minifiers`, canonicalizing a `<style>` — was caught by tsc rather
than by silently comparing unminified CSS, which is the check the overloads buy.

`SourceProcessor` is `@experimental`, and every caller in the repo moved with it.
@alexander-akait
alexander-akait force-pushed the perf/css-minifier-speed branch from cc86349 to 5adae77 Compare August 11, 2026 15:31
@alexander-akait
fix(css): part rgb() arguments on CSS whitespace only
9e0c12c
A control character between two numbers is not whitespace in CSS, so
`rgb(1<U+0001>2 3 4)` is an invalid declaration the engine ignores.
Comparing against the space folded it to a color and activated it;
compare against the five whitespace code points instead.

Also correct the source-map contract in `process()`'s JSDoc — `map` is
`undefined` unless the caller names its input — refresh two comments
that still spoke of `minimize`, shorten the changeset, and record in
AGENTS.md that every lint stage runs before every push and that a
generated file is stale the moment the JSDoc prose it copies changes.
@coderabbitai coderabbitai Bot added the breaking-change Semver-major impact (valid on issues and PRs) label Aug 11, 2026
coderabbitai[bot]
coderabbitai Bot reviewed Aug 11, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/SourceProcessor.unittest.js (1)

24-26: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reduce this comment to two short lines.

As per coding guidelines, comments in test/**/*.js must be at most two short lines.

Proposed change
-	// `mode` is the one thing that names the output a caller wants, so a language
-	// that read anything else would part it from the others. The resolution lives
-	// in the shared processor; these say so in both languages it is bound to.
+	// `mode` is the sole output selector across language bindings.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/SourceProcessor.unittest.js` around lines 24 - 26, Shorten the comment
above the shared processor language bindings to two concise lines while
preserving its point that mode determines the requested output and resolution is
shared across both languages.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@AGENTS.md`:
- Line 213: Update the lint guidance in the section describing `yarn fix` so
contributors must run `yarn lint` after `yarn fix`, ensuring generated-output
checks, type checks, formatting, and spellcheck all run before pushing.

---

Nitpick comments:
In `@test/SourceProcessor.unittest.js`:
- Around line 24-26: Shorten the comment above the shared processor language
bindings to two concise lines while preserving its point that mode determines
the requested output and resolution is shared across both languages.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9934918c-aaa4-40ef-bbf8-524774f55a83

📥 Commits

Reviewing files that changed from the base of the PR and between cc86349 and 9e0c12c.

⛔ Files ignored due to path filters (1)
  • types.d.ts is excluded by !types.d.ts
📒 Files selected for processing (8)
  • .changeset/072-css-html-minify-hot-paths.md
  • AGENTS.md
  • lib/css/cssMinify.js
  • lib/css/syntax.js
  • lib/html/htmlMinify.js
  • lib/util/SourceProcessor.js
  • test/CssSyntax.unittest.js
  • test/SourceProcessor.unittest.js
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • webpack/schema-utils (auto-detected)
  • webpack/tapable (auto-detected)
🚧 Files skipped from review as they are similar to previous changes (6)
  • lib/html/htmlMinify.js
  • .changeset/072-css-html-minify-hot-paths.md
  • lib/css/cssMinify.js
  • lib/css/syntax.js
  • lib/util/SourceProcessor.js
  • test/CssSyntax.unittest.js

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread AGENTS.md Resolved

Uh oh!

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

@alexander-akait
docs: correct the lint guidance cspell rejected
ba899a7
`yarn fix` regenerates and formats but runs no type check and no
spellcheck, so it is not a substitute for `yarn lint` — which is how a
coined word ("restaked") reached CI. Say to run `yarn lint` after it,
and to read each stage whole: the finding sat two lines above the
summary a `tail` had kept.

Also shorten a three-line test comment to the two the guide allows.
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Types Coverage

Coverage after merging perf/css-minifier-speed into main will be
99.25%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
bin
   webpack.js98.82%100%100%98.82%103
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/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
   APIPlugin.js100%100%100%100%
   AsyncDependenciesBlock.js100%100%100%100%
   AutomaticPrefetchPlugin.js100%100%100%100%
   BannerPlugin.js100%100%100%100%
   Cache.js98.21%100%100%98.21%101
   CacheFacade.js100%100%100%100%
   Chunk.js99.72%100%100%99.72%39
   ChunkGraph.js100%100%100%100%
   ChunkGroup.js100%100%100%100%
   ChunkTemplate.js100%100%100%100%
   CircularModulesPlugin.js98.81%100%100%98.81%136
   CleanPlugin.js99.12%100%100%99.12%214, 234
   CodeGenerationResults.js100%100%100%100%
   CompatibilityPlugin.js100%100%100%100%
   Compilation.js98.44%100%100%98.44%1673, 1992, 1999, 2007, 2029, 2032, 2971, 3450–3451, 3483, 4192, 4222, 4275–4276, 4280, 4285, 4301–4302, 4316–4317, 4322–4323, 4843, 4869, 549, 554, 5679, 5711, 5728, 5746, 5762, 5777, 5802–5803, 5805, 6140, 6145, 6151, 6154, 6161, 6173, 6175, 6179, 6197, 6212, 6246, 6302, 6326, 6442, 801–802
   Compiler.js99.56%100%100%99.56%1168–1169, 1177
   ConcatenationScope.js99.12%100%100%99.12%300
   ConditionalInitFragment.js100%100%100%100%
   ConstPlugin.js100%100%100%100%
   ContextExclusionPlugin.js100%100%100%100%
   ContextModule.js99.88%100%100%99.88%1461
   ContextModuleFactory.js97.20%100%100%97.20%266, 435, 456, 461, 501, 512, 514, 518, 527–528
   ContextReplacementPlugin.js100%100%100%100%
   DefinePlugin.js99.08%100%100%99.08%1080, 176–177, 193, 212, 286
   DependenciesBlock.js100%100%100%100%
   Dependency.js98.51%100%100%98.51%480, 527
   DependencyTemplate.js100%100%100%100%
   DependencyTemplates.js100%100%100%100%
   DotenvPlugin.js98.41%100%100%98.41%378, 391–392
   DynamicEntryPlugin.js100%100%100%100%
   EntryOptionPlugin.js100%100%100%100%
   EntryPlugin.js100%100%100%100%
   Entrypoint.js100%100%100%100%
   EnvironmentPlugin.js97.14%100%100%97.14%49
   ErrorHelpers.js100%100%100%100%
   EvalDevToolModulePlugin.js100%100%100%100%
   EvalSourceMapDevToolPlugin.js100%100%100%100%
   ExportsInfo.js100%100%100%100%
   ExportsInfoApiPlugin.js100%100%100%100%
   ExternalModule.js98.67%100%100%98.67%1220, 1223, 519–523, 525, 671
   ExternalModuleFactoryPlugin.js100%100%100%100%
   ExternalsPlugin.js100%100%100%100%
   FileSystemInfo.js99.53%100%100%99.53%186, 2454–2455, 2458, 2469, 2480, 2491, 284, 3928, 3943, 3967
   FlagAllModulesAsUsedPlugin.js100%100%100%100%
   FlagDependencyExportsPlugin.js98.36%100%100%98.36%504, 513, 516, 520, 532
   FlagDependencyUsagePlugin.js100%100%100%100%
   FlagEntryExportAsUsedPlugin.js100%100%100%100%
   Generator.js100%100%100%100%
   HotModuleReplacementPlugin.js100%100%100%100%
   HotUpdateChunk.js100%100%100%100%
   IgnorePlugin.js100%100%100%100%
   IgnoreWarningsPlugin.js100%100%100%100%
   InitFragment.js100%100%100%100%
   JavascriptMetaInfoPlugin.js100%100%100%100%
   LazyBarrel.js100%100%100%100%
   LibraryTemplatePlugin.js100%100%100%100%
   LoaderOptionsPlugin.js100%100%100%100%
   LoaderTargetPlugin.js100%100%100%100%
   MainTemplate.js100%100%100%100%
   ManifestPlugin.js100%100%100%100%
   Module.js98.51%100%100%98.51%1303, 1308, 1368, 1382, 1444, 1453
   ModuleFactory.js100%100%100%100%
   ModuleFilenameHelpers.js98.90%100%100%98.90%111, 113
   ModuleGraph.js99.78%100%100%99.78%1170
   ModuleGraphConnection.js100%100%100%100%
   ModuleInfoHeaderPlugin.js100%100%100%100%
   ModuleNotFoundError.js100%100%100%100%
   ModuleProfile.js100%100%100%100%
   ModuleSourceTypeConstants.js100%100%100%100%
   ModuleTemplate.js100%100%100%100%
   ModuleTypeConstants.js100%100%100%100%
   MultiCompiler.js99.72%100%100%99.72%721
   MultiStats.js100%100%100%100%
   MultiWatching.js100%100%100%100%
   NoEmitOnErrorsPlugin.js100%100%100%100%
   NodeStuffPlugin.js100%100%100%100%
   NormalModule.js97.99%100%100%97.99%1027, 1030, 1047, 1064, 1312, 1346, 1362, 1817, 2114, 2119–2129, 29
   NormalModuleFactory.js98.77%100%100%98.77%1142, 1410, 1421, 1431, 1482–1484, 1491, 536, 548
   NormalModuleReplacementPlugin.js100%100%100%100%
   NullFactory.js100%100%100%100%
   OptimizationStages.js100%100%100%100%
   OptionsApply.js100%100%100%100%
   Parser.js100%100%100%100%
   PlatformPlugin.js100%100%100%100%
   PrefetchPlugin.js100%100%100%100%
   ProgressPlugin.js99.80%100%100%99.80%690
   ProvidePlugin.js100%100%100%100%
   RawModule.js100%100%100%100%
   RecordIdsPlugin.js100%100%100%100%
   RequestShortener.js100%100%100%100%
   ResolverFactory.js100%100%100%100%
   RuntimeGlobals.js100%100%100%100%
   RuntimeModule.js100%100%100%100%
   RuntimePlugin.js95.69%100%100%95.69%310, 366, 375, 378, 402, 420, 441–442, 465, 485–486, 522–523, 546, 559–560, 632, 645, 666, 685
   RuntimeTemplate.js99.91%100%100%99.91%123
   SelfModuleFactory.js100%100%100%100%
   SingleEntryPlugin.js100%100%100%100%
   SourceMapDevToolModuleOptionsPlugin.js100%100%100%100%
   SourceMapDevToolPlugin.js98.63%100%100%98.63%220, 224, 226, 420, 431, 890
   Stats.js100%100%100%100%
   Template.js100%100%100%100%
   TemplatedPathPlugin.js99.48%100%100%99.48%364–365
   UseStrictPlugin.js100%100%100%100%
   WarnCaseSensitiveModulesPlugin.js100%100%100%100%
   WarnDeprecatedOptionPlugin.js100%100%100%100%
   WarnNoModeSetPlugin.js100%100%100%100%
   WatchIgnorePlugin.js100%100%100%100%
   Watching.js100%100%100%100%
   WebpackError.js100%100%100%100%
   WebpackIsIncludedPlugin.js100%100%100%100%
   WebpackOptionsApply.js100%100%100%100%
   WebpackOptionsDefaulter.js100%100%100%100%
   buildChunkGraph.js99.87%100%100%99.87%376
   cli.js98.63%100%100%98.63%10, 119, 549, 581, 631, 905
   index.js99.73%100%100%99.73%184
   validateSchema.js94.67%100%100%94.67%100, 87, 89, 98
   webpack.js97.12%100%100%97.12%10, 267, 289, 291
lib/asset
   AssetBytesGenerator.js100%100%100%100%
   AssetBytesParser.js100%100%100%100%
   AssetGenerator.js100%100%100%100%
   AssetModule.js100%100%100%100%
   AssetModulesPlugin.js98.15%100%100%98.15%330, 354, 357, 487, 49, 54
   AssetParser.js100%100%100%100%
   AssetSourceGenerator.js100%100%100%100%
   AssetSourceParser.js100%100%100%100%
   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%
   IdleFileCachePlugin.js97.92%100%100%97.92%75, 87, 95
   MemoryCachePlugin.js92%100%100%92%34, 43
   MemoryWithGcCachePlugin.js93.42%100%100%93.42%108, 122–123, 132, 90
   PackFileCacheStrategy.js96.52%100%100%96.52%1310, 1410, 1414, 1476, 1712, 1796, 1819, 1851, 675, 694, 704–706, 708, 724–725, 730, 733, 735, 740, 745, 770, 776, 810,
All reactions

Sorry, something went wrong.

Uh oh!

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

@alexander-akait
alexander-akait merged commit eb88274 into main Aug 11, 2026
63 of 64 checks passed

Uh oh!

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

@alexander-akait
alexander-akait deleted the perf/css-minifier-speed branch August 11, 2026 19:11
@coderabbitai coderabbitai Bot mentioned this pull request Oct 20, 2026
perf(css): print repeated blocks and declarations once, and remove quadratic joins #22818
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments

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: css CSS support (lib/css) area: html Experimental HTML support (lib/html) area: tooling Repo tooling, codegen, CLI entry (tooling/, bin/) area: types types.d.ts, JSDoc annotations, hand-maintained declarations breaking-change Semver-major impact (valid on issues and PRs)

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.