GeezerVison is showing github.com — refactor(types): type the JavaScript minimizer options, experiments and plugins by alexander-akait · Pull Request #23487 · webpack/webpack
Conversation
alexander-akait
commented
Nov 19, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
declarations/WebpackOptions.ts had 11 written any. Four of them had a real type to name; this replaces those.
optimization.minimizeOptions.javascript: typed as the printer's MinifyOptions instead of { [key: string]: any }. Outside futureDefaults these options go to terser, so the type also lists the 33 terser compress options the printer doesn't read, such as passes from the default { compress: { passes: 2 } }. They're written out in lib/javascript/syntax-printer.js, with no terser import.
experiments, WebpackPluginInstance and ResolvePluginInstance: the types name only the keys webpack reads. The schemas still accept the rest at runtime.
- Schema generator: the
@additionalProperties tag alone now keeps a schema open, for interfaces and for tagged union branches, without an any index signature. All 43 schemas still derive byte for byte.
lib/config/defaults.js: the minimizer options array was typed with each minimizer's source-map parameter instead of its options, and had no XML entry; the old any hid both. minimizer-webpack-plugin pairs minify[i] with minimizerOptions[i], which its types can't state, so each minimizer is cast once to one that reads all the options types.
- Type generator: a type argument's written node was stored on the type it resolves to. For the shared
any type that node was whichever place resolved to any last, so once the plugin index no longer came first, every any in types.d.ts printed as Head<T> (252 places). any now ignores the stored node. On main's sources this changes nothing in the output.
devServer, loader options, custom loader-context values, and parser and generator options for custom module types stay any. Their shape belongs to webpack-dev-server or to the loader or plugin that reads them, and lib/ types them the same way.
Type coverage on this branch: any 41 (from 45), unknown 18, object 18, Function 0, untyped 0.
What kind of change does this PR introduce?
refactor (types), fix (tooling)
Did you add tests for your changes?
No new tests: the changes are types and the generators, whose output for the schemas and for types.d.ts on main is unchanged.
These pass:
lint:types, lint:types-test, the redundant-cast, lint and format checks;
- the schema generator: all 43 schemas derive byte for byte;
- the minimizer, defaults and validation unit tests (177) and the tooling unit tests (423);
- every test whose config this changes: the
library/entry-merge-exports-* and target/universal-all-module-types config cases, the context-independence stats case, and the split-watch-notifications and hotspots-per-build watch cases.
Does this PR introduce a breaking change?
No runtime change. For TypeScript users:
- A config that sets an experiment webpack no longer reads, such as
outputModule, topLevelAwait or layers, fails type-checking. It still validates and runs; the key already did nothing. Four test configs did this and drop the key.
- A plugin written as an object literal with fields besides
apply needs a type for those fields, as two test plugins now have. Plugin classes are unaffected.
minimizeOptions.javascript accepts the printer's options and terser's; a key neither names fails type-checking.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Written with Claude Code (investigation, implementation, verification and this description), directed and reviewed by me.
Generated by Claude Code
Summary by CodeRabbit
-
Bug Fixes
- Corrected generated schema handling for object properties and documented permissive values.
- Fixed type generation for shared
any values so they use the correct type definition.
-
Documentation
- Added more specific type information for JavaScript minimizer options, experiments, and plugin instances.
- Clarified supported compression options. Configuration types now reject undeclared extra properties in these areas.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…nd plugins
`optimization.minimizeOptions.javascript` is the printer's
`MinifyOptions`, with the 33 terser `compress` options terser runs
outside `futureDefaults` and the printer passes by, `passes` among them.
`experiments` and a plugin instance name only the keys webpack reads; the
schema still admits the rest, read from `@additionalProperties` alone.
The minimizer options array was typed by each minimizer's source map
parameter and had no XML entry, which the old `any` hid.
The type generator read a node stamped on the shared `any` by whichever
place resolved to it last, and printed `Head<T>` for every `any` once
the plugin index no longer came first.
Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 19, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
The pull request narrows configuration and plugin declarations, updates minimizer option annotations and schema metadata, adjusts schema and type generation, and changes test configurations to match the updated types.
Changes: Configuration typing and schema alignment
| Layer / File(s) |
Summary |
Option and plugin contracts lib/javascript/syntax-printer.js, declarations/WebpackOptions.ts, lib/config/defaults.js, schemas/WebpackOptions.json, .changeset/402-typed-minimizer-experiments-plugins.md |
Declarations remove arbitrary properties from experiment and plugin instance types, and use MinifyOptions for JavaScript minimizer options. Minimizer annotations use shared types. A patch Changeset records the typing changes. |
Schema and type generator rules tooling/generate-schemas.js, tooling/generate-types.js |
Schema generation adjusts how additionalProperties combines for union branches and object members. Type parsing ignores a recorded type node for any. |
Test configuration updates test/configCases/..., test/helpers/mergedConfigCases.js, test/statsCases/..., test/watchCases/..., examples/wasm-complex/webpack.config.js |
Several configurations remove experiment settings. The filename extension helper retains its legacy outputModule fallback. Plugin test configurations declare custom properties with intersection types. |
Suggested labels: area: config, area: parser, area: tooling
Suggested reviewers: hai-x
Change: Refactor
Merge Risk: Minimal · up to 298fb
-
This change tightens TypeScript typings for minimizer options, experiments, and plugin instances, with no reported runtime change. TypeScript users may see new errors for keys webpack does not read. Merge risk is minimal.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
 |
