GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(types): let plugins type their own fields on stats groups, parser state and build info by alexander-akait · Pull Request #23602 · webpack/webpack

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Nov 27, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Summary

Type coverage: object 7 → 6. any, unknown, untyped and typed lines are unchanged.

  1. A stats group of a path without a declared group type is typed. StatsFactoryGroup<K> fell back to object for an array path that has no StatsFactoryGroupKeys entry, so a groupResults tap on, say, compilation.chunks could return anything. It now falls back to StatsGroup<Item>, the shape every built-in group shares:

    type StatsGroup<Item> = KnownStatsGroup & { children?: Item[] } & Record<string, StatsJsonValue>;
    // KnownStatsGroup: { type?: string; filteredChildren?: number }

    A group whose children are not the path's created items, or that has a field the stats JSON cannot hold (such as a function), is now a type error.

  2. Plugins extend open types the way they extend BuildInfo. Every type with a Record<string, …> fallback was checked. The ones that had no @augmentable Known* interface for declaration merging now have one:

    • KnownStatsGroup (new)
    • KnownParserState (new): the fields every parser state has, split out of the generic ParserStateBase<TModule> so a plugin can merge into it without repeating the type parameter. KnownJavascriptParserState is now augmentable too.
    • KnownCreateStatsOptionsContext and KnownUnsafeCacheData. Their any fallbacks get the same "drop in the next major release" TODO as BuildInfo's.
    • The build info and build meta of each public module class: Normal, Asset, Concatenated, Context, Css (info and meta), External, Html, Javascript (info and meta), Json, and SyncWasm (meta).

    Left out on purpose:

    • KnownLazyCompilationProxyModuleBuildInfo is not in the public types.
    • KnownStatsPrinterContext is already augmentable and covers the printer's colors and formatters.
    • The manifest types are generated from ManifestPlugin's options schema.
    • ObjectConfiguration (CLI) and PreparsedAst are not field bags plugins add to.

What kind of change does this PR introduce?

refactor

Did you add tests for your changes?

Yes. Each guard was run with the change it protects reverted, and failed:

  • test/unitCases/stats/StatsFactoryGroup.unittest.js (new):
    • A real build groups compilation.chunks into initial and async groups and checks the stats JSON.
    • Two type tests: a group with a function field, and a group whose children are not chunks, are both refused. With the old object fallback, both @ts-expect-errors go unused.
  • test/typesCases/augmentation/index.ts (new, run by lint:types-module-test):
    • It merges a field into each of the 17 interfaces through declare module "webpack" and checks the field's type.
    • A declare module block can also add a new interface of the same name, so each interface must also keep one of webpack's own fields. Removing @augmentable from KnownParserState fails it.

yarn lint passes from a removed tsc cache. The stats and parser suites pass (439 tests).

Does this PR introduce a breaking change?

No runtime change: the lib/ diff is JSDoc only. Two type changes:

  • A groupResults tap on a path without a declared group type that returns a field the stats JSON cannot hold, such as a function, no longer type-checks. Such a field would break the stats JSON output anyway.
  • Augmentable types become exported interfaces, so types.d.ts now names them through exports. (about 300 lines move).

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, tests, verification and this description), directed and reviewed by me.


Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • TypeScript users can now add typed, plugin-specific fields to more build metadata and parser-state types through declaration merging.
    • Stats group types now describe group properties and child items more precisely, improving type support when configuring grouped stats output.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
alexander-akait added 2 commits November 27, 2026 02:34
@alexander-akait
refactor(types): type a stats group of a path without a declared group
81ae795
`StatsFactoryGroup` fell back to `object` for an array path that has no
`StatsFactoryGroupKeys` entry, so a `groupResults` tap on such a path
could return anything. It now falls back to `StatsGroup<Item>`, the
shape every built-in group shares: an optional `type`, `children` of the
path's created item, `filteredChildren`, and other stats JSON fields.

Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh
@alexander-akait
refactor(types): let plugins type their own fields on open types
d038c5a
A plugin extends `BuildInfo`, `BuildMeta` and the stats objects by
declaration merging into an `@augmentable` `Known*` interface. Give
the other plugin-extensible types the same:

- the stats group of a path without a declared group: `KnownStatsGroup`
- every parser's state: `KnownParserState`, and the JavaScript one's
  `KnownJavascriptParserState`
- the stats options context and the unsafe cache data
- the build info and build meta of each public module class

A type test declares a field on each interface and checks that it
keeps webpack's own fields, so it fails when one is not merged.

Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh
@changeset-bot

