webpack 5.112.0 → 5.112.2
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/bin/webpack.js +13 -7
- package/lib/Compilation.js +198 -61
- package/lib/Compiler.js +12 -25
- package/lib/asset/AssetBytesGenerator.js +14 -6
- package/lib/asset/AssetBytesParser.js +10 -8
- package/lib/asset/AssetGenerator.js +36 -48
- package/lib/asset/AssetModule.js +11 -0
- package/lib/asset/AssetModulesPlugin.js +5 -4
- package/lib/asset/AssetParser.js +8 -8
- package/lib/asset/AssetSourceGenerator.js +16 -8
- package/lib/asset/AssetSourceParser.js +10 -8
- package/lib/asset/WebManifestGenerator.js +11 -6
- package/lib/asset/WebManifestParser.js +3 -3
- package/lib/async-modules/AsyncModuleHelpers.js +8 -2
- package/lib/async-modules/InferAsyncModulesPlugin.js +7 -2
- package/lib/cache/CacheFacade.js +1 -1
- package/lib/cache/PackFileCacheStrategy.js +6 -10
- package/lib/cache/ResolverCachePlugin.js +58 -8
- package/lib/config/WebpackOptionsApply.js +8 -28
- package/lib/config/cli.js +9 -6
- package/lib/config/defaults.js +24 -13
- package/lib/config/getClaimedAssetTypes.js +2 -2
- package/lib/config/target.js +1 -1
- package/lib/context/ContextModule.js +1 -1
- package/lib/context/ContextModuleFactory.js +1 -1
- package/lib/context/ContextReplacementPlugin.js +3 -9
- package/lib/css/CssGenerator.js +40 -47
- package/lib/css/CssModule.js +10 -0
- package/lib/css/CssModulesPlugin.js +13 -6
- package/lib/css/CssParser.js +33 -32
- package/lib/css/conventions.js +1 -1
- package/lib/css/data.js +224 -219
- package/lib/css/syntax-parser.js +1312 -312
- package/lib/css/syntax-printer.js +1142 -1025
- package/lib/debug/ProfilingPlugin.js +65 -43
- package/lib/define/DefinePlugin.js +10 -15
- package/lib/define/DotenvPlugin.js +10 -6
- package/lib/define/EnvironmentPlugin.js +4 -2
- package/lib/dependencies/amd/AMDDefineDependencyParserPlugin.js +1 -2
- package/lib/dependencies/amd/AMDRequireDependenciesBlockParserPlugin.js +4 -1
- package/lib/dependencies/commonjs/CommonJsExportRequireDependency.js +1 -4
- package/lib/dependencies/commonjs/CommonJsExportsParserPlugin.js +18 -33
- package/lib/dependencies/commonjs/CommonJsImportsParserPlugin.js +1 -3
- package/lib/dependencies/commonjs/CommonJsObjectExportDependency.js +4 -4
- package/lib/dependencies/commonjs/CommonJsPlugin.js +2 -5
- package/lib/dependencies/commonjs/RequireEnsureDependenciesBlockParserPlugin.js +4 -1
- package/lib/dependencies/context/ImportMetaContextDependencyParserPlugin.js +1 -2
- package/lib/dependencies/context/ImportMetaGlobDependencyParserPlugin.js +4 -7
- package/lib/dependencies/context/ImportMetaGlobHelpers.js +8 -10
- package/lib/dependencies/core/CachedConstDependency.js +9 -6
- package/lib/dependencies/css/CssIcssExportDependency.js +6 -7
- package/lib/dependencies/css/CssIcssImportDependency.js +1 -3
- package/lib/dependencies/css/CssUrlDependency.js +2 -6
- package/lib/dependencies/esm/ESMDetectionParserPlugin.js +2 -4
- package/lib/dependencies/esm/ESMExportExpressionDependency.js +2 -2
- package/lib/dependencies/esm/ESMExportImportedSpecifierDependency.js +16 -18
- package/lib/dependencies/esm/ESMExportSpecifierDependency.js +20 -3
- package/lib/dependencies/esm/ESMExports.js +2 -10
- package/lib/dependencies/esm/ESMImportDependency.js +17 -2
- package/lib/dependencies/esm/ESMImportDependencyParserPlugin.js +6 -17
- package/lib/dependencies/esm/ESMImportGuard.js +11 -23
- package/lib/dependencies/esm/ESMImportSideEffectDependency.js +1 -1
- package/lib/dependencies/esm/ESMImportSpecifierDependency.js +4 -1
- package/lib/dependencies/esm/ESMLiveExportDependency.js +311 -0
- package/lib/dependencies/esm/ESMLiveExportParserPlugin.js +862 -0
- package/lib/dependencies/esm/ESMModulesPlugin.js +1 -3
- package/lib/dependencies/esm/TopLevelAwaitDependency.js +1 -8
- package/lib/dependencies/helpers/DynamicExports.js +4 -6
- package/lib/dependencies/html/HtmlEntryDependency.js +5 -14
- package/lib/dependencies/html/HtmlInlineHtmlDependency.js +1 -4
- package/lib/dependencies/html/HtmlInlineScriptDependency.js +2 -6
- package/lib/dependencies/html/HtmlInlineStyleDependency.js +1 -4
- package/lib/dependencies/import/ImportParserPlugin.js +3 -6
- package/lib/dependencies/import-meta/ImportMetaPlugin.js +4 -6
- package/lib/dependencies/url/URLParserPlugin.js +1 -1
- package/lib/dependencies/worker/WorkerAndWorkletPlugin.js +51 -20
- package/lib/devtool/ModuleFilenameHelpers.js +1 -1
- package/lib/devtool/SourceMapDevToolPlugin.js +1 -1
- package/lib/dll/DelegatedModule.js +3 -3
- package/lib/dll/DllModule.js +3 -1
- package/lib/dll/DllReferencePlugin.js +1 -4
- package/lib/errors/AbstractMethodError.js +1 -1
- package/lib/errors/ErrorHelpers.js +2 -1
- package/lib/errors/HookWebpackError.js +2 -1
- package/lib/errors/JSONParseError.js +4 -4
- package/lib/errors/WebpackError.js +3 -2
- package/lib/esm/ModuleChunkFormatPlugin.js +36 -1
- package/lib/externals/ExternalModule.js +12 -9
- package/lib/externals/ExternalModuleFactoryPlugin.js +1 -2
- package/lib/externals/ExternalsPlugin.js +1 -1
- package/lib/fs/FileSystemInfo.js +4 -4
- package/lib/graph/AsyncDependenciesBlock.js +1 -1
- package/lib/graph/ChunkGraph.js +5 -0
- package/lib/graph/Dependency.js +8 -2
- package/lib/graph/ExportsInfo.js +1 -1
- package/lib/graph/ModuleGraph.js +14 -3
- package/lib/graph/buildChunkGraph.js +17 -19
- package/lib/graph/findGraphRoots.js +1 -1
- package/lib/hmr/HotModuleReplacement.runtime.js +10 -9
- package/lib/hmr/HotModuleReplacementPlugin.js +5 -11
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +16 -19
- package/lib/hmr/LazyCompilationPlugin.js +1 -7
- package/lib/html/HtmlGenerator.js +25 -17
- package/lib/html/HtmlModule.js +11 -1
- package/lib/html/HtmlModulesPlugin.js +12 -11
- package/lib/html/HtmlParser.js +10 -9
- package/lib/html/builtinEmbeddedRenderer.js +31 -33
- package/lib/html/data.js +42 -21
- package/lib/html/htmlMinify.js +4 -1
- package/lib/html/syntax-parser.js +34 -35
- package/lib/html/syntax-printer.js +2 -3
- package/lib/html/xmlMinify.js +4 -1
- package/lib/ids/HashedModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -12
- package/lib/javascript/APIPlugin.js +7 -13
- package/lib/javascript/BasicEvaluatedExpression.js +5 -5
- package/lib/javascript/CommonJsChunkFormatPlugin.js +2 -7
- package/lib/javascript/ConstPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +16 -11
- package/lib/javascript/JavascriptMetaInfoPlugin.js +3 -15
- package/lib/javascript/JavascriptModule.js +10 -0
- package/lib/javascript/JavascriptModulesPlugin.js +2 -4
- package/lib/javascript/JavascriptParser.js +99 -11
- package/lib/javascript/ScopeAnalyzer.js +183 -107
- package/lib/javascript/UseStrictPlugin.js +2 -5
- package/lib/javascript/jsMinify.js +1 -1
- package/lib/javascript/regexp.js +2 -2
- package/lib/javascript/syntax-parser.js +2114 -1506
- package/lib/javascript/syntax-printer-data.js +167 -1
- package/lib/javascript/syntax-printer.js +9554 -2782
- package/lib/json/JsonGenerator.js +15 -7
- package/lib/json/JsonModule.js +11 -0
- package/lib/json/JsonParser.js +7 -6
- package/lib/library/AssignLibraryPlugin.js +1 -1
- package/lib/library/JsonpLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +399 -23
- package/lib/loaders/LoaderRunner.js +76 -38
- package/lib/loaders/loadLoader.js +16 -10
- package/lib/module/Generator.js +17 -9
- package/lib/module/Module.js +2 -2
- package/lib/module/NormalModule.js +7 -5
- package/lib/module/NormalModuleFactory.js +11 -17
- package/lib/module/Parser.js +9 -2
- package/lib/module/extractSourceMap.js +69 -18
- package/lib/module/findCaseMismatch.js +2 -2
- package/lib/node/ExternalModuleInitFragment.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +4 -12
- package/lib/node/ReadFileCompileWasmPlugin.js +2 -6
- package/lib/node/nodeConsole.js +4 -3
- package/lib/optimize/CircularModulesPlugin.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +4 -8
- package/lib/optimize/FlagDependencyExportsPlugin.js +6 -11
- package/lib/optimize/FlagDependencyUsagePlugin.js +28 -3
- package/lib/optimize/InlineExports.js +4 -7
- package/lib/optimize/LazyBarrels.js +41 -5
- package/lib/optimize/ModuleConcatenationPlugin.js +8 -10
- package/lib/optimize/RealContentHashPlugin.js +2 -6
- package/lib/optimize/SideEffectsFlagPlugin.js +7 -21
- package/lib/optimize/SplitChunksPlugin.js +11 -24
- package/lib/optimize/TupleQueue.js +1 -1
- package/lib/output/CleanPlugin.js +3 -1
- package/lib/output/CopyPlugin.js +3 -4
- package/lib/performance/EvalUsagePlugin.js +1 -3
- package/lib/performance/HotspotsPlugin.js +33 -9
- package/lib/performance/PureAnnotationsPlugin.js +16 -10
- package/lib/performance/TopLevelThisPlugin.js +17 -9
- package/lib/prefetch/ResourceHintPlugin.js +1 -1
- package/lib/provide/ProvidedDependency.js +36 -4
- package/lib/rules/BasicEffectRulePlugin.js +1 -1
- package/lib/rules/RuleSetCompiler.js +15 -5
- package/lib/rules/UseEffectRulePlugin.js +1 -3
- package/lib/runtime/AsyncModuleRuntimeModule.js +7 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +1 -5
- package/lib/runtime/RuntimeGlobals.js +6 -0
- package/lib/runtime/RuntimePlugin.js +2 -0
- package/lib/schemes/HttpUriPlugin.js +1 -2
- package/lib/schemes/VirtualUrlPlugin.js +3 -1
- package/lib/serialization/AggregateErrorSerializer.js +3 -3
- package/lib/serialization/BinaryMiddleware.js +4 -1
- package/lib/serialization/ErrorObjectSerializer.js +2 -5
- package/lib/serialization/ObjectMiddleware.js +17 -15
- package/lib/serialization/PlainObjectSerializer.js +3 -7
- package/lib/serialization/Serializer.js +21 -11
- package/lib/serialization/SerializerMiddleware.js +8 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +35 -35
- package/lib/stats/DefaultStatsPresetPlugin.js +2 -6
- package/lib/stats/DefaultStatsPrinterPlugin.js +12 -11
- package/lib/stats/StatsFactory.js +194 -24
- package/lib/stats/StatsPrinter.js +126 -13
- package/lib/template/DependencyTemplate.js +1 -1
- package/lib/template/RuntimeTemplate.js +13 -32
- package/lib/template/Template.js +1 -1
- package/lib/util/SourceProcessor.js +146 -29
- package/lib/util/WeakTupleMap.js +10 -4
- package/lib/util/cleverMerge.js +61 -33
- package/lib/util/comparators.js +9 -5
- package/lib/util/dataURL.js +2 -0
- package/lib/util/deprecation.js +4 -3
- package/lib/util/globUtils.js +1 -4
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/makeSerializable.js +6 -4
- package/lib/util/memoize.js +1 -1
- package/lib/util/parseJson.js +2 -2
- package/lib/util/serialization.js +31 -27
- package/lib/wasm/AsyncWasmModule.js +12 -2
- package/lib/wasm/AsyncWebAssemblyGenerator.js +12 -4
- package/lib/wasm/AsyncWebAssemblyJavascriptGenerator.js +13 -5
- package/lib/wasm/AsyncWebAssemblyParser.js +7 -5
- package/lib/wasm/UniversalCompileAsyncWasmPlugin.js +2 -6
- package/lib/wasm-sync/SyncWasmModule.js +16 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +15 -10
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +13 -5
- package/lib/wasm-sync/WebAssemblyParser.js +10 -12
- package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -12
- package/lib/web/FetchCompileWasmPlugin.js +2 -6
- package/package.json +18 -19
- package/schemas/WebpackOptions.check.js +3 -3
- package/schemas/WebpackOptions.json +2 -2
- package/schemas/plugins/BannerPlugin.check.js +3 -3
- package/schemas/plugins/HtmlGeneratorOptions.check.js +3 -3
- package/schemas/plugins/HtmlParserOptions.check.js +3 -3
- package/schemas/plugins/IgnorePlugin.check.js +3 -3
- package/schemas/plugins/LoaderOptionsPlugin.check.js +3 -3
- package/schemas/plugins/ManifestPlugin.check.js +3 -3
- package/schemas/plugins/ProgressPlugin.check.js +3 -3
- package/schemas/plugins/SSRManifestPlugin.check.js +3 -3
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +3 -3
- package/schemas/plugins/WatchIgnorePlugin.check.js +3 -3
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetParserOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +3 -3
- package/schemas/plugins/container/ContainerPlugin.check.js +3 -3
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +3 -3
- package/schemas/plugins/container/ExternalsType.check.js +3 -3
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +3 -3
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +3 -3
- package/schemas/plugins/css/CssGeneratorOptions.check.js +3 -3
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +3 -3
- package/schemas/plugins/css/CssModuleParserOptions.check.js +3 -3
- package/schemas/plugins/css/CssParserOptions.check.js +3 -3
- package/schemas/plugins/debug/ProfilingPlugin.check.js +3 -3
- package/schemas/plugins/define/DotenvPluginOptions.check.js +7 -0
- package/schemas/plugins/define/DotenvPluginOptions.json +3 -0
- package/schemas/plugins/dll/DllPlugin.check.js +3 -3
- package/schemas/plugins/dll/DllReferencePlugin.check.js +3 -3
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +3 -3
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +3 -3
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +3 -3
- package/schemas/plugins/json/JsonModulesPluginGenerator.check.js +3 -3
- package/schemas/plugins/json/JsonModulesPluginParser.check.js +3 -3
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +3 -3
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +3 -3
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +3 -3
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +3 -3
- package/schemas/plugins/output/CleanOptions.check.js +7 -0
- package/schemas/plugins/output/CleanOptions.json +3 -0
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +3 -3
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +3 -3
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +3 -3
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +3 -3
- package/schemas/plugins/sharing/SharePlugin.check.js +3 -3
- package/types.d.ts +1482 -358
|
@@ -20,15 +20,20 @@ const { isAbsolute, join } = require("../fs/fs");
|
|
|
20
20
|
* @typedef {object} SourceMappingURL
|
|
21
21
|
* @property {string} sourceMappingURL
|
|
22
22
|
* @property {string} replacementString
|
|
23
|
+
* @property {number} replacementStart
|
|
23
24
|
*/
|
|
24
25
|
|
|
25
26
|
// Matches only the last occurrence of sourceMappingURL
|
|
26
27
|
const innerRegex = /\s*[#@]\s*sourceMappingURL\s*=\s*([^\s'"]*)\s*/;
|
|
27
28
|
|
|
28
29
|
const validProtocolPattern = /^[a-z][a-z0-9+.-]*:/i;
|
|
30
|
+
const whitespaceRegex = /\s/;
|
|
31
|
+
const lineBreakRegex = /[\r\n\u2028\u2029]/;
|
|
32
|
+
const ambiguousCommentRegex = /['"`]|\*\//;
|
|
33
|
+
const ambiguousBlockCommentRegex = /['"`\]]|\*\/(?!$)/;
|
|
29
34
|
|
|
30
35
|
const sourceMappingURLRegex = new RegExp(
|
|
31
|
-
"(?:" +
|
|
36
|
+
"^(?:" +
|
|
32
37
|
"/\\*" +
|
|
33
38
|
"(?:\\s*\r?\n(?://)?)?" +
|
|
34
39
|
`(?:${innerRegex.source})` +
|
|
@@ -37,7 +42,7 @@ const sourceMappingURLRegex = new RegExp(
|
|
|
37
42
|
"|" +
|
|
38
43
|
`//(?:${innerRegex.source})` +
|
|
39
44
|
")" +
|
|
40
|
-
"\\s
|
|
45
|
+
"\\s*$"
|
|
41
46
|
);
|
|
42
47
|
|
|
43
48
|
/**
|
|
@@ -46,24 +51,67 @@ const sourceMappingURLRegex = new RegExp(
|
|
|
46
51
|
* @returns {SourceMappingURL} source mapping information
|
|
47
52
|
*/
|
|
48
53
|
function getSourceMappingURL(code) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (
|
|
54
|
+
let end = code.length;
|
|
55
|
+
let lineStart = end;
|
|
56
|
+
// ECMA-426's non-parsing extraction stops at code or ambiguous comments.
|
|
57
|
+
// Block comments also support CSS and existing JavaScript annotations.
|
|
58
|
+
while (end > 0) {
|
|
59
|
+
while (end > 0 && whitespaceRegex.test(code[end - 1])) end--;
|
|
60
|
+
if (end === 0) break;
|
|
61
|
+
// Consecutive block comments can share a long line of generated code.
|
|
62
|
+
if (lineStart >= end) {
|
|
63
|
+
lineStart = end;
|
|
64
|
+
while (lineStart > 0 && !lineBreakRegex.test(code[lineStart - 1])) {
|
|
65
|
+
lineStart--;
|
|
66
|
+
}
|
|
67
|
+
while (lineStart < end && whitespaceRegex.test(code[lineStart])) {
|
|
68
|
+
lineStart++;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
let start = lineStart;
|
|
72
|
+
let comment;
|
|
73
|
+
if (code.startsWith("//", start)) {
|
|
74
|
+
comment = code.slice(start, end);
|
|
75
|
+
if (ambiguousCommentRegex.test(comment)) break;
|
|
76
|
+
} else if (code.endsWith("*/", end)) {
|
|
77
|
+
start = code.lastIndexOf("/*", end - 2);
|
|
78
|
+
if (start < 0) break;
|
|
79
|
+
comment = code.slice(start, end);
|
|
80
|
+
// An escaped opener or a character class can belong to a trailing RegExp.
|
|
81
|
+
if (
|
|
82
|
+
code[start - 1] === "\\" ||
|
|
83
|
+
ambiguousBlockCommentRegex.test(comment)
|
|
84
|
+
) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
// Comments cannot nest; an inner opener may only be comment text.
|
|
88
|
+
if (
|
|
89
|
+
start > 0 &&
|
|
90
|
+
code.lastIndexOf("/*", start - 1) > code.lastIndexOf("*/", start - 1)
|
|
91
|
+
) {
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
56
95
|
break;
|
|
57
96
|
}
|
|
97
|
+
const match = sourceMappingURLRegex.exec(comment);
|
|
98
|
+
if (match) {
|
|
99
|
+
const sourceMappingURL = match[1] || match[2] || "";
|
|
100
|
+
return {
|
|
101
|
+
sourceMappingURL: sourceMappingURL
|
|
102
|
+
? decodeURI(sourceMappingURL)
|
|
103
|
+
: sourceMappingURL,
|
|
104
|
+
replacementString: comment,
|
|
105
|
+
replacementStart: start
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
end = start;
|
|
58
109
|
}
|
|
59
110
|
|
|
60
|
-
const sourceMappingURL = match ? match[1] || match[2] || "" : "";
|
|
61
|
-
|
|
62
111
|
return {
|
|
63
|
-
sourceMappingURL:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
replacementString: match ? match[0] : ""
|
|
112
|
+
sourceMappingURL: "",
|
|
113
|
+
replacementString: "",
|
|
114
|
+
replacementStart: 0
|
|
67
115
|
};
|
|
68
116
|
}
|
|
69
117
|
|
|
@@ -229,7 +277,8 @@ async function extractSourceMap(stringOrBuffer, resourcePath, readResource) {
|
|
|
229
277
|
source: stringOrBuffer,
|
|
230
278
|
sourceMap: inputSourceMap
|
|
231
279
|
};
|
|
232
|
-
const { sourceMappingURL, replacementString } =
|
|
280
|
+
const { sourceMappingURL, replacementString, replacementStart } =
|
|
281
|
+
getSourceMappingURL(input);
|
|
233
282
|
|
|
234
283
|
if (!sourceMappingURL) {
|
|
235
284
|
return output;
|
|
@@ -310,8 +359,10 @@ async function extractSourceMap(stringOrBuffer, resourcePath, readResource) {
|
|
|
310
359
|
}
|
|
311
360
|
|
|
312
361
|
return {
|
|
313
|
-
source:
|
|
314
|
-
|
|
362
|
+
source:
|
|
363
|
+
input.slice(0, replacementStart) +
|
|
364
|
+
input.slice(replacementStart + replacementString.length),
|
|
365
|
+
sourceMap: newMap
|
|
315
366
|
};
|
|
316
367
|
}
|
|
317
368
|
|
|
@@ -68,7 +68,7 @@ const findCaseMismatch = (fs, missingPath, callback) => {
|
|
|
68
68
|
}
|
|
69
69
|
fs.readdir(next, (err, nextEntries) => {
|
|
70
70
|
if (err || !nextEntries) return callback();
|
|
71
|
-
walkDown(next,
|
|
71
|
+
walkDown(next, nextEntries, index + 1);
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
74
|
|
|
@@ -89,7 +89,7 @@ const findCaseMismatch = (fs, missingPath, callback) => {
|
|
|
89
89
|
return walkUp();
|
|
90
90
|
}
|
|
91
91
|
segments.reverse();
|
|
92
|
-
walkDown(parent,
|
|
92
|
+
walkDown(parent, entries, 0);
|
|
93
93
|
});
|
|
94
94
|
};
|
|
95
95
|
|
|
@@ -9,7 +9,7 @@ const InitFragment = require("../template/InitFragment");
|
|
|
9
9
|
const makeSerializable = require("../util/makeSerializable");
|
|
10
10
|
|
|
11
11
|
/** @import { Source } from "webpack-sources" */
|
|
12
|
-
/** @import { GenerateContext } from "../
|
|
12
|
+
/** @import { ChunkRenderContext as GenerateContext } from "../javascript/JavascriptModulesPlugin" */
|
|
13
13
|
/** @typedef {{ name: string, value?: string }[]} ArrayImportSpecifiers */
|
|
14
14
|
/** @typedef {Set<string>} ImportSpecifier */
|
|
15
15
|
/** @typedef {Map<string, ImportSpecifier>} ImportSpecifiers */
|
|
@@ -81,7 +81,7 @@ class ExternalModuleInitFragment extends InitFragment {
|
|
|
81
81
|
* @param {GenerateContext} context context
|
|
82
82
|
* @returns {string | Source | undefined} the source code that will be included as initialization code
|
|
83
83
|
*/
|
|
84
|
-
getContent(
|
|
84
|
+
getContent(context) {
|
|
85
85
|
/** @type {string[]} */
|
|
86
86
|
const namedImports = [];
|
|
87
87
|
|
|
@@ -154,9 +154,7 @@ class ReadFileCompileAsyncWasmPlugin {
|
|
|
154
154
|
chunk.runtime
|
|
155
155
|
) &&
|
|
156
156
|
needsRuntimeFullHash(
|
|
157
|
-
|
|
158
|
-
compilation.outputOptions.webassemblyModuleFilename
|
|
159
|
-
)
|
|
157
|
+
compilation.outputOptions.webassemblyModuleFilename
|
|
160
158
|
)
|
|
161
159
|
) {
|
|
162
160
|
set.add(RuntimeGlobals.getFullHash);
|
|
@@ -165,9 +163,7 @@ class ReadFileCompileAsyncWasmPlugin {
|
|
|
165
163
|
chunk,
|
|
166
164
|
new AsyncWasmLoadingRuntimeModule({
|
|
167
165
|
fullHashDigest: usesFullHashDigest(
|
|
168
|
-
|
|
169
|
-
compilation.outputOptions.webassemblyModuleFilename
|
|
170
|
-
)
|
|
166
|
+
compilation.outputOptions.webassemblyModuleFilename
|
|
171
167
|
),
|
|
172
168
|
generateLoadBinaryCode,
|
|
173
169
|
supportsStreaming: false
|
|
@@ -196,9 +192,7 @@ class ReadFileCompileAsyncWasmPlugin {
|
|
|
196
192
|
chunk.runtime
|
|
197
193
|
) &&
|
|
198
194
|
needsRuntimeFullHash(
|
|
199
|
-
|
|
200
|
-
compilation.outputOptions.webassemblyModuleFilename
|
|
201
|
-
)
|
|
195
|
+
compilation.outputOptions.webassemblyModuleFilename
|
|
202
196
|
)
|
|
203
197
|
) {
|
|
204
198
|
set.add(RuntimeGlobals.getFullHash);
|
|
@@ -207,9 +201,7 @@ class ReadFileCompileAsyncWasmPlugin {
|
|
|
207
201
|
chunk,
|
|
208
202
|
new AsyncWasmCompileRuntimeModule({
|
|
209
203
|
fullHashDigest: usesFullHashDigest(
|
|
210
|
-
|
|
211
|
-
compilation.outputOptions.webassemblyModuleFilename
|
|
212
|
-
)
|
|
204
|
+
compilation.outputOptions.webassemblyModuleFilename
|
|
213
205
|
),
|
|
214
206
|
generateLoadBinaryCode,
|
|
215
207
|
supportsStreaming: false
|
|
@@ -137,9 +137,7 @@ class ReadFileCompileWasmPlugin {
|
|
|
137
137
|
set.add(RuntimeGlobals.moduleCache);
|
|
138
138
|
if (
|
|
139
139
|
needsRuntimeFullHash(
|
|
140
|
-
|
|
141
|
-
compilation.outputOptions.webassemblyModuleFilename
|
|
142
|
-
)
|
|
140
|
+
compilation.outputOptions.webassemblyModuleFilename
|
|
143
141
|
)
|
|
144
142
|
) {
|
|
145
143
|
set.add(RuntimeGlobals.getFullHash);
|
|
@@ -148,9 +146,7 @@ class ReadFileCompileWasmPlugin {
|
|
|
148
146
|
chunk,
|
|
149
147
|
new WasmChunkLoadingRuntimeModule({
|
|
150
148
|
fullHashDigest: usesFullHashDigest(
|
|
151
|
-
|
|
152
|
-
compilation.outputOptions.webassemblyModuleFilename
|
|
153
|
-
)
|
|
149
|
+
compilation.outputOptions.webassemblyModuleFilename
|
|
154
150
|
),
|
|
155
151
|
generateLoadBinaryCode,
|
|
156
152
|
supportsStreaming: false,
|
package/lib/node/nodeConsole.js
CHANGED
|
@@ -129,7 +129,8 @@ module.exports = ({ colors, appendOnly, stream, compiler }) => {
|
|
|
129
129
|
};
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
|
-
* @
|
|
132
|
+
* @template T
|
|
133
|
+
* @param {T[]} statusMessage status message
|
|
133
134
|
* @returns {void}
|
|
134
135
|
*/
|
|
135
136
|
const setStatusMessage = (statusMessage) => {
|
|
@@ -155,10 +156,10 @@ module.exports = ({ colors, appendOnly, stream, compiler }) => {
|
|
|
155
156
|
writeStatusMessage();
|
|
156
157
|
};
|
|
157
158
|
|
|
158
|
-
/** @type {
|
|
159
|
+
/** @type {LoggerConsole["log"]} */
|
|
159
160
|
const writeGroupMessage = writeColored("<-> ", (str) => c.bold(c.cyan(str)));
|
|
160
161
|
|
|
161
|
-
/** @type {
|
|
162
|
+
/** @type {LoggerConsole["log"]} */
|
|
162
163
|
const writeGroupCollapsedMessage = writeColored("<+> ", (str) =>
|
|
163
164
|
c.bold(c.cyan(str))
|
|
164
165
|
);
|
|
@@ -357,7 +357,7 @@ class CircularModulesPlugin {
|
|
|
357
357
|
* @returns {number | undefined} bit flags from CircularKind
|
|
358
358
|
*/
|
|
359
359
|
static getCircularKind(module) {
|
|
360
|
-
const buildInfo =
|
|
360
|
+
const buildInfo = module.buildInfo;
|
|
361
361
|
if (!buildInfo || buildInfo.circularKind === undefined) return undefined;
|
|
362
362
|
return buildInfo.circularKind;
|
|
363
363
|
}
|
|
@@ -1471,8 +1471,6 @@ class ConcatenatedModule extends Module {
|
|
|
1471
1471
|
if (runtimeCondition === false) continue;
|
|
1472
1472
|
const nonDeferAccess = !defer;
|
|
1473
1473
|
const module = connection.module;
|
|
1474
|
-
if (targets === undefined) targets = [module];
|
|
1475
|
-
else if (!targets.includes(module)) targets.push(module);
|
|
1476
1474
|
const dependency = connection.dependency;
|
|
1477
1475
|
if (
|
|
1478
1476
|
dependency !== null &&
|
|
@@ -1483,6 +1481,8 @@ class ConcatenatedModule extends Module {
|
|
|
1483
1481
|
}
|
|
1484
1482
|
const entry = referencesMap.get(module);
|
|
1485
1483
|
if (entry === undefined) {
|
|
1484
|
+
if (targets === undefined) targets = [module];
|
|
1485
|
+
else targets.push(module);
|
|
1486
1486
|
referencesMap.set(module, {
|
|
1487
1487
|
connection,
|
|
1488
1488
|
runtimeCondition,
|
|
@@ -2342,9 +2342,7 @@ class ConcatenatedModule extends Module {
|
|
|
2342
2342
|
newName &&
|
|
2343
2343
|
concatenatedModuleInfo.call(
|
|
2344
2344
|
{
|
|
2345
|
-
rawExportMap: new Map([
|
|
2346
|
-
[exportId, /** @type {string} */ (newName)]
|
|
2347
|
-
])
|
|
2345
|
+
rawExportMap: new Map([[exportId, newName]])
|
|
2348
2346
|
},
|
|
2349
2347
|
/** @type {ConcatenatedModuleInfo} */ (referencedInfo)
|
|
2350
2348
|
);
|
|
@@ -2820,9 +2818,7 @@ ${defineGetters}`
|
|
|
2820
2818
|
if (!info.wrapped) {
|
|
2821
2819
|
const source = namespaceObjectSources.get(info);
|
|
2822
2820
|
if (source) result.add(source);
|
|
2823
|
-
const escapeSource = escapeNamespaceObjectSources.get(
|
|
2824
|
-
/** @type {ConcatenatedModuleInfo} */ (info)
|
|
2825
|
-
);
|
|
2821
|
+
const escapeSource = escapeNamespaceObjectSources.get(info);
|
|
2826
2822
|
if (escapeSource) result.add(escapeSource);
|
|
2827
2823
|
}
|
|
2828
2824
|
} else if (info.type === "external" && info.deferred) {
|
|
@@ -39,7 +39,7 @@ const PLUGIN_LOGGER_NAME = `webpack.${PLUGIN_NAME}`;
|
|
|
39
39
|
*/
|
|
40
40
|
const getProvidedExportsEtag = (module, lazyBarrels, hashFunction) => {
|
|
41
41
|
const lazyRequests = lazyBarrels.getLazyRequests(module);
|
|
42
|
-
const buildInfo =
|
|
42
|
+
const buildInfo = module.buildInfo;
|
|
43
43
|
const valueDependencies = buildInfo && buildInfo.valueDependencies;
|
|
44
44
|
const hasValueDependencies =
|
|
45
45
|
valueDependencies !== undefined && valueDependencies.size > 0;
|
|
@@ -145,9 +145,8 @@ class FlagDependencyExportsPlugin {
|
|
|
145
145
|
exportsInfo.restoreProvided(memCacheEntry.data);
|
|
146
146
|
return callback();
|
|
147
147
|
}
|
|
148
|
-
const buildHash = /** @type {
|
|
149
|
-
|
|
150
|
-
);
|
|
148
|
+
const buildHash = /** @type {BuildInfo} */ (module.buildInfo)
|
|
149
|
+
.hash;
|
|
151
150
|
cache.get(
|
|
152
151
|
module.identifier(),
|
|
153
152
|
etag ? `${buildHash}|${etag}` : buildHash,
|
|
@@ -391,10 +390,7 @@ class FlagDependencyExportsPlugin {
|
|
|
391
390
|
if (exports) {
|
|
392
391
|
const nestedExportsInfo =
|
|
393
392
|
exportInfo.createNestedExportsInfo();
|
|
394
|
-
mergeExports(
|
|
395
|
-
/** @type {ExportsInfo} */ (nestedExportsInfo),
|
|
396
|
-
exports
|
|
397
|
-
);
|
|
393
|
+
mergeExports(nestedExportsInfo, exports);
|
|
398
394
|
}
|
|
399
395
|
|
|
400
396
|
if (
|
|
@@ -545,9 +541,8 @@ class FlagDependencyExportsPlugin {
|
|
|
545
541
|
};
|
|
546
542
|
memCache.set(this, entry);
|
|
547
543
|
}
|
|
548
|
-
const buildHash = /** @type {
|
|
549
|
-
|
|
550
|
-
);
|
|
544
|
+
const buildHash = /** @type {BuildInfo} */ (module.buildInfo)
|
|
545
|
+
.hash;
|
|
551
546
|
cache.store(
|
|
552
547
|
module.identifier(),
|
|
553
548
|
etag ? `${buildHash}|${etag}` : buildHash,
|
|
@@ -16,7 +16,7 @@ const TupleQueue = require("./TupleQueue");
|
|
|
16
16
|
|
|
17
17
|
/** @import Compiler from "../Compiler" */
|
|
18
18
|
/** @import DependenciesBlock from "../graph/DependenciesBlock" */
|
|
19
|
-
/** @import { ReferencedExport, ReferencedExports } from "../graph/Dependency" */
|
|
19
|
+
/** @import { ExportInfoName, ReferencedExport, ReferencedExports } from "../graph/Dependency" */
|
|
20
20
|
/** @import ExportsInfo from "../graph/ExportsInfo" */
|
|
21
21
|
/** @import Module from "../module/Module" */
|
|
22
22
|
/** @import { RuntimeSpec } from "../util/runtime" */
|
|
@@ -77,6 +77,25 @@ class FlagDependencyUsagePlugin {
|
|
|
77
77
|
/** @type {Map<ExportsInfo, Module>} */
|
|
78
78
|
const exportInfoToModuleMap = new Map();
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Returns the module owning an export of a nested exports info. A
|
|
82
|
+
* nested exports info redirecting to a module's exports owns only
|
|
83
|
+
* its own names, the rest belong to the redirect target.
|
|
84
|
+
* @param {ExportsInfo} exportsInfo nested exports info
|
|
85
|
+
* @param {ExportInfoName} name export name
|
|
86
|
+
* @returns {Module | undefined} the module owning the export
|
|
87
|
+
*/
|
|
88
|
+
const getExportOwnerModule = (exportsInfo, name) => {
|
|
89
|
+
/** @type {ExportsInfo | undefined} */
|
|
90
|
+
let current = exportsInfo;
|
|
91
|
+
while (current !== undefined) {
|
|
92
|
+
const owner = exportInfoToModuleMap.get(current);
|
|
93
|
+
if (owner !== undefined) return owner;
|
|
94
|
+
if (current._exports.has(name)) return;
|
|
95
|
+
current = current._redirectTo;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
80
99
|
/** @type {TupleQueue<[Module], RuntimeSpec>} */
|
|
81
100
|
const queue = new TupleQueue();
|
|
82
101
|
|
|
@@ -179,7 +198,10 @@ class FlagDependencyUsagePlugin {
|
|
|
179
198
|
const currentModule =
|
|
180
199
|
currentExportsInfo === exportsInfo
|
|
181
200
|
? module
|
|
182
|
-
:
|
|
201
|
+
: getExportOwnerModule(
|
|
202
|
+
currentExportsInfo,
|
|
203
|
+
usedExport[i]
|
|
204
|
+
);
|
|
183
205
|
if (currentModule) {
|
|
184
206
|
queue.enqueue(currentModule, runtime);
|
|
185
207
|
}
|
|
@@ -198,7 +220,10 @@ class FlagDependencyUsagePlugin {
|
|
|
198
220
|
const currentModule =
|
|
199
221
|
currentExportsInfo === exportsInfo
|
|
200
222
|
? module
|
|
201
|
-
:
|
|
223
|
+
: getExportOwnerModule(
|
|
224
|
+
currentExportsInfo,
|
|
225
|
+
usedExport[i]
|
|
226
|
+
);
|
|
202
227
|
if (currentModule) {
|
|
203
228
|
queue.enqueue(currentModule, runtime);
|
|
204
229
|
}
|
|
@@ -170,11 +170,7 @@ const isInlineExportsEnabled = (moduleGraph) =>
|
|
|
170
170
|
* @returns {boolean} true when inlining is enabled for this module
|
|
171
171
|
*/
|
|
172
172
|
const isInlineEnabled = (module) =>
|
|
173
|
-
Boolean(
|
|
174
|
-
module.buildInfo &&
|
|
175
|
-
/** @type {import("../module/Module").BuildInfo} */
|
|
176
|
-
(module.buildInfo).inlineExports
|
|
177
|
-
);
|
|
173
|
+
Boolean(module.buildInfo && module.buildInfo.inlineExports);
|
|
178
174
|
|
|
179
175
|
/**
|
|
180
176
|
* Check whether an import to `module` for `ids` resolves to an inlined value.
|
|
@@ -192,8 +188,9 @@ const isExportInlined = (moduleGraph, module, ids, runtime) => {
|
|
|
192
188
|
|
|
193
189
|
/**
|
|
194
190
|
* Whether a used name is an inlined value rather than a property name.
|
|
195
|
-
* @
|
|
196
|
-
* @
|
|
191
|
+
* @template V
|
|
192
|
+
* @param {V} value a used name
|
|
193
|
+
* @returns {value is Extract<V, InlinedUsedName>} true when the value is inlined
|
|
197
194
|
*/
|
|
198
195
|
const isInlinedUsedName = (value) => value instanceof InlinedUsedName;
|
|
199
196
|
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
const { ImportPhaseUtils } = require("../dependencies/core/ImportPhase");
|
|
8
9
|
const Dependency = require("../graph/Dependency");
|
|
10
|
+
const isDependencyKind = require("../graph/isDependencyKind");
|
|
9
11
|
|
|
10
12
|
/** @import Compilation, { DependencyConstructor } from "../Compilation" */
|
|
11
13
|
/** @import ModuleGraph from "../graph/ModuleGraph" */
|
|
@@ -76,13 +78,23 @@ const getRequestKey = (dependency) => {
|
|
|
76
78
|
};
|
|
77
79
|
|
|
78
80
|
/**
|
|
79
|
-
* Returns
|
|
80
|
-
*
|
|
81
|
+
* Returns whether the re-export reads an `import defer` namespace, which `SideEffectsFlagPlugin` keeps on the barrel.
|
|
82
|
+
* @param {Dependency} dependency the re-export dependency
|
|
83
|
+
* @returns {boolean} true, when requesting it runs the barrel
|
|
84
|
+
*/
|
|
85
|
+
const isDeferredReexport = (dependency) =>
|
|
86
|
+
isDependencyKind(dependency, "esm-import") &&
|
|
87
|
+
ImportPhaseUtils.isDefer(dependency.phase);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Returns true if names were requested and none of them runs the barrel.
|
|
91
|
+
* Only a running barrel uses the import declarations, so it can defer them until such a name is requested.
|
|
81
92
|
* @param {Set<string> | true | undefined} forwardedIds names requested before classification
|
|
82
93
|
* @param {Set<string>} localIds locally provided export names
|
|
94
|
+
* @param {Map<string, string> | undefined} deferredReexports names re-exported from an `import defer` namespace
|
|
83
95
|
* @returns {boolean} true, when import declarations can be deferred
|
|
84
96
|
*/
|
|
85
|
-
const canLazyImports = (forwardedIds, localIds) => {
|
|
97
|
+
const canLazyImports = (forwardedIds, localIds, deferredReexports) => {
|
|
86
98
|
if (
|
|
87
99
|
forwardedIds === undefined ||
|
|
88
100
|
forwardedIds === true ||
|
|
@@ -92,6 +104,9 @@ const canLazyImports = (forwardedIds, localIds) => {
|
|
|
92
104
|
}
|
|
93
105
|
for (const id of forwardedIds) {
|
|
94
106
|
if (localIds.has(id)) return false;
|
|
107
|
+
if (deferredReexports !== undefined && deferredReexports.has(id)) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
95
110
|
}
|
|
96
111
|
return true;
|
|
97
112
|
};
|
|
@@ -319,6 +334,11 @@ class LazyBarrels {
|
|
|
319
334
|
this._modules = new WeakMap();
|
|
320
335
|
/** @type {WeakSet<Dependency>} */
|
|
321
336
|
this._lazyDependencies = new WeakSet();
|
|
337
|
+
// without provided exports no import is redirected past the barrel, so it runs
|
|
338
|
+
/** @type {boolean} */
|
|
339
|
+
this._canLazyImports = Boolean(
|
|
340
|
+
compilation.options.optimization.providedExports
|
|
341
|
+
);
|
|
322
342
|
lazyBarrelsByModuleGraph.set(compilation.moduleGraph, this);
|
|
323
343
|
}
|
|
324
344
|
|
|
@@ -429,6 +449,8 @@ class LazyBarrels {
|
|
|
429
449
|
/** @type {Set<string>} */
|
|
430
450
|
const localIds = new Set();
|
|
431
451
|
let hasFallbackStarReexport = false;
|
|
452
|
+
/** @type {Map<string, string> | undefined} export name -> request key */
|
|
453
|
+
let deferredReexports;
|
|
432
454
|
|
|
433
455
|
// re-export starts deferred and this compilation's requests activate the ones it needs
|
|
434
456
|
for (const dep of dependencies) {
|
|
@@ -451,7 +473,12 @@ class LazyBarrels {
|
|
|
451
473
|
if (info === undefined) info = new LazyBarrelInfo(this._lazyDependencies);
|
|
452
474
|
info.addLazy(requestKey, dep, factory);
|
|
453
475
|
if (role === Dependency.LAZY_NAMED_REEXPORT) {
|
|
454
|
-
|
|
476
|
+
const name = /** @type {string} */ (dep.lazyName);
|
|
477
|
+
info.addForwardId(name, requestKey);
|
|
478
|
+
if (isDeferredReexport(dep)) {
|
|
479
|
+
if (deferredReexports === undefined) deferredReexports = new Map();
|
|
480
|
+
deferredReexports.set(name, requestKey);
|
|
481
|
+
}
|
|
455
482
|
} else if (role === Dependency.LAZY_STAR_REEXPORT) {
|
|
456
483
|
info.addFallback(requestKey);
|
|
457
484
|
hasFallbackStarReexport = true;
|
|
@@ -461,7 +488,10 @@ class LazyBarrels {
|
|
|
461
488
|
// import declarations
|
|
462
489
|
/** @type {Set<string> | undefined} */
|
|
463
490
|
let importRequests;
|
|
464
|
-
if (
|
|
491
|
+
if (
|
|
492
|
+
this._canLazyImports &&
|
|
493
|
+
canLazyImports(forwardedIds, localIds, deferredReexports)
|
|
494
|
+
) {
|
|
465
495
|
for (const dep of dependencies) {
|
|
466
496
|
if (dep.lazyRole !== Dependency.LAZY_IMPORT_DECLARATION) continue;
|
|
467
497
|
const factory = this._getDepFactory(dep);
|
|
@@ -478,6 +508,12 @@ class LazyBarrels {
|
|
|
478
508
|
|
|
479
509
|
if (info === undefined) return;
|
|
480
510
|
|
|
511
|
+
if (importRequests !== undefined && deferredReexports !== undefined) {
|
|
512
|
+
for (const [id, requestKey] of deferredReexports) {
|
|
513
|
+
info.addForwardId(id, new Set([...importRequests, requestKey]));
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
481
517
|
// local exports: known names, so they skip the star fallback but active the deferred imports
|
|
482
518
|
if (hasFallbackStarReexport || importRequests !== undefined) {
|
|
483
519
|
const requests =
|
|
@@ -32,6 +32,8 @@ const { STAGE_DEFAULT } = require("./OptimizationStages");
|
|
|
32
32
|
/** @import { BuildInfo, BuildMeta } from "../module/Module" */
|
|
33
33
|
/** @import RequestShortener from "../util/RequestShortener" */
|
|
34
34
|
/** @import { RuntimeSpec } from "../util/runtime" */
|
|
35
|
+
/** @import { ResolverWithOptions } from "../resolve/ResolverFactory" */
|
|
36
|
+
/** @import { InputFileSystem } from "../fs/fs" */
|
|
35
37
|
|
|
36
38
|
/** @typedef {Module | ((requestShortener: RequestShortener) => string)} Problem */
|
|
37
39
|
|
|
@@ -112,11 +114,6 @@ class ModuleConcatenationPlugin {
|
|
|
112
114
|
apply(compiler) {
|
|
113
115
|
const { _backCompat: backCompat } = compiler;
|
|
114
116
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
115
|
-
if (compilation.moduleMemCaches) {
|
|
116
|
-
throw new Error(
|
|
117
|
-
"optimization.concatenateModules can't be used with cacheUnaffected as module concatenation is a global effect"
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
117
|
const moduleGraph = compilation.moduleGraph;
|
|
121
118
|
/** @type {Map<Module, string | ((requestShortener: RequestShortener) => string)>} */
|
|
122
119
|
const bailoutReasonMap = new Map();
|
|
@@ -196,6 +193,7 @@ class ModuleConcatenationPlugin {
|
|
|
196
193
|
stage: STAGE_DEFAULT
|
|
197
194
|
},
|
|
198
195
|
(allChunks, modules, callback) => {
|
|
196
|
+
// set once the modules are built, so not yet when the compilation starts
|
|
199
197
|
const logger = compilation.getLogger(
|
|
200
198
|
"webpack.ModuleConcatenationPlugin"
|
|
201
199
|
);
|
|
@@ -523,10 +521,10 @@ class ModuleConcatenationPlugin {
|
|
|
523
521
|
newModule.build(
|
|
524
522
|
compilation.options,
|
|
525
523
|
compilation,
|
|
526
|
-
/** @type {
|
|
527
|
-
(null),
|
|
528
|
-
/** @type {
|
|
529
|
-
(null),
|
|
524
|
+
/** @type {ResolverWithOptions} */
|
|
525
|
+
(/** @type {ResolverWithOptions | null} */ (null)),
|
|
526
|
+
/** @type {InputFileSystem} */
|
|
527
|
+
(/** @type {InputFileSystem | null} */ (null)),
|
|
530
528
|
(err) => {
|
|
531
529
|
if (err) {
|
|
532
530
|
if (!err.module) {
|
|
@@ -1027,7 +1025,7 @@ class ModuleConcatenationPlugin {
|
|
|
1027
1025
|
)} (expected runtime ${runtimeToString(
|
|
1028
1026
|
runtime
|
|
1029
1027
|
)}, module is only referenced in ${runtimeToString(
|
|
1030
|
-
|
|
1028
|
+
runtimeCondition
|
|
1031
1029
|
)})`
|
|
1032
1030
|
).join(", ")}`;
|
|
1033
1031
|
return cacheFailure(
|
|
@@ -600,9 +600,7 @@ ${referencingAssets
|
|
|
600
600
|
);
|
|
601
601
|
}
|
|
602
602
|
const digest = hash.digest(
|
|
603
|
-
|
|
604
|
-
hashToDigest.get(oldHash) || this._hashDigest
|
|
605
|
-
)
|
|
603
|
+
hashToDigest.get(oldHash) || this._hashDigest
|
|
606
604
|
);
|
|
607
605
|
hashToNewHash.set(oldHash, digest.slice(0, oldHash.length));
|
|
608
606
|
}
|
|
@@ -650,9 +648,7 @@ ${referencingAssets
|
|
|
650
648
|
for (const c of chunks) hash.update(c);
|
|
651
649
|
}
|
|
652
650
|
const digest = hash.digest(
|
|
653
|
-
|
|
654
|
-
hashToDigest.get(oldHash) || this._hashDigest
|
|
655
|
-
)
|
|
651
|
+
hashToDigest.get(oldHash) || this._hashDigest
|
|
656
652
|
);
|
|
657
653
|
newHash = digest.slice(0, oldHash.length);
|
|
658
654
|
}
|