The title uses the required conventional-commit form with type "refactor" and scope "types". It matches the main change: replacing any types in declarations/WebpackOptions.ts with named types for Ja… |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Title check
-
Explanation
The title uses the required conventional-commit form with type "refactor" and scope "types". It matches the main change: replacing any types in declarations/WebpackOptions.ts with named types for JavaScript minimizer options, experiments, and plugin instances. The PR objectives describe the same change, so the title is fully related to the changeset. The branch prefix was not provided, so the match with the branch prefix could not be verified.
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
-
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 37df05b and 298fbac.
Files selected for processing: 2
-
examples/wasm-complex/webpack.config.js
schemas/WebpackOptions.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
codecov
Bot
commented
Nov 19, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.14%. Comparing base (c4666b0) to head (298fbac).
⚠️ Report is 20 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #23487 +/- ##
==========================================
+ Coverage 97.13% 97.14% +0.01%
==========================================
Files 815 816 +1
Lines 158353 160156 +1803
Branches 56927 57860 +933
==========================================
+ Hits 153809 155579 +1770
- Misses 4544 4577 +33
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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…schema's key order
`examples/wasm-complex` set `experiments.topLevelAwait`, which webpack no
longer reads and the type no longer names. The schema keeps its committed
key order, which the `format-schema` lint rule holds it to, with only the
`tsType` added.
Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh
|
Reports for 298fbac, computed by this pull request's own code. Each section updates when its workflow finishes.
Preview package
This PR is packaged and the instant preview of its latest commit is available.
Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@23487
yarn add -D webpack@https://pkg.pr.new/webpack@23487
pnpm add -D webpack@https://pkg.pr.new/webpack@23487
From Preview package run #13734.
Generated code size
Comparing base (9637a13) to head (298fbac). Merging this pull request will not change the code webpack generates.
| What moved |
Tests |
Assets |
Gzip |
Raw |
Test edit |
| Changed, test untouched |
0 |
0 |
— |
— |
— |
| Changed, test edited |
0 |
0 |
— |
— |
— |
| New |
0 |
0 |
— |
— |
— |
| Deleted |
0 |
0 |
— |
— |
— |
| Unchanged |
— |
10864 |
— |
— |
— |
Read Changed, test untouched first: the test is byte-identical on both sides, so webpack generated the difference. Changed, test edited moved partly because the test did — Test edit is how many bytes the test gained, and a bundle that grew by less is not a regression. New and Deleted are whole files, not deltas — a new asset was created, not grown, so it reads gray (⚪ added) — and adding tests cannot bury a real change. Gzip decides, because that is what users download; raw is the tiebreak, and brotli and zstd are per asset below.
Sample apps
No sample app changed size.
26 unchanged app(s)
| App |
Gzip |
Gzip change |
Raw |
Raw change |
library amd |
1.38 KiB |
— |
2.68 KiB |
— |
library amd-require |
1.38 KiB |
— |
2.67 KiB |
— |
library assign |
1.38 KiB |
— |
2.67 KiB |
— |
library assign-properties |
1.42 KiB |
— |
2.80 KiB |
— |
library commonjs |
1.38 KiB |
— |
2.66 KiB |
— |
library commonjs-module |
1.38 KiB |
— |
2.67 KiB |
— |
library commonjs-static |
1.55 KiB |
— |
3.54 KiB |
— |
library commonjs2 |
1.38 KiB |
— |
2.67 KiB |
— |
library global |
1.38 KiB |
— |
2.66 KiB |
— |
library jsonp |
1.37 KiB |
— |
2.66 KiB |
— |
library module |
1.21 KiB |
— |
2.35 KiB |
— |
library self |
1.38 KiB |
— |
2.66 KiB |
— |
library system |
1.41 KiB |
— |
2.73 KiB |
— |
library this |
1.38 KiB |
— |
2.66 KiB |
— |
library umd |
1.44 KiB |
— |
2.86 KiB |
— |
library umd2 |
1.44 KiB |
— |
2.86 KiB |
— |
library var |
1.38 KiB |
— |
2.67 KiB |
— |
library window |
1.38 KiB |
— |
2.66 KiB |
— |
node-ssr |
96.36 KiB |
— |
371.30 KiB |
— |
node-ssr-esm |
96.61 KiB |
— |
372.00 KiB |
— |
react-100 |
32.17 KiB |
— |
150.55 KiB |
— |
react-1k |
73.34 KiB |
— |
907.38 KiB |
— |
react-1k-esm |
72.54 KiB |
— |
906.44 KiB |
— |
react-5k |
191.49 KiB |
— |
4.08 MiB |
— |
webworker |
36.60 KiB |
— |
95.02 KiB |
— |
webworker-esm |
35.67 KiB |
— |
94.21 KiB |
— |
No asset changed size.
No runtime gained or lost a runtime module.
Built test/configCases with the defaults a user gets, and the apps in test/sizeCoreReports (apps/): 2499 test(s), 10864 asset(s), 112 emitted nothing.
From Generated code size run #8369.
Types Coverage
Typed lines: 99.65% (201006 of 201702)
| Kind |
Base |
Head |
Change |
any |
45 |
41 |
🟢 −4 |
unknown |
18 |
18 |
— |
object |
18 |
18 |
— |
Function |
0 |
0 |
— |
| untyped |
0 |
0 |
— |
any counts EXPECTED_ANY, a written any and JSDoc's * and ? for any type. unknown counts a written unknown; ThrownValue, the unknown a throw or a rejected promise hands on, is left out. object counts EXPECTED_OBJECT and Object, Function counts EXPECTED_FUNCTION. Untyped counts the any TypeScript infers where no type is written: a type argument a call leaves to inference that comes out any, whether a lib signature defaults it, as in const map = new Map() and Array(5), or a generic call infers it from an any argument; and const list = []. An identifier that only holds an any written in the project's files is not counted again, as the any row counts it where it is written; an any a lib signature returns, such as JSON.parse's, is counted in neither row.
Changed by this pull request
| File |
Typed lines |
any |
unknown |
object |
Function |
untyped |
declarations/WebpackOptions.ts |
100.00% |
7 (🟢 −4) |
|
|
|
|
What the files this pull request changes still have
declarations/WebpackOptions.ts:889 any
declarations/WebpackOptions.ts:1909 any
declarations/WebpackOptions.ts:2854 any
declarations/WebpackOptions.ts:4878 any
declarations/WebpackOptions.ts:5466 any
declarations/WebpackOptions.ts:5558 any
declarations/WebpackOptions.ts:5601 any
33 file(s) in lib/, hot/, declarations/ and bin/ still have an escape hatch, `any` or untyped identifiers
| File |
Typed lines |
any |
unknown |
object |
Function |
untyped |
declarations/WebpackOptions.ts |
100.00% |
7 (🟢 −4) |
|
|
|
|
lib/Compilation.js |
99.97% |
5 |
2 |
|
|
|
lib/javascript/syntax-printer.js |
100.00% |
|
|
5 |
|
|
lib/module/NormalModule.js |
100.00% |
4 |
1 |
|
|
|
lib/loaders/LoaderOptionsPlugin.js |
100.00% |
4 |
|
|
|
|
lib/serialization/ObjectMiddleware.js |
100.00% |
|
|
4 |
|
|
lib/util/SortableSet.js |
100.00% |
|
4 |
|
|
|
lib/hmr/HotModuleReplacement.runtime.js |
100.00% |
|
2 |
1 |
|
|
lib/module/NormalModuleFactory.js |
100.00% |
|
3 |
|
|
|
lib/stats/StatsFactory.js |
100.00% |
2 |
|
1 |
|
|
lib/Compiler.js |
100.00% |
2 |
|
|
|
|
lib/config/defineConfig.js |
100.00% |
2 |
|
|
|
|
lib/hmr/JavascriptHotModuleReplacement.runtime.js |
100.00% |
|
|
2 |
|
|
lib/index.js |
100.00% |
2 |
|
|
|
|
lib/loaders/LoaderRunner.js |
100.00% |
2 |
|
|
|
|
lib/module/Module.js |
100.00% |
2 |
|
|
|
|
lib/module/Parser.js |
100.00% |
2 |
|
|
|
|
lib/node/nodeConsole.js |
100.00% |
|
2 |
|
|
|
lib/util/cleverMerge.js |
100.00% |
|
|
2 |
|
|
lib/config/cli.js |
100.00% |
1 |
|
|
|
|
lib/dll/DllReferencePlugin.js |
100.00% |
1 |
|
|
|
|
lib/graph/ModuleGraph.js |
100.00% |
1 |
|
|
|
|
lib/hmr/HotModuleReplacementPlugin.js |
100.00% |
|
1 |
|
|
|
lib/javascript/JavascriptParser.js |
100.00% |
|
|
1 |
|
|
lib/javascript/syntax-parser.js |
100.00% |
1 |
|
|
|
|
lib/logging/Logger.js |
100.00% |
1 |
|
|
|
|
lib/logging/createConsoleLogger.js |
100.00% |
|
1 |
|
|
|
lib/output/ManifestPlugin.js |
100.00% |
1 |
|
|
|
|
lib/serialization/types.js |
100.00% |
|
|
1 |
|
|
lib/stats/DefaultStatsFactoryPlugin.js |
100.00% |
|
1 |
|
|
|
lib/stats/StatsPrinter.js |
100.00% |
1 |
|
|
|
|
lib/util/makeSerializable.js |
100.00% |
|
|
1 |
|
|
lib/util/terminalColors.js |
100.00% |
|
1 |
|
|
|
From Types Coverage run #4428.
Module loading
How many files a fresh Node.js process loads (require or import) to do each thing below; a change from the pull request's base is marked 🔴 when it grew and 🟢 when it shrank. Every file is startup time, so fewer is better. webpack files are this package's own (lib/, hot/); node_modules files are its dependencies'.
| What the process does |
webpack files |
node_modules files |
require("webpack") |
2 |
0 |
import "webpack" |
2 |
0 |
| JavaScript syntax |
12 |
0 |
| CSS syntax |
12 |
0 |
| HTML syntax |
11 |
0 |
| XML syntax |
11 |
0 |
| JavaScript minifier |
13 |
0 |
| CSS minifier |
14 |
0 |
| HTML minifier |
19 |
0 |
| XML minifier |
14 |
0 |
| JSON minifier |
1 |
0 |
| development build |
422 |
103 |
| production build |
430 |
133 |
| watch with HMR, one rebuild |
446 |
110 |
From Module loading run #1672.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Merging this PR will improve performance by 51.52%
3 warnings, 1 note
⚠️ 117 benchmarks are dominated by system calls
System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.
Learn more about system calls
See affected benchmarks
⚠️ 2 benchmarks with a significant change ran on different hardware
Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.
Learn more about Macro Runners
See affected benchmarks
⚠️ 1 benchmark with a significant change ran in a different software environment
Its base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the change might come from this difference rather than from the code. Open the benchmark to see what changed.
See affected benchmarks
ℹ️ 39 benchmarks have no flamegraph
The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.
See affected benchmarks
⚡ 2 improved benchmarks
✅ 349 untouched benchmarks
Performance Changes
Tip Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing refactor/typed-webpack-options-any (298fbac) with main (9637a13)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
runtimes (bun) failed on one watch case, WatchCacheUnaffectedTestCases › cache › plugin-error-recovery › exported tests 6: "No build reported the change", with the watcher suspended. This PR doesn't cause it:
- The
lib/ changes don't change runtime behavior. They are JSDoc in syntax-printer.js, and in defaults.js the same options objects built through typed variables and casts. The rest is declarations, the schema tsType, the two type generators and test configs.
- The case passes 3 of 3 runs locally under Bun (
yarn test:base:bun --ci test/WatchCacheUnaffectedTestCases.longtest.js -t plugin-error-recovery).
- None of the 20 newer commits on
main touch this test or the watch code.
I'll re-run the failed job once the run's coverage-notify job lets it finish.
Generated by Claude Code
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
area: config
Options, defaults, validation (lib/config, schemas/)
area: parser
JavaScript parsing and dependency analysis (lib/javascript, lib/dependencies)
area: tooling
Repo tooling, codegen, CLI entry (tooling/, bin/)
area: types
types.d.ts, JSDoc annotations, hand-maintained declarations
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.
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.
|