refactor: type buildInfo and buildMeta per module type#21172
Conversation
Split the monolithic KnownBuildInfo/KnownBuildMeta typedefs into common properties on Module plus module-type-specific typedefs declared in the dedicated module classes (JavascriptModule, CssModule, AssetModule, JsonModule, HtmlModule, SyncWasmModule, ExternalModule, ContextModule, ConcatenatedModule, LazyCompilationProxyModule). Each class redeclares buildInfo/buildMeta with its narrowed type and consumers cast to the specific type instead of the catch-all BuildInfo/BuildMeta. https://claude.ai/code/session_01XLFFANdnYhzJfJW4MxNoAP
🦋 Changeset detectedLatest commit: c49bc9c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
This PR is packaged and the instant preview is available (2a74860). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@2a74860
yarn add -D webpack@https://pkg.pr.new/webpack@2a74860
pnpm add -D webpack@https://pkg.pr.new/webpack@2a74860 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21172 +/- ##
==========================================
+ Coverage 92.58% 92.59% +0.01%
==========================================
Files 587 586 -1
Lines 63666 63786 +120
Branches 17636 17677 +41
==========================================
+ Hits 58946 59064 +118
- Misses 4720 4722 +2
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:
|
Rename CssBuildInfo -> CssModuleBuildInfo, JavascriptBuildInfo -> JavascriptModuleBuildInfo, AssetBuildInfo -> AssetModuleBuildInfo, JsonBuildInfo -> JsonModuleBuildInfo, HtmlBuildInfo -> HtmlModuleBuildInfo and SyncWasmBuildMeta -> SyncWasmModuleBuildMeta (incl. their Known* variants) so every type follows the <ClassName>BuildInfo/BuildMeta pattern already used by NormalModule, ExternalModule, ContextModule and ConcatenatedModule. https://claude.ai/code/session_01XLFFANdnYhzJfJW4MxNoAP
Merging this PR will improve performance by 24.7%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | benchmark "side-effects-reexport", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
758.1 KB | 1,196.2 KB | -36.62% |
| ❌ | Memory | benchmark "asset-modules-bytes", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
249 KB | 322.5 KB | -22.8% |
| ⚡ | Memory | benchmark "asset-modules-inline", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
1,299.6 KB | 319.3 KB | ×4.1 |
| ⚡ | Memory | benchmark "many-modules-commonjs", scenario '{"name":"mode-production","mode":"production"}' |
9 MB | 7.3 MB | +23.55% |
| ⚡ | Memory | benchmark "many-chunks-commonjs", scenario '{"name":"mode-production","mode":"production"}' |
8.8 MB | 7.1 MB | +22.57% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing refactor/buildinfo-buildmeta-types (c49bc9c) with main (5f01ae5)
Summary
Splits the monolithic
KnownBuildInfo/KnownBuildMetatypedefs into common properties onModuleplus module-type-specific typedefs (JavascriptBuildInfo/JavascriptBuildMeta,CssBuildInfo/CssBuildMeta,AssetBuildInfo,JsonBuildInfo,HtmlBuildInfo,SyncWasmBuildMeta,ExternalModuleBuildInfo,ContextModuleBuildInfo,ConcatenatedModuleBuildInfo) declared in the dedicated module classes (follow-up to #21164); each class redeclaresbuildInfo/buildMetawith its narrowed type and consumers cast to the specific type, so fields are documented and type-checked where they belong.What kind of change does this PR introduce?
refactor
Did you add tests for your changes?
No — type-level refactor with no runtime behavior change; covered by
tsc/type tests and existing test suites (module-classes, asset-modules, html, library config cases pass).Does this PR introduce a breaking change?
No —
BuildInfo/BuildMetakeep theirRecord<string, any>fallback, and the new per-type types are additionally exported fromlib/index.js.If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
This PR was implemented with Claude Code (AI) under maintainer direction, including the type split, call-site updates and regeneration of
types.d.ts.https://claude.ai/code/session_01XLFFANdnYhzJfJW4MxNoAP
Generated by Claude Code