Skip to content

feat: add built-in HTML minimizers from html-minimizer-webpack-plugin#668

Merged
alexander-akait merged 5 commits intomainfrom
claude/move-html-minimizers-ARCPO
May 4, 2026
Merged

feat: add built-in HTML minimizers from html-minimizer-webpack-plugin#668
alexander-akait merged 5 commits intomainfrom
claude/move-html-minimizers-ARCPO

Conversation

@alexander-akait
Copy link
Copy Markdown
Member

Move the HTML minifier implementations from html-minimizer-webpack-plugin
into this plugin so HTML assets can be minified via the standard
TerserPlugin interface. Adds four new static helpers:

  • TerserPlugin.htmlMinifierTerser (uses html-minifier-terser)
  • TerserPlugin.swcMinifyHtml (uses @swc/html for full documents)
  • TerserPlugin.swcMinifyHtmlFragment (uses @swc/html for fragments)
  • TerserPlugin.minifyHtmlNode (uses @minify-html/node)

The HTML packages are declared as optional peer dependencies — install
only the one you actually use. Documentation in the README now includes
a dedicated HTML section with usage examples for each minimizer.

claude added 2 commits May 4, 2026 17:17
Move the HTML minifier implementations from `html-minimizer-webpack-plugin`
into this plugin so HTML assets can be minified via the standard
`TerserPlugin` interface. Adds four new static helpers:

- `TerserPlugin.htmlMinifierTerser` (uses `html-minifier-terser`)
- `TerserPlugin.swcMinifyHtml` (uses `@swc/html` for full documents)
- `TerserPlugin.swcMinifyHtmlFragment` (uses `@swc/html` for fragments)
- `TerserPlugin.minifyHtmlNode` (uses `@minify-html/node`)

The HTML packages are declared as optional peer dependencies — install
only the one you actually use. Documentation in the README now includes
a dedicated HTML section with usage examples for each minimizer.
Replace the brief intro with a structured overview that groups every
built-in minimizer (JS, JSON, HTML) under its asset type, names the
static helper, links the upstream tool, and notes which optional peer
dependency to install. This makes it easy to pick the right minimizer
without reading the full Examples section.
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 4, 2026

CLA Not Signed

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #668      +/-   ##
==========================================
+ Coverage   97.38%   97.53%   +0.15%     
==========================================
  Files           3        3              
  Lines         382      406      +24     
  Branches      154      160       +6     
==========================================
+ Hits          372      396      +24     
  Misses         10       10              

☔ View full report in Codecov by Sentry.
📢 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.

claude added 3 commits May 4, 2026 17:47
Replace the standalone unit tests with end-to-end tests that go through
the full webpack pipeline — same pattern used by `test/minify-option.test.js`
for `terserMinify`, `swcMinify`, `esbuildMinify`, and `jsonMinify`.

Each test now spins up a webpack compiler with `getCompiler`, applies a
`TerserPlugin` configured for HTML, runs `compile`, and snapshots the
emitted assets, errors and warnings via `readsAssets` / `getErrors` /
`getWarnings`. New fixtures (`file.html`, `fragment.html`, plus
matching `html.js`/`html-fragment.js` entries that reference them via
`new URL(...)`) drive the asset emission, mirroring the existing
`fixtures/json.js` / `fixtures/file.json` setup for `jsonMinify`.

Coverage: each HTML minimizer (`htmlMinifierTerser`, `swcMinifyHtml`,
`swcMinifyHtmlFragment`, `minifyHtmlNode`) is exercised with default
options, plus dedicated cases for custom `minimizerOptions`,
`parallel: true` / `false` (htmlMinifierTerser, which supports worker
threads), and an array-of-`minify` chaining case.
Fold the 10 HTML-minimizer cases (and their snapshots) into the
existing `minify option` describe block in `test/minify-option.test.js`,
alongside the JS, JSON, and esbuild cases that already live there. The
standalone `test/htmlMinimizers.test.js` and its dedicated snapshot
file are removed.

The HTML fixtures (`fixtures/file.html`, `fixtures/fragment.html`,
`fixtures/html.js`, `fixtures/html-fragment.js`) stay where they are
and are now consumed from `minify-option.test.js`.
- Quote `parallel` and `true`/`false` with double quotes (matching
  the existing 'should work when the "parallel" option is "true"'
  style at the top of the file).
- Rename the array-of-`minify` chaining case to mirror the existing
  "should work when \`minify\` is an array of functions" wording.

Snapshots are regenerated under the new keys; obsolete keys removed.
@alexander-akait alexander-akait merged commit 9ddd343 into main May 4, 2026
28 of 29 checks passed
@alexander-akait alexander-akait deleted the claude/move-html-minimizers-ARCPO branch May 4, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants