Skip to content

feat: configure or exclude each asset type's minifier via optimization.minimize - #21663

Merged
alexander-akait merged 6 commits into
mainfrom
feat/optimization-minimize-by-type
Aug 10, 2026
Merged

feat: configure or exclude each asset type's minifier via optimization.minimize#21663
alexander-akait merged 6 commits into
mainfrom
feat/optimization-minimize-by-type

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

optimization.minimize also accepts a per-asset-type object (javascript / css / html): false disables minimizing that type, an object configures it — css.convertLengthUnits is the first option, forwarded to .css assets and the inline CSS in HTML alike, and javascript is handed as-is to the JS minimizer, with its { compress: { passes: 2 } } default now visible in the resolved config. Normalization canonicalizes the true shorthand into the object form, so this generalizes the single-type approach proposed earlier. Closes #21537.

What kind of change does this PR introduce?

feat

Did you add tests for your changes?

Yes — configCases/css/minimize-convert-length-units, configCases/html/minimize-css-options, and configCases/optimization/minimize-{css-only,html-only,javascript-only,javascript-options,nothing}, all passing under ConfigTestCases and ConfigCacheTestCases.

Does this PR introduce a breaking change?

No — minimize: true / false keep their behavior; the object form is new.

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

The optimization.minimize object form: per-type false, css.convertLengthUnits, and the javascript minimizer options with their default.

Use of AI

Implemented with Claude Code under my direction: it wrote the schema/config wiring and tests per my design decisions, and I reviewed the changes.


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Configure minimization independently for JavaScript, CSS, and HTML assets.
    • Customize JavaScript minimizer options, including compression and mangling.
    • Enable CSS length-unit conversion for stylesheets and inline HTML styles.
    • Collapse HTML whitespace during minification while preserving preformatted content.
    • Disable minimization for selected or all asset types.
  • Bug Fixes

    • Ensured CSS minimizer options apply consistently to standalone and inline styles.
    • Preserved asset-specific minimization settings when processing build output.

…n.minimize

`optimization.minimize` also accepts an object keyed by asset type
(`javascript`, `css`, `html`): `false` excludes a type from the built-in
minimizer, an object configures what it may do beyond the always-applied
transforms. First option: `css.convertLengthUnits`, handed to `.css` assets
and the inline CSS in HTML alike.
…hrough it

Per-type values are `false | options` — enable-with-defaults is expressed by
omitting the key, like `splitChunks`. Normalization canonicalizes the `true`
shorthand into the object form, and the defaults fill each type, so the JS
minimizer's `{ compress: { passes: 2 } }` shows up in the resolved config and
is overridable (`minimize.javascript` is handed as-is to the minimizer).
@changeset-bot

changeset-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: baa2fc1

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 area: config Options, defaults, validation (lib/config, schemas/) area: css CSS support (lib/css) area: html Experimental HTML support (lib/html) area: types types.d.ts, JSDoc annotations, hand-maintained declarations labels Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

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: 33 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: 4fbd646c-aa13-43ba-97be-c9a090140d87

📥 Commits

Reviewing files that changed from the base of the PR and between f4219a6 and baa2fc1.

📒 Files selected for processing (1)
  • test/HtmlSyntax.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

Webpack now accepts per-asset minimization options for JavaScript, CSS, and HTML. The default minimizer enables selected asset types and forwards CSS and HTML options to standalone and inline processing. New configuration cases validate these behaviors.

Changes

Per-asset minimization

Layer / File(s) Summary
Minimization contracts and normalization
schemas/WebpackOptions.json, lib/config/normalization.js, lib/config/defaults.js, .changeset/062-optimization-minimize-by-type.md
optimization.minimize accepts booleans or per-asset options. Normalization preserves omitted and disabled values and clones object configurations.
Type-specific minimizer wiring
lib/config/defaults.js, lib/css/cssMinify.js, lib/html/htmlMinify.js, test/configCases/html/minimize-css-options/webpack.config.js
The minimizer independently enables JavaScript, CSS, and HTML. CSS options, including convertLengthUnits, reach standalone CSS and inline HTML CSS processing. HTML options reach HTML processing.
HTML printing and whitespace handling
lib/html/syntax.js, lib/util/SourceProcessor.js
HTML printing supports collapseWhitespace. Whitespace runs collapse outside preformatted elements, and inline CSS receives per-print length-unit settings.
Configuration and output validation
test/Defaults.unittest.js, test/configCases/css/..., test/configCases/html/..., test/configCases/optimization/...
Snapshots and configuration cases validate default options, type-specific minimization, JavaScript options, CSS unit conversion, inline HTML CSS handling, and HTML whitespace collapsing.

