Repository navigation
Commit 3733511
authored
refactor: group loose lib/ sources into directories (#22118)
* refactor(externals): move externals module sources into lib/externals/
ExternalModule, ExternalModuleFactoryPlugin and ExternalsPlugin move out
of the top of lib/ into their own directory, following lib/context/.
Both of ExternalModule's serialization requests move with it, and the
schema's tsType paths and the Architecture listing are updated.
ExternalModuleFactoryPlugin declared ExternalItemFunctionPromise through
`import("../lib/ExternalModuleFactoryPlugin")`, a path that resolved to
the file itself and would not survive the move; it now names the local
typedef directly, as the line above it already does.
* refactor(optimize): move export-flagging plugins into lib/optimize/
The four Flag*Plugin files and OptimizationStages join the optimization
plugins they belong with; eleven of OptimizationStages' fourteen callers
already sat in that directory.
ExportsInfo and ConcatenationScope stay where they are on purpose:
ExportsInfo is module-graph state reached through ModuleGraph from
dependencies, library and the css/json generators, and ConcatenationScope
is the codegen contract every Generator receives, so neither is an
optimization plugin.
* fix(serialization): keep pre-move requests restorable from old caches
Moving a serializable changes its request string, so a filesystem cache
written before the move names a key nothing registers and the entry is
rebuilt instead of restored. The existing generator aliases only load the
module; the inversed lookup still misses, so restoring throws.
ObjectMiddleware.registerLegacyRequest adds the historical request as an
extra deserialization key for an already registered constructor. Writes
keep using the current request, so only old caches reach the old key, and
the generator derives the loader entry from the call.
ContextModule, ExternalModule and ModuleExternalInitFragment register the
requests they had before moving, each marked for removal in webpack 6.
* chore: shorten the changeset summary to the 80-character limit
* refactor(watch): move watch mode sources into lib/watch/
Watching, MultiWatching and WatchIgnorePlugin leave the top of lib/ for
their own directory. No serializers are involved and the move is paths
only; the "webpack.Watching" logger names stay as they are.
* refactor(template): move template sources into lib/template/
Template, the three deprecated *Template shims, TemplatedPathPlugin,
InitFragment, ConditionalInitFragment and DependencyTemplate(s) move into
their own directory. Template alone is required from 185 files, so the
specifiers were rewritten by resolving each one rather than by hand.
InitFragment keeps its pre-move serialization request, the schema tsType
paths for TemplatedPathPlugin follow the file, and codecov.yml's ignores
for the deprecated shims are repointed so they stay out of coverage.
* fix(serialization): restore the three historical requests, not just load them
The generator's LEGACY_ALIASES table pointed three historical requests at
the module that now owns them, which loaded that module but registered
nothing under the old key, so restoring still threw and the entry was
rebuilt. Each owner now calls registerLegacyRequest instead, and the
generator derives the loader entry from that call, leaving
internalSerializables byte-identical while the keys actually resolve.
Also ignore a root dist/, which a watch test writes and a commit picked up.
* refactor(devtool): move source map sources into lib/devtool/
The three devtool plugins, SourceMapDevToolModuleOptionsPlugin and
ModuleFilenameHelpers move into their own directory. No serializers are
involved; the schema tsType paths for ModuleFilenameHelpers follow the
file across WebpackOptions, BannerPlugin and SourceMapDevToolPlugin.
* refactor(runtime): move the runtime module base into lib/runtime/
RuntimeGlobals, RuntimeModule and RuntimePlugin join the 39 runtime
modules already there: RuntimeModule is the class each extends,
RuntimeGlobals the symbols each declares, and RuntimePlugin what
injects them for the requirements a build collects.
RuntimeTemplate stays put — it is the codegen printing helper the
generators receive, and none of its referrers are in lib/runtime/.
* refactor(template): move RuntimeTemplate into lib/template/
Despite the name it is not a runtime-module concern: none of its
referrers sit in lib/runtime/, and what it does is print — module ids,
import statements, returning functions — for the generators and
dependency templates handed it.
TemplatedPathPlugin becomes a sibling, so prettier collapses the
memoize call that reaches for it onto one line.
* refactor(graph): move the module and chunk graphs into lib/graph/
ModuleGraph, ModuleGraphConnection, ChunkGraph, buildChunkGraph and
ExportsInfo form a unit: eight of the references between them point at
another member, and nothing else in lib/ sits between them.
ExportsInfo registers RestoreProvidedData under ModuleGraph's request
rather than its own, so that request moves with it and keeps a
registerLegacyRequest for packs written before.
The generator no longer needs its hand-written REQUIRE_OVERRIDES entry:
that existed to point the ModuleGraph key at a file other than the one
registering it, and the derived path now names ExportsInfo directly.
ConcatenationScope was considered and left alone — it holds no reference
to any of these, being the codegen contract every Generator receives.
* refactor(prefetch): move the build-time prefetch plugins into lib/prefetch/
PrefetchPlugin and AutomaticPrefetchPlugin were the only two files left
whose subject the directory already names. Nothing outside lib/index.js
reached for either.
They are prefetch in a different sense from what was already there: the
runtime modules emit a link rel=prefetch for a chunk, while these two
resolve a module eagerly at build time through PrefetchDependency. The
Architecture bullet now says so rather than letting the name blur them.
* refactor(errors): move ErrorHelpers into lib/errors/
Four of its referrers are the error classes themselves, and
deriveStackFromNestedError.js already shows a helper belongs beside
them rather than at the root.
Compilation reads toError off it through a destructure that sat between
two requires and blocked eslint's import sort, so that line now follows
the require block instead of splitting it.
* refactor(cache): move Cache and CacheFacade into lib/cache/
Cache has its referrer plurality there and CacheFacade is the handle
every cache/ plugin hands out, so both join the strategies rather than
sitting a directory above them.
The changeset folds in the ErrorHelpers move, which rides the same
branch.
* test: pin the two lib paths derived from __dirname
Moving ErrorHelpers into lib/errors/ changed what its WEBPACK_SOURCE_PATH
named, so frames in webpack's own source kept a position that moves with
a release. Nothing failed until a cache case noticed.
Both derivations are now pinned. The ErrorHelpers one walks lib/ and
asserts every file loses its position, so a file at any depth is covered
and a failure names the offenders. The defaults.js one asserts
cache.buildDependencies.defaultWebpack is lib/, which decides whether a
pack invalidates when webpack itself changes.
* refactor(entry): move the entry option's plugins into lib/entry/
EntryPlugin, EntryOptionPlugin and DynamicEntryPlugin reference each
other four times over and nothing else sits between them.
Two files that look like they belong were left where they are.
SingleEntryPlugin is the webpack 4 name and re-exports EntryPlugin, so
it stays at the root for require("webpack/lib/SingleEntryPlugin").
Entrypoint extends ChunkGroup and is reached from ten directories, only
two of them these plugins, so it stays beside ChunkGroup.
The schema's two DynamicEntryPlugin tsType paths follow the file.
* build: report which webpack/lib paths the ecosystem imports directly
A file moved out of lib/ root breaks any published package that named
its old path, and nothing in the repo could say which paths those are.
This ranks the most downloaded webpack-plugin and webpack-loader
packages, reads what each one requires, and exits non-zero while this
checkout fails to resolve something they name.
The registry's search endpoint carries weekly downloads with each hit,
so it answers discovery and ranking in one set of calls and api.npmjs.org
is never needed. Each package is read from its tarball rather than
installed, so no lifecycle script of a stranger's package runs.
* fix: re-export the three moved paths published plugins import
yarn find-deep-imports over the 100 most downloaded webpack-plugin and
webpack-loader packages found three paths this stack moved that shipped
packages still require by their old name: ModuleFilenameHelpers, at
521k weekly downloads across six of them, plus InitFragment and
DependencyTemplate.
Each keeps a re-export at the old path, as WebpackError and
ModuleNotFoundError already did. DependencyTemplate is not on
compiler.webpack, so its note names the new deep path instead of a
public API that does not exist.
A test asserts every shim resolves to the moved file, so the next move
fails rather than silently breaking them again.
* build: record what the ecosystem imports deeply, and check it offline
The scan always exited non-zero, because four of the paths it finds are
webpack 4 API that webpack 5 dropped on purpose, so it could gate
nothing. What it collects now lands in tooling/deep-webpack-imports.json,
whose removed map names those four with the reason each is deliberate.
That splits the tool in two. --write refreshes the record from npm and
is the half needing the network. --check reads only the record and fails
when a recorded path stopped resolving, naming the packages and the
downloads behind it, and a unit test asserts the same off the same file,
so a move out of lib/ root is caught by a test rather than by a report
from a user.
The record is written through prettier, so a refresh cannot leave
fmt:check red, and cspell ignores it because it is full of package names
no dictionary should carry.
* chore: fold the lib grouping changesets into one
Eleven entries for what lands as one pull request; the guide asks for a
single one naming them together.
* fix(tooling): keep a package name from naming a path outside the cache
CodeQL flagged the single-occurrence replace building the packument url.
The same replace named the cache directory, where it mattered more: a
name holding a second separator resolved outside CACHE_ROOT, and the
name comes from a registry response rather than from us.
Both now replace globally, and the directory keeps only characters a
name may safely contribute. Checked: "@a/b/../../../x" escaped before
and is contained after.
* fix: restore the relative-path literals the move rewrote
Moving RuntimeTemplate into lib/template/ ran its string literals through
the same relative-path resolver as its requires, so three "./" literals
became ".." and the public path gained a second "./": analyzable asset
urls read "././asset.txt".
Audited every moved file for the same class of damage by comparing each
against main with module specifiers blanked out; only this one was hit.
Also drops the JSDoc block the REQUIRE_OVERRIDES removal left orphaned.
* build(tooling): widen the deep-import scan and match only real imports
The scan took the top 100 `webpack-plugin` and `webpack-loader` packages.
Adding the broad `webpack` keyword and raising the default to 200 widens
it to 570 packages; one two keywords share is scanned once.
It also matched any quoted `webpack/lib/…` string, so a package that
bundled webpack reported webpack's own `makeSerializable` requests as
imports it does not make. Matching import positions only drops those 51.
What is left is two paths this pull request broke: ExternalsPlugin, which
worker-loader requires at load on webpack 5 at 568k weekly downloads, and
EntryPlugin, which @stylable/webpack-extensions requires. Both keep a
re-export at their old path.
The ten still unresolved are recorded under `removed`: nine reach webpack
only through hard-source-webpack-plugin, which is webpack 4 only, and
@sector-labs/lingui-loader probes JavascriptGenerator inside a `try` to
detect webpack 4, so re-exporting it would pick the wrong branch.
* ci: report the deep imports a pull request breaks
The record already said which `webpack/lib/…` paths published plugins and
loaders import, but only someone running the check by hand learned that a
move broke one.
`--check` now writes the finding as markdown, and a job posts it on the
pull request: which path stopped resolving, which packages import it and
how many weekly downloads sit behind them. It comments only once there is
something to say and edits that comment away when the paths resolve
again, so a green pull request stays quiet.
The check reads the record and the checkout alone, so the job needs no
install and no network — `prettier` moves into the one function that
writes the record. It runs in under a second, and fails after commenting
so the thread names the break rather than only the red check.1 parent db24532 commit 3733511
386 files changed
Lines changed: 3759 additions & 2086 deletions
File tree
- .changeset
- .github/workflows
- lib
- asset
- async-modules
- bun
- cache
- config
- container
- context
- css
- deno
- dependencies
- devtool
- dll
- electron
- entry
- errors
- esm
- externals
- graph
- hmr
- html
- ids
- javascript
- json
- library
- node
- optimize
- performance
- prefetch
- runtime
- serialization
- sharing
- stats
- template
- url
- util
- wasm-async
- wasm-sync
- wasm
- watch
- webworker
- web
- schemas
- plugins
- test
- configCases
- plugins/add-lazy-runtime-module
- runtime/on-chunks-loaded-priority
- web/prefetch-preload-module-only-js
- 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 | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
| 312 | + | |
312 | 313 | | |
313 | 314 | | |
314 | 315 | | |
| |||
326 | 327 | | |
327 | 328 | | |
328 | 329 | | |
| 330 | + | |
329 | 331 | | |
330 | 332 | | |
331 | 333 | | |
| |||
594 | 596 | | |
595 | 597 | | |
596 | 598 | | |
| 599 | + | |
597 | 600 | | |
598 | 601 | | |
599 | 602 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | 8 | | |
12 | 9 | | |
13 | 10 | | |
14 | 11 | | |
15 | 12 | | |
16 | | - | |
17 | 13 | | |
18 | 14 | | |
19 | 15 | | |
20 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
0 commit comments