webpack 5.36.2 → 5.37.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/lib/Chunk.js CHANGED
@@ -568,9 +568,15 @@ class Chunk {
568
568
  Array.from(this.groupsIterable, g => new Set(g.chunks))
569
569
  );
570
570
 
571
- for (const chunkGroup of this.groupsIterable) {
571
+ const initialQueue = new Set(this.groupsIterable);
572
+
573
+ for (const chunkGroup of initialQueue) {
572
574
  for (const child of chunkGroup.childrenIterable) {
573
- queue.add(child);
575
+ if (child instanceof Entrypoint) {
576
+ initialQueue.add(child);
577
+ } else {
578
+ queue.add(child);
579
+ }
574
580
  }
575
581
  }
576
582
 
@@ -3993,8 +3993,8 @@ This prevents using hashes of each other and should be avoided.`);
3993
3993
  * from parent (or top level compiler) and creates a child Compilation
3994
3994
  *
3995
3995
  * @param {string} name name of the child compiler
3996
- * @param {OutputOptions} outputOptions // Need to convert config schema to types for this
3997
- * @param {Array<WebpackPluginInstance | WebpackPluginFunction>} plugins webpack plugins that will be applied
3996
+ * @param {OutputOptions=} outputOptions // Need to convert config schema to types for this
3997
+ * @param {Array<WebpackPluginInstance | WebpackPluginFunction>=} plugins webpack plugins that will be applied
3998
3998
  * @returns {Compiler} creates a child Compiler instance
3999
3999
  */
4000
4000
  createChildCompiler(name, outputOptions, plugins) {
package/lib/Compiler.js CHANGED
@@ -931,8 +931,8 @@ ${other}`);
931
931
  * @param {Compilation} compilation the compilation
932
932
  * @param {string} compilerName the compiler's name
933
933
  * @param {number} compilerIndex the compiler's index
934
- * @param {OutputOptions} outputOptions the output options
935
- * @param {WebpackPluginInstance[]} plugins the plugins to apply
934
+ * @param {OutputOptions=} outputOptions the output options
935
+ * @param {WebpackPluginInstance[]=} plugins the plugins to apply
936
936
  * @returns {Compiler} a child compiler
937
937
  */
