Skip to content

feat: add the imageminGenerate generator - #723

Merged
alexander-akait merged 1 commit into
mainfrom
feat/imagemin-generate
Sep 5, 2026
Merged

feat: add the imageminGenerate generator#723
alexander-akait merged 1 commit into
mainfrom
feat/imagemin-generate

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

The last capability image-minimizer-webpack-plugin has and this one does not, so it closes the functional gap between them. imageminMinify cannot write a converted image: a plugin like imagemin-webp produces a format the asset's name does not claim, and processAssets is past the point where a name can change, so it keeps the original and warns. generate runs while the module builds, which is where the rename is still possible.

Which format gets written is the plugins' decision rather than the caller's, so unlike sharpGenerate this one asks for no target: it reads the format back off the bytes and renames to match, leaving an asset its plugins did not convert under the name it had. Query and fragment survive, since they name the asset too. Everything else mirrors imageminMinify — the same imageminNormalizeConfig, the same ESM import(), the same imagemin@8-Buffer / @9-Uint8Array handling, and the same declared contract.

What kind of change does this PR introduce?

feat

Did you add tests for your changes?

Yes — four cases in test/image-minify-option.test.js: the rename, the unchanged-format case, query and fragment surviving, and the contract it declares. They drive imagemin-svgo over SVG markup carrying a raster name, which is the same mismatch imageminMinify refuses and needs no new dependency. It also joins the minimizer-version table, which now covers both generators.

Does this PR introduce a breaking change?

No — a new export, nothing existing changes.

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

Documented here: the generate section now says the two bundled generators differ in who picks the format, the note about a converting imagemin plugin points at this one, and the image-minimizer list says conversion is generate's job rather than a minimizer's.

Use of AI

Claude Code wrote it, from image-minimizer-webpack-plugin's own imageminGenerate and this repo's imageminMinify and sharpGenerate side by side, so the port keeps upstream's behaviour in this plugin's calling convention. The test reuses a trick already in the suite rather than adding imagemin-webp as a dependency, and was checked with a name filter to confirm the new cases execute rather than being skipped by the suite's package gate.


🤖 Generated with Claude Code

https://claude.ai/code/session_016TQeNpahUSDUjD2Crugy5H


Generated by Claude Code

The last capability `image-minimizer-webpack-plugin` had and this one did
not. `imageminMinify` cannot write a converted image: a plugin like
`imagemin-webp` produces a format the asset's name does not claim, and
`processAssets` is past the point where a name can change, so it keeps the
original and warns. `generate` runs while the module builds, which is where
the rename is still possible.

Which format gets written is the plugins' decision rather than the caller's,
so unlike `sharpGenerate` this one asks for no target: it reads the format
back off the bytes and renames to match, and leaves an asset its plugins did
not convert under the name it had. Query and fragment survive, since they
name the asset too.

Tested against `imagemin-svgo` over SVG markup carrying a raster name -- the
mismatch `imageminMinify` refuses, which is the one a generator exists to
take -- plus the unchanged-format and query cases and the contract it
declares. It joins the version table too, which now covers both generators.
@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a5909fb

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

This PR includes changesets to release 1 package
Name Type
minimizer-webpack-plugin 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

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.76%. Comparing base (cc1f712) to head (a5909fb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #723      +/-   ##
==========================================
+ Coverage   94.73%   94.76%   +0.02%     
==========================================
  Files           4        4              
  Lines        1102     1108       +6     
  Branches      386      386              
==========================================
+ Hits         1044     1050       +6     
  Misses         51       51              
  Partials        7        7              

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

@alexander-akait
alexander-akait merged commit d7e7346 into main Sep 5, 2026
31 checks passed
@alexander-akait
alexander-akait deleted the feat/imagemin-generate branch September 5, 2026 11:40
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.

1 participant