webpack 5.99.6 → 5.99.7
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 +9 -8
- package/lib/Compiler.js +2 -1
- package/lib/ContextExclusionPlugin.js +4 -2
- package/lib/ContextReplacementPlugin.js +5 -3
- 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 +137 -138
- package/lib/ExternalsPlugin.js +3 -1
- package/lib/FlagDependencyExportsPlugin.js +2 -1
- package/lib/IgnorePlugin.js +6 -4
- package/lib/IgnoreWarningsPlugin.js +4 -2
- package/lib/LibManifestPlugin.js +3 -4
- package/lib/LoaderOptionsPlugin.js +4 -2
- package/lib/LoaderTargetPlugin.js +4 -2
- package/lib/Module.js +19 -12
- package/lib/ModuleInfoHeaderPlugin.js +11 -12
- package/lib/MultiCompiler.js +5 -3
- package/lib/NoEmitOnErrorsPlugin.js +5 -3
- package/lib/NormalModule.js +5 -1
- 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 +7 -5
- 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 +5 -3
- 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/normalization.js +9 -3
- 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 +6 -4
- 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/RequireEnsureDependenciesBlockParserPlugin.js +94 -100
- package/lib/esm/ModuleChunkLoadingPlugin.js +72 -73
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +0 -1
- 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/javascript/JavascriptParser.js +634 -656
- package/lib/library/ModuleLibraryPlugin.js +60 -42
- package/lib/node/CommonJsChunkLoadingPlugin.js +69 -73
- package/lib/node/NodeEnvironmentPlugin.js +3 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +224 -232
- package/lib/optimize/ConcatenatedModule.js +12 -15
- 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 +4 -2
- 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 +17 -18
- package/lib/optimize/SplitChunksPlugin.js +7 -5
- package/lib/performance/SizeLimitsPlugin.js +3 -1
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +61 -62
- 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 +32 -39
- 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/wasm-sync/WasmFinalizeExportsPlugin.js +55 -57
- package/lib/web/JsonpChunkLoadingPlugin.js +73 -74
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +77 -78
- package/package.json +4 -3
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +24 -2
- package/types.d.ts +148 -55
@@ -15,83 +15,82 @@ const ChunkPreloadTriggerRuntimeModule = require("./ChunkPreloadTriggerRuntimeMo
|
|
15
15
|
/** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */
|
16
16
|
/** @typedef {import("../Compiler")} Compiler */
|
17
17
|
|
18
|
+
const PLUGIN_NAME = "ChunkPrefetchPreloadPlugin";
|
19
|
+
|
18
20
|
class ChunkPrefetchPreloadPlugin {
|
19
21
|
/**
|
20
22
|
* @param {Compiler} compiler the compiler
|
21
23
|
* @returns {void}
|
22
24
|
*/
|
23
25
|
apply(compiler) {
|
24
|
-
compiler.hooks.compilation.tap(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
27
|
+
compilation.hooks.additionalChunkRuntimeRequirements.tap(
|
28
|
+
PLUGIN_NAME,
|
29
|
+
(chunk, set, { chunkGraph }) => {
|
30
|
+
if (chunkGraph.getNumberOfEntryModules(chunk) === 0) return;
|
31
|
+
const startupChildChunks = chunk.getChildrenOfTypeInOrder(
|
32
|
+
chunkGraph,
|
33
|
+
"prefetchOrder"
|
34
|
+
);
|
35
|
+
if (startupChildChunks) {
|
36
|
+
set.add(RuntimeGlobals.prefetchChunk);
|
37
|
+
set.add(RuntimeGlobals.onChunksLoaded);
|
38
|
+
set.add(RuntimeGlobals.exports);
|
39
|
+
compilation.addRuntimeModule(
|
40
|
+
chunk,
|
41
|
+
new ChunkPrefetchStartupRuntimeModule(startupChildChunks)
|
34
42
|
);
|
35
|
-
if (startupChildChunks) {
|
36
|
-
set.add(RuntimeGlobals.prefetchChunk);
|
37
|
-
set.add(RuntimeGlobals.onChunksLoaded);
|
38
|
-
set.add(RuntimeGlobals.exports);
|
39
|
-
compilation.addRuntimeModule(
|
40
|
-
chunk,
|
41
|
-
new ChunkPrefetchStartupRuntimeModule(startupChildChunks)
|
42
|
-
);
|
43
|
-
}
|
44
43
|
}
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
}
|
45
|
+
);
|
46
|
+
compilation.hooks.additionalTreeRuntimeRequirements.tap(
|
47
|
+
PLUGIN_NAME,
|
48
|
+
(chunk, set, { chunkGraph }) => {
|
49
|
+
const chunkMap = chunk.getChildIdsByOrdersMap(chunkGraph);
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
compilation.addRuntimeModule(
|
54
|
-
chunk,
|
55
|
-
new ChunkPrefetchTriggerRuntimeModule(chunkMap.prefetch)
|
56
|
-
);
|
57
|
-
}
|
58
|
-
if (chunkMap.preload) {
|
59
|
-
set.add(RuntimeGlobals.preloadChunk);
|
60
|
-
compilation.addRuntimeModule(
|
61
|
-
chunk,
|
62
|
-
new ChunkPreloadTriggerRuntimeModule(chunkMap.preload)
|
63
|
-
);
|
64
|
-
}
|
65
|
-
}
|
66
|
-
);
|
67
|
-
compilation.hooks.runtimeRequirementInTree
|
68
|
-
.for(RuntimeGlobals.prefetchChunk)
|
69
|
-
.tap("ChunkPrefetchPreloadPlugin", (chunk, set) => {
|
51
|
+
if (chunkMap.prefetch) {
|
52
|
+
set.add(RuntimeGlobals.prefetchChunk);
|
70
53
|
compilation.addRuntimeModule(
|
71
54
|
chunk,
|
72
|
-
new
|
73
|
-
"prefetch",
|
74
|
-
RuntimeGlobals.prefetchChunk,
|
75
|
-
RuntimeGlobals.prefetchChunkHandlers
|
76
|
-
)
|
55
|
+
new ChunkPrefetchTriggerRuntimeModule(chunkMap.prefetch)
|
77
56
|
);
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
.for(RuntimeGlobals.preloadChunk)
|
82
|
-
.tap("ChunkPrefetchPreloadPlugin", (chunk, set) => {
|
57
|
+
}
|
58
|
+
if (chunkMap.preload) {
|
59
|
+
set.add(RuntimeGlobals.preloadChunk);
|
83
60
|
compilation.addRuntimeModule(
|
84
61
|
chunk,
|
85
|
-
new
|
86
|
-
"preload",
|
87
|
-
RuntimeGlobals.preloadChunk,
|
88
|
-
RuntimeGlobals.preloadChunkHandlers
|
89
|
-
)
|
62
|
+
new ChunkPreloadTriggerRuntimeModule(chunkMap.preload)
|
90
63
|
);
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
64
|
+
}
|
65
|
+
}
|
66
|
+
);
|
67
|
+
compilation.hooks.runtimeRequirementInTree
|
68
|
+
.for(RuntimeGlobals.prefetchChunk)
|
69
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
70
|
+
compilation.addRuntimeModule(
|
71
|
+
chunk,
|
72
|
+
new ChunkPrefetchFunctionRuntimeModule(
|
73
|
+
"prefetch",
|
74
|
+
RuntimeGlobals.prefetchChunk,
|
75
|
+
RuntimeGlobals.prefetchChunkHandlers
|
76
|
+
)
|
77
|
+
);
|
78
|
+
set.add(RuntimeGlobals.prefetchChunkHandlers);
|
79
|
+
});
|
80
|
+
compilation.hooks.runtimeRequirementInTree
|
81
|
+
.for(RuntimeGlobals.preloadChunk)
|
82
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
83
|
+
compilation.addRuntimeModule(
|
84
|
+
chunk,
|
85
|
+
new ChunkPrefetchFunctionRuntimeModule(
|
86
|
+
"preload",
|
87
|
+
RuntimeGlobals.preloadChunk,
|
88
|
+
RuntimeGlobals.preloadChunkHandlers
|
89
|
+
)
|
90
|
+
);
|
91
|
+
set.add(RuntimeGlobals.preloadChunkHandlers);
|
92
|
+
});
|
93
|
+
});
|
95
94
|
}
|
96
95
|
}
|
97
96
|
|
@@ -18,6 +18,8 @@ const StartupEntrypointRuntimeModule = require("./StartupEntrypointRuntimeModule
|
|
18
18
|
* @property {boolean=} asyncChunkLoading
|
19
19
|
*/
|
20
20
|
|
21
|
+
const PLUGIN_NAME = "StartupChunkDependenciesPlugin";
|
22
|
+
|
21
23
|
class StartupChunkDependenciesPlugin {
|
22
24
|
/**
|
23
25
|
* @param {Options} options options
|
@@ -36,53 +38,48 @@ class StartupChunkDependenciesPlugin {
|
|
36
38
|
* @returns {void}
|
37
39
|
*/
|
38
40
|
apply(compiler) {
|
39
|
-
compiler.hooks.thisCompilation.tap(
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
const
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
(chunk
|
58
|
-
|
59
|
-
if (chunkGraph.hasChunkEntryDependentChunks(chunk)) {
|
60
|
-
set.add(RuntimeGlobals.startup);
|
61
|
-
set.add(RuntimeGlobals.ensureChunk);
|
62
|
-
set.add(RuntimeGlobals.ensureChunkIncludeEntries);
|
63
|
-
compilation.addRuntimeModule(
|
64
|
-
chunk,
|
65
|
-
new StartupChunkDependenciesRuntimeModule(
|
66
|
-
this.asyncChunkLoading
|
67
|
-
)
|
68
|
-
);
|
69
|
-
}
|
70
|
-
}
|
71
|
-
);
|
72
|
-
compilation.hooks.runtimeRequirementInTree
|
73
|
-
.for(RuntimeGlobals.startupEntrypoint)
|
74
|
-
.tap("StartupChunkDependenciesPlugin", (chunk, set) => {
|
75
|
-
if (!isEnabledForChunk(chunk)) return;
|
76
|
-
set.add(RuntimeGlobals.require);
|
41
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
42
|
+
const globalChunkLoading = compilation.outputOptions.chunkLoading;
|
43
|
+
/**
|
44
|
+
* @param {Chunk} chunk chunk to check
|
45
|
+
* @returns {boolean} true, when the plugin is enabled for the chunk
|
46
|
+
*/
|
47
|
+
const isEnabledForChunk = chunk => {
|
48
|
+
const options = chunk.getEntryOptions();
|
49
|
+
const chunkLoading =
|
50
|
+
options && options.chunkLoading !== undefined
|
51
|
+
? options.chunkLoading
|
52
|
+
: globalChunkLoading;
|
53
|
+
return chunkLoading === this.chunkLoading;
|
54
|
+
};
|
55
|
+
compilation.hooks.additionalTreeRuntimeRequirements.tap(
|
56
|
+
PLUGIN_NAME,
|
57
|
+
(chunk, set, { chunkGraph }) => {
|
58
|
+
if (!isEnabledForChunk(chunk)) return;
|
59
|
+
if (chunkGraph.hasChunkEntryDependentChunks(chunk)) {
|
60
|
+
set.add(RuntimeGlobals.startup);
|
77
61
|
set.add(RuntimeGlobals.ensureChunk);
|
78
62
|
set.add(RuntimeGlobals.ensureChunkIncludeEntries);
|
79
63
|
compilation.addRuntimeModule(
|
80
64
|
chunk,
|
81
|
-
new
|
65
|
+
new StartupChunkDependenciesRuntimeModule(this.asyncChunkLoading)
|
82
66
|
);
|
83
|
-
}
|
84
|
-
|
85
|
-
|
67
|
+
}
|
68
|
+
}
|
69
|
+
);
|
70
|
+
compilation.hooks.runtimeRequirementInTree
|
71
|
+
.for(RuntimeGlobals.startupEntrypoint)
|
72
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
73
|
+
if (!isEnabledForChunk(chunk)) return;
|
74
|
+
set.add(RuntimeGlobals.require);
|
75
|
+
set.add(RuntimeGlobals.ensureChunk);
|
76
|
+
set.add(RuntimeGlobals.ensureChunkIncludeEntries);
|
77
|
+
compilation.addRuntimeModule(
|
78
|
+
chunk,
|
79
|
+
new StartupEntrypointRuntimeModule(this.asyncChunkLoading)
|
80
|
+
);
|
81
|
+
});
|
82
|
+
});
|
86
83
|
}
|
87
84
|
}
|
88
85
|
|
@@ -37,6 +37,8 @@ const decodeDataURI = uri => {
|
|
37
37
|
}
|
38
38
|
};
|
39
39
|
|
40
|
+
const PLUGIN_NAME = "DataUriPlugin";
|
41
|
+
|
40
42
|
class DataUriPlugin {
|
41
43
|
/**
|
42
44
|
* Apply the plugin
|
@@ -45,11 +47,11 @@ class DataUriPlugin {
|
|
45
47
|
*/
|
46
48
|
apply(compiler) {
|
47
49
|
compiler.hooks.compilation.tap(
|
48
|
-
|
50
|
+
PLUGIN_NAME,
|
49
51
|
(compilation, { normalModuleFactory }) => {
|
50
52
|
normalModuleFactory.hooks.resolveForScheme
|
51
53
|
.for("data")
|
52
|
-
.tap(
|
54
|
+
.tap(PLUGIN_NAME, resourceData => {
|
53
55
|
const match = URIRegEx.exec(resourceData.resource);
|
54
56
|
if (match) {
|
55
57
|
resourceData.data.mimetype = match[1] || "";
|
@@ -60,7 +62,7 @@ class DataUriPlugin {
|
|
60
62
|
});
|
61
63
|
NormalModule.getCompilationHooks(compilation)
|
62
64
|
.readResourceForScheme.for("data")
|
63
|
-
.tap(
|
65
|
+
.tap(PLUGIN_NAME, resource => decodeDataURI(resource));
|
64
66
|
}
|
65
67
|
);
|
66
68
|
}
|
@@ -10,6 +10,8 @@ const { NormalModule } = require("..");
|
|
10
10
|
|
11
11
|
/** @typedef {import("../Compiler")} Compiler */
|
12
12
|
|
13
|
+
const PLUGIN_NAME = "FileUriPlugin";
|
14
|
+
|
13
15
|
class FileUriPlugin {
|
14
16
|
/**
|
15
17
|
* Apply the plugin
|
@@ -18,11 +20,11 @@ class FileUriPlugin {
|
|
18
20
|
*/
|
19
21
|
apply(compiler) {
|
20
22
|
compiler.hooks.compilation.tap(
|
21
|
-
|
23
|
+
PLUGIN_NAME,
|
22
24
|
(compilation, { normalModuleFactory }) => {
|
23
25
|
normalModuleFactory.hooks.resolveForScheme
|
24
26
|
.for("file")
|
25
|
-
.tap(
|
27
|
+
.tap(PLUGIN_NAME, resourceData => {
|
26
28
|
const url = new URL(resourceData.resource);
|
27
29
|
const path = fileURLToPath(url);
|
28
30
|
const query = url.search;
|
@@ -36,7 +38,7 @@ class FileUriPlugin {
|
|
36
38
|
const hooks = NormalModule.getCompilationHooks(compilation);
|
37
39
|
hooks.readResource
|
38
40
|
.for(undefined)
|
39
|
-
.tapAsync(
|
41
|
+
.tapAsync(PLUGIN_NAME, (loaderContext, callback) => {
|
40
42
|
const { resourcePath } = loaderContext;
|
41
43
|
loaderContext.addDependency(resourcePath);
|
42
44
|
loaderContext.fs.readFile(resourcePath, callback);
|
@@ -405,6 +405,8 @@ const cachedWithKey = (fn, forceFn = fn) => {
|
|
405
405
|
/** @typedef {FetchResultMeta & { entry: LockfileEntry, content: Buffer }} ContentFetchResult */
|
406
406
|
/** @typedef {RedirectFetchResult | ContentFetchResult} FetchResult */
|
407
407
|
|
408
|
+
const PLUGIN_NAME = "HttpUriPlugin";
|
409
|
+
|
408
410
|
class HttpUriPlugin {
|
409
411
|
/**
|
410
412
|
* @param {HttpUriPluginOptions} options options
|
@@ -440,14 +442,14 @@ class HttpUriPlugin {
|
|
440
442
|
/** @type {LockfileCache} */
|
441
443
|
let lockfileCache;
|
442
444
|
compiler.hooks.compilation.tap(
|
443
|
-
|
445
|
+
PLUGIN_NAME,
|
444
446
|
(compilation, { normalModuleFactory }) => {
|
445
447
|
const intermediateFs =
|
446
448
|
/** @type {IntermediateFileSystem} */
|
447
449
|
(compiler.intermediateFileSystem);
|
448
450
|
const fs = compilation.inputFileSystem;
|
449
|
-
const cache = compilation.getCache(
|
450
|
-
const logger = compilation.getLogger(
|
451
|
+
const cache = compilation.getCache(`webpack.${PLUGIN_NAME}`);
|
452
|
+
const logger = compilation.getLogger(`webpack.${PLUGIN_NAME}`);
|
451
453
|
/** @type {string} */
|
452
454
|
const lockfileLocation =
|
453
455
|
this._lockfileLocation ||
|
@@ -1154,19 +1156,16 @@ Run build with un-frozen lockfile to automatically fix lockfile.`
|
|
1154
1156
|
};
|
1155
1157
|
normalModuleFactory.hooks.resolveForScheme
|
1156
1158
|
.for(scheme)
|
1157
|
-
.tapAsync(
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
);
|
1165
|
-
}
|
1166
|
-
);
|
1159
|
+
.tapAsync(PLUGIN_NAME, (resourceData, resolveData, callback) => {
|
1160
|
+
respondWithUrlModule(
|
1161
|
+
new URL(resourceData.resource),
|
1162
|
+
resourceData,
|
1163
|
+
callback
|
1164
|
+
);
|
1165
|
+
});
|
1167
1166
|
normalModuleFactory.hooks.resolveInScheme
|
1168
1167
|
.for(scheme)
|
1169
|
-
.tapAsync(
|
1168
|
+
.tapAsync(PLUGIN_NAME, (resourceData, data, callback) => {
|
1170
1169
|
// Only handle relative urls (./xxx, ../xxx, /xxx, //xxx)
|
1171
1170
|
if (
|
1172
1171
|
data.dependencyType !== "url" &&
|
@@ -1183,7 +1182,7 @@ Run build with un-frozen lockfile to automatically fix lockfile.`
|
|
1183
1182
|
const hooks = NormalModule.getCompilationHooks(compilation);
|
1184
1183
|
hooks.readResourceForScheme
|
1185
1184
|
.for(scheme)
|
1186
|
-
.tapAsync(
|
1185
|
+
.tapAsync(PLUGIN_NAME, (resource, module, callback) =>
|
1187
1186
|
getInfo(resource, (err, _result) => {
|
1188
1187
|
if (err) return callback(err);
|
1189
1188
|
const result = /** @type {Info} */ (_result);
|
@@ -1192,33 +1191,27 @@ Run build with un-frozen lockfile to automatically fix lockfile.`
|
|
1192
1191
|
callback(null, result.content);
|
1193
1192
|
})
|
1194
1193
|
);
|
1195
|
-
hooks.needBuild.tapAsync(
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
}
|
1212
|
-
callback();
|
1213
|
-
});
|
1214
|
-
} else {
|
1215
|
-
return callback();
|
1216
|
-
}
|
1194
|
+
hooks.needBuild.tapAsync(PLUGIN_NAME, (module, context, callback) => {
|
1195
|
+
if (module.resource && module.resource.startsWith(`${scheme}://`)) {
|
1196
|
+
getInfo(module.resource, (err, _result) => {
|
1197
|
+
if (err) return callback(err);
|
1198
|
+
const result = /** @type {Info} */ (_result);
|
1199
|
+
if (
|
1200
|
+
result.entry.integrity !==
|
1201
|
+
/** @type {BuildInfo} */
|
1202
|
+
(module.buildInfo).resourceIntegrity
|
1203
|
+
) {
|
1204
|
+
return callback(null, true);
|
1205
|
+
}
|
1206
|
+
callback();
|
1207
|
+
});
|
1208
|
+
} else {
|
1209
|
+
return callback();
|
1217
1210
|
}
|
1218
|
-
);
|
1211
|
+
});
|
1219
1212
|
}
|
1220
1213
|
compilation.hooks.finishModules.tapAsync(
|
1221
|
-
|
1214
|
+
PLUGIN_NAME,
|
1222
1215
|
(modules, callback) => {
|
1223
1216
|
if (!lockfileUpdates) return callback();
|
1224
1217
|
const ext = extname(lockfileLocation);
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
*/
|
4
|
+
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
/** @typedef {import("./ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
8
|
+
/** @typedef {import("./ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
9
|
+
|
10
|
+
/** @typedef {Error & { cause: unknown, errors: EXPECTED_ANY[] }} AggregateError */
|
11
|
+
|
12
|
+
class AggregateErrorSerializer {
|
13
|
+
/**
|
14
|
+
* @param {AggregateError} obj error
|
15
|
+
* @param {ObjectSerializerContext} context context
|
16
|
+
*/
|
17
|
+
serialize(obj, context) {
|
18
|
+
context.write(obj.errors);
|
19
|
+
context.write(obj.message);
|
20
|
+
context.write(obj.stack);
|
21
|
+
context.write(obj.cause);
|
22
|
+
}
|
23
|
+
|
24
|
+
/**
|
25
|
+
* @param {ObjectDeserializerContext} context context
|
26
|
+
* @returns {AggregateError} error
|
27
|
+
*/
|
28
|
+
deserialize(context) {
|
29
|
+
const errors = context.read();
|
30
|
+
// @ts-expect-error ES2018 doesn't `AggregateError`, but it can be used by developers
|
31
|
+
// eslint-disable-next-line n/no-unsupported-features/es-builtins, n/no-unsupported-features/es-syntax
|
32
|
+
const err = new AggregateError(errors);
|
33
|
+
|
34
|
+
err.message = context.read();
|
35
|
+
err.stack = context.read();
|
36
|
+
err.cause = context.read();
|
37
|
+
|
38
|
+
return err;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
module.exports = AggregateErrorSerializer;
|
@@ -7,6 +7,8 @@
|
|
7
7
|
/** @typedef {import("./ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
8
8
|
/** @typedef {import("./ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
9
9
|
|
10
|
+
/** @typedef {Error & { cause?: unknown }} ErrorWithCause */
|
11
|
+
|
10
12
|
class ErrorObjectSerializer {
|
11
13
|
/**
|
12
14
|
* @param {ErrorConstructor | EvalErrorConstructor | RangeErrorConstructor | ReferenceErrorConstructor | SyntaxErrorConstructor | TypeErrorConstructor} Type error type
|
@@ -22,7 +24,10 @@ class ErrorObjectSerializer {
|
|
22
24
|
serialize(obj, context) {
|
23
25
|
context.write(obj.message);
|
24
26
|
context.write(obj.stack);
|
25
|
-
context.write(
|
27
|
+
context.write(
|
28
|
+
/** @type {ErrorWithCause} */
|
29
|
+
(obj).cause
|
30
|
+
);
|
26
31
|
}
|
27
32
|
|
28
33
|
/**
|
@@ -34,7 +39,7 @@ class ErrorObjectSerializer {
|
|
34
39
|
|
35
40
|
err.message = context.read();
|
36
41
|
err.stack = context.read();
|
37
|
-
/** @type {
|
42
|
+
/** @type {ErrorWithCause} */
|
38
43
|
(err).cause = context.read();
|
39
44
|
|
40
45
|
return err;
|
@@ -6,6 +6,7 @@
|
|
6
6
|
|
7
7
|
const { DEFAULTS } = require("../config/defaults");
|
8
8
|
const createHash = require("../util/createHash");
|
9
|
+
const AggregateErrorSerializer = require("./AggregateErrorSerializer");
|
9
10
|
const ArraySerializer = require("./ArraySerializer");
|
10
11
|
const DateObjectSerializer = require("./DateObjectSerializer");
|
11
12
|
const ErrorObjectSerializer = require("./ErrorObjectSerializer");
|
@@ -140,6 +141,7 @@ const loadedRequests = new Set();
|
|
140
141
|
const NOT_SERIALIZABLE = {};
|
141
142
|
|
142
143
|
const jsTypes = new Map();
|
144
|
+
|
143
145
|
jsTypes.set(Object, new PlainObjectSerializer());
|
144
146
|
jsTypes.set(Array, new ArraySerializer());
|
145
147
|
jsTypes.set(null, new NullPrototypeObjectSerializer());
|
@@ -154,6 +156,17 @@ jsTypes.set(ReferenceError, new ErrorObjectSerializer(ReferenceError));
|
|
154
156
|
jsTypes.set(SyntaxError, new ErrorObjectSerializer(SyntaxError));
|
155
157
|
jsTypes.set(TypeError, new ErrorObjectSerializer(TypeError));
|
156
158
|
|
159
|
+
// @ts-expect-error ES2018 doesn't `AggregateError`, but it can be used by developers
|
160
|
+
// eslint-disable-next-line n/no-unsupported-features/es-builtins, n/no-unsupported-features/es-syntax
|
161
|
+
if (typeof AggregateError !== "undefined") {
|
162
|
+
jsTypes.set(
|
163
|
+
// @ts-expect-error ES2018 doesn't `AggregateError`, but it can be used by developers
|
164
|
+
// eslint-disable-next-line n/no-unsupported-features/es-builtins, n/no-unsupported-features/es-syntax
|
165
|
+
AggregateError,
|
166
|
+
new AggregateErrorSerializer()
|
167
|
+
);
|
168
|
+
}
|
169
|
+
|
157
170
|
// If in a sandboxed environment (e.g. jest), this escapes the sandbox and registers
|
158
171
|
// real Object and Array types to. These types may occur in the wild too, e.g. when
|
159
172
|
// using Structured Clone in postMessage.
|
@@ -36,6 +36,8 @@ const validate = createSchemaValidation(
|
|
36
36
|
|
37
37
|
/** @typedef {Map<string, { config: ProvideOptions, version: string | undefined | false }>} ResolvedProvideMap */
|
38
38
|
|
39
|
+
const PLUGIN_NAME = "ProvideSharedPlugin";
|
40
|
+
|
39
41
|
class ProvideSharedPlugin {
|
40
42
|
/**
|
41
43
|
* @param {ProvideSharedPluginOptions} options options
|
@@ -83,7 +85,7 @@ class ProvideSharedPlugin {
|
|
83
85
|
const compilationData = new WeakMap();
|
84
86
|
|
85
87
|
compiler.hooks.compilation.tap(
|
86
|
-
|
88
|
+
PLUGIN_NAME,
|
87
89
|
(compilation, { normalModuleFactory }) => {
|
88
90
|
/** @type {ResolvedProvideMap} */
|
89
91
|
const resolvedProvideMap = new Map();
|
@@ -156,7 +158,7 @@ class ProvideSharedPlugin {
|
|
156
158
|
});
|
157
159
|
};
|
158
160
|
normalModuleFactory.hooks.module.tap(
|
159
|
-
|
161
|
+
PLUGIN_NAME,
|
160
162
|
(module, { resource, resourceResolveData }, resolveData) => {
|
161
163
|
if (resolvedProvideMap.has(/** @type {string} */ (resource))) {
|
162
164
|
return module;
|
@@ -194,7 +196,7 @@ class ProvideSharedPlugin {
|
|
194
196
|
);
|
195
197
|
}
|
196
198
|
);
|
197
|
-
compiler.hooks.finishMake.tapPromise(
|
199
|
+
compiler.hooks.finishMake.tapPromise(PLUGIN_NAME, compilation => {
|
198
200
|
const resolvedProvideMap = compilationData.get(compilation);
|
199
201
|
if (!resolvedProvideMap) return Promise.resolve();
|
200
202
|
return Promise.all(
|
@@ -225,7 +227,7 @@ class ProvideSharedPlugin {
|
|
225
227
|
});
|
226
228
|
|
227
229
|
compiler.hooks.compilation.tap(
|
228
|
-
|
230
|
+
PLUGIN_NAME,
|
229
231
|
(compilation, { normalModuleFactory }) => {
|
230
232
|
compilation.dependencyFactories.set(
|
231
233
|
ProvideForSharedDependency,
|