Repository navigation
refactor: group the module model, the diagnostics and four more out of lib/ root - #22202
Conversation
|
|
Important Review skippedToo many files! This PR contains 328 files, which is 28 over the limit of 300. To get a review, reduce the PR to 300 files or fewer by splitting it into smaller PRs or changing its base branch. Usage-priced reviews support at most 300 files. ⚙️ Run configurationConfiguration used: Repository: webpack/webpack/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (328)
You can disable this status message by setting the 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. Comment |
|
This PR is packaged and the instant preview is available (8165624). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@8165624
yarn add -D webpack@https://pkg.pr.new/webpack@8165624
pnpm add -D webpack@https://pkg.pr.new/webpack@8165624 |
Generated code sizeComparing base (
Read 9 asset(s) changed size, test untouched
No runtime gained or lost a runtime module. Built |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22202 +/- ##
==========================================
+ Coverage 94.98% 95.00% +0.01%
==========================================
Files 749 751 +2
Lines 104424 104428 +4
Branches 32161 32161
==========================================
+ Hits 99189 99209 +20
+ Misses 5235 5219 -16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 44.58%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | benchmark "side-effects-reexport", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
152.9 KB | 903.2 KB | -83.07% |
| ❌ | Memory | benchmark "future-defaults", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
166.6 KB | 663.9 KB | -74.91% |
| ❌ | Memory | benchmark "many-modules-interop-runtime", scenario '{"name":"mode-production","mode":"production"}', measure 'exec' |
15.2 KB | 22 KB | -30.75% |
| ❌ | Simulation | benchmark "wasm-modules-sync", scenario '{"name":"mode-development","mode":"development"}' |
818.9 ms | 1,146.3 ms | -28.56% |
| ❌ | Memory | benchmark "html-many-chunks", scenario '{"name":"mode-development","mode":"development"}' |
1.7 MB | 2.3 MB | -26.3% |
| ⚡ | Memory | benchmark "wasm-modules-async", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
412.7 KB | 220.4 KB | +87.19% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing refactor/group-more-lib-directories (bf58839) with main (1046319)2
Footnotes
-
6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
No successful run was found on
main(39f17ad) during the generation of this report, so 1046319 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
A new `lib/diagnostics/` holds the plugins that raise a build-wide warning of their own — a case-insensitive filesystem collision, a deprecated option, a missing `mode` — plus `IgnoreWarningsPlugin`, which filters what they produced, and `NoEmitOnErrorsPlugin`, which reacts to errors rather than raising one. The classes they construct stay in `lib/errors/` and the `performance` hints in `lib/performance/`. `CircularModulesPlugin` joins `lib/optimize/` beside the passes that reason about the same cycles, and `LibraryTemplatePlugin` `lib/library/`. `lib/` root goes from 66 files to 60. `LibraryTemplatePlugin` keeps a re-export at its old path: `@aiot-toolkit/` and `@hap-toolkit/dsl-xvm` depend on webpack 5 directly and `@stylable/webpack-extensions` peers `^5.30.0`, and all three require it at the top level, for 139k weekly downloads. Nothing else moved here is imported from outside. `schemas/WebpackOptions.json` follows the file its `tsType` points at, without which `ignoreWarnings` regenerates as `any[]`. `types.d.ts` is byte-identical.
The `Module` base class and `NormalModule`, the `ModuleFactory` hierarchy that builds them, the `Generator` base class and the `CodeGenerationResults` its output lands in, `ModuleProfile`, and the two type-constant files leave `lib/` root together. A module subclass a plugin owns stays with that plugin, so this holds the ones every build has. Root goes from 60 files to 51. Three classes carry a serialization request. Each moves to `webpack/lib/module/<Name>` and keeps the old one restorable through `registerLegacyRequest`, so a pack written before this still loads; `internalSerializables` records both. `NormalModule`, `RawModule` and `NullFactory` keep a re-export at their old paths — webpack-5 packages require each at the top level, for 271k weekly downloads between them. `Module` and `Generator` do not: their only importer is hard-source-webpack-plugin, which also imports `lib/DependenciesBlockVariable` and `lib/JavascriptGenerator`, both removed in webpack 5, so both paths are recorded as unreachable instead. Two `schemas/WebpackOptions.json` `tsType` paths follow the files they point at. `types.d.ts` regenerates byte-identical.
`PlatformPlugin` pins the target platform a `target: false` build cannot infer, so it joins the rest of the option handling in `lib/config/`, and `HotModuleReplacementPlugin` joins the runtime modules and backend it drives in `lib/hmr/`. Neither is imported by any package the ecosystem scan reaches, so neither needs a re-export. Root goes from 51 files to 49. The scan itself gains a rule and loses an ambiguity: `--write` now skips a path the `removed` map names instead of recording it as a request too, so the two maps are disjoint and the request count means what it says. Refreshing the record over today's registry moved 25 such paths out of `requests`. AGENTS.md gains a required section on moving a file out of `lib/` root — run the scan, what earns a re-export, and the five places a path hides, of which only `require()` is obvious. Two references it already carried had gone stale under earlier moves and are corrected.
b9bc578 to
bf58839
Compare
Types CoverageCoverage after merging refactor/group-more-lib-directories into main will be
Coverage Report |
Summary
Continues the
lib/grouping from #22118 and #22191. 21 files move out oflib/root (66 → 49): a newlib/module/takes the module model — theModulebase class andNormalModule, theModuleFactoryhierarchy,GeneratorandCodeGenerationResults,ModuleProfileand the two type-constant files — and a newlib/diagnostics/takes the plugins that raise a build-wide warning of their own plusNoEmitOnErrorsPlugin;CircularModulesPlugin,LibraryTemplatePlugin,PlatformPluginandHotModuleReplacementPluginjoinoptimize/,library/,config/andhmr/. Behaviour is unchanged: every file moves as a git rename andtypes.d.tsregenerates byte-identical.Four re-exports are owed and kept —
NormalModule,RawModule,NullFactoryandLibraryTemplatePlugin, each required at the top level by a package that depends on or peers webpack 5.ModuleandGeneratorare not: their only importer also importslib/DependenciesBlockVariableandlib/JavascriptGenerator, both removed in webpack 5, so they are recorded as unreachable instead. The three serializable classes keep their old request restorable throughregisterLegacyRequest, so a cache pack written before this still loads.The scan tool gains one rule:
--writeno longer records a path theremovedmap already names, so the two maps are disjoint and the request count means what it says.AGENTS.mdgains a required section on moving a file out oflib/root, listing the five places a path hides — of which onlyrequire()is caught by anything automatic — and two stale file references it already carried are corrected.What kind of change does this PR introduce?
refactor
Did you add tests for your changes?
No new cases —
test/unitCases/deepPathShims.unittest.jsalready asserts every deep path the recorded scan names still resolves, and covers the four new re-exports off the same record.Generator.unittest.jsneeded its stack-frame expectation updated to the new path.Does this PR introduce a breaking change?
No.
compiler.webpack.*and the documented API are unchanged, every deep path the scan found either still resolves or is re-exported, and a pre-move persistent cache pack still restores.If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a — the Architecture listing in
AGENTS.mdgains a bullet per new directory, plus the new section on how to perform a move.Use of AI
Claude Code performed the moves and reference rewrites and ran the verification; each grouping was reviewed before pushing.
yarn lintpasses all nine stages,yarn fix:specialleavestypes.d.tsbyte-identical,ConfigCacheTestCasesreports noPack got invalidline across 16578 tests, and each re-export decision was made by reading the importing package's declared webpack range and its actual import site rather than its download count.🤖 Generated with Claude Code
https://claude.ai/code/session_01GWQWGaxh78jX2Ffh4EZ878
Generated by Claude Code