Repository navigation
Commit 6b15260
authored
refactor: group the graph, the define plugins and three stragglers out of lib/ root (#22213)
* refactor: group the module graph's nodes and edges into lib/graph/
`lib/graph/` already held the two graphs a compilation carries; it now holds
what they are graphs of. The edges join it — `Dependency`, the
`DependenciesBlock` holding them and the `AsyncDependenciesBlock` for a block
loaded on demand — and so does the chunk side, `Chunk`, `ChunkGroup`,
`Entrypoint` and `HotUpdateChunk`. `lib/dependencies/` keeps the concrete
subclasses and `lib/template/` the `DependencyTemplate` they print through;
these are the base classes every build has. Root goes from 49 files to 45.
Three re-exports are owed and kept. `ignore-webpack-plugin` requires
`lib/Dependency` at the top level and peers webpack >=5;
`external-svg-sprite-loader` and its pixolith fork require `lib/Chunk` the
same way; `@vue/preload-webpack-plugin` requires `lib/Entrypoint` at module
scope and peers webpack 5. `lib/Chunk`'s and `lib/Entrypoint`'s `tsType` in
the schema point at the real path, since a type cannot be read through the
re-export.
`lib/AsyncDependenciesBlock` is recorded as unreachable instead: its only
importer is hard-source-webpack-plugin, which also imports
`lib/DependenciesBlockVariable` and `lib/JavascriptGenerator`, both removed
in webpack 5. The two serializable classes keep their old request restorable
through `registerLegacyRequest`, so a cache pack written before this loads.
`AsyncDependenciesBlock`'s removed-property tombstone gains the JSDoc its
`Dependency` counterpart already carried — without it the getter infers an
implicit `any` that `tsc` reports once the file moves.
* refactor: group the define plugins into lib/define/
`DefinePlugin` replaces a free identifier with a constant at parse time, and
`EnvironmentPlugin` and `DotenvPlugin` are each that same plugin fed from
somewhere else — one from `process.env`, one from a `.env` file, both
constructing a `DefinePlugin` and handing it definitions. The three move
together. `ProvidePlugin` substitutes an import rather than a value, so it
stays out. Root goes from 45 files to 42.
No re-export is owed: the ecosystem scan records no package importing any of
the three paths, and none of them is serializable or named by a `tsType`.
`DotenvPlugin` reads `schemas/WebpackOptions.json` relative to itself to
validate its own options, so that request moves down a level with it.
* refactor: move the last three stragglers into the directories that own them
`ModuleInfoHeaderPlugin` prints the per-module comment header into the
generated bundle through `Template`, so it joins `lib/template/`.
`LazyBarrel` finds the barrel files worth deferring and is required only by
`Compilation`, and `ConcatenationScope` is the protocol scope hoisting runs
on — `lib/optimize/ConcatenatedModule.js` is the only thing that constructs
one, while generators across `lib/` render through it — so both join
`lib/optimize/`. Root goes from 42 files to 39.
`lib/errors/` needed nothing: `WebpackError` and `ModuleNotFoundError` were
moved there already and the root files are re-exports, as are `InitFragment`
and `DependencyTemplate` for `lib/template/`. No re-export is owed for these
three — the ecosystem scan records no package importing them — and none is
serializable or named by a `tsType`.
* refactor: record every path this moves that the scan finds no importer for
The three-way classification the guide describes leaves a path nobody imports
in neither map, which reads as an omission rather than as a decision. Record
those nine under `removed` with the reason, so the record answers for every
path that left `lib/` root in this change rather than only for the ones an
importer was found for.
The consequence is worth stating: `--write` skips a path `removed` names, so
a package that starts importing one of these later is no longer recorded, and
`--check` no longer learns a re-export is owed.
* test(css): expect an escaped at-keyword to join like the name it spells
`mergeDistantRules` landed with two expectations written before #22201 made
an at-keyword read as the name its escapes spell. They assert that
`@\6d edia` is left as it stands and that an escaped `@keyframes` keeps
`from` — both of which were only true while the tables were keyed by the raw
spelling, so they have failed on `main` since #22174 merged.
The behaviour is the one #22201 established and is what the plain spelling
already gets: the two escaped conditions join, the sheet echoes the spelling
back as written, and the keyframe selector shortens. Added alongside is the
refusal under an escaped name, since reading the name is what reaches it.1 parent 8a404c6 commit 6b15260
286 files changed
Lines changed: 2251 additions & 2148 deletions
File tree
- lib
- asset
- config
- container
- context
- css
- define
- dependencies
- devtool
- dll
- electron
- entry
- errors
- esm
- externals
- graph
- hmr
- html
- ids
- javascript
- json
- library
- module
- node
- optimize
- performance
- prefetch
- runtime
- sharing
- stats
- template
- util
- wasm-async
- wasm-sync
- webworker
- web
- schemas
- test
- configCases/runtime/on-chunks-loaded-priority
- helpers
- unitCases
- tooling
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
| |||
82 | 89 | | |
83 | 90 | | |
84 | 91 | | |
85 | | - | |
| 92 | + | |
86 | 93 | | |
87 | 94 | | |
88 | 95 | | |
89 | | - | |
90 | | - | |
91 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
92 | 104 | | |
93 | 105 | | |
94 | 106 | | |
| |||
110 | 122 | | |
111 | 123 | | |
112 | 124 | | |
113 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
114 | 130 | | |
115 | 131 | | |
116 | 132 | | |
| |||
128 | 144 | | |
129 | 145 | | |
130 | 146 | | |
131 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
132 | 150 | | |
133 | 151 | | |
134 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
0 commit comments