Possibly related PRs

  • webpack/webpack#21595: Both changes extend HTML processing and printing through lib/html/syntax.js and lib/util/SourceProcessor.js.
  • webpack/webpack#21649: Both changes modify HTML minification behavior and add related HTML minimization tests.
🚥 Pre-merge checks | ✅ 2 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The changes add object-form minimization and collapseWhitespace, but omit the required removeAttributeQuotes and collapseBooleanAttributes support [#21537]. Implement removeAttributeQuotes and collapseBooleanAttributes in the schema, HTML printer, normalization, and tests, or update the linked issue scope.
Out of Scope Changes check ⚠️ Warning The PR adds CSS and JavaScript-specific options and CSS length-unit conversion, which are outside the directly linked HTML-focused issue [#21537]. Move CSS and JavaScript minimizer features to separate issues or link issues that explicitly cover those requirements.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses the valid feat conventional-commit type and clearly describes per-asset minifier configuration.

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

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

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

Install it locally:

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

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #21663   +/-   ##
=======================================
  Coverage   94.50%   94.51%           
=======================================
  Files         630      630           
  Lines       81830    81889   +59     
  Branches    24204    24231   +27     
=======================================
+ Hits        77337    77398   +61     
+ Misses       4493     4491    -2     
Flag Coverage Δ
css-parsing 26.39% <87.50%> (+0.02%) ⬆️
html5lib 30.84% <51.35%> (+0.01%) ⬆️
integration 88.33% <66.21%> (-0.03%) ⬇️
test262 50.99% <90.00%> (+0.01%) ⬆️
unit 54.49% <93.24%> (+0.03%) ⬆️

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.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Generated code size

Comparing baa2fc1 merged into 78d0d4c against 78d0d4c. Merging this PR will change the code webpack generates.

Changed New Deleted Unchanged Raw change
Cases 0 8 0 1539 🔴 ↑ +3.88 KiB
Assets 0 17 0 6007 🔴 ↑ +3.88 KiB
Runtimes 0 4 0 1891
17 asset(s) changed size
Asset Before After Change Gzip (9) Brotli (11) Zstd (19)
optimization/minimize-html-only main.js 727 B +727 B (new) new new new
optimization/minimize-css-only main.js 632 B +632 B (new) new new new
css/minimize-convert-length-units bundle0.css 405 B +405 B (new) new new new
html/minimize-collapse-whitespace page.html 331 B +331 B (new) new new new
optimization/minimize-nothing bundle0.js 282 B +282 B (new) new new new
html/minimize-css-options page.html 248 B +248 B (new) new new new
optimization/minimize-html-only page.html 207 B +207 B (new) new new new
optimization/minimize-javascript-options bundle0.js 201 B +201 B (new) new new new
optimization/minimize-css-only page.html 154 B +154 B (new) new new new
optimization/minimize-javascript-only page.html 154 B +154 B (new) new new new
html/minimize-css-options main.js 130 B +130 B (new) new new new
optimization/minimize-javascript-only main.js 129 B +129 B (new) new new new
html/minimize-collapse-whitespace main.js 126 B +126 B (new) new new new
css/minimize-convert-length-units bundle0.js 124 B +124 B (new) new new new
optimization/minimize-html-only main.css 54 B +54 B (new) new new new
optimization/minimize-javascript-only main.css 54 B +54 B (new) new new new
optimization/minimize-css-only main.css 13 B +13 B (new) new new new
4 runtime(s) changed which runtime modules they carry
Runtime Modules Added Removed
css/minimize-convert-length-units main 0 → 1 css loading
optimization/minimize-css-only main 0 → 1 css loading
optimization/minimize-html-only main 0 → 1 css loading
optimization/minimize-javascript-only main 0 → 1 css loading

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

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Caution

CodeRabbit couldn't update its existing comment. The review summary may be out of date.

Error details
putComment timed out

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (3)
lib/html/htmlMinify.js (2)

55-57: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Shorten the new explanatory comments.

  • lib/html/htmlMinify.js#L55-L57: reduce this comment to no more than two short lines.
  • lib/html/htmlMinify.js#L62-L64: reduce this comment to no more than two short lines.
  • lib/html/syntax.js#L8553-L8555: reduce this comment to no more than two short lines.

As per coding guidelines, comments must be “generally one line and no more than 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/html/htmlMinify.js` around lines 55 - 57, Shorten the explanatory
comments at lib/html/htmlMinify.js lines 55-57 and 62-64, and lib/html/syntax.js
lines 8553-8555, to no more than two short lines each while preserving their
essential meaning.

Sources: Coding guidelines, Path instructions


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

Use the precise minimizerOptions type.

The exact option shape is known in Lines 58-61. Replace object with { environment?: CssEnvironment, convertLengthUnits?: boolean } and remove the redundant assertion.

As per coding guidelines, prefer specific real JSDoc types when a precise type is available.

🤖 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/html/htmlMinify.js` at line 26, Update the minimizerOptions JSDoc
annotation above the relevant HTML minification function to use the precise
optional shape `{ environment?: CssEnvironment, convertLengthUnits?: boolean }`
shown in the existing implementation, and remove the redundant assertion
associated with the generic object type.

Sources: Coding guidelines, Path instructions

lib/css/cssMinify.js (1)

34-37: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the TODO within the source-comment limit.

The updated TODO uses four lines and includes detailed rationale. Keep the TODO to one or two short lines. Move the rationale to issue or documentation text.

Proposed edit
-	// TODO expose the remaining declined transforms on `optimization.minimize.css`
-	// (the way `convertLengthUnits` already is), each off by default. Every one is
-	// something csso, cssnano, lightningcss or esbuild ships on, and every one
-	// costs something a build may not want to pay:
+	// TODO expose the remaining declined transforms in `optimization.minimize.css`.

As per coding guidelines and path instructions, comments in lib/** must be at most two short lines and add non-obvious information.

🤖 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/css/cssMinify.js` around lines 34 - 37, Shorten the TODO in the CSS
minification configuration near convertLengthUnits to one or two concise lines
describing only the remaining declined transforms; remove the detailed rationale
from the source comment and leave it for issue or documentation text.

Sources: Coding guidelines, Path instructions

🤖 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/062-optimization-minimize-by-type.md:
- Line 5: Shorten the changeset sentence to a single concise imperative
statement under 80 characters, preserving the instruction to configure or
exclude asset-type minifiers through optimization.minimize.

In `@lib/config/defaults.js`:
- Around line 2531-2536: Update the HTML minimizer branch around minify and
minimizerOptions to pass the HTML-specific optimization.minimize.html options
through htmlMinify into SourceProcessor.process, while retaining cssOptions for
inline styles. Add an output snapshot covering an HTML-only setting such as
removeAttributeQuotes to verify it affects generated output.
- Around line 2435-2437: Shorten the comments at lib/config/defaults.js lines
2435-2437, 2465-2468, and 2511-2513, plus
test/configCases/html/minimize-css-options/webpack.config.js lines 29-31, so
each is no more than two short lines while preserving its meaning.

In `@schemas/WebpackOptions.json`:
- Around line 3705-3709: Extend the OptimizationMinimizeHtml schema to define
the supported HTML minifier controls, including removeAttributeQuotes and
collapseBooleanAttributes, while preserving strict validation for unknown
properties. Update the htmlMinify wiring to pass these HTML-specific options
through to HTML serialization rather than CSS options, and add output coverage
verifying each option’s enabled and disabled behavior.

---

Nitpick comments:
In `@lib/css/cssMinify.js`:
- Around line 34-37: Shorten the TODO in the CSS minification configuration near
convertLengthUnits to one or two concise lines describing only the remaining
declined transforms; remove the detailed rationale from the source comment and
leave it for issue or documentation text.

In `@lib/html/htmlMinify.js`:
- Around line 55-57: Shorten the explanatory comments at lib/html/htmlMinify.js
lines 55-57 and 62-64, and lib/html/syntax.js lines 8553-8555, to no more than
two short lines each while preserving their essential meaning.
- Line 26: Update the minimizerOptions JSDoc annotation above the relevant HTML
minification function to use the precise optional shape `{ environment?:
CssEnvironment, convertLengthUnits?: boolean }` shown in the existing
implementation, and remove the redundant assertion associated with the generic
object type.
🪄 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: c17d8e5a-3c16-49a0-883f-d22d375667c1

📥 Commits

Reviewing files that changed from the base of the PR and between 78d0d4c and 9d813be.

⛔ Files ignored due to path filters (8)
  • declarations/WebpackOptions.d.ts is excluded by !declarations/**
  • schemas/WebpackOptions.check.js is excluded by !schemas/**/*.check.js
  • test/__snapshots__/Cli.basictest.js.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
  • test/configCases/css/minimize-convert-length-units/__snapshots__/ConfigCacheTest.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
  • test/configCases/css/minimize-convert-length-units/__snapshots__/ConfigTest.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
  • test/configCases/html/minimize-css-options/__snapshots__/ConfigCacheTest.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
  • test/configCases/html/minimize-css-options/__snapshots__/ConfigTest.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
  • types.d.ts is excluded by !types.d.ts
📒 Files selected for processing (37)
  • .changeset/062-optimization-minimize-by-type.md
  • lib/config/defaults.js
  • lib/config/normalization.js
  • lib/css/cssMinify.js
  • lib/html/htmlMinify.js
  • lib/html/syntax.js
  • schemas/WebpackOptions.json
  • test/Defaults.unittest.js
  • test/configCases/css/minimize-convert-length-units/index.js
  • test/configCases/css/minimize-convert-length-units/style.css
  • test/configCases/css/minimize-convert-length-units/test.config.js
  • test/configCases/css/minimize-convert-length-units/webpack.config.js
  • test/configCases/html/minimize-css-options/index.js
  • test/configCases/html/minimize-css-options/page.html
  • test/configCases/html/minimize-css-options/test.config.js
  • test/configCases/html/minimize-css-options/webpack.config.js
  • test/configCases/optimization/minimize-css-only/index.js
  • test/configCases/optimization/minimize-css-only/page.html
  • test/configCases/optimization/minimize-css-only/style.css
  • test/configCases/optimization/minimize-css-only/test.config.js
  • test/configCases/optimization/minimize-css-only/webpack.config.js
  • test/configCases/optimization/minimize-html-only/index.js
  • test/configCases/optimization/minimize-html-only/page.html
  • test/configCases/optimization/minimize-html-only/style.css
  • test/configCases/optimization/minimize-html-only/test.config.js
  • test/configCases/optimization/minimize-html-only/webpack.config.js
  • test/configCases/optimization/minimize-javascript-only/index.js
  • test/configCases/optimization/minimize-javascript-only/page.html
  • test/configCases/optimization/minimize-javascript-only/style.css
  • test/configCases/optimization/minimize-javascript-only/test.config.js
  • test/configCases/optimization/minimize-javascript-only/webpack.config.js
  • test/configCases/optimization/minimize-javascript-options/index.js
  • test/configCases/optimization/minimize-javascript-options/test.config.js
  • test/configCases/optimization/minimize-javascript-options/webpack.config.js
  • test/configCases/optimization/minimize-nothing/index.js
  • test/configCases/optimization/minimize-nothing/test.config.js
  • test/configCases/optimization/minimize-nothing/webpack.config.js
🔗 Linked repositories identified

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

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

Comment thread .changeset/062-optimization-minimize-by-type.md Outdated
Comment thread lib/config/defaults.js Outdated
Comment thread lib/config/defaults.js
Comment on lines +3705 to +3709
"OptimizationMinimizeHtml": {
"description": "What the HTML minimizer may do beyond the transforms that always apply. No additional options are supported yet.",
"type": "object",
"additionalProperties": false,
"added": "5.110.0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Implement the required HTML minifier options.

OptimizationMinimizeHtml accepts only {}. The schema rejects HTML controls such as removeAttributeQuotes and collapseBooleanAttributes. The current minimizer wiring passes CSS options to htmlMinify, but it does not provide HTML-specific controls. Add the schema properties, propagate them to HTML serialization, and add output tests for enabled and disabled behavior.

🤖 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 `@schemas/WebpackOptions.json` around lines 3705 - 3709, Extend the
OptimizationMinimizeHtml schema to define the supported HTML minifier controls,
including removeAttributeQuotes and collapseBooleanAttributes, while preserving
strict validation for unknown properties. Update the htmlMinify wiring to pass
these HTML-specific options through to HTML serialization rather than CSS
options, and add output coverage verifying each option’s enabled and disabled
behavior.

@codspeed-hq

codspeed-hq Bot commented Aug 10, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 7.3%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 2 regressed benchmarks
✅ 307 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation benchmark "wasm-modules-sync", scenario '{"name":"mode-development","mode":"development"}' 1.1 s 1.5 s -26.83%
Memory benchmark "cache-filesystem", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 862.1 KB 1,151.8 KB -25.15%
Memory benchmark "asset-modules-bytes", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 1,143.2 KB 786 KB +45.45%

Tip

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


Comparing feat/optimization-minimize-by-type (baa2fc1) with main (78d0d4c)

Open in CodSpeed

The first HTML-specific minimizer option, wired through the per-type map:
each run of text whitespace collapses to one space — never removed
outright — skipping `pre` / `textarea` / `listing` ancestors and any text
carrying a `<`, which stays on the source-passthrough path.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
lib/html/syntax.js (1)

5558-5564: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Shorten the new prose comments.

Keep each comment to two short lines or fewer.

  • lib/html/syntax.js#L5558-L5564: reduce the prose that explains whitespace preservation.
  • lib/html/syntax.js#L9318-L9320: reduce the prose that explains preformatted-element handling.

As per coding guidelines and path instructions, “Comments must be at most two short lines and add non-obvious information.”

🤖 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/html/syntax.js` around lines 5558 - 5564, Shorten the comments in
lib/html/syntax.js at lines 5558-5564 and 9318-9320 to no more than two short
lines each, retaining only the non-obvious guidance about whitespace
preservation and preformatted-element handling.

Sources: Coding guidelines, Path instructions

🤖 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.

Nitpick comments:
In `@lib/html/syntax.js`:
- Around line 5558-5564: Shorten the comments in lib/html/syntax.js at lines
5558-5564 and 9318-9320 to no more than two short lines each, retaining only the
non-obvious guidance about whitespace preservation and preformatted-element
handling.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 99ee556e-fcc9-4646-8919-d319a5c2b030

📥 Commits

Reviewing files that changed from the base of the PR and between 339d931 and 30d6bbc.

⛔ Files ignored due to path filters (6)
  • declarations/WebpackOptions.d.ts is excluded by !declarations/**
  • schemas/WebpackOptions.check.js is excluded by !schemas/**/*.check.js
  • test/__snapshots__/Cli.basictest.js.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
  • test/configCases/html/minimize-collapse-whitespace/__snapshots__/ConfigCacheTest.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
  • test/configCases/html/minimize-collapse-whitespace/__snapshots__/ConfigTest.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
  • types.d.ts is excluded by !types.d.ts
📒 Files selected for processing (9)
  • lib/config/defaults.js
  • lib/html/htmlMinify.js
  • lib/html/syntax.js
  • lib/util/SourceProcessor.js
  • schemas/WebpackOptions.json
  • test/configCases/html/minimize-collapse-whitespace/index.js
  • test/configCases/html/minimize-collapse-whitespace/page.html
  • test/configCases/html/minimize-collapse-whitespace/test.config.js
  • test/configCases/html/minimize-collapse-whitespace/webpack.config.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 (3)
  • schemas/WebpackOptions.json
  • lib/config/defaults.js
  • lib/html/htmlMinify.js

Prettier's first pass over two untouched regions was not a fixed point;
the committed form now matches what `--check` verifies.
The config case exercises it only inside the minimizer's worker pool,
which jest's coverage cannot see — the same reason the CSS
`convertLengthUnits` transforms are unit-tested directly.
@github-actions

Copy link
Copy Markdown
Contributor

Types Coverage

Coverage after merging feat/optimization-minimize-by-type into main will be
99.27%
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.43%100%100%98.43%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, 6139, 6144, 6150, 6153, 6160, 6172, 6174, 6178, 6196, 6211, 6245, 6301, 6325, 6441, 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.70%100%100%95.70%319, 375, 384, 387, 411, 429, 450–451, 474, 494–495, 531–532, 555, 568–569, 641, 654, 675, 694
   RuntimeTemplate.js99.90%100%100%99.90%119
   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.47%100%100%99.47%352–353
   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.03%100%100%98.03%324, 348, 351, 43, 48, 481
   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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: config Options, defaults, validation (lib/config, schemas/) area: css CSS support (lib/css) area: html Experimental HTML support (lib/html) area: types types.d.ts, JSDoc annotations, hand-maintained declarations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Sponsor
SponsoredKunjungi sekarang
Promo