Skip to content

Commit 526d2d9

Browse files
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`.
1 parent 57d6b4e commit 526d2d9

21 files changed

Lines changed: 41 additions & 35 deletions

‎AGENTS.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ The directory listings below are the canonical map of the repository. **Whenever
122122
that plugin — `ExternalModule` in `lib/externals/`, `CssModule` in `lib/css/` — so
123123
this holds the ones every build has.
124124
- `lib/optimize/` — Optimization plugins (`SplitChunksPlugin`, `ConcatenatedModule`, …),
125-
including `CircularModulesPlugin`, which flags the import cycles the others reason about.
125+
including `CircularModulesPlugin`, which flags the import cycles the others reason
126+
about, and `LazyBarrel`, which finds the barrel files worth deferring.
127+
`ConcatenationScope` is the protocol scope hoisting runs on: `ConcatenatedModule`
128+
is the only thing that constructs one, and a generator anywhere in `lib/` renders
129+
through it.
126130
- `lib/performance/` — Asset/entrypoint size hints.
127131
- `lib/prefetch/` — Prefetch and preload, which are two mechanisms sharing a word:
128132
the runtime modules emitting `<link rel="prefetch">` for a chunk, and `PrefetchPlugin`
@@ -140,7 +144,9 @@ The directory listings below are the canonical map of the repository. **Whenever
140144
- `lib/stats/` — Stats output (default printer, JSON factories).
141145
- `lib/template/` — Source templates and init fragments the generators print through,
142146
including `RuntimeTemplate`, the printing helper every generator and dependency
143-
template is handed.
147+
template is handed, the `DependencyTemplate` base class, and
148+
`ModuleInfoHeaderPlugin`, which prints the per-module comment header into the
149+
generated bundle.
144150
- `lib/typescript/` — Experimental TypeScript module support (strip types via the Node.js TypeScript API).
145151
- `lib/url/` — `new URL(asset, import.meta.url)` references.
146152
- `lib/util/` — Utility helpers, including `RequestShortener`, which renders a request

‎lib/Compilation.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const {
1818
} = require("tapable");
1919
const { CachedSource } = require("webpack-sources");
2020
const FileSystemInfo = require("./FileSystemInfo");
21-
const LazyBarrelController = require("./LazyBarrel");
2221
const Stats = require("./Stats");
2322
const { MultiItemCache } = require("./cache/CacheFacade");
2423
const ErrorHelpers = require("./errors/ErrorHelpers");
@@ -39,6 +38,7 @@ const CodeGenerationResults = require("./module/CodeGenerationResults");
3938
const Module = require("./module/Module");
4039
const ModuleProfile = require("./module/ModuleProfile");
4140
const { WEBPACK_MODULE_TYPE_RUNTIME } = require("./module/ModuleTypeConstants");
41+
const LazyBarrelController = require("./optimize/LazyBarrel");
4242
const RuntimeGlobals = require("./runtime/RuntimeGlobals");
4343
const StatsFactory = require("./stats/StatsFactory");
4444
const StatsPrinter = require("./stats/StatsPrinter");

‎lib/asset/AssetBytesGenerator.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"use strict";
77

88
const { RawSource } = require("webpack-sources");
9-
const ConcatenationScope = require("../ConcatenationScope");
109
const Generator = require("../module/Generator");
1110
const {
1211
ASSET_URL_TYPE,
@@ -18,6 +17,7 @@ const {
1817
JAVASCRIPT_TYPES,
1918
NO_TYPES
2019
} = require("../module/ModuleSourceTypeConstants");
20+
const ConcatenationScope = require("../optimize/ConcatenationScope");
2121
const RuntimeGlobals = require("../runtime/RuntimeGlobals");
2222

2323
/** @import { Source } from "webpack-sources" */

‎lib/asset/AssetGenerator.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
const path = require("path");
99
const { RawSource } = require("webpack-sources");
10-
const ConcatenationScope = require("../ConcatenationScope");
1110
const URLDependency = require("../dependencies/URLDependency");
1211
const Generator = require("../module/Generator");
1312
const {
@@ -23,6 +22,7 @@ const {
2322
NO_TYPES
2423
} = require("../module/ModuleSourceTypeConstants");
2524
const { ASSET_MODULE_TYPE } = require("../module/ModuleTypeConstants");
25+
const ConcatenationScope = require("../optimize/ConcatenationScope");
2626
const RuntimeGlobals = require("../runtime/RuntimeGlobals");
2727
const { toTemplateSourceFileName } = require("../template/TemplatedPathPlugin");
2828
const { getScheme } = require("../util/URLAbsoluteSpecifier");

‎lib/asset/AssetSourceGenerator.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"use strict";
77

88
const { RawSource } = require("webpack-sources");
9-
const ConcatenationScope = require("../ConcatenationScope");
109
const Generator = require("../module/Generator");
1110
const {
1211
ASSET_URL_TYPE,
@@ -18,6 +17,7 @@ const {
1817
JAVASCRIPT_TYPES,
1918
NO_TYPES
2019
} = require("../module/ModuleSourceTypeConstants");
20+
const ConcatenationScope = require("../optimize/ConcatenationScope");
2121
const RuntimeGlobals = require("../runtime/RuntimeGlobals");
2222
const { languageOfFilename } = require("../util/dataURL");
2323

‎lib/config/WebpackOptionsApply.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ class WebpackOptionsApply extends OptionsApply {
405405
}
406406

407407
if (options.output.pathinfo) {
408-
const ModuleInfoHeaderPlugin = require("../ModuleInfoHeaderPlugin");
408+
const ModuleInfoHeaderPlugin = require("../template/ModuleInfoHeaderPlugin");
409409

410410
new ModuleInfoHeaderPlugin(options.output.pathinfo !== true).apply(
411411
compiler

‎lib/dependencies/CommonJsRequireDependency.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const HarmonyImportGuard = require("./HarmonyImportGuard");
2020
const ModuleDependency = require("./ModuleDependency");
2121

2222
/** @import { ReplaceSource } from "webpack-sources" */
23-
/** @import ConcatenationScope from "../ConcatenationScope" */
23+
/** @import ConcatenationScope from "../optimize/ConcatenationScope" */
2424
/**
2525
* @import {
2626
* GetConditionFn,

‎lib/dependencies/HarmonyExportExpressionDependency.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
"use strict";
77

8-
const ConcatenationScope = require("../ConcatenationScope");
98
const Dependency = require("../graph/Dependency");
9+
const ConcatenationScope = require("../optimize/ConcatenationScope");
1010
const { InlinedUsedName } = require("../optimize/InlineExports");
1111
const RuntimeGlobals = require("../runtime/RuntimeGlobals");
1212
const InitFragment = require("../template/InitFragment");

‎lib/dependencies/HarmonyExportImportedSpecifierDependency.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const processExportInfo = require("./processExportInfo");
8787
* JavascriptModuleBuildMeta
8888
* } from "../javascript/JavascriptModule"
8989
*/
90-
/** @import ConcatenationScope from "../ConcatenationScope" */
90+
/** @import ConcatenationScope from "../optimize/ConcatenationScope" */
9191

9292
/** @typedef {"missing" | "unused" | "empty-star" | "reexport-dynamic-default" | "reexport-named-default" | "reexport-namespace-object" | "reexport-fake-namespace-object" | "reexport-undefined" | "normal-reexport" | "dynamic-reexport"} ExportModeType */
9393

‎lib/externals/ExternalModule.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
const { SyncBailHook } = require("tapable");
99
const { OriginalSource, RawSource } = require("webpack-sources");
10-
const ConcatenationScope = require("../ConcatenationScope");
1110
const WebpackError = require("../WebpackError");
1211
const { DEFAULTS } = require("../config/defaults");
1312
const { ImportPhaseUtils } = require("../dependencies/ImportPhase");
@@ -25,6 +24,7 @@ const {
2524
JAVASCRIPT_MODULE_TYPE_DYNAMIC
2625
} = require("../module/ModuleTypeConstants");
2726
const { coreModules } = require("../node/nodeBuiltins");
27+
const ConcatenationScope = require("../optimize/ConcatenationScope");
2828
const RuntimeGlobals = require("../runtime/RuntimeGlobals");
2929
const InitFragment = require("../template/InitFragment");
3030
const Template = require("../template/Template");

0 commit comments

Comments
 (0)