Skip to content

Commit e3d8874

Browse files
docs: describe the minifier fix by module loading, not its cache symptom
Claude-Session: https://claude.ai/code/session_013FhutPJQq4FqAi1cjUXmv1
1 parent 9778658 commit e3d8874

4 files changed

Lines changed: 6 additions & 18 deletions

File tree

‎.changeset/079-minifier-build-dependencies.md‎

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": patch
3+
---
4+
5+
Load the default CSS and HTML minifiers in webpack, not through the plugin.

‎docs/caching.md‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,3 @@ The one expected write webpack ships is a module carrying a **build error**: `No
2424
## Diagnostics
2525

2626
**`makeSerializable` follows from where a diagnostic is created.** Anything reachable from a module (`ModuleError`, `ModuleWarning`, `ModuleBuildError`) is serialized with the module graph and must register. One built after seal and pushed onto `compilation.warnings` never enters the pack, which is why the size-limit and duplicate-package warnings register nothing. A wrong guess is silent except for `Pack got invalid because of write to:` under `ConfigCacheTestCases`, so cover a new diagnostic there.
27-
28-
## Build dependencies
29-
30-
Before saving, the cache resolves its build dependencies (`FileSystemInfo#resolveBuildDependencies`) and snapshots every file it reaches, on every cold build. It follows imports inside `node_modules` too: for CommonJS, `require.cache[file].children`, so the cost depends on **which module first loaded each file**, not only on what the code does; for ES modules (and every `.mjs`), the static and string-literal dynamic `import`s `es-module-lexer` finds in the source.
31-
32-
webpack's own directory is a managed path, so the walk normally stops there. A `lib/` file loaded by another package breaks that: it becomes a child of that package's module, which the walk reaches through the user's config. If that file reaches `require("webpack")`, `lib/index.js` joins its children and every webpack file loaded so far follows. That is how #22309 (the default CSS and HTML minifiers handed to `minimizer-webpack-plugin` as module paths) grew a cold production build of react-1k by about 15%: 729 files snapshotted instead of 44, with identical output.
33-
34-
So:
35-
36-
- **Hand webpack's own code to a third-party package as a value** (a function or object `lib/` already required), not a path it `require`s, unless the module never loads `webpack` in the main process.
37-
- **`yarn lint:module-loading` catches it**: it fails when a module outside webpack loads one of webpack's internal files.

‎tooling/check-module-loading.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
// Counts the modules a fresh process loads for each way webpack is used, and
99
// fails when a count grows past `module-loading.json` or a module outside
10-
// webpack loads one of its internal files: such a file then hangs under that
11-
// package, so the cache's build-dependency walk drags all of webpack in.
10+
// webpack loads one of its internal files rather than being handed it.
1211
//
1312
// node tooling/check-module-loading.js # check
1413
// node tooling/check-module-loading.js --write # rewrite the baseline

0 commit comments

Comments
 (0)