webpack 5.99.6 → 5.99.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/AutomaticPrefetchPlugin.js +21 -22
- package/lib/BannerPlugin.js +31 -35
- package/lib/CleanPlugin.js +5 -3
- package/lib/Compilation.js +21 -15
- package/lib/Compiler.js +2 -1
- package/lib/ContextExclusionPlugin.js +4 -2
- package/lib/ContextModule.js +1 -1
- package/lib/ContextModuleFactory.js +1 -2
- package/lib/ContextReplacementPlugin.js +7 -4
- package/lib/DefinePlugin.js +2 -2
- package/lib/DelegatedModule.js +18 -8
- package/lib/DelegatedModuleFactoryPlugin.js +9 -7
- package/lib/DelegatedPlugin.js +4 -2
- package/lib/DllEntryPlugin.js +4 -2
- package/lib/DllPlugin.js +5 -3
- package/lib/DllReferencePlugin.js +56 -60
- package/lib/DynamicEntryPlugin.js +4 -2
- package/lib/EntryOptionPlugin.js +3 -1
- package/lib/EntryPlugin.js +4 -2
- package/lib/EnvironmentPlugin.js +4 -2
- package/lib/EvalDevToolModulePlugin.js +9 -7
- package/lib/EvalSourceMapDevToolPlugin.js +138 -139
- package/lib/ExportsInfo.js +35 -16
- package/lib/ExternalModule.js +6 -5
- package/lib/ExternalsPlugin.js +3 -1
- package/lib/FileSystemInfo.js +2 -2
- package/lib/FlagDependencyExportsPlugin.js +2 -1
- package/lib/IgnorePlugin.js +6 -4
- package/lib/IgnoreWarningsPlugin.js +4 -2
- package/lib/LibManifestPlugin.js +5 -6
- package/lib/LoaderOptionsPlugin.js +4 -2
- package/lib/LoaderTargetPlugin.js +4 -2
- package/lib/Module.js +19 -12
- package/lib/ModuleFilenameHelpers.js +8 -4
- package/lib/ModuleInfoHeaderPlugin.js +11 -12
- package/lib/MultiCompiler.js +5 -3
- package/lib/NoEmitOnErrorsPlugin.js +5 -3
- package/lib/NormalModule.js +13 -8
- package/lib/NormalModuleReplacementPlugin.js +33 -36
- package/lib/PlatformPlugin.js +3 -1
- package/lib/PrefetchPlugin.js +4 -2
- package/lib/ProgressPlugin.js +23 -26
- package/lib/RecordIdsPlugin.js +72 -102
- package/lib/RuntimePlugin.js +34 -32
- package/lib/SourceMapDevToolPlugin.js +9 -8
- package/lib/WarnCaseSensitiveModulesPlugin.js +36 -37
- package/lib/WarnNoModeSetPlugin.js +3 -1
- package/lib/WatchIgnorePlugin.js +3 -1
- package/lib/WebpackError.js +11 -3
- package/lib/WebpackOptionsApply.js +6 -7
- package/lib/asset/AssetGenerator.js +2 -2
- package/lib/async-modules/InferAsyncModulesPlugin.js +25 -26
- package/lib/cache/IdleFileCachePlugin.js +11 -12
- package/lib/cache/MemoryWithGcCachePlugin.js +7 -5
- package/lib/cache/ResolverCachePlugin.js +8 -6
- package/lib/cli.js +5 -1
- package/lib/config/defaults.js +10 -6
- package/lib/config/normalization.js +14 -8
- package/lib/container/ContainerReferencePlugin.js +24 -26
- package/lib/container/ModuleFederationPlugin.js +2 -1
- package/lib/css/CssGenerator.js +1 -1
- package/lib/css/CssModulesPlugin.js +8 -6
- package/lib/debug/ProfilingPlugin.js +18 -21
- package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +9 -15
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -15
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -2
- package/lib/dependencies/LoaderPlugin.js +5 -3
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +46 -46
- package/lib/dependencies/RequireContextPlugin.js +2 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +94 -100
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/esm/ModuleChunkLoadingPlugin.js +72 -73
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +0 -2
- package/lib/hmr/LazyCompilationPlugin.js +17 -18
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -6
- package/lib/ids/DeterministicModuleIdsPlugin.js +47 -48
- package/lib/ids/HashedModuleIdsPlugin.js +4 -2
- package/lib/ids/NamedChunkIdsPlugin.js +4 -2
- package/lib/ids/NamedModuleIdsPlugin.js +4 -2
- package/lib/ids/NaturalChunkIdsPlugin.js +4 -2
- package/lib/ids/NaturalModuleIdsPlugin.js +4 -2
- package/lib/ids/OccurrenceChunkIdsPlugin.js +4 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -2
- package/lib/index.js +11 -0
- package/lib/javascript/JavascriptModulesPlugin.js +2 -2
- package/lib/javascript/JavascriptParser.js +634 -656
- package/lib/json/JsonModulesPlugin.js +4 -4
- package/lib/library/AbstractLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +60 -42
- package/lib/node/CommonJsChunkLoadingPlugin.js +69 -73
- package/lib/node/NodeEnvironmentPlugin.js +3 -1
- package/lib/node/nodeConsole.js +3 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +224 -232
- package/lib/optimize/ConcatenatedModule.js +15 -16
- package/lib/optimize/FlagIncludedChunksPlugin.js +92 -97
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +15 -16
- package/lib/optimize/MinChunkSizePlugin.js +4 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +6 -4
- package/lib/optimize/RealContentHashPlugin.js +4 -2
- package/lib/optimize/RemoveEmptyChunksPlugin.js +5 -3
- package/lib/optimize/RemoveParentModulesPlugin.js +4 -2
- package/lib/optimize/RuntimeChunkPlugin.js +21 -23
- package/lib/optimize/SideEffectsFlagPlugin.js +9 -6
- package/lib/optimize/SplitChunksPlugin.js +9 -7
- package/lib/performance/SizeLimitsPlugin.js +3 -1
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +61 -62
- package/lib/rules/BasicEffectRulePlugin.js +1 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +2 -1
- package/lib/rules/RuleSetCompiler.js +19 -5
- package/lib/rules/UseEffectRulePlugin.js +4 -6
- package/lib/runtime/StartupChunkDependenciesPlugin.js +39 -42
- package/lib/schemes/DataUriPlugin.js +5 -3
- package/lib/schemes/FileUriPlugin.js +5 -3
- package/lib/schemes/HttpUriPlugin.js +186 -188
- package/lib/serialization/AggregateErrorSerializer.js +42 -0
- package/lib/serialization/ErrorObjectSerializer.js +7 -2
- package/lib/serialization/ObjectMiddleware.js +13 -0
- package/lib/sharing/ProvideSharedPlugin.js +6 -4
- package/lib/stats/DefaultStatsFactoryPlugin.js +89 -33
- package/lib/stats/DefaultStatsPresetPlugin.js +25 -20
- package/lib/stats/DefaultStatsPrinterPlugin.js +306 -341
- package/lib/util/concatenate.js +4 -2
- package/lib/util/createHash.js +3 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +55 -57
- package/lib/web/JsonpChunkLoadingPlugin.js +73 -74
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +77 -78
- package/package.json +35 -30
- package/schemas/WebpackOptions.check.d.ts +1 -1
- package/schemas/WebpackOptions.check.js +2 -2
- package/schemas/WebpackOptions.json +267 -26
- package/schemas/plugins/BannerPlugin.check.d.ts +1 -1
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/DllPlugin.check.d.ts +1 -1
- package/schemas/plugins/DllPlugin.check.js +1 -1
- package/schemas/plugins/DllReferencePlugin.check.d.ts +1 -1
- package/schemas/plugins/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/IgnorePlugin.check.d.ts +1 -1
- package/schemas/plugins/IgnorePlugin.check.js +1 -1
- package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +1 -1
- package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.check.d.ts +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
- package/schemas/plugins/WatchIgnorePlugin.check.d.ts +1 -1
- package/schemas/plugins/WatchIgnorePlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ExternalsType.check.d.ts +1 -1
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssAutoParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssAutoParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssGlobalParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +1 -1
- package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +1 -1
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +1 -1
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +1 -1
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/json/JsonModulesPluginGenerator.check.d.ts +7 -0
- package/schemas/plugins/{JsonModulesPluginGenerator.check.js → json/JsonModulesPluginGenerator.check.js} +1 -1
- package/schemas/plugins/json/JsonModulesPluginGenerator.json +3 -0
- package/schemas/plugins/json/JsonModulesPluginParser.check.d.ts +7 -0
- package/schemas/plugins/{JsonModulesPluginParser.check.js → json/JsonModulesPluginParser.check.js} +1 -1
- package/schemas/plugins/json/JsonModulesPluginParser.json +3 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +1 -1
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +1 -1
- package/schemas/plugins/sharing/SharePlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
- package/types.d.ts +587 -207
- package/schemas/plugins/JsonModulesPluginGenerator.check.d.ts +0 -7
- package/schemas/plugins/JsonModulesPluginGenerator.json +0 -11
- package/schemas/plugins/JsonModulesPluginParser.check.d.ts +0 -7
- package/schemas/plugins/JsonModulesPluginParser.json +0 -16
@@ -11,6 +11,8 @@ const PrefetchDependency = require("./dependencies/PrefetchDependency");
|
|
11
11
|
|
12
12
|
/** @typedef {import("./Compiler")} Compiler */
|
13
13
|
|
14
|
+
const PLUGIN_NAME = "AutomaticPrefetchPlugin";
|
15
|
+
|
14
16
|
class AutomaticPrefetchPlugin {
|
15
17
|
/**
|
16
18
|
* Apply the plugin
|
@@ -19,7 +21,7 @@ class AutomaticPrefetchPlugin {
|
|
19
21
|
*/
|
20
22
|
apply(compiler) {
|
21
23
|
compiler.hooks.compilation.tap(
|
22
|
-
|
24
|
+
PLUGIN_NAME,
|
23
25
|
(compilation, { normalModuleFactory }) => {
|
24
26
|
compilation.dependencyFactories.set(
|
25
27
|
PrefetchDependency,
|
@@ -29,7 +31,7 @@ class AutomaticPrefetchPlugin {
|
|
29
31
|
);
|
30
32
|
/** @type {{context: string | null, request: string}[] | null} */
|
31
33
|
let lastModules = null;
|
32
|
-
compiler.hooks.afterCompile.tap(
|
34
|
+
compiler.hooks.afterCompile.tap(PLUGIN_NAME, compilation => {
|
33
35
|
lastModules = [];
|
34
36
|
|
35
37
|
for (const m of compilation.modules) {
|
@@ -41,26 +43,23 @@ class AutomaticPrefetchPlugin {
|
|
41
43
|
}
|
42
44
|
}
|
43
45
|
});
|
44
|
-
compiler.hooks.make.tapAsync(
|
45
|
-
|
46
|
-
(
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
err
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
);
|
62
|
-
}
|
63
|
-
);
|
46
|
+
compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => {
|
47
|
+
if (!lastModules) return callback();
|
48
|
+
asyncLib.each(
|
49
|
+
lastModules,
|
50
|
+
(m, callback) => {
|
51
|
+
compilation.addModuleChain(
|
52
|
+
m.context || compiler.context,
|
53
|
+
new PrefetchDependency(`!!${m.request}`),
|
54
|
+
callback
|
55
|
+
);
|
56
|
+
},
|
57
|
+
err => {
|
58
|
+
lastModules = null;
|
59
|
+
callback(err);
|
60
|
+
}
|
61
|
+
);
|
62
|
+
});
|
64
63
|
}
|
65
64
|
}
|
66
65
|
module.exports = AutomaticPrefetchPlugin;
|
package/lib/BannerPlugin.js
CHANGED
@@ -44,6 +44,8 @@ const wrapComment = str => {
|
|
44
44
|
.trimEnd()}\n */`;
|
45
45
|
};
|
46
46
|
|
47
|
+
const PLUGIN_NAME = "BannerPlugin";
|
48
|
+
|
47
49
|
class BannerPlugin {
|
48
50
|
/**
|
49
51
|
* @param {BannerPluginArgument} options options object
|
@@ -91,47 +93,41 @@ class BannerPlugin {
|
|
91
93
|
const stage =
|
92
94
|
this.options.stage || Compilation.PROCESS_ASSETS_STAGE_ADDITIONS;
|
93
95
|
|
94
|
-
compiler.hooks.compilation.tap(
|
95
|
-
compilation.hooks.processAssets.tap(
|
96
|
-
{
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
for (const
|
102
|
-
if (
|
96
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
97
|
+
compilation.hooks.processAssets.tap({ name: PLUGIN_NAME, stage }, () => {
|
98
|
+
for (const chunk of compilation.chunks) {
|
99
|
+
if (options.entryOnly && !chunk.canBeInitial()) {
|
100
|
+
continue;
|
101
|
+
}
|
102
|
+
|
103
|
+
for (const file of chunk.files) {
|
104
|
+
if (!matchObject(file)) {
|
103
105
|
continue;
|
104
106
|
}
|
105
107
|
|
106
|
-
|
107
|
-
|
108
|
-
|
108
|
+
/** @type {PathData} */
|
109
|
+
const data = { chunk, filename: file };
|
110
|
+
|
111
|
+
const comment = compilation.getPath(
|
112
|
+
/** @type {TemplatePath} */
|
113
|
+
(banner),
|
114
|
+
data
|
115
|
+
);
|
116
|
+
|
117
|
+
compilation.updateAsset(file, old => {
|
118
|
+
const cached = cache.get(old);
|
119
|
+
if (!cached || cached.comment !== comment) {
|
120
|
+
const source = options.footer
|
121
|
+
? new ConcatSource(old, "\n", comment)
|
122
|
+
: new ConcatSource(comment, "\n", old);
|
123
|
+
cache.set(old, { source, comment });
|
124
|
+
return source;
|
109
125
|
}
|
110
|
-
|
111
|
-
|
112
|
-
const data = { chunk, filename: file };
|
113
|
-
|
114
|
-
const comment = compilation.getPath(
|
115
|
-
/** @type {TemplatePath} */
|
116
|
-
(banner),
|
117
|
-
data
|
118
|
-
);
|
119
|
-
|
120
|
-
compilation.updateAsset(file, old => {
|
121
|
-
const cached = cache.get(old);
|
122
|
-
if (!cached || cached.comment !== comment) {
|
123
|
-
const source = options.footer
|
124
|
-
? new ConcatSource(old, "\n", comment)
|
125
|
-
: new ConcatSource(comment, "\n", old);
|
126
|
-
cache.set(old, { source, comment });
|
127
|
-
return source;
|
128
|
-
}
|
129
|
-
return cached.source;
|
130
|
-
});
|
131
|
-
}
|
126
|
+
return cached.source;
|
127
|
+
});
|
132
128
|
}
|
133
129
|
}
|
134
|
-
);
|
130
|
+
});
|
135
131
|
});
|
136
132
|
}
|
137
133
|
}
|
package/lib/CleanPlugin.js
CHANGED
@@ -296,6 +296,8 @@ const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
|
|
296
296
|
/** @type {WeakMap<Compilation, CleanPluginCompilationHooks>} */
|
297
297
|
const compilationHooksMap = new WeakMap();
|
298
298
|
|
299
|
+
const PLUGIN_NAME = "CleanPlugin";
|
300
|
+
|
299
301
|
class CleanPlugin {
|
300
302
|
/**
|
301
303
|
* @param {Compilation} compilation the compilation
|
@@ -349,18 +351,18 @@ class CleanPlugin {
|
|
349
351
|
|
350
352
|
compiler.hooks.emit.tapAsync(
|
351
353
|
{
|
352
|
-
name:
|
354
|
+
name: PLUGIN_NAME,
|
353
355
|
stage: 100
|
354
356
|
},
|
355
357
|
(compilation, callback) => {
|
356
358
|
const hooks = CleanPlugin.getCompilationHooks(compilation);
|
357
|
-
const logger = compilation.getLogger(
|
359
|
+
const logger = compilation.getLogger(`webpack.${PLUGIN_NAME}`);
|
358
360
|
const fs = /** @type {OutputFileSystem} */ (compiler.outputFileSystem);
|
359
361
|
|
360
362
|
if (!fs.readdir) {
|
361
363
|
return callback(
|
362
364
|
new Error(
|
363
|
-
|
365
|
+
`${PLUGIN_NAME}: Output filesystem doesn't support listing directories (readdir)`
|
364
366
|
)
|
365
367
|
);
|
366
368
|
}
|
package/lib/Compilation.js
CHANGED
@@ -130,7 +130,7 @@ const { isSourceEqual } = require("./util/source");
|
|
130
130
|
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsModule} StatsModule */
|
131
131
|
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
132
132
|
/** @typedef {import("./util/Hash")} Hash */
|
133
|
-
/** @typedef {import("
|
133
|
+
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
134
134
|
/**
|
135
135
|
* @template T
|
136
136
|
* @typedef {import("./util/deprecation").FakeHook<T>} FakeHook<T>
|
@@ -973,9 +973,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
973
973
|
/** @type {SyncBailHook<[string, LogEntry], boolean | void>} */
|
974
974
|
log: new SyncBailHook(["origin", "logEntry"]),
|
975
975
|
|
976
|
-
/** @type {SyncWaterfallHook<[
|
976
|
+
/** @type {SyncWaterfallHook<[Error[]]>} */
|
977
977
|
processWarnings: new SyncWaterfallHook(["warnings"]),
|
978
|
-
/** @type {SyncWaterfallHook<[
|
978
|
+
/** @type {SyncWaterfallHook<[Error[]]>} */
|
979
979
|
processErrors: new SyncWaterfallHook(["errors"]),
|
980
980
|
|
981
981
|
/** @type {HookMap<SyncHook<[Partial<NormalizedStatsOptions>, CreateStatsOptionsContext]>>} */
|
@@ -1143,9 +1143,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1143
1143
|
this.assetsInfo = new Map();
|
1144
1144
|
/** @type {Map<string, Map<string, Set<string>>>} */
|
1145
1145
|
this._assetsRelatedIn = new Map();
|
1146
|
-
/** @type {
|
1146
|
+
/** @type {Error[]} */
|
1147
1147
|
this.errors = [];
|
1148
|
-
/** @type {
|
1148
|
+
/** @type {Error[]} */
|
1149
1149
|
this.warnings = [];
|
1150
1150
|
/** @type {Compilation[]} */
|
1151
1151
|
this.children = [];
|
@@ -1520,7 +1520,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1520
1520
|
this.options,
|
1521
1521
|
this,
|
1522
1522
|
this.resolverFactory.get("normal", module.resolveOptions),
|
1523
|
-
/** @type {InputFileSystem} */
|
1523
|
+
/** @type {InputFileSystem} */
|
1524
|
+
(this.inputFileSystem),
|
1524
1525
|
err => {
|
1525
1526
|
if (currentProfile !== undefined) {
|
1526
1527
|
currentProfile.markBuildingEnd();
|
@@ -4313,7 +4314,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
4313
4314
|
) {
|
4314
4315
|
let moduleHashDigest;
|
4315
4316
|
try {
|
4316
|
-
const moduleHash = createHash(/** @type {
|
4317
|
+
const moduleHash = createHash(/** @type {HashFunction} */ (hashFunction));
|
4317
4318
|
module.updateHash(moduleHash, {
|
4318
4319
|
chunkGraph,
|
4319
4320
|
runtime,
|
@@ -4341,7 +4342,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
4341
4342
|
const hashFunction = outputOptions.hashFunction;
|
4342
4343
|
const hashDigest = outputOptions.hashDigest;
|
4343
4344
|
const hashDigestLength = outputOptions.hashDigestLength;
|
4344
|
-
const hash = createHash(/** @type {
|
4345
|
+
const hash = createHash(/** @type {HashFunction} */ (hashFunction));
|
4345
4346
|
if (outputOptions.hashSalt) {
|
4346
4347
|
hash.update(outputOptions.hashSalt);
|
4347
4348
|
}
|
@@ -4524,7 +4525,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4524
4525
|
this.logger.timeAggregate("hashing: hash runtime modules");
|
4525
4526
|
try {
|
4526
4527
|
this.logger.time("hashing: hash chunks");
|
4527
|
-
const chunkHash = createHash(
|
4528
|
+
const chunkHash = createHash(
|
4529
|
+
/** @type {HashFunction} */ (hashFunction)
|
4530
|
+
);
|
4528
4531
|
if (outputOptions.hashSalt) {
|
4529
4532
|
chunkHash.update(outputOptions.hashSalt);
|
4530
4533
|
}
|
@@ -4577,7 +4580,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4577
4580
|
for (const module of /** @type {Iterable<RuntimeModule>} */ (
|
4578
4581
|
chunkGraph.getChunkFullHashModulesIterable(chunk)
|
4579
4582
|
)) {
|
4580
|
-
const moduleHash = createHash(
|
4583
|
+
const moduleHash = createHash(
|
4584
|
+
/** @type {HashFunction} */ (hashFunction)
|
4585
|
+
);
|
4581
4586
|
module.updateHash(moduleHash, {
|
4582
4587
|
chunkGraph,
|
4583
4588
|
runtime: chunk.runtime,
|
@@ -4599,7 +4604,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4599
4604
|
(codeGenerationJobsMap.get(oldHash)).get(module)
|
4600
4605
|
).hash = moduleHashDigest;
|
4601
4606
|
}
|
4602
|
-
const chunkHash = createHash(/** @type {
|
4607
|
+
const chunkHash = createHash(/** @type {HashFunction} */ (hashFunction));
|
4603
4608
|
chunkHash.update(chunk.hash);
|
4604
4609
|
chunkHash.update(this.hash);
|
4605
4610
|
const chunkHashDigest =
|
@@ -5486,9 +5491,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
5486
5491
|
if (strictModuleExceptionHandling) {
|
5487
5492
|
if (id) delete moduleCache[id];
|
5488
5493
|
} else if (strictModuleErrorHandling) {
|
5489
|
-
moduleObject.error =
|
5490
|
-
|
5491
|
-
|
5494
|
+
moduleObject.error =
|
5495
|
+
/** @type {WebpackError} */
|
5496
|
+
(execErr);
|
5492
5497
|
}
|
5493
5498
|
if (!(/** @type {WebpackError} */ (execErr).module)) {
|
5494
5499
|
/** @type {WebpackError} */
|
@@ -5515,7 +5520,8 @@ This prevents using hashes of each other and should be avoided.`);
|
|
5515
5520
|
`Execution of module code from module graph (${
|
5516
5521
|
/** @type {Module} */
|
5517
5522
|
(module).readableIdentifier(this.requestShortener)
|
5518
|
-
}) failed: ${message}
|
5523
|
+
}) failed: ${message}`,
|
5524
|
+
{ cause: execErr }
|
5519
5525
|
);
|
5520
5526
|
err.stack = stack;
|
5521
5527
|
err.module = module;
|
package/lib/Compiler.js
CHANGED
@@ -625,7 +625,8 @@ class Compiler {
|
|
625
625
|
callback(err, entries, compilation);
|
626
626
|
} catch (runAsChildErr) {
|
627
627
|
const err = new WebpackError(
|
628
|
-
`compiler.runAsChild callback error: ${runAsChildErr}
|
628
|
+
`compiler.runAsChild callback error: ${runAsChildErr}`,
|
629
|
+
{ cause: runAsChildErr }
|
629
630
|
);
|
630
631
|
err.details = /** @type {Error} */ (runAsChildErr).stack;
|
631
632
|
/** @type {Compilation} */
|
@@ -7,6 +7,8 @@
|
|
7
7
|
/** @typedef {import("./Compiler")} Compiler */
|
8
8
|
/** @typedef {import("./ContextModuleFactory")} ContextModuleFactory */
|
9
9
|
|
10
|
+
const PLUGIN_NAME = "ContextExclusionPlugin";
|
11
|
+
|
10
12
|
class ContextExclusionPlugin {
|
11
13
|
/**
|
12
14
|
* @param {RegExp} negativeMatcher Matcher regular expression
|
@@ -21,8 +23,8 @@ class ContextExclusionPlugin {
|
|
21
23
|
* @returns {void}
|
22
24
|
*/
|
23
25
|
apply(compiler) {
|
24
|
-
compiler.hooks.contextModuleFactory.tap(
|
25
|
-
cmf.hooks.contextModuleFiles.tap(
|
26
|
+
compiler.hooks.contextModuleFactory.tap(PLUGIN_NAME, cmf => {
|
27
|
+
cmf.hooks.contextModuleFiles.tap(PLUGIN_NAME, files =>
|
26
28
|
files.filter(filePath => !this.negativeMatcher.test(filePath))
|
27
29
|
);
|
28
30
|
});
|
package/lib/ContextModule.js
CHANGED
@@ -81,7 +81,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
81
81
|
|
82
82
|
/**
|
83
83
|
* @typedef {object} ContextModuleOptionsExtras
|
84
|
-
* @property {false|string|string[]} resource
|
84
|
+
* @property {false | string | string[]} resource
|
85
85
|
* @property {string=} resourceQuery
|
86
86
|
* @property {string=} resourceFragment
|
87
87
|
* @property {ResolveOptions=} resolveOptions
|
@@ -14,6 +14,8 @@ const { join } = require("./util/fs");
|
|
14
14
|
|
15
15
|
/** @typedef {Record<string, string>} NewContentCreateContextMap */
|
16
16
|
|
17
|
+
const PLUGIN_NAME = "ContextReplacementPlugin";
|
18
|
+
|
17
19
|
class ContextReplacementPlugin {
|
18
20
|
/**
|
19
21
|
* @param {RegExp} resourceRegExp A regular expression that determines which files will be selected
|
@@ -95,8 +97,8 @@ class ContextReplacementPlugin {
|
|
95
97
|
const newContentRegExp = this.newContentRegExp;
|
96
98
|
const newContentCreateContextMap = this.newContentCreateContextMap;
|
97
99
|
|
98
|
-
compiler.hooks.contextModuleFactory.tap(
|
99
|
-
cmf.hooks.beforeResolve.tap(
|
100
|
+
compiler.hooks.contextModuleFactory.tap(PLUGIN_NAME, cmf => {
|
101
|
+
cmf.hooks.beforeResolve.tap(PLUGIN_NAME, result => {
|
100
102
|
if (!result) return;
|
101
103
|
if (resourceRegExp.test(result.request)) {
|
102
104
|
if (newContentResource !== undefined) {
|
@@ -118,7 +120,7 @@ class ContextReplacementPlugin {
|
|
118
120
|
}
|
119
121
|
return result;
|
120
122
|
});
|
121
|
-
cmf.hooks.afterResolve.tap(
|
123
|
+
cmf.hooks.afterResolve.tap(PLUGIN_NAME, result => {
|
122
124
|
if (!result) return;
|
123
125
|
if (resourceRegExp.test(result.resource)) {
|
124
126
|
if (newContentResource !== undefined) {
|
@@ -188,7 +190,8 @@ const createResolveDependenciesFromContextMap =
|
|
188
190
|
map[key] + options.resourceQuery + options.resourceFragment,
|
189
191
|
key,
|
190
192
|
options.typePrefix,
|
191
|
-
/** @type {string} */
|
193
|
+
/** @type {string} */
|
194
|
+
(options.category),
|
192
195
|
options.referencedExports
|
193
196
|
)
|
194
197
|
);
|
package/lib/DefinePlugin.js
CHANGED
@@ -22,6 +22,7 @@ const {
|
|
22
22
|
const createHash = require("./util/createHash");
|
23
23
|
|
24
24
|
/** @typedef {import("estree").Expression} Expression */
|
25
|
+
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
25
26
|
/** @typedef {import("./Compiler")} Compiler */
|
26
27
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
27
28
|
/** @typedef {import("./Module").ValueCacheVersions} ValueCacheVersions */
|
@@ -31,7 +32,6 @@ const createHash = require("./util/createHash");
|
|
31
32
|
/** @typedef {import("./javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */
|
32
33
|
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
|
33
34
|
/** @typedef {import("./logging/Logger").Logger} Logger */
|
34
|
-
/** @typedef {import("./util/createHash").Algorithm} Algorithm */
|
35
35
|
|
36
36
|
/** @typedef {null | undefined | RegExp | EXPECTED_FUNCTION | string | number | boolean | bigint | undefined} CodeValuePrimitive */
|
37
37
|
/** @typedef {RecursiveArrayOrRecord<CodeValuePrimitive | RuntimeValue>} CodeValue */
|
@@ -367,7 +367,7 @@ class DefinePlugin {
|
|
367
367
|
const { runtimeTemplate } = compilation;
|
368
368
|
|
369
369
|
const mainHash = createHash(
|
370
|
-
/** @type {
|
370
|
+
/** @type {HashFunction} */
|
371
371
|
(compilation.outputOptions.hashFunction)
|
372
372
|
);
|
373
373
|
mainHash.update(
|
package/lib/DelegatedModule.js
CHANGED
@@ -16,6 +16,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
16
16
|
|
17
17
|
/** @typedef {import("webpack-sources").Source} Source */
|
18
18
|
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
19
|
+
/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */
|
19
20
|
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
20
21
|
/** @typedef {import("./Compilation")} Compilation */
|
21
22
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
@@ -23,6 +24,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
23
24
|
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
|
24
25
|
/** @typedef {import("./LibManifestPlugin").ManifestModuleData} ManifestModuleData */
|
25
26
|
/** @typedef {import("./Module").BuildCallback} BuildCallback */
|
27
|
+
/** @typedef {import("./Module").BuildMeta} BuildMeta */
|
26
28
|
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
27
29
|
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
28
30
|
/** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
|
@@ -39,9 +41,16 @@ const makeSerializable = require("./util/makeSerializable");
|
|
39
41
|
/** @typedef {import("./util/Hash")} Hash */
|
40
42
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
41
43
|
|
42
|
-
/** @typedef {string}
|
43
|
-
|
44
|
-
/** @typedef {
|
44
|
+
/** @typedef {string} DelegatedModuleSourceRequest */
|
45
|
+
|
46
|
+
/** @typedef {NonNullable<DllReferencePluginOptions["type"]>} DelegatedModuleType */
|
47
|
+
|
48
|
+
/**
|
49
|
+
* @typedef {object} DelegatedModuleData
|
50
|
+
* @property {BuildMeta=} buildMeta build meta
|
51
|
+
* @property {true | string[]=} exports exports
|
52
|
+
* @property {number | string} id module id
|
53
|
+
*/
|
45
54
|
|
46
55
|
const RUNTIME_REQUIREMENTS = new Set([
|
47
56
|
RuntimeGlobals.module,
|
@@ -50,9 +59,9 @@ const RUNTIME_REQUIREMENTS = new Set([
|
|
50
59
|
|
51
60
|
class DelegatedModule extends Module {
|
52
61
|
/**
|
53
|
-
* @param {
|
54
|
-
* @param {
|
55
|
-
* @param {
|
62
|
+
* @param {DelegatedModuleSourceRequest} sourceRequest source request
|
63
|
+
* @param {DelegatedModuleData} data data
|
64
|
+
* @param {DelegatedModuleType} type type
|
56
65
|
* @param {string} userRequest user request
|
57
66
|
* @param {string | Module} originalRequest original request
|
58
67
|
*/
|
@@ -65,7 +74,6 @@ class DelegatedModule extends Module {
|
|
65
74
|
this.delegationType = type;
|
66
75
|
this.userRequest = userRequest;
|
67
76
|
this.originalRequest = originalRequest;
|
68
|
-
/** @type {ManifestModuleData | undefined} */
|
69
77
|
this.delegateData = data;
|
70
78
|
|
71
79
|
// Build info
|
@@ -255,7 +263,9 @@ class DelegatedModule extends Module {
|
|
255
263
|
*/
|
256
264
|
cleanupForCache() {
|
257
265
|
super.cleanupForCache();
|
258
|
-
this.delegateData =
|
266
|
+
this.delegateData =
|
267
|
+
/** @type {EXPECTED_ANY} */
|
268
|
+
(undefined);
|
259
269
|
}
|
260
270
|
}
|
261
271
|
|
@@ -9,15 +9,14 @@ const DelegatedModule = require("./DelegatedModule");
|
|
9
9
|
|
10
10
|
/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */
|
11
11
|
/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptionsContent} DllReferencePluginOptionsContent */
|
12
|
-
/** @typedef {import("./DelegatedModule").
|
13
|
-
/** @typedef {import("./DelegatedModule").
|
14
|
-
/** @typedef {import("./DelegatedModule").Type} Type */
|
12
|
+
/** @typedef {import("./DelegatedModule").DelegatedModuleSourceRequest} DelegatedModuleSourceRequest */
|
13
|
+
/** @typedef {import("./DelegatedModule").DelegatedModuleType} DelegatedModuleType */
|
15
14
|
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
|
16
15
|
/** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
17
16
|
|
18
17
|
/**
|
19
18
|
* @typedef {object} Options
|
20
|
-
* @property {
|
19
|
+
* @property {DelegatedModuleSourceRequest} source source
|
21
20
|
* @property {NonNullable<DllReferencePluginOptions["context"]>} context absolute context path to which lib ident is relative to
|
22
21
|
* @property {DllReferencePluginOptionsContent} content content
|
23
22
|
* @property {DllReferencePluginOptions["type"]} type type
|
@@ -58,7 +57,8 @@ class DelegatedModuleFactoryPlugin {
|
|
58
57
|
new DelegatedModule(
|
59
58
|
this.options.source,
|
60
59
|
resolved,
|
61
|
-
/** @type {
|
60
|
+
/** @type {DelegatedModuleType} */
|
61
|
+
(this.options.type),
|
62
62
|
innerRequest,
|
63
63
|
request
|
64
64
|
)
|
@@ -77,7 +77,8 @@ class DelegatedModuleFactoryPlugin {
|
|
77
77
|
new DelegatedModule(
|
78
78
|
this.options.source,
|
79
79
|
resolved,
|
80
|
-
/** @type {
|
80
|
+
/** @type {DelegatedModuleType} */
|
81
|
+
(this.options.type),
|
81
82
|
requestPlusExt,
|
82
83
|
request + extension
|
83
84
|
)
|
@@ -98,7 +99,8 @@ class DelegatedModuleFactoryPlugin {
|
|
98
99
|
return new DelegatedModule(
|
99
100
|
this.options.source,
|
100
101
|
resolved,
|
101
|
-
/** @type {
|
102
|
+
/** @type {DelegatedModuleType} */
|
103
|
+
(this.options.type),
|
102
104
|
request,
|
103
105
|
module
|
104
106
|
);
|
package/lib/DelegatedPlugin.js
CHANGED
@@ -11,6 +11,8 @@ const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDepende
|
|
11
11
|
/** @typedef {import("./Compiler")} Compiler */
|
12
12
|
/** @typedef {import("./DelegatedModuleFactoryPlugin").Options} Options */
|
13
13
|
|
14
|
+
const PLUGIN_NAME = "DelegatedPlugin";
|
15
|
+
|
14
16
|
class DelegatedPlugin {
|
15
17
|
/**
|
16
18
|
* @param {Options} options options
|
@@ -26,7 +28,7 @@ class DelegatedPlugin {
|
|
26
28
|
*/
|
27
29
|
apply(compiler) {
|
28
30
|
compiler.hooks.compilation.tap(
|
29
|
-
|
31
|
+
PLUGIN_NAME,
|
30
32
|
(compilation, { normalModuleFactory }) => {
|
31
33
|
compilation.dependencyFactories.set(
|
32
34
|
DelegatedSourceDependency,
|
@@ -35,7 +37,7 @@ class DelegatedPlugin {
|
|
35
37
|
}
|
36
38
|
);
|
37
39
|
|
38
|
-
compiler.hooks.compile.tap(
|
40
|
+
compiler.hooks.compile.tap(PLUGIN_NAME, ({ normalModuleFactory }) => {
|
39
41
|
new DelegatedModuleFactoryPlugin({
|
40
42
|
associatedObjectForCache: compiler.root,
|
41
43
|
...this.options
|
package/lib/DllEntryPlugin.js
CHANGED
@@ -13,6 +13,8 @@ const EntryDependency = require("./dependencies/EntryDependency");
|
|
13
13
|
/** @typedef {string[]} Entries */
|
14
14
|
/** @typedef {{ name: string, filename: TODO }} Options */
|
15
15
|
|
16
|
+
const PLUGIN_NAME = "DllEntryPlugin";
|
17
|
+
|
16
18
|
class DllEntryPlugin {
|
17
19
|
/**
|
18
20
|
* @param {string} context context
|
@@ -32,7 +34,7 @@ class DllEntryPlugin {
|
|
32
34
|
*/
|
33
35
|
apply(compiler) {
|
34
36
|
compiler.hooks.compilation.tap(
|
35
|
-
|
37
|
+
PLUGIN_NAME,
|
36
38
|
(compilation, { normalModuleFactory }) => {
|
37
39
|
const dllModuleFactory = new DllModuleFactory();
|
38
40
|
compilation.dependencyFactories.set(
|
@@ -45,7 +47,7 @@ class DllEntryPlugin {
|
|
45
47
|
);
|
46
48
|
}
|
47
49
|
);
|
48
|
-
compiler.hooks.make.tapAsync(
|
50
|
+
compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => {
|
49
51
|
compilation.addEntry(
|
50
52
|
this.context,
|
51
53
|
new DllEntryDependency(
|
package/lib/DllPlugin.js
CHANGED
@@ -24,6 +24,8 @@ const validate = createSchemaValidation(
|
|
24
24
|
}
|
25
25
|
);
|
26
26
|
|
27
|
+
const PLUGIN_NAME = "DllPlugin";
|
28
|
+
|
27
29
|
class DllPlugin {
|
28
30
|
/**
|
29
31
|
* @param {DllPluginOptions} options options object
|
@@ -42,7 +44,7 @@ class DllPlugin {
|
|
42
44
|
* @returns {void}
|
43
45
|
*/
|
44
46
|
apply(compiler) {
|
45
|
-
compiler.hooks.entryOption.tap(
|
47
|
+
compiler.hooks.entryOption.tap(PLUGIN_NAME, (context, entry) => {
|
46
48
|
if (typeof entry !== "function") {
|
47
49
|
for (const name of Object.keys(entry)) {
|
48
50
|
/** @type {Options} */
|
@@ -55,14 +57,14 @@ class DllPlugin {
|
|
55
57
|
}
|
56
58
|
} else {
|
57
59
|
throw new Error(
|
58
|
-
|
60
|
+
`${PLUGIN_NAME} doesn't support dynamic entry (function) yet`
|
59
61
|
);
|
60
62
|
}
|
61
63
|
return true;
|
62
64
|
});
|
63
65
|
new LibManifestPlugin(this.options).apply(compiler);
|
64
66
|
if (!this.options.entryOnly) {
|
65
|
-
new FlagAllModulesAsUsedPlugin(
|
67
|
+
new FlagAllModulesAsUsedPlugin(PLUGIN_NAME).apply(compiler);
|
66
68
|
}
|
67
69
|
}
|
68
70
|
}
|