938
938
  createChildCompiler(
@@ -17,7 +17,7 @@ class EntryPlugin {
17
17
  *
18
18
  * @param {string} context context path
19
19
  * @param {string} entry entry path
20
- * @param {EntryOptions | string} options entry options (passing a string is deprecated)
20
+ * @param {EntryOptions | string=} options entry options (passing a string is deprecated)
21
21
  */
22
22
  constructor(context, entry, options) {
23
23
  this.context = context;
@@ -1472,7 +1472,7 @@ class FileSystemInfo {
1472
1472
  }
1473
1473
  } else if (supportsEsm && /\.m?js$/.test(path)) {
1474
1474
  if (!this._warnAboutExperimentalEsmTracking) {
1475
- this.logger.info(
1475
+ this.logger.log(
1476
1476
  "Node.js doesn't offer a (nice) way to introspect the ESM dependency graph yet.\n" +
1477
1477
  "Until a full solution is available webpack uses an experimental ESM tracking based on parsing.\n" +
1478
1478
  "As best effort webpack parses the ESM files to guess dependencies. But this can lead to expensive and incorrect tracking."
@@ -41,10 +41,12 @@ const { contextify, absolutify } = require("./util/identifier");
41
41
  const makeSerializable = require("./util/makeSerializable");
42
42
  const memoize = require("./util/memoize");
43
43
 
44
- /** @typedef {import("source-map").RawSourceMap} SourceMap */
45
44
  /** @typedef {import("webpack-sources").Source} Source */
45
+ /** @typedef {import("../declarations/LoaderContext").NormalModuleLoaderContext} NormalModuleLoaderContext */
46
+ /** @typedef {import("../declarations/WebpackOptions").Mode} Mode */
46
47
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
47
48
  /** @typedef {import("./ChunkGraph")} ChunkGraph */
49
+ /** @typedef {import("./Compiler")} Compiler */
48
50
  /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
49
51
  /** @typedef {import("./DependencyTemplates")} DependencyTemplates */
50
52
  /** @typedef {import("./Generator")} Generator */
@@ -60,10 +62,22 @@ const memoize = require("./util/memoize");
60
62
  /** @typedef {import("./RequestShortener")} RequestShortener */
61
63
  /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
62
64
  /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
65
+ /** @typedef {import("./logging/Logger").Logger} WebpackLogger */
63
66
  /** @typedef {import("./util/Hash")} Hash */
64
67
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
65
68
  /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
66
69
 
70
+ /**
71
+ * @typedef {Object} SourceMap
72
+ * @property {number} version
73
+ * @property {string[]} sources
74
+ * @property {string} mappings
75
+ * @property {string=} file
76
+ * @property {string=} sourceRoot
77
+ * @property {string[]=} sourcesContent
78
+ * @property {string[]=} names
79
+ */
80
+
67
81
  const getInvalidDependenciesModuleWarning = memoize(() =>
68
82
  require("./InvalidDependenciesModuleWarning")
69
83
  );
@@ -421,7 +435,7 @@ class NormalModule extends Module {
421
435
  * @param {WebpackOptions} options webpack options
422
436
  * @param {Compilation} compilation the compilation
423
437
  * @param {InputFileSystem} fs file system from reading
424
- * @returns {any} loader context
438
+ * @returns {NormalModuleLoaderContext} loader context
425
439
  */
426
440
  createLoaderContext(resolver, options, compilation, fs) {
427
441
  const { requestShortener } = compilation.runtimeTemplate;
@@ -168,6 +168,13 @@ exports.scriptNonce = "__webpack_require__.nc";
168
168
  */
169
169
  exports.loadScript = "__webpack_require__.l";
170
170
 
171
+ /**
172
+ * function to promote a string to a TrustedScriptURL using webpack's Trusted
173
+ * Types policy
174
+ * Arguments: (url: string) => TrustedScriptURL
175
+ */
176
+ exports.createScriptUrl = "__webpack_require__.tu";
177
+
171
178
  /**
172
179
  * the chunk name of the chunk with the runtime
173
180
  */
@@ -13,6 +13,7 @@ const AutoPublicPathRuntimeModule = require("./runtime/AutoPublicPathRuntimeModu
13
13
  const CompatGetDefaultExportRuntimeModule = require("./runtime/CompatGetDefaultExportRuntimeModule");
14
14
  const CompatRuntimeModule = require("./runtime/CompatRuntimeModule");
15
15
  const CreateFakeNamespaceObjectRuntimeModule = require("./runtime/CreateFakeNamespaceObjectRuntimeModule");
16
+ const CreateScriptUrlRuntimeModule = require("./runtime/CreateScriptUrlRuntimeModule");
16
17
  const DefinePropertyGettersRuntimeModule = require("./runtime/DefinePropertyGettersRuntimeModule");
17
18
  const EnsureChunkRuntimeModule = require("./runtime/EnsureChunkRuntimeModule");
18
19
  const GetChunkFilenameRuntimeModule = require("./runtime/GetChunkFilenameRuntimeModule");
@@ -38,6 +39,7 @@ const GLOBALS_ON_REQUIRE = [
38
39
  RuntimeGlobals.runtimeId,
39
40
  RuntimeGlobals.compatGetDefaultExport,
40
41
  RuntimeGlobals.createFakeNamespaceObject,
42
+ RuntimeGlobals.createScriptUrl,
41
43
  RuntimeGlobals.definePropertyGetters,
42
44
  RuntimeGlobals.ensureChunk,
43
45
  RuntimeGlobals.entryModuleId,
@@ -319,7 +321,23 @@ class RuntimePlugin {
319
321
  compilation.hooks.runtimeRequirementInTree
320
322
  .for(RuntimeGlobals.loadScript)
321
323
  .tap("RuntimePlugin", (chunk, set) => {
322
- compilation.addRuntimeModule(chunk, new LoadScriptRuntimeModule());
324
+ const withCreateScriptUrl = !!compilation.outputOptions.trustedTypes;
325
+ if (withCreateScriptUrl) {
326
+ set.add(RuntimeGlobals.createScriptUrl);
327
+ }
328
+ compilation.addRuntimeModule(
329
+ chunk,
330
+ new LoadScriptRuntimeModule(withCreateScriptUrl)
331
+ );
332
+ return true;
333
+ });
334
+ compilation.hooks.runtimeRequirementInTree
335
+ .for(RuntimeGlobals.createScriptUrl)
336
+ .tap("RuntimePlugin", (chunk, set) => {
337
+ compilation.addRuntimeModule(
338
+ chunk,
339
+ new CreateScriptUrlRuntimeModule()
340
+ );
323
341
  return true;
324
342
  });
325
343
  compilation.hooks.runtimeRequirementInTree
@@ -16,7 +16,6 @@ const createHash = require("./util/createHash");
16
16
  const { relative, dirname } = require("./util/fs");
17
17
  const { absolutify } = require("./util/identifier");
18
18
 
19
- /** @typedef {import("source-map").RawSourceMap} SourceMap */
20
19
  /** @typedef {import("webpack-sources").MapOptions} MapOptions */
21
20
  /** @typedef {import("webpack-sources").Source} Source */
22
21
  /** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
@@ -26,6 +25,7 @@ const { absolutify } = require("./util/identifier");
26
25
  /** @typedef {import("./Compilation").AssetInfo} AssetInfo */
27
26
  /** @typedef {import("./Compiler")} Compiler */
28
27
  /** @typedef {import("./Module")} Module */
28
+ /** @typedef {import("./NormalModule").SourceMap} SourceMap */
29
29
  /** @typedef {import("./util/Hash")} Hash */
30
30
 
31
31
  const validate = createSchemaValidation(
@@ -732,6 +732,16 @@ const applyOutputDefaults = (
732
732
  F(output.environment, "dynamicImport", () => tp && tp.dynamicImport);
733
733
  F(output.environment, "module", () => tp && tp.module);
734
734
 
735
+ const { trustedTypes } = output;
736
+ if (trustedTypes) {
737
+ F(
738
+ trustedTypes,
739
+ "policyName",
740
+ () =>
741
+ output.uniqueName.replace(/[^a-zA-Z0-9\-#=_/@.%]+/g, "_") || "webpack"
742
+ );
743
+ }
744
+
735
745
  /**
736
746
  * @param {function(EntryDescription): void} fn iterator
737
747
  * @returns {void}
@@ -338,6 +338,15 @@ const getNormalizedWebpackOptions = config => {
338
338
  sourceMapFilename: output.sourceMapFilename,
339
339
  sourcePrefix: output.sourcePrefix,
340
340
  strictModuleExceptionHandling: output.strictModuleExceptionHandling,
341
+ trustedTypes: optionalNestedConfig(
342
+ output.trustedTypes,
343
+ trustedTypes => {
344
+ if (trustedTypes === true) return {};
345
+ if (typeof trustedTypes === "string")
346
+ return { policyName: trustedTypes };
347
+ return { ...trustedTypes };
348
+ }
349
+ ),
341
350
  uniqueName: output.uniqueName,
342
351
  wasmLoading: output.wasmLoading,
343
352
  webassemblyModuleFilename: output.webassemblyModuleFilename,
@@ -0,0 +1,54 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const RuntimeGlobals = require("../RuntimeGlobals");
9
+ const makeSerializable = require("../util/makeSerializable");
10
+ const NullDependency = require("./NullDependency");
11
+
12
+ /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
13
+ /** @typedef {import("../Dependency")} Dependency */
14
+ /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
15
+
16
+ class CreateScriptUrlDependency extends NullDependency {
17
+ /**
18
+ * @param {[number, number]} range range
19
+ */
20
+ constructor(range) {
21
+ super();
22
+ this.range = range;
23
+ }
24
+
25
+ get type() {
26
+ return "create script url";
27
+ }
28
+ }
29
+
30
+ CreateScriptUrlDependency.Template = class CreateScriptUrlDependencyTemplate extends (
31
+ NullDependency.Template
32
+ ) {
33
+ /**
34
+ * @param {Dependency} dependency the dependency for which the template should be applied
35
+ * @param {ReplaceSource} source the current replace source which can be modified
36
+ * @param {DependencyTemplateContext} templateContext the context object
37
+ * @returns {void}
38
+ */
39
+ apply(dependency, source, { runtimeRequirements }) {
40
+ const dep = /** @type {CreateScriptUrlDependency} */ (dependency);
41
+
42
+ runtimeRequirements.add(RuntimeGlobals.createScriptUrl);
43
+
44
+ source.insert(dep.range[0], `${RuntimeGlobals.createScriptUrl}(`);
45
+ source.insert(dep.range[1], ")");
46
+ }
47
+ };
48
+
49
+ makeSerializable(
50
+ CreateScriptUrlDependency,
51
+ "webpack/lib/dependencies/CreateScriptUrlDependency"
52
+ );
53
+
54
+ module.exports = CreateScriptUrlDependency;
@@ -15,6 +15,7 @@ const createHash = require("../util/createHash");
15
15
  const { contextify } = require("../util/identifier");
16
16
  const EnableWasmLoadingPlugin = require("../wasm/EnableWasmLoadingPlugin");
17
17
  const ConstDependency = require("./ConstDependency");
18
+ const CreateScriptUrlDependency = require("./CreateScriptUrlDependency");
18
19
  const {
19
20
  harmonySpecifierTag
20
21
  } = require("./HarmonyImportDependencyParserPlugin");
@@ -78,6 +79,10 @@ class WorkerPlugin {
78
79
  WorkerDependency,
79
80
  new WorkerDependency.Template()
80
81
  );
82
+ compilation.dependencyTemplates.set(
83
+ CreateScriptUrlDependency,
84
+ new CreateScriptUrlDependency.Template()
85
+ );
81
86
 
82
87
  /**
83
88
  * @param {JavascriptParser} parser the parser
@@ -297,7 +302,14 @@ class WorkerPlugin {
297
302
  dep.loc = expr.loc;
298
303
  block.addDependency(dep);
299
304
  parser.state.module.addBlock(block);
300
- parser.walkExpression(expr.callee);
305
+
306
+ if (compilation.outputOptions.trustedTypes) {
307
+ const dep = new CreateScriptUrlDependency(
308
+ expr.arguments[0].range
309
+ );
310
+ dep.loc = expr.loc;
311
+ parser.state.module.addDependency(dep);
312
+ }
301
313
 
302
314
  if (expressions.type) {
303
315
  const expr = expressions.type;
@@ -329,6 +341,7 @@ class WorkerPlugin {
329
341
  parser.state.module.addPresentationalDependency(dep2);
330
342
  }
331
343
 
344
+ parser.walkExpression(expr.callee);
332
345
  for (const key of Object.keys(expressions)) {
333
346
  if (expressions[key]) parser.walkExpression(expressions[key]);
334
347
  }
@@ -0,0 +1,61 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ */
4
+
5
+ "use strict";
6
+
7
+ const RuntimeGlobals = require("../RuntimeGlobals");
8
+ const Template = require("../Template");
9
+ const HelperRuntimeModule = require("./HelperRuntimeModule");
10
+
11
+ class CreateScriptUrlRuntimeModule extends HelperRuntimeModule {
12
+ constructor() {
13
+ super("trusted types");
14
+ }
15
+
16
+ /**
17
+ * @returns {string} runtime code
18
+ */
19
+ generate() {
20
+ const { compilation } = this;
21
+ const { runtimeTemplate, outputOptions } = compilation;
22
+ const { trustedTypes } = outputOptions;
23
+ const fn = RuntimeGlobals.createScriptUrl;
24
+
25
+ if (!trustedTypes) {
26
+ // Skip Trusted Types logic.
27
+ return Template.asString([
28
+ `${fn} = ${runtimeTemplate.returningFunction("url", "url")};`
29
+ ]);
30
+ }
31
+
32
+ return Template.asString([
33
+ "var policy;",
34
+ `${fn} = ${runtimeTemplate.basicFunction("url", [
35
+ "// Create Trusted Type policy if Trusted Types are available and the policy doesn't exist yet.",
36
+ "if (policy === undefined) {",
37
+ Template.indent([
38
+ "policy = {",
39
+ Template.indent([
40
+ `createScriptURL: ${runtimeTemplate.returningFunction(
41
+ "url",
42
+ "url"
43
+ )}`
44
+ ]),
45
+ "};",
46
+ 'if (typeof trustedTypes !== "undefined" && trustedTypes.createPolicy) {',
47
+ Template.indent([
48
+ `policy = trustedTypes.createPolicy(${JSON.stringify(
49
+ trustedTypes.policyName
50
+ )}, policy);`
51
+ ]),
52
+ "}"
53
+ ]),
54
+ "}",
55
+ "return policy.createScriptURL(url);"
56
+ ])};`
57
+ ]);
58
+ }
59
+ }
60
+
61
+ module.exports = CreateScriptUrlRuntimeModule;
@@ -42,8 +42,12 @@ class LoadScriptRuntimeModule extends HelperRuntimeModule {
42
42
  return hooks;
43
43
  }
44
44
 
45
- constructor() {
45
+ /**
46
+ * @param {boolean=} withCreateScriptUrl use create script url for trusted types
47
+ */
48
+ constructor(withCreateScriptUrl) {
46
49
  super("load script");
50
+ this._withCreateScriptUrl = withCreateScriptUrl;
47
51
  }
48
52
 
49
53
  /**
@@ -78,7 +82,11 @@ class LoadScriptRuntimeModule extends HelperRuntimeModule {
78
82
  uniqueName
79
83
  ? 'script.setAttribute("data-webpack", dataWebpackPrefix + key);'
80
84
  : "",
81
- `script.src = url;`,
85
+ `script.src = ${
86
+ this._withCreateScriptUrl
87
+ ? `${RuntimeGlobals.createScriptUrl}(url)`
88
+ : "url"
89
+ };`,
82
90
  crossOriginLoading
83
91
  ? Template.asString([
84
92
  "if (script.src.indexOf(window.location.origin + '/') !== 0) {",
package/lib/util/fs.js CHANGED
@@ -51,14 +51,14 @@ const path = require("path");
51
51
  * @property {string | Buffer} name
52
52
  */
53
53
 
54
- /** @typedef {function(NodeJS.ErrnoException=): void} Callback */
55
- /** @typedef {function(NodeJS.ErrnoException=, Buffer=): void} BufferCallback */
56
- /** @typedef {function(NodeJS.ErrnoException=, Buffer|string=): void} BufferOrStringCallback */
57
- /** @typedef {function(NodeJS.ErrnoException=, (string | Buffer)[] | IDirent[]=): void} DirentArrayCallback */
58
- /** @typedef {function(NodeJS.ErrnoException=, string=): void} StringCallback */
59
- /** @typedef {function(NodeJS.ErrnoException=, number=): void} NumberCallback */
60
- /** @typedef {function(NodeJS.ErrnoException=, IStats=): void} StatsCallback */
61
- /** @typedef {function((NodeJS.ErrnoException | Error)=, any=): void} ReadJsonCallback */
54
+ /** @typedef {function((NodeJS.ErrnoException | null)=): void} Callback */
55
+ /** @typedef {function((NodeJS.ErrnoException | null)=, Buffer=): void} BufferCallback */
56
+ /** @typedef {function((NodeJS.ErrnoException | null)=, Buffer|string=): void} BufferOrStringCallback */
57
+ /** @typedef {function((NodeJS.ErrnoException | null)=, (string | Buffer)[] | IDirent[]=): void} DirentArrayCallback */
58
+ /** @typedef {function((NodeJS.ErrnoException | null)=, string=): void} StringCallback */
59
+ /** @typedef {function((NodeJS.ErrnoException | null)=, number=): void} NumberCallback */
60
+ /** @typedef {function((NodeJS.ErrnoException | null)=, IStats=): void} StatsCallback */
61
+ /** @typedef {function((NodeJS.ErrnoException | Error | null)=, any=): void} ReadJsonCallback */
62
62
 
63
63
  /**
64
64
  * @typedef {Object} Watcher
@@ -45,6 +45,8 @@ module.exports = {
45
45
  require("../dependencies/AMDRequireItemDependency"),
46
46
  "dependencies/CachedConstDependency": () =>
47
47
  require("../dependencies/CachedConstDependency"),
48
+ "dependencies/CreateScriptUrlDependency": () =>
49
+ require("../dependencies/CreateScriptUrlDependency"),
48
50
  "dependencies/CommonJsRequireContextDependency": () =>
49
51
  require("../dependencies/CommonJsRequireContextDependency"),
50
52
  "dependencies/CommonJsExportRequireDependency": () =>
@@ -6,6 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  const RuntimeGlobals = require("../RuntimeGlobals");
9
+ const CreateScriptUrlRuntimeModule = require("../runtime/CreateScriptUrlRuntimeModule");
9
10
  const StartupChunkDependenciesPlugin = require("../runtime/StartupChunkDependenciesPlugin");
10
11
  const ImportScriptsChunkLoadingRuntimeModule = require("./ImportScriptsChunkLoadingRuntimeModule");
11
12
 
@@ -39,11 +40,13 @@ class ImportScriptsChunkLoadingPlugin {
39
40
  if (onceForChunkSet.has(chunk)) return;
40
41
  onceForChunkSet.add(chunk);
41
42
  if (!isEnabledForChunk(chunk)) return;
43
+ const withCreateScriptUrl = !!compilation.outputOptions.trustedTypes;
42
44
  set.add(RuntimeGlobals.moduleFactoriesAddOnly);
43
45
  set.add(RuntimeGlobals.hasOwnProperty);
46
+ if (withCreateScriptUrl) set.add(RuntimeGlobals.createScriptUrl);
44
47
  compilation.addRuntimeModule(
45
48
  chunk,
46
- new ImportScriptsChunkLoadingRuntimeModule(set)
49
+ new ImportScriptsChunkLoadingRuntimeModule(set, withCreateScriptUrl)
47
50
  );
48
51
  };
49
52
  compilation.hooks.runtimeRequirementInTree
@@ -58,6 +61,15 @@ class ImportScriptsChunkLoadingPlugin {
58
61
  compilation.hooks.runtimeRequirementInTree
59
62
  .for(RuntimeGlobals.baseURI)
60
63
  .tap("ImportScriptsChunkLoadingPlugin", handler);
64
+ compilation.hooks.runtimeRequirementInTree
65
+ .for(RuntimeGlobals.createScriptUrl)
66
+ .tap("RuntimePlugin", (chunk, set) => {
67
+ compilation.addRuntimeModule(
68
+ chunk,
69
+ new CreateScriptUrlRuntimeModule()
70
+ );
71
+ return true;
72
+ });
61
73
 
62
74
  compilation.hooks.runtimeRequirementInTree
63
75
  .for(RuntimeGlobals.ensureChunkHandlers)
@@ -16,9 +16,10 @@ const compileBooleanMatcher = require("../util/compileBooleanMatcher");
16
16
  const { getUndoPath } = require("../util/identifier");
17
17
 
18
18
  class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
19
- constructor(runtimeRequirements) {
19
+ constructor(runtimeRequirements, withCreateScriptUrl) {
20
20
  super("importScripts chunk loading", RuntimeModule.STAGE_ATTACH);
21
21
  this.runtimeRequirements = runtimeRequirements;
22
+ this._withCreateScriptUrl = withCreateScriptUrl;
22
23
  }
23
24
 
24
25
  /**
@@ -31,7 +32,8 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
31
32
  compilation: {
32
33
  runtimeTemplate,
33
34
  outputOptions: { globalObject, chunkLoadingGlobal, hotUpdateGlobal }
34
- }
35
+ },
36
+ _withCreateScriptUrl: withCreateScriptUrl
35
37
  } = this;
36
38
  const fn = RuntimeGlobals.ensureChunkHandlers;
37
39
  const withBaseURI = this.runtimeRequirements.has(RuntimeGlobals.baseURI);
@@ -121,7 +123,11 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
121
123
  ? "if(true) { // all chunks have JS"
122
124
  : `if(${hasJsMatcher("chunkId")}) {`,
123
125
  Template.indent(
124
- `importScripts(${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId));`
126
+ `importScripts(${
127
+ withCreateScriptUrl
128
+ ? `${RuntimeGlobals.createScriptUrl}(${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId))`
129
+ : `${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId)`
130
+ });`
125
131
  ),
126
132
  "}"
127
133
  ]),
@@ -158,7 +164,11 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
158
164
  "success = true;"
159
165
  ])};`,
160
166
  "// start update chunk loading",
161
- `importScripts(${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId));`,
167
+ `importScripts(${
168
+ withCreateScriptUrl
169
+ ? `${RuntimeGlobals.createScriptUrl}(${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId))`
170
+ : `${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId)`
171
+ });`,
162
172
  'if(!success) throw new Error("Loading update chunk failed for unknown reason");'
163
173
  ]),
164
174
  "}",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.36.2",
3
+ "version": "5.37.0",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",
@@ -92,7 +92,7 @@
92
92
  "style-loader": "^2.0.0",
93
93
  "terser": "^5.5.0",
94
94
  "toml": "^3.0.0",
95
- "tooling": "webpack/tooling#v1.18.0",
95
+ "tooling": "webpack/tooling#v1.19.0",
96
96
  "ts-loader": "^8.0.2",
97
97
  "typescript": "^4.2.0-beta",
98
98
  "url-loader": "^4.1.0",