Visitar URL original
docs: document the generate option, and correct what it supersedes by alexander-akait · Pull Request #719 · webpack/minimizer-webpack-plugin · GitHub
Skip to content

docs: document the generate option, and correct what it supersedes - #719

Merged
alexander-akait merged 1 commit into
mainfrom
docs/document-generate-option
Sep 4, 2026
Merged

alexander-akait merged 1 commit into
mainfrom
docs/document-generate-option

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

generate and generatorOptions have been in src/options.json since the processResult hook landed in #711, and sharpGenerate is exported, but neither option was documented — generatorOptions appeared zero times in the README. The schema's own link fields already point at #generate and #generatoroptions, so a validation error linked to anchors that did not exist. This adds both sections.

Two existing Notes said the opposite of what the plugin now does: that these minimizers "never change an image's format or name" and that converting .png to .webp "stays with image-minimizer-webpack-plugin", and that ?as=webp is read by that plugin's loader. generate receives the module's resource with its query and can return a filename, and sharpGenerate reads ?as= — so both claims are now wrong. Each note now says which path it applies to and points at generate.

What kind of change does this PR introduce?

docs

Did you add tests for your changes?

No — documentation only, no source change. The behaviour described is already covered by test/generate-option.test.js; see Use of AI for how it was checked, since that suite self-skips on the webpack this repo locks.

Does this PR introduce a breaking change?

No.

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

This is the documentation. Worth knowing separately: generate needs the awaitable NormalModule.processResult hook, which is in no released webpack yet — it is on webpack main (5.110.3) from webpack/webpack#21854 and no release tag contains it. The plugin's own error message names 5.111, which the new section repeats.

Use of AI

Claude Code wrote the sections from the implementation rather than from the existing prose — the schema, the generate() method, and sharpGenerate's format selection. test/generate-option.test.js passes trivially here because it self-skips on webpack 5.109.2, which this repo locks, so it was re-run against webpack main with the skip guard temporarily made fatal, to confirm the eleven cases really exercise the rename, the query and fragment surviving, the filters, and the format-ambiguity errors before any of it was written down.


Generated by Claude Code

`generate` and `generatorOptions` have been in the options schema since the
`processResult` hook landed, and the schema's own `link` fields point at
`#generate` and `#generatoroptions` -- anchors the README did not have. Add
both sections: the function shape, the `filename` that renames the asset,
which filters select a module, that it runs in process, and `sharpGenerate`
taking its target format from `?as=` or from a single `encodeOptions` entry.

Two notes said the opposite and are now wrong. Format conversion no longer
"stays with image-minimizer-webpack-plugin", and `?as=webp` is read here --
by `generate`, which sees the module while it builds. Both now say which
path each applies to and point at `generate` rather than the other plugin.
@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.73%. Comparing base (4f65acd) to head (12cd2e5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #719   +/-   ##
=======================================
  Coverage   94.73%   94.73%           
=======================================
  Files           4        4           
  Lines        1102     1102           
  Branches      392      386    -6     
=======================================
  Hits         1044     1044           
  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 cc1f712 into main Sep 4, 2026
31 checks passed
@alexander-akait
alexander-akait deleted the docs/document-generate-option branch September 4, 2026 12:56
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