webpack 5.83.1 → 5.85.0
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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +2 -2
- package/lib/AsyncDependenciesBlock.js +2 -2
- package/lib/AutomaticPrefetchPlugin.js +1 -0
- package/lib/BannerPlugin.js +4 -0
- package/lib/CacheFacade.js +4 -0
- package/lib/ChunkGroup.js +5 -1
- package/lib/CleanPlugin.js +30 -7
- package/lib/CompatibilityPlugin.js +4 -3
- package/lib/Compilation.js +3 -3
- package/lib/Compiler.js +1 -1
- package/lib/ContextModule.js +3 -3
- package/lib/ContextModuleFactory.js +1 -1
- package/lib/DefinePlugin.js +11 -2
- package/lib/DllEntryPlugin.js +5 -0
- package/lib/DllModule.js +1 -1
- package/lib/DllModuleFactory.js +1 -1
- package/lib/EvalSourceMapDevToolPlugin.js +3 -1
- package/lib/HookWebpackError.js +1 -1
- package/lib/IgnoreErrorModuleFactory.js +1 -1
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +21 -9
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleTypeConstants.js +2 -1
- package/lib/NormalModuleFactory.js +1 -1
- package/lib/NormalModuleReplacementPlugin.js +4 -2
- package/lib/NullFactory.js +1 -1
- package/lib/PrefetchPlugin.js +4 -0
- package/lib/RecordIdsPlugin.js +4 -4
- package/lib/RuntimeModule.js +5 -5
- package/lib/RuntimePlugin.js +4 -0
- package/lib/RuntimeTemplate.js +7 -7
- package/lib/SelfModuleFactory.js +12 -0
- package/lib/SourceMapDevToolPlugin.js +9 -2
- package/lib/Template.js +3 -2
- package/lib/UseStrictPlugin.js +4 -0
- package/lib/WarnDeprecatedOptionPlugin.js +7 -0
- package/lib/WatchIgnorePlugin.js +4 -0
- package/lib/WebpackOptionsApply.js +2 -1
- package/lib/asset/AssetGenerator.js +7 -2
- package/lib/asset/AssetModulesPlugin.js +7 -1
- package/lib/asset/AssetParser.js +4 -1
- package/lib/asset/RawDataUrlModule.js +5 -3
- package/lib/async-modules/InferAsyncModulesPlugin.js +1 -1
- package/lib/cache/PackFileCacheStrategy.js +7 -1
- package/lib/config/browserslistTargetHandler.js +3 -3
- package/lib/config/defaults.js +240 -73
- package/lib/config/normalization.js +104 -71
- package/lib/config/target.js +37 -10
- package/lib/container/ContainerEntryModule.js +4 -0
- package/lib/container/ContainerEntryModuleFactory.js +1 -1
- package/lib/container/FallbackDependency.js +7 -0
- package/lib/container/FallbackItemDependency.js +3 -0
- package/lib/container/FallbackModule.js +5 -1
- package/lib/container/FallbackModuleFactory.js +1 -1
- package/lib/container/RemoteModule.js +4 -0
- package/lib/container/RemoteRuntimeModule.js +2 -1
- package/lib/container/RemoteToExternalDependency.js +3 -0
- package/lib/css/CssParser.js +168 -73
- package/lib/debug/ProfilingPlugin.js +11 -0
- package/lib/dependencies/AMDDefineDependency.js +12 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -2
- package/lib/dependencies/AMDPlugin.js +7 -0
- package/lib/dependencies/AMDRequireArrayDependency.js +5 -0
- package/lib/dependencies/AMDRequireContextDependency.js +6 -0
- package/lib/dependencies/AMDRequireDependenciesBlock.js +6 -0
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +8 -2
- package/lib/dependencies/AMDRequireDependency.js +8 -1
- package/lib/dependencies/AMDRequireItemDependency.js +6 -0
- package/lib/dependencies/CachedConstDependency.js +6 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +11 -0
- package/lib/dependencies/CommonJsExportsDependency.js +8 -0
- package/lib/dependencies/CommonJsExportsParserPlugin.js +2 -2
- package/lib/dependencies/CommonJsFullRequireDependency.js +2 -1
- package/lib/dependencies/CommonJsPlugin.js +28 -12
- package/lib/dependencies/CommonJsRequireContextDependency.js +8 -0
- package/lib/dependencies/CommonJsRequireDependency.js +7 -0
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +8 -0
- package/lib/dependencies/ConstDependency.js +2 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -3
- package/lib/dependencies/CreateScriptUrlDependency.js +2 -1
- package/lib/dependencies/CriticalDependencyWarning.js +3 -0
- package/lib/dependencies/CssImportDependency.js +2 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +12 -2
- package/lib/dependencies/DelegatedSourceDependency.js +3 -0
- package/lib/dependencies/ExportsInfoDependency.js +6 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +2 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +3 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +16 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +12 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +3 -0
- package/lib/dependencies/HarmonyExportExpressionDependency.js +8 -0
- package/lib/dependencies/HarmonyExportHeaderDependency.js +5 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -1
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
- package/lib/dependencies/HarmonyExports.js +3 -1
- package/lib/dependencies/HarmonyImportDependency.js +2 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +18 -5
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +6 -0
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +86 -6
- package/lib/dependencies/HarmonyModulesPlugin.js +12 -0
- package/lib/dependencies/ImportContextDependency.js +6 -0
- package/lib/dependencies/ImportDependency.js +2 -1
- package/lib/dependencies/ImportEagerDependency.js +2 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +32 -13
- package/lib/dependencies/ImportMetaContextPlugin.js +7 -0
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +6 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +6 -0
- package/lib/dependencies/ImportParserPlugin.js +5 -0
- package/lib/dependencies/ImportPlugin.js +7 -0
- package/lib/dependencies/ImportWeakDependency.js +2 -1
- package/lib/dependencies/LocalModule.js +16 -0
- package/lib/dependencies/LocalModuleDependency.js +7 -0
- package/lib/dependencies/LocalModulesHelpers.js +18 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +6 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +6 -0
- package/lib/dependencies/PrefetchDependency.js +3 -0
- package/lib/dependencies/ProvidedDependency.js +2 -1
- package/lib/dependencies/PureExpressionDependency.js +2 -1
- package/lib/dependencies/RequireContextDependency.js +6 -0
- package/lib/dependencies/RequireContextPlugin.js +7 -0
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +4 -0
- package/lib/dependencies/RequireEnsureDependency.js +8 -2
- package/lib/dependencies/RequireEnsureItemDependency.js +3 -0
- package/lib/dependencies/RequireEnsurePlugin.js +14 -0
- package/lib/dependencies/RequireHeaderDependency.js +5 -1
- package/lib/dependencies/RequireIncludeDependency.js +5 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -0
- package/lib/dependencies/RequireIncludePlugin.js +14 -0
- package/lib/dependencies/RequireResolveContextDependency.js +8 -0
- package/lib/dependencies/RequireResolveDependency.js +6 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +4 -0
- package/lib/dependencies/SystemPlugin.js +10 -1
- package/lib/dependencies/URLDependency.js +3 -2
- package/lib/dependencies/URLPlugin.js +7 -5
- package/lib/dependencies/UnsupportedDependency.js +5 -0
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +6 -0
- package/lib/dependencies/WebpackIsIncludedDependency.js +5 -0
- package/lib/dependencies/WorkerDependency.js +2 -1
- package/lib/dependencies/WorkerPlugin.js +30 -3
- package/lib/dependencies/getFunctionExpression.js +7 -0
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +2 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +15 -7
- package/lib/esm/ModuleChunkLoadingPlugin.js +9 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +14 -9
- package/lib/hmr/LazyCompilationPlugin.js +1 -1
- package/lib/ids/ChunkModuleIdRangePlugin.js +11 -0
- package/lib/ids/DeterministicChunkIdsPlugin.js +11 -2
- package/lib/ids/DeterministicModuleIdsPlugin.js +11 -7
- package/lib/ids/HashedModuleIdsPlugin.js +8 -1
- package/lib/ids/IdHelpers.js +6 -0
- package/lib/ids/NamedChunkIdsPlugin.js +13 -1
- package/lib/ids/NamedModuleIdsPlugin.js +14 -3
- package/lib/ids/OccurrenceChunkIdsPlugin.js +6 -2
- package/lib/ids/SyncModuleIdsPlugin.js +2 -2
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +3 -3
- package/lib/javascript/BasicEvaluatedExpression.js +11 -1
- package/lib/javascript/ChunkHelpers.js +2 -2
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/EnableChunkLoadingPlugin.js +4 -0
- package/lib/javascript/JavascriptModulesPlugin.js +36 -31
- package/lib/javascript/JavascriptParser.js +586 -192
- package/lib/javascript/StartupHelpers.js +2 -2
- package/lib/json/JsonGenerator.js +7 -5
- package/lib/json/JsonParser.js +1 -1
- package/lib/library/AbstractLibraryPlugin.js +4 -0
- package/lib/library/AssignLibraryPlugin.js +6 -4
- package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
- package/lib/library/ModuleLibraryPlugin.js +6 -3
- package/lib/library/SystemLibraryPlugin.js +1 -0
- package/lib/library/UmdLibraryPlugin.js +4 -0
- package/lib/node/CommonJsChunkLoadingPlugin.js +17 -2
- package/lib/node/NodeTemplatePlugin.js +10 -2
- package/lib/node/NodeWatchFileSystem.js +1 -1
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +6 -3
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +8 -0
- package/lib/node/ReadFileCompileWasmPlugin.js +19 -2
- package/lib/node/RequireChunkLoadingRuntimeModule.js +6 -3
- package/lib/optimize/ConcatenatedModule.js +1 -1
- package/lib/optimize/InnerGraphPlugin.js +11 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +5 -1
- package/lib/runtime/BaseUriRuntimeModule.js +5 -1
- package/lib/runtime/EnsureChunkRuntimeModule.js +3 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +35 -16
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +1 -1
- package/lib/runtime/PublicPathRuntimeModule.js +5 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +15 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +4 -1
- package/lib/runtime/StartupEntrypointRuntimeModule.js +8 -5
- package/lib/serialization/ArraySerializer.js +22 -6
- package/lib/serialization/BinaryMiddleware.js +21 -0
- package/lib/serialization/DateObjectSerializer.js +15 -4
- package/lib/serialization/ErrorObjectSerializer.js +20 -8
- package/lib/serialization/FileMiddleware.js +17 -0
- package/lib/serialization/MapObjectSerializer.js +24 -8
- package/lib/serialization/NullPrototypeObjectSerializer.js +25 -8
- package/lib/serialization/ObjectMiddleware.js +23 -0
- package/lib/serialization/PlainObjectSerializer.js +23 -12
- package/lib/serialization/RegExpObjectSerializer.js +16 -5
- package/lib/serialization/SetObjectSerializer.js +21 -6
- package/lib/sharing/ProvideSharedModuleFactory.js +1 -1
- package/lib/sharing/ShareRuntimeModule.js +1 -1
- package/lib/util/createHash.js +1 -1
- package/lib/util/makeSerializable.js +7 -0
- package/lib/util/serialization.js +10 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +9 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +13 -3
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +19 -2
- package/lib/wasm-async/AsyncWebAssemblyParser.js +3 -0
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +25 -1
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +14 -5
- package/lib/wasm-sync/WebAssemblyGenerator.js +18 -5
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +12 -1
- package/lib/wasm-sync/WebAssemblyParser.js +9 -2
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/FetchCompileAsyncWasmPlugin.js +9 -0
- package/lib/web/FetchCompileWasmPlugin.js +19 -2
- package/lib/web/JsonpChunkLoadingPlugin.js +9 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -1
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +9 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -2
- package/package.json +3 -3
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +12 -0
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +4 -0
- package/types.d.ts +655 -290
@@ -19,7 +19,7 @@ const { getAllChunks } = require("./ChunkHelpers");
|
|
19
19
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
20
20
|
/** @typedef {(string|number)[]} EntryItem */
|
21
21
|
|
22
|
-
const EXPORT_PREFIX =
|
22
|
+
const EXPORT_PREFIX = `var ${RuntimeGlobals.exports} = `;
|
23
23
|
|
24
24
|
/**
|
25
25
|
* @param {ChunkGraph} chunkGraph chunkGraph
|
@@ -39,7 +39,7 @@ exports.generateEntryStartup = (
|
|
39
39
|
/** @type {string[]} */
|
40
40
|
const runtime = [
|
41
41
|
`var __webpack_exec__ = ${runtimeTemplate.returningFunction(
|
42
|
-
|
42
|
+
`${RuntimeGlobals.require}(${RuntimeGlobals.entryModuleId} = moduleId)`,
|
43
43
|
"moduleId"
|
44
44
|
)}`
|
45
45
|
];
|
@@ -45,13 +45,14 @@ const createObjectForExportsInfo = (data, exportsInfo, runtime) => {
|
|
45
45
|
if (exportsInfo.otherExportsInfo.getUsed(runtime) !== UsageState.Unused)
|
46
46
|
return data;
|
47
47
|
const isArray = Array.isArray(data);
|
48
|
+
/** @type {RawJsonData} */
|
48
49
|
const reducedData = isArray ? [] : {};
|
49
50
|
for (const key of Object.keys(data)) {
|
50
51
|
const exportInfo = exportsInfo.getReadOnlyExportInfo(key);
|
51
52
|
const used = exportInfo.getUsed(runtime);
|
52
53
|
if (used === UsageState.Unused) continue;
|
53
54
|
|
54
|
-
/** @type {
|
55
|
+
/** @type {RawJsonData} */
|
55
56
|
let value;
|
56
57
|
if (used === UsageState.OnlyPropertiesUsed && exportInfo.exportsInfo) {
|
57
58
|
value = createObjectForExportsInfo(
|
@@ -62,8 +63,9 @@ const createObjectForExportsInfo = (data, exportsInfo, runtime) => {
|
|
62
63
|
} else {
|
63
64
|
value = data[key];
|
64
65
|
}
|
65
|
-
|
66
|
-
|
66
|
+
|
67
|
+
const name = /** @type {string} */ (exportInfo.getUsedName(key, runtime));
|
68
|
+
/** @type {Record<string, RawJsonData>} */ (reducedData)[name] = value;
|
67
69
|
}
|
68
70
|
if (isArray) {
|
69
71
|
let arrayLengthWhenUsed =
|
@@ -130,7 +132,7 @@ class JsonGenerator extends Generator {
|
|
130
132
|
module.buildInfo.jsonData &&
|
131
133
|
module.buildInfo.jsonData.get();
|
132
134
|
if (!data) return 0;
|
133
|
-
return stringifySafe(data).length + 10;
|
135
|
+
return /** @type {string} */ (stringifySafe(data)).length + 10;
|
134
136
|
}
|
135
137
|
|
136
138
|
/**
|
@@ -178,7 +180,7 @@ class JsonGenerator extends Generator {
|
|
178
180
|
? createObjectForExportsInfo(data, exportsInfo, runtime)
|
179
181
|
: data;
|
180
182
|
// Use JSON because JSON.parse() is much faster than JavaScript evaluation
|
181
|
-
const jsonStr = stringifySafe(finalJson);
|
183
|
+
const jsonStr = /** @type {string} */ (stringifySafe(finalJson));
|
182
184
|
const jsonExpr =
|
183
185
|
jsonStr.length > 20 && typeof finalJson === "object"
|
184
186
|
? `JSON.parse('${jsonStr.replace(/[\\']/g, "\\$&")}')`
|
package/lib/json/JsonParser.js
CHANGED
@@ -34,7 +34,7 @@ class JsonParser extends Parser {
|
|
34
34
|
source = source.toString("utf-8");
|
35
35
|
}
|
36
36
|
|
37
|
-
/** @type {JsonModulesPluginParserOptions["parse"]} */
|
37
|
+
/** @type {NonNullable<JsonModulesPluginParserOptions["parse"]>} */
|
38
38
|
const parseFn =
|
39
39
|
typeof this.options.parse === "function" ? this.options.parse : parseJson;
|
40
40
|
/** @type {Buffer | RawJsonData} */
|
@@ -87,6 +87,10 @@ class AbstractLibraryPlugin {
|
|
87
87
|
}
|
88
88
|
);
|
89
89
|
|
90
|
+
/**
|
91
|
+
* @param {Chunk} chunk chunk
|
92
|
+
* @returns {TODO} options for the chunk
|
93
|
+
*/
|
90
94
|
const getOptionsForChunk = chunk => {
|
91
95
|
if (compilation.chunkGraph.getNumberOfEntryModules(chunk) === 0)
|
92
96
|
return false;
|
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
const { ConcatSource } = require("webpack-sources");
|
9
9
|
const { UsageState } = require("../ExportsInfo");
|
10
|
+
const RuntimeGlobals = require("../RuntimeGlobals");
|
10
11
|
const Template = require("../Template");
|
11
12
|
const propertyAccess = require("../util/propertyAccess");
|
12
13
|
const { getEntryRuntime } = require("../util/runtime");
|
@@ -296,7 +297,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
|
|
296
297
|
if (!exportInfo.provided) continue;
|
297
298
|
const nameAccess = propertyAccess([exportInfo.name]);
|
298
299
|
result.add(
|
299
|
-
`${exportTarget}${nameAccess} =
|
300
|
+
`${exportTarget}${nameAccess} = ${RuntimeGlobals.exports}${exportAccess}${nameAccess};\n`
|
300
301
|
);
|
301
302
|
}
|
302
303
|
result.add(
|
@@ -310,10 +311,11 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
|
|
310
311
|
true
|
311
312
|
)};\n`
|
312
313
|
);
|
313
|
-
|
314
|
+
/** @type {String} */
|
315
|
+
let exports = RuntimeGlobals.exports;
|
314
316
|
if (exportAccess) {
|
315
317
|
result.add(
|
316
|
-
`var __webpack_exports_export__ =
|
318
|
+
`var __webpack_exports_export__ = ${RuntimeGlobals.exports}${exportAccess};\n`
|
317
319
|
);
|
318
320
|
exports = "__webpack_exports_export__";
|
319
321
|
}
|
@@ -329,7 +331,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
|
|
329
331
|
fullNameResolved,
|
330
332
|
this._getPrefix(compilation).length,
|
331
333
|
false
|
332
|
-
)} =
|
334
|
+
)} = ${RuntimeGlobals.exports}${exportAccess};\n`
|
333
335
|
);
|
334
336
|
}
|
335
337
|
return result;
|
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
const { ConcatSource } = require("webpack-sources");
|
9
9
|
const { UsageState } = require("../ExportsInfo");
|
10
|
+
const RuntimeGlobals = require("../RuntimeGlobals");
|
10
11
|
const propertyAccess = require("../util/propertyAccess");
|
11
12
|
const { getEntryRuntime } = require("../util/runtime");
|
12
13
|
const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
|
@@ -103,7 +104,9 @@ class ExportPropertyLibraryPlugin extends AbstractLibraryPlugin {
|
|
103
104
|
*/
|
104
105
|
renderStartup(source, module, renderContext, { options }) {
|
105
106
|
if (!options.export) return source;
|
106
|
-
const postfix =
|
107
|
+
const postfix = `${RuntimeGlobals.exports} = ${
|
108
|
+
RuntimeGlobals.exports
|
109
|
+
}${propertyAccess(
|
107
110
|
Array.isArray(options.export) ? options.export : [options.export]
|
108
111
|
)};\n`;
|
109
112
|
return new ConcatSource(source, postfix);
|
@@ -6,6 +6,7 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const { ConcatSource } = require("webpack-sources");
|
9
|
+
const RuntimeGlobals = require("../RuntimeGlobals");
|
9
10
|
const Template = require("../Template");
|
10
11
|
const propertyAccess = require("../util/propertyAccess");
|
11
12
|
const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
|
@@ -80,15 +81,17 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
80
81
|
const exports = [];
|
81
82
|
const isAsync = moduleGraph.isAsync(module);
|
82
83
|
if (isAsync) {
|
83
|
-
result.add(
|
84
|
+
result.add(
|
85
|
+
`${RuntimeGlobals.exports} = await ${RuntimeGlobals.exports};\n`
|
86
|
+
);
|
84
87
|
}
|
85
88
|
for (const exportInfo of exportsInfo.orderedExports) {
|
86
89
|
if (!exportInfo.provided) continue;
|
87
|
-
const varName =
|
90
|
+
const varName = `${RuntimeGlobals.exports}${Template.toIdentifier(
|
88
91
|
exportInfo.name
|
89
92
|
)}`;
|
90
93
|
result.add(
|
91
|
-
`var ${varName} =
|
94
|
+
`var ${varName} = ${RuntimeGlobals.exports}${propertyAccess([
|
92
95
|
/** @type {string} */
|
93
96
|
(exportInfo.getUsedName(exportInfo.name, chunk.runtime))
|
94
97
|
])};\n`
|
@@ -106,6 +106,7 @@ class SystemLibraryPlugin extends AbstractLibraryPlugin {
|
|
106
106
|
.join("\n");
|
107
107
|
|
108
108
|
// Define __esModule flag on all internal variables and helpers
|
109
|
+
/** @type {string[]} */
|
109
110
|
const externalVarInitialization = [];
|
110
111
|
|
111
112
|
// The system.register format requires an array of setter functions for externals.
|
@@ -208,6 +208,10 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
|
|
208
208
|
);
|
209
209
|
};
|
210
210
|
|
211
|
+
/**
|
212
|
+
* @param {ExternalModule[]} modules external modules
|
213
|
+
* @returns {string} arguments
|
214
|
+
*/
|
211
215
|
const externalsArguments = modules => {
|
212
216
|
return modules
|
213
217
|
.map(
|
@@ -8,11 +8,18 @@
|
|
8
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
9
9
|
const StartupChunkDependenciesPlugin = require("../runtime/StartupChunkDependenciesPlugin");
|
10
10
|
|
11
|
+
/** @typedef {import("../Chunk")} Chunk */
|
11
12
|
/** @typedef {import("../Compiler")} Compiler */
|
12
13
|
|
14
|
+
/** @typedef {Object} CommonJsChunkLoadingPluginOptions
|
15
|
+
* @property {boolean} [asyncChunkLoading] enable async chunk loading
|
16
|
+
*/
|
17
|
+
|
13
18
|
class CommonJsChunkLoadingPlugin {
|
14
|
-
|
15
|
-
|
19
|
+
/**
|
20
|
+
* @param {CommonJsChunkLoadingPluginOptions} [options] options
|
21
|
+
*/
|
22
|
+
constructor(options = {}) {
|
16
23
|
this._asyncChunkLoading = options.asyncChunkLoading;
|
17
24
|
}
|
18
25
|
|
@@ -36,6 +43,10 @@ class CommonJsChunkLoadingPlugin {
|
|
36
43
|
"CommonJsChunkLoadingPlugin",
|
37
44
|
compilation => {
|
38
45
|
const globalChunkLoading = compilation.outputOptions.chunkLoading;
|
46
|
+
/**
|
47
|
+
* @param {Chunk} chunk chunk
|
48
|
+
* @returns {boolean} true, if wasm loading is enabled for the chunk
|
49
|
+
*/
|
39
50
|
const isEnabledForChunk = chunk => {
|
40
51
|
const options = chunk.getEntryOptions();
|
41
52
|
const chunkLoading =
|
@@ -45,6 +56,10 @@ class CommonJsChunkLoadingPlugin {
|
|
45
56
|
return chunkLoading === chunkLoadingValue;
|
46
57
|
};
|
47
58
|
const onceForChunkSet = new WeakSet();
|
59
|
+
/**
|
60
|
+
* @param {Chunk} chunk chunk
|
61
|
+
* @param {Set<string>} set runtime requirements
|
62
|
+
*/
|
48
63
|
const handler = (chunk, set) => {
|
49
64
|
if (onceForChunkSet.has(chunk)) return;
|
50
65
|
onceForChunkSet.add(chunk);
|
@@ -10,9 +10,17 @@ const EnableChunkLoadingPlugin = require("../javascript/EnableChunkLoadingPlugin
|
|
10
10
|
|
11
11
|
/** @typedef {import("../Compiler")} Compiler */
|
12
12
|
|
13
|
+
/**
|
14
|
+
* @typedef {Object} NodeTemplatePluginOptions
|
15
|
+
* @property {boolean} [asyncChunkLoading] enable async chunk loading
|
16
|
+
*/
|
17
|
+
|
13
18
|
class NodeTemplatePlugin {
|
14
|
-
|
15
|
-
|
19
|
+
/**
|
20
|
+
* @param {NodeTemplatePluginOptions} [options] options object
|
21
|
+
*/
|
22
|
+
constructor(options = {}) {
|
23
|
+
this._options = options;
|
16
24
|
}
|
17
25
|
|
18
26
|
/**
|
@@ -29,7 +29,7 @@ class NodeWatchFileSystem {
|
|
29
29
|
* @param {Iterable<string>} missing watched exitance entries
|
30
30
|
* @param {number} startTime timestamp of start time
|
31
31
|
* @param {WatchOptions} options options object
|
32
|
-
* @param {function(Error=, Map<string, FileSystemInfoEntry>, Map<string, FileSystemInfoEntry>, Set<string>, Set<string>): void} callback aggregated callback
|
32
|
+
* @param {function((Error | null)=, Map<string, FileSystemInfoEntry>, Map<string, FileSystemInfoEntry>, Set<string>, Set<string>): void} callback aggregated callback
|
33
33
|
* @param {function(string, number): void} callbackUndelayed callback when the first change was detected
|
34
34
|
* @returns {Watcher} a watcher
|
35
35
|
*/
|
@@ -18,6 +18,9 @@ const { getUndoPath } = require("../util/identifier");
|
|
18
18
|
/** @typedef {import("../Chunk")} Chunk */
|
19
19
|
|
20
20
|
class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
21
|
+
/**
|
22
|
+
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
|
23
|
+
*/
|
21
24
|
constructor(runtimeRequirements) {
|
22
25
|
super("readFile chunk loading", RuntimeModule.STAGE_ATTACH);
|
23
26
|
this.runtimeRequirements = runtimeRequirements;
|
@@ -78,7 +81,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
|
78
81
|
);
|
79
82
|
const rootOutputDir = getUndoPath(
|
80
83
|
outputName,
|
81
|
-
this.compilation.outputOptions.path,
|
84
|
+
/** @type {string} */ (this.compilation.outputOptions.path),
|
82
85
|
false
|
83
86
|
);
|
84
87
|
|
@@ -124,7 +127,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
|
124
127
|
"}"
|
125
128
|
]),
|
126
129
|
"}",
|
127
|
-
`if(runtime) runtime(
|
130
|
+
`if(runtime) runtime(${RuntimeGlobals.require});`,
|
128
131
|
"for(var i = 0; i < chunkIds.length; i++) {",
|
129
132
|
Template.indent([
|
130
133
|
"if(installedChunks[chunkIds[i]]) {",
|
@@ -193,7 +196,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
|
193
196
|
"",
|
194
197
|
withExternalInstallChunk
|
195
198
|
? Template.asString([
|
196
|
-
|
199
|
+
`module.exports = ${RuntimeGlobals.require};`,
|
197
200
|
`${RuntimeGlobals.externalInstallChunk} = installChunk;`
|
198
201
|
])
|
199
202
|
: "// no external install chunk",
|
@@ -10,6 +10,7 @@ const RuntimeGlobals = require("../RuntimeGlobals");
|
|
10
10
|
const Template = require("../Template");
|
11
11
|
const AsyncWasmLoadingRuntimeModule = require("../wasm-async/AsyncWasmLoadingRuntimeModule");
|
12
12
|
|
13
|
+
/** @typedef {import("../Chunk")} Chunk */
|
13
14
|
/** @typedef {import("../Compiler")} Compiler */
|
14
15
|
|
15
16
|
class ReadFileCompileAsyncWasmPlugin {
|
@@ -27,6 +28,10 @@ class ReadFileCompileAsyncWasmPlugin {
|
|
27
28
|
"ReadFileCompileAsyncWasmPlugin",
|
28
29
|
compilation => {
|
29
30
|
const globalWasmLoading = compilation.outputOptions.wasmLoading;
|
31
|
+
/**
|
32
|
+
* @param {Chunk} chunk chunk
|
33
|
+
* @returns {boolean} true, if wasm loading is enabled for the chunk
|
34
|
+
*/
|
30
35
|
const isEnabledForChunk = chunk => {
|
31
36
|
const options = chunk.getEntryOptions();
|
32
37
|
const wasmLoading =
|
@@ -35,6 +40,9 @@ class ReadFileCompileAsyncWasmPlugin {
|
|
35
40
|
: globalWasmLoading;
|
36
41
|
return wasmLoading === this._type;
|
37
42
|
};
|
43
|
+
/**
|
44
|
+
* @type {(path: string) => string}
|
45
|
+
*/
|
38
46
|
const generateLoadBinaryCode = this._import
|
39
47
|
? path =>
|
40
48
|
Template.asString([
|
@@ -10,13 +10,22 @@ const RuntimeGlobals = require("../RuntimeGlobals");
|
|
10
10
|
const Template = require("../Template");
|
11
11
|
const WasmChunkLoadingRuntimeModule = require("../wasm-sync/WasmChunkLoadingRuntimeModule");
|
12
12
|
|
13
|
+
/** @typedef {import("../Chunk")} Chunk */
|
13
14
|
/** @typedef {import("../Compiler")} Compiler */
|
14
15
|
|
16
|
+
/**
|
17
|
+
* @typedef {Object} ReadFileCompileWasmPluginOptions
|
18
|
+
* @property {boolean} [mangleImports] mangle imports
|
19
|
+
*/
|
20
|
+
|
15
21
|
// TODO webpack 6 remove
|
16
22
|
|
17
23
|
class ReadFileCompileWasmPlugin {
|
18
|
-
|
19
|
-
|
24
|
+
/**
|
25
|
+
* @param {ReadFileCompileWasmPluginOptions} [options] options object
|
26
|
+
*/
|
27
|
+
constructor(options = {}) {
|
28
|
+
this.options = options;
|
20
29
|
}
|
21
30
|
|
22
31
|
/**
|
@@ -29,6 +38,10 @@ class ReadFileCompileWasmPlugin {
|
|
29
38
|
"ReadFileCompileWasmPlugin",
|
30
39
|
compilation => {
|
31
40
|
const globalWasmLoading = compilation.outputOptions.wasmLoading;
|
41
|
+
/**
|
42
|
+
* @param {Chunk} chunk chunk
|
43
|
+
* @returns {boolean} true, when wasm loading is enabled for the chunk
|
44
|
+
*/
|
32
45
|
const isEnabledForChunk = chunk => {
|
33
46
|
const options = chunk.getEntryOptions();
|
34
47
|
const wasmLoading =
|
@@ -37,6 +50,10 @@ class ReadFileCompileWasmPlugin {
|
|
37
50
|
: globalWasmLoading;
|
38
51
|
return wasmLoading === "async-node";
|
39
52
|
};
|
53
|
+
/**
|
54
|
+
* @param {string} path path to wasm file
|
55
|
+
* @returns {string} generated code to load the wasm file
|
56
|
+
*/
|
40
57
|
const generateLoadBinaryCode = path =>
|
41
58
|
Template.asString([
|
42
59
|
"new Promise(function (resolve, reject) {",
|
@@ -18,6 +18,9 @@ const { getUndoPath } = require("../util/identifier");
|
|
18
18
|
/** @typedef {import("../Chunk")} Chunk */
|
19
19
|
|
20
20
|
class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
21
|
+
/**
|
22
|
+
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
|
23
|
+
*/
|
21
24
|
constructor(runtimeRequirements) {
|
22
25
|
super("require chunk loading", RuntimeModule.STAGE_ATTACH);
|
23
26
|
this.runtimeRequirements = runtimeRequirements;
|
@@ -78,7 +81,7 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
|
78
81
|
);
|
79
82
|
const rootOutputDir = getUndoPath(
|
80
83
|
outputName,
|
81
|
-
this.compilation.outputOptions.path,
|
84
|
+
/** @type {string} */ (this.compilation.outputOptions.path),
|
82
85
|
true
|
83
86
|
);
|
84
87
|
|
@@ -124,7 +127,7 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
|
124
127
|
"}"
|
125
128
|
]),
|
126
129
|
"}",
|
127
|
-
`if(runtime) runtime(
|
130
|
+
`if(runtime) runtime(${RuntimeGlobals.require});`,
|
128
131
|
"for(var i = 0; i < chunkIds.length; i++)",
|
129
132
|
Template.indent("installedChunks[chunkIds[i]] = 1;"),
|
130
133
|
withOnChunkLoad ? `${RuntimeGlobals.onChunksLoaded}();` : ""
|
@@ -163,7 +166,7 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
|
163
166
|
"",
|
164
167
|
withExternalInstallChunk
|
165
168
|
? Template.asString([
|
166
|
-
|
169
|
+
`module.exports = ${RuntimeGlobals.require};`,
|
167
170
|
`${RuntimeGlobals.externalInstallChunk} = installChunk;`
|
168
171
|
])
|
169
172
|
: "// no external install chunk",
|
@@ -1611,7 +1611,7 @@ ${defineGetters}`
|
|
1611
1611
|
result.add(`if (${condition}) {\n`);
|
1612
1612
|
}
|
1613
1613
|
result.add(
|
1614
|
-
`var ${info.name} =
|
1614
|
+
`var ${info.name} = ${RuntimeGlobals.require}(${JSON.stringify(
|
1615
1615
|
chunkGraph.getModuleId(info.module)
|
1616
1616
|
)});`
|
1617
1617
|
);
|
@@ -120,7 +120,10 @@ class InnerGraphPlugin {
|
|
120
120
|
if (!InnerGraph.isEnabled(parser.state)) return;
|
121
121
|
|
122
122
|
if (parser.scope.topLevelScope === true) {
|
123
|
-
if (
|
123
|
+
if (
|
124
|
+
statement.type === "ClassDeclaration" &&
|
125
|
+
parser.isPure(statement, statement.range[0])
|
126
|
+
) {
|
124
127
|
const name = statement.id ? statement.id.name : "*default*";
|
125
128
|
const fn = InnerGraph.tagTopLevelSymbol(parser, name);
|
126
129
|
classWithTopLevelSymbol.set(statement, fn);
|
@@ -131,8 +134,9 @@ class InnerGraphPlugin {
|
|
131
134
|
const fn = InnerGraph.tagTopLevelSymbol(parser, name);
|
132
135
|
const decl = statement.declaration;
|
133
136
|
if (
|
134
|
-
decl.type === "ClassExpression" ||
|
135
|
-
|
137
|
+
(decl.type === "ClassExpression" ||
|
138
|
+
decl.type === "ClassDeclaration") &&
|
139
|
+
parser.isPure(decl, decl.range[0])
|
136
140
|
) {
|
137
141
|
classWithTopLevelSymbol.set(decl, fn);
|
138
142
|
} else if (parser.isPure(decl, statement.range[0])) {
|
@@ -157,7 +161,10 @@ class InnerGraphPlugin {
|
|
157
161
|
decl.id.type === "Identifier"
|
158
162
|
) {
|
159
163
|
const name = decl.id.name;
|
160
|
-
if (
|
164
|
+
if (
|
165
|
+
decl.init.type === "ClassExpression" &&
|
166
|
+
parser.isPure(decl.init, decl.id.range[1])
|
167
|
+
) {
|
161
168
|
const fn = InnerGraph.tagTopLevelSymbol(parser, name);
|
162
169
|
classWithTopLevelSymbol.set(decl.init, fn);
|
163
170
|
} else if (parser.isPure(decl.init, decl.id.range[1])) {
|
@@ -21,7 +21,7 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
|
|
21
21
|
const fn = RuntimeGlobals.asyncModule;
|
22
22
|
return Template.asString([
|
23
23
|
'var webpackQueues = typeof Symbol === "function" ? Symbol("webpack queues") : "__webpack_queues__";',
|
24
|
-
|
24
|
+
`var webpackExports = typeof Symbol === "function" ? Symbol("webpack exports") : "${RuntimeGlobals.exports}";`,
|
25
25
|
'var webpackError = typeof Symbol === "function" ? Symbol("webpack error") : "__webpack_error__";',
|
26
26
|
`var resolveQueue = ${runtimeTemplate.basicFunction("queue", [
|
27
27
|
"if(queue && !queue.d) {",
|
@@ -31,7 +31,11 @@ class AutoPublicPathRuntimeModule extends RuntimeModule {
|
|
31
31
|
contentHashType: "javascript"
|
32
32
|
}
|
33
33
|
);
|
34
|
-
const undoPath = getUndoPath(
|
34
|
+
const undoPath = getUndoPath(
|
35
|
+
chunkName,
|
36
|
+
/** @type {string} */ (path),
|
37
|
+
false
|
38
|
+
);
|
35
39
|
|
36
40
|
return Template.asString([
|
37
41
|
"var scriptUrl;",
|
@@ -8,6 +8,8 @@
|
|
8
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
9
9
|
const RuntimeModule = require("../RuntimeModule");
|
10
10
|
|
11
|
+
/** @typedef {import("../../declarations/WebpackOptions").EntryDescriptionNormalized} EntryDescriptionNormalized */
|
12
|
+
|
11
13
|
class BaseUriRuntimeModule extends RuntimeModule {
|
12
14
|
constructor() {
|
13
15
|
super("base uri", RuntimeModule.STAGE_ATTACH);
|
@@ -19,7 +21,9 @@ class BaseUriRuntimeModule extends RuntimeModule {
|
|
19
21
|
generate() {
|
20
22
|
const { chunk } = this;
|
21
23
|
|
22
|
-
const options =
|
24
|
+
const options =
|
25
|
+
/** @type {EntryDescriptionNormalized} */
|
26
|
+
(chunk.getEntryOptions());
|
23
27
|
return `${RuntimeGlobals.baseURI} = ${
|
24
28
|
options.baseUri === undefined
|
25
29
|
? "undefined"
|
@@ -9,6 +9,9 @@ const RuntimeModule = require("../RuntimeModule");
|
|
9
9
|
const Template = require("../Template");
|
10
10
|
|
11
11
|
class EnsureChunkRuntimeModule extends RuntimeModule {
|
12
|
+
/**
|
13
|
+
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
|
14
|
+
*/
|
12
15
|
constructor(runtimeRequirements) {
|
13
16
|
super("ensure chunk");
|
14
17
|
this.runtimeRequirements = runtimeRequirements;
|
@@ -51,7 +51,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
51
51
|
/** @type {Map<string | FilenameFunction, Set<Chunk>>} */
|
52
52
|
const chunkFilenames = new Map();
|
53
53
|
let maxChunks = 0;
|
54
|
-
/** @type {string} */
|
54
|
+
/** @type {string | undefined} */
|
55
55
|
let dynamicFilename;
|
56
56
|
|
57
57
|
/**
|
@@ -69,9 +69,20 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
69
69
|
if (typeof chunkFilename === "string") {
|
70
70
|
if (set.size < maxChunks) return;
|
71
71
|
if (set.size === maxChunks) {
|
72
|
-
if (
|
73
|
-
|
74
|
-
|
72
|
+
if (
|
73
|
+
chunkFilename.length <
|
74
|
+
/** @type {string} */ (dynamicFilename).length
|
75
|
+
) {
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
|
79
|
+
if (
|
80
|
+
chunkFilename.length ===
|
81
|
+
/** @type {string} */ (dynamicFilename).length
|
82
|
+
) {
|
83
|
+
if (chunkFilename < /** @type {string} */ (dynamicFilename)) {
|
84
|
+
return;
|
85
|
+
}
|
75
86
|
}
|
76
87
|
}
|
77
88
|
maxChunks = set.size;
|
@@ -108,7 +119,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
108
119
|
addChunk(entrypoint.chunks[entrypoint.chunks.length - 1]);
|
109
120
|
}
|
110
121
|
|
111
|
-
/** @type {Map<string, Set<string | number>>} */
|
122
|
+
/** @type {Map<string, Set<string | number | null>>} */
|
112
123
|
const staticUrls = new Map();
|
113
124
|
/** @type {Set<Chunk>} */
|
114
125
|
const dynamicUrlChunks = new Set();
|
@@ -152,10 +163,14 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
152
163
|
hashWithLength: length =>
|
153
164
|
`" + ${RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
|
154
165
|
chunk: {
|
155
|
-
id: unquotedStringify(c.id),
|
156
|
-
hash: unquotedStringify(c.renderedHash),
|
157
|
-
hashWithLength: unquotedStringifyWithLength(
|
158
|
-
|
166
|
+
id: unquotedStringify(/** @type {number | string} */ (c.id)),
|
167
|
+
hash: unquotedStringify(/** @type {string} */ (c.renderedHash)),
|
168
|
+
hashWithLength: unquotedStringifyWithLength(
|
169
|
+
/** @type {string} */ (c.renderedHash)
|
170
|
+
),
|
171
|
+
name: unquotedStringify(
|
172
|
+
c.name || /** @type {number | string} */ (c.id)
|
173
|
+
),
|
159
174
|
contentHash: {
|
160
175
|
[contentType]: unquotedStringify(c.contentHash[contentType])
|
161
176
|
},
|
@@ -187,8 +202,10 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
187
202
|
* @returns {string} code with static mapping of results of fn
|
188
203
|
*/
|
189
204
|
const createMap = fn => {
|
205
|
+
/** @type {Record<number | string, number | string>} */
|
190
206
|
const obj = {};
|
191
207
|
let useId = false;
|
208
|
+
/** @type {number | string | undefined} */
|
192
209
|
let lastKey;
|
193
210
|
let entries = 0;
|
194
211
|
for (const c of dynamicUrlChunks) {
|
@@ -196,8 +213,8 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
196
213
|
if (value === c.id) {
|
197
214
|
useId = true;
|
198
215
|
} else {
|
199
|
-
obj[c.id] = value;
|
200
|
-
lastKey = c.id;
|
216
|
+
obj[/** @type {number | string} */ (c.id)] = value;
|
217
|
+
lastKey = /** @type {number | string} */ (c.id);
|
201
218
|
entries++;
|
202
219
|
}
|
203
220
|
}
|
@@ -205,9 +222,9 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
205
222
|
if (entries === 1) {
|
206
223
|
return useId
|
207
224
|
? `(chunkId === ${JSON.stringify(lastKey)} ? ${JSON.stringify(
|
208
|
-
obj[lastKey]
|
225
|
+
obj[/** @type {number | string} */ (lastKey)]
|
209
226
|
)} : chunkId)`
|
210
|
-
: JSON.stringify(obj[lastKey]);
|
227
|
+
: JSON.stringify(obj[/** @type {number | string} */ (lastKey)]);
|
211
228
|
}
|
212
229
|
return useId
|
213
230
|
? `(${JSON.stringify(obj)}[chunkId] || chunkId)`
|
@@ -238,9 +255,11 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
238
255
|
`" + ${RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
|
239
256
|
chunk: {
|
240
257
|
id: `" + chunkId + "`,
|
241
|
-
hash: mapExpr(c => c.renderedHash),
|
242
|
-
hashWithLength: mapExprWithLength(
|
243
|
-
|
258
|
+
hash: mapExpr(c => /** @type {string} */ (c.renderedHash)),
|
259
|
+
hashWithLength: mapExprWithLength(
|
260
|
+
c => /** @type {string} */ (c.renderedHash)
|
261
|
+
),
|
262
|
+
name: mapExpr(c => c.name || /** @type {number | string} */ (c.id)),
|
244
263
|
contentHash: {
|
245
264
|
[contentType]: mapExpr(c => c.contentHash[contentType])
|
246
265
|
},
|
@@ -10,7 +10,7 @@ const HelperRuntimeModule = require("./HelperRuntimeModule");
|
|
10
10
|
|
11
11
|
class GetTrustedTypesPolicyRuntimeModule extends HelperRuntimeModule {
|
12
12
|
/**
|
13
|
-
* @param {
|
13
|
+
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
|
14
14
|
*/
|
15
15
|
constructor(runtimeRequirements) {
|
16
16
|
super("trusted types policy");
|
@@ -72,7 +72,7 @@ class LoadScriptRuntimeModule extends HelperRuntimeModule {
|
|
72
72
|
"script = document.createElement('script');",
|
73
73
|
scriptType ? `script.type = ${JSON.stringify(scriptType)};` : "",
|
74
74
|
charset ? "script.charset = 'utf-8';" : "",
|
75
|
-
`script.timeout = ${loadTimeout / 1000};`,
|
75
|
+
`script.timeout = ${/** @type {number} */ (loadTimeout) / 1000};`,
|
76
76
|
`if (${RuntimeGlobals.scriptNonce}) {`,
|
77
77
|
Template.indent(
|
78
78
|
`script.setAttribute("nonce", ${RuntimeGlobals.scriptNonce});`
|