changeset-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d038c5a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack Patch

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coderabbitai coderabbitai Bot added area: css CSS support (lib/css) area: html Experimental HTML support (lib/html) area: optimization Tree-shaking, splitChunks, concatenation, ids (lib/optimize, lib/ids) area: parser JavaScript parsing and dependency analysis (lib/javascript, lib/dependencies) area: types types.d.ts, JSDoc annotations, hand-maintained declarations area: wasm WebAssembly modules (lib/wasm-*) labels Nov 27, 2026
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

This change adds augmentable JSDoc typedefs for plugin-specific fields, defines a shared parser-state shape, and gives stats-factory groups a typed fallback based on their created items. It adds TypeScript augmentation checks, stats-grouping tests, and a patch Changeset.

Changes: Typed plugin fields and stats groups

Layer / File(s) Summary
Document augmentable plugin types
.changeset/491-typed-stats-factory-group.md, lib/Compilation.js, lib/asset/AssetModule.js, lib/context/ContextModule.js, lib/css/CssModule.js, lib/externals/ExternalModule.js, lib/html/HtmlModule.js, lib/javascript/JavascriptModule.js, lib/javascript/JavascriptParser.js, lib/json/JsonModule.js, lib/module/NormalModule.js, lib/optimize/ConcatenatedModule.js, lib/wasm-sync/SyncWasmModule.js
The typedef documentation describes declaration merging for plugin fields and marks the types augmentable. The Changeset declares a patch release.
Define and check parser state types
lib/module/Parser.js, test/typesCases/augmentation/index.ts
KnownParserState provides the shared parser-state shape, and ParserStateBase<TModule> combines it with the module field. Type checks cover merged fields and retained properties across webpack interfaces.
Type and test stats groups
lib/stats/StatsFactory.js, test/fixtures/stats-grouping/*, test/unitCases/stats/StatsFactoryGroup.unittest.js
StatsFactoryGroup uses a typed group fallback based on the path’s created item. Tests check initial and async chunk groups. Additional test callbacks contain expected type errors and assert that the callbacks are functions.

Suggested labels: area: css, area: html, area: parser, area: optimization, area: wasm, area: types

Suggested reviewers: hai-x, avivkeller

Change: Refactor

Merge Risk: Minimal · up to d038c · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Inconclusive The title uses the conventional-commit form with type refactor and scope types. The change refactors TypeScript types so plugins can declare their own fields on stats groups, parser state, and build i… Confirm that the source branch name starts with the refactor prefix, or update the branch name to match the title type. The title format and type otherwise meet the requirement.
Passed Passed checks: 3 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title uses the conventional-commit form with type refactor and scope types. The change refactors TypeScript types so plugins can declare their own fields on stats groups, parser state, and build info, which matches the title. The title does not state the branch prefix, so the branch-match part of the requirement cannot be verified from the supplied context.

Resolution

Confirm that the source branch name starts with the refactor prefix, or update the branch name to match the title type. The title format and type otherwise meet the requirement.

  • 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

  • X
  • Mastodon
  • Reddit
  • LinkedIn
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: webpack/webpack
  • Branch: refactor/stats-factory-group
  • File: .coderabbit.yaml
  • Commit: d038c5a
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 31c9ead5-a2aa-42af-8b18-afc0f23c7270
Commits

Reviewing files that changed from the base of the PR and between ddf5a4b and d038c5a.

Files ignored due to path filters: 1

  • types.d.ts is excluded by !types.d.ts
Files selected for processing: 19

  • .changeset/491-typed-stats-factory-group.md
  • lib/Compilation.js
  • lib/asset/AssetModule.js
  • lib/context/ContextModule.js
  • lib/css/CssModule.js
  • lib/externals/ExternalModule.js
  • lib/html/HtmlModule.js
  • lib/javascript/JavascriptModule.js
  • lib/javascript/JavascriptParser.js
  • lib/json/JsonModule.js
  • lib/module/NormalModule.js
  • lib/module/Parser.js
  • lib/optimize/ConcatenatedModule.js
  • lib/stats/StatsFactory.js
  • lib/wasm-sync/SyncWasmModule.js
  • test/fixtures/stats-grouping/index.js
  • test/fixtures/stats-grouping/lazy.js
  • test/typesCases/augmentation/index.ts
  • test/unitCases/stats/StatsFactoryGroup.unittest.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Nov 27, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Reports for d038c5a, 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
npm i -D webpack@https://pkg.pr.new/webpack@23602
  • yarn
yarn add -D webpack@https://pkg.pr.new/webpack@23602
  • pnpm
pnpm add -D webpack@https://pkg.pr.new/webpack@23602

From Preview package run #14197.


Generated code size

Comparing base (ddf5a4b) to head (d038c5a). 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 — 11082 — — —

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.37 KiB — 2.64 KiB —
library amd-require 1.37 KiB — 2.63 KiB —
library assign 1.37 KiB — 2.63 KiB —
library assign-properties 1.41 KiB — 2.75 KiB —
library commonjs 1.37 KiB — 2.62 KiB —
library commonjs-module 1.37 KiB — 2.63 KiB —
library commonjs-static 1.54 KiB — 3.50 KiB —
library commonjs2 1.37 KiB — 2.63 KiB —
library global 1.37 KiB — 2.62 KiB —
library jsonp 1.37 KiB — 2.62 KiB —
library module 1.20 KiB — 2.30 KiB —
library self 1.37 KiB — 2.62 KiB —
library system 1.40 KiB — 2.69 KiB —
library this 1.37 KiB — 2.62 KiB —
library umd 1.43 KiB — 2.82 KiB —
library umd2 1.43 KiB — 2.82 KiB —
library var 1.37 KiB — 2.63 KiB —
library window 1.37 KiB — 2.62 KiB —
node-ssr 96.21 KiB — 370.39 KiB —
node-ssr-esm 96.56 KiB — 370.95 KiB —
react-100 32.83 KiB — 151.45 KiB —
react-1k 73.38 KiB — 897.75 KiB —
react-1k-esm 72.87 KiB — 896.58 KiB —
react-5k 188.96 KiB — 4.02 MiB —
webworker 36.75 KiB — 95.18 KiB —
webworker-esm 35.89 KiB — 93.90 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/): 2529 test(s), 11082 asset(s), 112 emitted nothing.

From Generated code size run #8832.


Types Coverage

Typed lines: 99.67% (215157 of 215875)

Kind Base Head Change
any 41 41 —
unknown 17 17 —
object 7 6 🟢 −1
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
lib/stats/StatsFactory.js 100.00% 2 0 (🟢 −1)
What the files this pull request changes still have
  • lib/stats/StatsFactory.js:64 any (EXPECTED_ANY)
  • lib/stats/StatsFactory.js:211 any (EXPECTED_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
lib/Compilation.js 99.97% 5 2
lib/module/NormalModule.js 100.00% 4 1
lib/loaders/LoaderOptionsPlugin.js 100.00% 4
lib/module/NormalModuleFactory.js 100.00% 3
lib/Compiler.js 99.89% 2
lib/config/defineConfig.js 100.00% 2
lib/hmr/HotModuleReplacement.runtime.js 100.00% 2
lib/index.js 100.00% 2
lib/javascript/syntax-printer.js 99.99% 1 1
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/stats/StatsFactory.js 100.00% 2 0 (🟢 −1)
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/hmr/JavascriptHotModuleReplacement.runtime.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/ObjectMiddleware.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/SortableSet.js 100.00% 1
lib/util/makeSerializable.js 100.00% 1
lib/util/terminalColors.js 100.00% 1
lib/worker/Worker.js 100.00% 1

From Types Coverage run #4798.


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 13 0
CSS syntax 13 0
HTML syntax 12 0
XML syntax 12 0
JavaScript minifier 14 0
CSS minifier 15 0
HTML minifier 21 0
XML minifier 15 0
JSON minifier 1 0
development build 425 103
production build 433 131
watch with HMR, one rebuild 449 110

From Module loading run #2042.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codspeed

codspeed Bot commented Nov 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning, 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

ℹ️ 30 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

✅ 351 untouched benchmarks


Comparing refactor/stats-factory-group (d038c5a) with main (ddf5a4b)

Open in CodSpeed
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait
alexander-akait merged commit d9a7441 into main Nov 27, 2026
90 of 92 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait
alexander-akait deleted the refactor/stats-factory-group branch November 27, 2026 12:08
@github-actions github-actions Bot mentioned this pull request Nov 27, 2026
chore(release): new release #23490
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

area: css CSS support (lib/css) area: html Experimental HTML support (lib/html) area: optimization Tree-shaking, splitChunks, concatenation, ids (lib/optimize, lib/ids) area: parser JavaScript parsing and dependency analysis (lib/javascript, lib/dependencies) area: types types.d.ts, JSDoc annotations, hand-maintained declarations area: wasm WebAssembly modules (lib/wasm-*)

Projects

None yet

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.

1 participant

@alexander-akait
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.