Repository navigation
refactor(types): type rule effects and the CLI config walker - #23034
Conversation
|
Types CoverageTyped lines: 99.56% (195225 of 196083)
Inferred Changed by this pull request
119 file(s) in
|
| File | Typed lines | EXPECTED_ANY |
EXPECTED_OBJECT |
EXPECTED_FUNCTION |
unknown |
inferred any |
|---|---|---|---|---|---|---|
lib/javascript/syntax-printer.js |
99.95% | 17 | 10 | 17 | 73 | |
lib/javascript/syntax-parser.js |
99.96% | 1 | 37 | |||
lib/Compilation.js |
99.63% | 6 | 2 | 19 | ||
lib/Compiler.js |
100.00% | 5 | 2 | 6 | ||
lib/stats/StatsFactory.js |
96.99% | 4 | 1 | 6 | ||
lib/cache/PackFileCacheStrategy.js |
99.23% | 10 | ||||
lib/hmr/JavascriptHotModuleReplacement.runtime.js |
100.00% | 1 | 7 | |||
lib/module/Module.js |
98.77% | 7 | ||||
lib/module/NormalModule.js |
99.45% | 4 | 1 | 2 | ||
lib/util/cleverMerge.js |
100.00% | 1 | 6 | |||
lib/util/terminalColors.js |
98.73% | 1 | 6 | |||
lib/module/NormalModuleFactory.js |
98.20% | 2 (🔴 +2) | 4 (🟢 −3) | |||
lib/resolve/getResolveOptionsKey.js |
100.00% | 1 | 1 | 4 | ||
lib/serialization/SerializerMiddleware.js |
100.00% | 3 | 3 | |||
lib/debug/ProfilingPlugin.js |
100.00% | 1 | 4 | |||
lib/define/DefinePlugin.js |
100.00% | 1 | 4 | |||
lib/hmr/HotModuleReplacement.runtime.js |
100.00% | 5 | ||||
lib/loaders/LoaderOptionsPlugin.js |
90.63% | 5 | ||||
lib/serialization/ObjectMiddleware.js |
99.79% | 1 | 4 | |||
lib/cache/MemoryWithGcCachePlugin.js |
100.00% | 4 | ||||
lib/config/cli.js |
99.73% | 1 | 1 | 2 (🟢 −20) | ||
lib/config/normalization.js |
99.14% | 4 | ||||
lib/graph/ModuleGraph.js |
100.00% | 3 | 1 | |||
lib/loaders/LoaderPlugin.js |
99.41% | 4 | ||||
lib/performance/HotspotsPlugin.js |
100.00% | 4 | ||||
lib/util/SortableSet.js |
98.98% | 4 | ||||
lib/cache/MemoryCachePlugin.js |
100.00% | 3 | ||||
lib/errors/WebpackError.js |
97.14% | 1 | 2 | |||
lib/util/WeakTupleMap.js |
100.00% | 3 | ||||
lib/util/deprecation.js |
99.24% | 1 | 1 | 1 | ||
lib/asset/AssetModulesPlugin.js |
99.38% | 2 | ||||
lib/cache/Cache.js |
100.00% | 2 | ||||
lib/cache/IdleFileCachePlugin.js |
100.00% | 2 | ||||
lib/config/defineConfig.js |
100.00% | 2 | ||||
lib/css/syntax-parser.js |
99.89% | 2 | ||||
lib/html/syntax-parser.js |
99.95% | 2 | ||||
lib/javascript/JavascriptModulesPlugin.js |
100.00% | 2 | ||||
lib/loaders/LoaderRunner.js |
97.55% | 2 | ||||
lib/module/Parser.js |
100.00% | 2 | ||||
lib/node/nodeConsole.js |
100.00% | 2 | ||||
lib/stats/DefaultStatsFactoryPlugin.js |
99.87% | 1 | 1 | |||
lib/stats/DefaultStatsPrinterPlugin.js |
99.88% | 2 | ||||
lib/util/SourceProcessor.js |
100.00% | 2 | ||||
lib/util/comparators.js |
100.00% | 2 | ||||
lib/util/serialization.js |
98.68% | 2 | ||||
lib/util/validateSchema.js |
100.00% | 2 | ||||
lib/MultiCompiler.js |
99.74% | 1 | ||||
lib/context/ContextModuleFactory.js |
100.00% | 1 | ||||
lib/css/CssModulesPlugin.js |
100.00% | 1 | ||||
lib/dependencies/import/ImportParserPlugin.js |
100.00% | 1 | ||||
lib/devtool/ModuleFilenameHelpers.js |
99.47% | 1 | ||||
lib/dll/DllReferencePlugin.js |
100.00% | 1 | ||||
lib/errors/NonErrorEmittedError.js |
100.00% | 1 | ||||
lib/hmr/HotModuleReplacementPlugin.js |
100.00% | 1 | ||||
lib/html/HtmlModulesPlugin.js |
99.51% | 1 | ||||
lib/index.js |
100.00% | 1 | ||||
lib/javascript/JavascriptParser.js |
100.00% | 1 | ||||
lib/logging/Logger.js |
100.00% | 1 | ||||
lib/logging/ProgressPlugin.js |
99.80% | 1 | ||||
lib/module/ModuleSourceTypeConstants.js |
100.00% | 1 | ||||
lib/optimize/ConcatenatedModule.js |
99.89% | 1 | ||||
lib/optimize/TupleQueue.js |
100.00% | 1 | ||||
lib/output/CopyPlugin.js |
100.00% | 1 | ||||
lib/output/ManifestPlugin.js |
100.00% | 1 | ||||
lib/performance/UnusedExternalsPlugin.js |
95.35% | 1 | ||||
lib/rules/BasicEffectRulePlugin.js |
100.00% | 1 | ||||
lib/rules/RuleSetCompiler.js |
99.72% | 1 | ||||
lib/serialization/PlainObjectSerializer.js |
100.00% | 1 | ||||
lib/serialization/SingleItemMiddleware.js |
100.00% | 1 | ||||
lib/serialization/types.js |
100.00% | 1 | ||||
lib/stats/DefaultStatsPresetPlugin.js |
100.00% | 1 | ||||
lib/stats/StatsPrinter.js |
99.11% | 1 | ||||
lib/template/Template.js |
100.00% | 1 | ||||
lib/util/TupleSet.js |
100.00% | 1 | ||||
lib/util/identifier.js |
100.00% | 1 | ||||
lib/util/magicComment.js |
100.00% | 1 | ||||
lib/util/makeSerializable.js |
100.00% | 1 | ||||
lib/asset/AssetBytesParser.js |
91.67% | |||||
lib/asset/AssetParser.js |
96.15% | |||||
lib/asset/AssetSourceParser.js |
91.67% | |||||
lib/config/validateSchema.js |
94.67% | |||||
lib/css/CssGenerator.js |
99.65% | |||||
lib/css/conventions.js |
98.68% | |||||
lib/css/syntax-printer.js |
99.73% | |||||
lib/dependencies/amd/AMDPlugin.js |
99.31% | |||||
lib/dependencies/amd/AMDRuntimeModules.js |
95.45% | |||||
lib/dependencies/commonjs/CommonJsExportsParserPlugin.js |
99.79% | |||||
lib/dependencies/esm/ESMExportInitFragment.js |
99.35% | |||||
lib/dependencies/helpers/processExportInfo.js |
96.97% | |||||
lib/dependencies/html/HtmlEntryDependency.js |
99.83% | |||||
lib/dependencies/import-meta/ImportMetaPlugin.js |
99.63% | |||||
lib/devtool/SourceMapDevToolPlugin.js |
99.78% | |||||
lib/errors/CacheEffectivenessWarning.js |
93.75% | |||||
lib/externals/ExternalModule.js |
99.87% | |||||
lib/fs/FileSystemInfo.js |
99.92% | |||||
lib/graph/buildChunkGraph.js |
99.88% | |||||
lib/hmr/HotModuleReplacementChunkVersionCheckRuntimeModule.js |
87.50% | |||||
lib/hmr/HotModuleReplacementRuntimeModule.js |
77.78% | |||||
lib/hmr/JavascriptHotModuleReplacementHelper.js |
91.30% | |||||
lib/hmr/lazyCompilationBackend.js |
99.07% | |||||
lib/html/HtmlGenerator.js |
99.87% | |||||
lib/javascript/JavascriptMetaInfoPlugin.js |
98.08% | |||||
lib/json/JsonParser.js |
96.88% | |||||
lib/optimize/LazyBucketSortedSet.js |
96.85% | |||||
lib/optimize/SideEffectsFlagPlugin.js |
99.78% | |||||
lib/performance/UnusedDefinesPlugin.js |
96.97% | |||||
lib/runtime/MakeDeferredNamespaceObjectRuntime.js |
99.65% | |||||
lib/schemes/HttpUriPlugin.js |
99.87% | |||||
lib/serialization/BinaryMiddleware.js |
99.27% | |||||
lib/sharing/semver.js |
99.54% | |||||
lib/template/RuntimeTemplate.js |
99.95% | |||||
lib/util/async.js |
97.62% | |||||
lib/util/binarySearchBounds.js |
94.74% | |||||
lib/util/createMappings.js |
98.45% | |||||
lib/util/globUtils.js |
99.83% | |||||
lib/util/registerExternalSerializer.js |
96.85% | |||||
lib/wasm-sync/WebAssemblyParser.js |
98.94% | |||||
lib/wasm/AsyncWebAssemblyParser.js |
97.83% | |||||
lib/webpack.js |
98.62% |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Schema values and path traversal types lib/config/cli.js |
Reads schemaPart.const through a typed local and widens path-value types for array-valued intermediates and results. Existing [] path handling remains unchanged. |
NormalModuleFactory rule effects
| Layer / File(s) | Summary |
|---|---|
Loader results and module settings lib/module/NormalModuleFactory.js |
Casts loader-effect results to LoaderItem without changing loader-selection conditions. Other object-valued effects merge with an existing non-null object setting; other values replace the setting. |
Possibly related PRs
- webpack/webpack#23021: Adds type annotations in
cli.jsandNormalModuleFactory.js, which are also updated here.
Suggested labels: area: config, area: types
Change: Refactor
Merge Risk: 
Minimal · up to ae7b8
-
The changes preserve existing CLI path handling and rule-effect merge behavior, with no merge-blocking risk identified.
Pre-merge checks: 
3 · 
1
-
Failed checks: 1 inconclusive Passed checks: 3 passed -
- 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.
|
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@23034
yarn add -D webpack@https://pkg.pr.new/webpack@23034
pnpm add -D webpack@https://pkg.pr.new/webpack@23034 |
Generated code sizeComparing base (
Read Sample appsNo sample app changed size. 26 unchanged app(s)
No asset changed size. No runtime gained or lost a runtime module. Built |
Merging this PR will degrade performance by 22.05%2 warnings, 1 note
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing |
Summary
Follow-up to #23021: removes 27 of the 29 inferred
anyleft inlib/module/NormalModuleFactory.jsandlib/config/cli.js. Public types are unchanged.NormalModuleFactory: a rule'suseeffects are cast toLoaderItem, which is the shapeUseEffectRulePluginalways builds. Every other effect value is read asunknown, then merged into or assigned to its setting as before:settings[type]once instead of three times.cli.js: the path walker ingetObjectAndPropertytypes each step as a newPathValue(an object, an array or a value). It also returns the array it builds instead of re-reading it fromcurrent[name], and reads the schema'sconstthrough a typed local.anylib/module/NormalModuleFactory.jslib/config/cli.jsThe 6 left are each a read of a public type that is
anyat its source:EffectBasic.value, the index signature ofObjectConfigurationand ofJSONSchema4. Narrowing those would change the public types.What kind of change does this PR introduce?
refactor
Did you add tests for your changes?
No new tests; the behaviour is unchanged. The
rule-setconfig cases (59), theloadersandmoduleconfig cases (437) andCli.basictest.jspass. InCli.basictest.js,createColors › simple (colors by default)also fails onmainin a session with no TTY.Does this PR introduce a breaking change?
No.
types.d.tsis unchanged.If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Claude Code wrote the change, using the Types Coverage tool's inferred-
anylist. It checked the change withyarn lintand the targeted config and CLI tests. The author reviewed it.Generated by Claude Code
Summary by CodeRabbit