webpack 5.97.1 → 5.98.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.
@@ -3895,28 +3895,30 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3895
3895
  assignDepths(modules) {
3896
3896
  const moduleGraph = this.moduleGraph;
3897
3897
 
3898
- /** @type {Set<Module | number>} */
3898
+ /** @type {Set<Module>} */
3899
3899
  const queue = new Set(modules);
3900
- queue.add(1);
3900
+ // Track these in local variables so that queue only has one data type
3901
+ let nextDepthAt = queue.size;
3901
3902
  let depth = 0;
3902
3903
 
3903
3904
  let i = 0;
3904
3905
  for (const module of queue) {
3905
- i++;
3906
- if (typeof module === "number") {
3907
- depth = module;
3908
- if (queue.size === i) return;
3909
- queue.add(depth + 1);
3910
- } else {
3911
- moduleGraph.setDepth(module, depth);
3912
- for (const { module: refModule } of moduleGraph.getOutgoingConnections(
3913
- module
3914
- )) {
3915
- if (refModule) {
3916
- queue.add(refModule);
3917
- }
3906
+ moduleGraph.setDepth(module, depth);
3907
+ // Some of these results come from cache, which speeds this up
3908
+ const connections = moduleGraph.getOutgoingConnectionsByModule(module);
3909
+ // connections will be undefined if there are no outgoing connections
3910
+ if (connections) {
3911
+ for (const refModule of connections.keys()) {
3912
+ if (refModule) queue.add(refModule);
3918
3913
  }
3919
3914
  }
3915
+ i++;
3916
+ // Since this is a breadth-first search, all modules added to the queue
3917
+ // while at depth N will be depth N+1
3918
+ if (i >= nextDepthAt) {
3919
+ depth++;
3920
+ nextDepthAt = queue.size;
3921
+ }
3920
3922
  }
3921
3923
  }
3922
3924
 
package/lib/Module.js CHANGED
@@ -97,10 +97,6 @@ const makeSerializable = require("./util/makeSerializable");
97
97
 
98
98
  /**
99
99
  * @typedef {object} KnownBuildMeta
100
- * @property {string=} moduleArgument
101
- * @property {string=} exportsArgument
102
- * @property {boolean=} strict
103
- * @property {string=} moduleConcatenationBailout
104
100
  * @property {("default" | "namespace" | "flagged" | "dynamic")=} exportsType
105
101
  * @property {(false | "redirect" | "redirect-warn")=} defaultObject
106
102
  * @property {boolean=} strictHarmonyModule
@@ -113,6 +109,10 @@ const makeSerializable = require("./util/makeSerializable");
113
109
  * @typedef {object} KnownBuildInfo
114
110
  * @property {boolean=} cacheable
115
111
  * @property {boolean=} parsed
112
+ * @property {string=} moduleArgument
113
+ * @property {string=} exportsArgument
114
+ * @property {boolean=} strict
115
+ * @property {string=} moduleConcatenationBailout
116
116
  * @property {LazySet<string>=} fileDependencies
117
117
  * @property {LazySet<string>=} contextDependencies
118
118
  * @property {LazySet<string>=} missingDependencies
@@ -87,28 +87,6 @@ const getHash =
87
87
  return digest.slice(0, 4);
88
88
  };
89
89
 
90
- /**
91
- * Returns a function that returns the string with the token replaced with the replacement
92
- * @param {string|RegExp} test A regular expression string or Regular Expression object
93
- * @returns {RegExp} A regular expression object
94
- * @example
95
- * ```js
96
- * const test = asRegExp("test");
97
- * test.test("test"); // true
98
- *
99
- * const test2 = asRegExp(/test/);
100
- * test2.test("test"); // true
101
- * ```
102
- */
103
- const asRegExp = test => {
104
- if (typeof test === "string") {
105
- // Escape special characters in the string to prevent them from being interpreted as special characters in a regular expression. Do this by
106
- // adding a backslash before each special character
107
- test = new RegExp(`^${test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")}`);
108
- }
109
- return test;
110
- };
111
-
112
90
  /**
113
91
  * @template T
114
92
  * Returns a lazy object. The object is lazy in the sense that the properties are
@@ -335,15 +313,19 @@ ModuleFilenameHelpers.replaceDuplicates = (array, fn, comparator) => {
335
313
  * ModuleFilenameHelpers.matchPart("foo.js", [/^baz/, /^bar/]); // false
336
314
  * ```
337
315
  */
338
- ModuleFilenameHelpers.matchPart = (str, test) => {
316
+ const matchPart = (str, test) => {
339
317
  if (!test) return true;
340
-
341
318
  if (Array.isArray(test)) {
342
- return test.map(asRegExp).some(regExp => regExp.test(str));
319
+ return test.some(test => matchPart(str, test));
343
320
  }
344
- return asRegExp(test).test(str);
321
+ if (typeof test === "string") {
322
+ return str.startsWith(test);
323
+ }
324
+ return test.test(str);
345
325
  };
346
326
 
327
+ ModuleFilenameHelpers.matchPart = matchPart;
328
+
347
329
  /**
348
330
  * Tests if a string matches a match object. The match object can have the following properties:
349
331
  * - `test`: a RegExp or an array of RegExp
@@ -12,7 +12,7 @@ const {
12
12
  ASSET_MODULE_TYPE_SOURCE
13
13
  } = require("../ModuleTypeConstants");
14
14
  const { cleverMerge } = require("../util/cleverMerge");
15
- const { compareModulesByIdentifier } = require("../util/comparators");
15
+ const { compareModulesByIdOrIdentifier } = require("../util/comparators");
16
16
  const createSchemaValidation = require("../util/create-schema-validation");
17
17
  const memoize = require("../util/memoize");
18
18
 
@@ -189,7 +189,7 @@ class AssetModulesPlugin {
189
189
  const modules = chunkGraph.getOrderedChunkModulesIterableBySourceType(
190
190
  chunk,
191
191
  ASSET_MODULE_TYPE,
192
- compareModulesByIdentifier
192
+ compareModulesByIdOrIdentifier(chunkGraph)
193
193
  );
194
194
  if (modules) {
195
195
  for (const module of modules) {
@@ -262,7 +262,8 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
262
262
  futureDefaults,
263
263
  isNode: targetProperties && targetProperties.node === true,
264
264
  uniqueName: options.output.uniqueName,
265
- targetProperties
265
+ targetProperties,
266
+ mode: options.mode
266
267
  });
267
268
 
268
269
  applyExternalsPresetsDefaults(options.externalsPresets, {
@@ -609,6 +610,7 @@ const applyCssGeneratorOptionsDefaults = (
609
610
  * @param {string} options.uniqueName the unique name
610
611
  * @param {boolean} options.isNode is node target platform
611
612
  * @param {TargetProperties | false} options.targetProperties target properties
613
+ * @param {Mode} options.mode mode
612
614
  * @returns {void}
613
615
  */
614
616
  const applyModuleDefaults = (
@@ -621,7 +623,8 @@ const applyModuleDefaults = (
621
623
  futureDefaults,
622
624
  isNode,
623
625
  uniqueName,
624
- targetProperties
626
+ targetProperties,
627
+ mode
625
628
  }
626
629
  ) => {
627
630
  if (cache) {
@@ -663,6 +666,12 @@ const applyModuleDefaults = (
663
666
  }
664
667
 
665
668
  F(module.parser, "javascript", () => ({}));
669
+ F(module.parser, JSON_MODULE_TYPE, () => ({}));
670
+ D(
671
+ module.parser[JSON_MODULE_TYPE],
672
+ "exportsDepth",
673
+ mode === "development" ? 1 : Infinity
674
+ );
666
675
 
667
676
  applyJavascriptParserOptionsDefaults(
668
677
  /** @type {NonNullable<ParserOptionsByModuleTypeKnown["javascript"]>} */
@@ -1075,7 +1084,7 @@ const applyOutputDefaults = (
1075
1084
  D(output, "assetModuleFilename", "[hash][ext][query]");
1076
1085
  D(output, "webassemblyModuleFilename", "[hash].module.wasm");
1077
1086
  D(output, "compareBeforeEmit", true);
1078
- D(output, "charset", true);
1087
+ D(output, "charset", !futureDefaults);
1079
1088
  const uniqueNameId = Template.toIdentifier(
1080
1089
  /** @type {NonNullable<Output["uniqueName"]>} */ (output.uniqueName)
1081
1090
  );
@@ -74,7 +74,8 @@ class CssLoadingRuntimeModule extends RuntimeModule {
74
74
  outputOptions: {
75
75
  crossOriginLoading,
76
76
  uniqueName,
77
- chunkLoadTimeout: loadTimeout
77
+ chunkLoadTimeout: loadTimeout,
78
+ charset
78
79
  }
79
80
  } = compilation;
80
81
  const fn = RuntimeGlobals.ensureChunkHandlers;
@@ -138,6 +139,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
138
139
 
139
140
  const code = Template.asString([
140
141
  "link = document.createElement('link');",
142
+ charset ? "link.charset = 'utf-8';" : "",
141
143
  `if (${RuntimeGlobals.scriptNonce}) {`,
142
144
  Template.indent(
143
145
  `link.setAttribute("nonce", ${RuntimeGlobals.scriptNonce});`
@@ -351,6 +353,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
351
353
  linkPrefetch.call(
352
354
  Template.asString([
353
355
  "var link = document.createElement('link');",
356
+ charset ? "link.charset = 'utf-8';" : "",
354
357
  crossOriginLoading
355
358
  ? `link.crossOrigin = ${JSON.stringify(
356
359
  crossOriginLoading
@@ -390,7 +393,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
390
393
  linkPreload.call(
391
394
  Template.asString([
392
395
  "var link = document.createElement('link');",
393
- "link.charset = 'utf-8';",
396
+ charset ? "link.charset = 'utf-8';" : "",
394
397
  `if (${RuntimeGlobals.scriptNonce}) {`,
395
398
  Template.indent(
396
399
  `link.setAttribute("nonce", ${RuntimeGlobals.scriptNonce});`
@@ -36,7 +36,7 @@ const CssSelfLocalIdentifierDependency = require("../dependencies/CssSelfLocalId
36
36
  const CssUrlDependency = require("../dependencies/CssUrlDependency");
37
37
  const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
38
38
  const JavascriptModulesPlugin = require("../javascript/JavascriptModulesPlugin");
39
- const { compareModulesByIdentifier } = require("../util/comparators");
39
+ const { compareModulesByIdOrIdentifier } = require("../util/comparators");
40
40
  const createSchemaValidation = require("../util/create-schema-validation");
41
41
  const createHash = require("../util/createHash");
42
42
  const { getUndoPath } = require("../util/identifier");
@@ -598,6 +598,10 @@ class CssModulesPlugin {
598
598
  if (modulesByChunkGroup.length === 1)
599
599
  return modulesByChunkGroup[0].list.reverse();
600
600
 
601
+ const boundCompareModulesByIdOrIdentifier = compareModulesByIdOrIdentifier(
602
+ compilation.chunkGraph
603
+ );
604
+
601
605
  /**
602
606
  * @param {{ list: Module[] }} a a
603
607
  * @param {{ list: Module[] }} b b
@@ -608,7 +612,10 @@ class CssModulesPlugin {
608
612
  return b.length === 0 ? 0 : 1;
609
613
  }
610
614
  if (b.length === 0) return -1;
611
- return compareModulesByIdentifier(a[a.length - 1], b[b.length - 1]);
615
+ return boundCompareModulesByIdOrIdentifier(
616
+ a[a.length - 1],
617
+ b[b.length - 1]
618
+ );
612
619
  };
613
620
 
614
621
  modulesByChunkGroup.sort(compareModuleLists);
@@ -690,7 +697,7 @@ class CssModulesPlugin {
690
697
  chunkGraph.getOrderedChunkModulesIterableBySourceType(
691
698
  chunk,
692
699
  "css-import",
693
- compareModulesByIdentifier
700
+ compareModulesByIdOrIdentifier(chunkGraph)
694
701
  )
695
702
  ),
696
703
  compilation
@@ -702,7 +709,7 @@ class CssModulesPlugin {
702
709
  chunkGraph.getOrderedChunkModulesIterableBySourceType(
703
710
  chunk,
704
711
  "css",
705
- compareModulesByIdentifier
712
+ compareModulesByIdOrIdentifier(chunkGraph)
706
713
  )
707
714
  ),
708
715
  compilation
@@ -464,6 +464,36 @@ class CommonJsImportsParserPlugin {
464
464
  * @returns {boolean | void} true when handled
465
465
  */
466
466
  const processResolve = (expr, weak) => {
467
+ if (!weak && options.commonjsMagicComments) {
468
+ const { options: requireOptions, errors: commentErrors } =
469
+ parser.parseCommentOptions(/** @type {Range} */ (expr.range));
470
+
471
+ if (commentErrors) {
472
+ for (const e of commentErrors) {
473
+ const { comment } = e;
474
+ parser.state.module.addWarning(
475
+ new CommentCompilationWarning(
476
+ `Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
477
+ /** @type {DependencyLocation} */ (comment.loc)
478
+ )
479
+ );
480
+ }
481
+ }
482
+ if (requireOptions && requireOptions.webpackIgnore !== undefined) {
483
+ if (typeof requireOptions.webpackIgnore !== "boolean") {
484
+ parser.state.module.addWarning(
485
+ new UnsupportedFeatureWarning(
486
+ `\`webpackIgnore\` expected a boolean, but received: ${requireOptions.webpackIgnore}.`,
487
+ /** @type {DependencyLocation} */ (expr.loc)
488
+ )
489
+ );
490
+ } else if (requireOptions.webpackIgnore) {
491
+ // Do not instrument `require()` if `webpackIgnore` is `true`
492
+ return true;
493
+ }
494
+ }
495
+ }
496
+
467
497
  if (expr.arguments.length !== 1) return;
468
498
  const param = parser.evaluateExpression(expr.arguments[0]);
469
499
  if (param.isConditional()) {
@@ -237,7 +237,7 @@ CssLocalIdentifierDependency.Template = class CssLocalIdentifierDependencyTempla
237
237
  source.replace(dep.range[0], dep.range[1] - 1, identifier);
238
238
 
239
239
  for (const used of usedNames.concat(names)) {
240
- cssData.exports.set(used, identifier);
240
+ cssData.exports.set(used, getCssParser().unescapeIdentifier(identifier));
241
241
  }
242
242
  }
243
243
  };
@@ -20,40 +20,44 @@ const NullDependency = require("./NullDependency");
20
20
  /** @typedef {import("../util/Hash")} Hash */
21
21
 
22
22
  /**
23
- * @param {RawJsonData} data data
24
- * @returns {TODO} value
23
+ * @param {number} exportsDepth exportsDepth
24
+ * @returns {((data: RawJsonData, curDepth?: number) => ExportSpec[] | undefined)} value
25
25
  */
26
- const getExportsFromData = data => {
27
- if (data && typeof data === "object") {
28
- if (Array.isArray(data)) {
29
- return data.length < 100
30
- ? data.map((item, idx) => ({
31
- name: `${idx}`,
32
- canMangle: true,
33
- exports: getExportsFromData(item)
34
- }))
35
- : undefined;
26
+ const getExportsWithDepth = exportsDepth =>
27
+ function getExportsFromData(data, curDepth = 1) {
28
+ if (curDepth > exportsDepth) return undefined;
29
+ if (data && typeof data === "object") {
30
+ if (Array.isArray(data)) {
31
+ return data.length < 100
32
+ ? data.map((item, idx) => ({
33
+ name: `${idx}`,
34
+ canMangle: true,
35
+ exports: getExportsFromData(item, curDepth + 1)
36
+ }))
37
+ : undefined;
38
+ }
39
+ const exports = [];
40
+ for (const key of Object.keys(data)) {
41
+ exports.push({
42
+ name: key,
43
+ canMangle: true,
44
+ exports: getExportsFromData(data[key], curDepth + 1)
45
+ });
46
+ }
47
+ return exports;
36
48
  }
37
- const exports = [];
38
- for (const key of Object.keys(data)) {
39
- exports.push({
40
- name: key,
41
- canMangle: true,
42
- exports: getExportsFromData(data[key])
43
- });
44
- }
45
- return exports;
46
- }
47
- return undefined;
48
- };
49
+ return undefined;
50
+ };
49
51
 
50
52
  class JsonExportsDependency extends NullDependency {
51
53
  /**
52
54
  * @param {JsonData} data json data
55
+ * @param {number} exportsDepth the depth of json exports to analyze
53
56
  */
54
- constructor(data) {
57
+ constructor(data, exportsDepth) {
55
58
  super();
56
59
  this.data = data;
60
+ this.exportsDepth = exportsDepth;
57
61
  }
58
62
 
59
63
  get type() {
@@ -67,7 +71,7 @@ class JsonExportsDependency extends NullDependency {
67
71
  */
68
72
  getExports(moduleGraph) {
69
73
  return {
70
- exports: getExportsFromData(
74
+ exports: getExportsWithDepth(this.exportsDepth)(
71
75
  this.data && /** @type {RawJsonData} */ (this.data.get())
72
76
  ),
73
77
  dependencies: undefined
@@ -90,6 +94,7 @@ class JsonExportsDependency extends NullDependency {
90
94
  serialize(context) {
91
95
  const { write } = context;
92
96
  write(this.data);
97
+ write(this.exportsDepth);
93
98
  super.serialize(context);
94
99
  }
95
100
 
@@ -99,6 +104,7 @@ class JsonExportsDependency extends NullDependency {
99
104
  deserialize(context) {
100
105
  const { read } = context;
101
106
  this.data = read();
107
+ this.exportsDepth = read();
102
108
  super.deserialize(context);
103
109
  }
104
110
  }
@@ -93,7 +93,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
93
93
  (compilation.outputOptions.environment);
94
94
  const {
95
95
  runtimeTemplate,
96
- outputOptions: { importFunctionName, crossOriginLoading }
96
+ outputOptions: { importFunctionName, crossOriginLoading, charset }
97
97
  } = compilation;
98
98
  const fn = RuntimeGlobals.ensureChunkHandlers;
99
99
  const withBaseURI = this._runtimeRequirements.has(RuntimeGlobals.baseURI);
@@ -261,6 +261,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
261
261
  linkPrefetch.call(
262
262
  Template.asString([
263
263
  "var link = document.createElement('link');",
264
+ charset ? "link.charset = 'utf-8';" : "",
264
265
  crossOriginLoading
265
266
  ? `link.crossOrigin = ${JSON.stringify(
266
267
  crossOriginLoading
@@ -300,7 +301,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
300
301
  linkPreload.call(
301
302
  Template.asString([
302
303
  "var link = document.createElement('link');",
303
- "link.charset = 'utf-8';",
304
+ charset ? "link.charset = 'utf-8';" : "",
304
305
  `if (${RuntimeGlobals.scriptNonce}) {`,
305
306
  Template.indent(
306
307
  `link.setAttribute("nonce", ${RuntimeGlobals.scriptNonce});`
@@ -30,7 +30,7 @@ const RuntimeGlobals = require("../RuntimeGlobals");
30
30
  const Template = require("../Template");
31
31
  const { last, someInIterable } = require("../util/IterableHelpers");
32
32
  const StringXor = require("../util/StringXor");
33
- const { compareModulesByIdentifier } = require("../util/comparators");
33
+ const { compareModulesByIdOrIdentifier } = require("../util/comparators");
34
34
  const {
35
35
  getPathInAst,
36
36
  getAllReferences,
@@ -678,7 +678,7 @@ class JavascriptModulesPlugin {
678
678
  const modules = chunkGraph.getOrderedChunkModulesIterableBySourceType(
679
679
  chunk,
680
680
  "javascript",
681
- compareModulesByIdentifier
681
+ compareModulesByIdOrIdentifier(chunkGraph)
682
682
  );
683
683
  const allModules = modules ? Array.from(modules) : [];
684
684
  let strictHeader;
@@ -757,7 +757,7 @@ class JavascriptModulesPlugin {
757
757
  chunkGraph.getOrderedChunkModulesIterableBySourceType(
758
758
  chunk,
759
759
  "javascript",
760
- compareModulesByIdentifier
760
+ compareModulesByIdOrIdentifier(chunkGraph)
761
761
  ) || []
762
762
  );
763
763
 
@@ -42,7 +42,6 @@ class JsonModulesPlugin {
42
42
  .for(JSON_MODULE_TYPE)
43
43
  .tap(PLUGIN_NAME, parserOptions => {
44
44
  validate(parserOptions);
45
-
46
45
  return new JsonParser(parserOptions);
47
46
  });
48
47
  normalModuleFactory.hooks.createGenerator
@@ -63,7 +63,9 @@ class JsonParser extends Parser {
63
63
  buildMeta.exportsType = "default";
64
64
  buildMeta.defaultObject =
65
65
  typeof data === "object" ? "redirect-warn" : false;
66
- state.module.addDependency(new JsonExportsDependency(jsonData));
66
+ state.module.addDependency(
67
+ new JsonExportsDependency(jsonData, this.options.exportsDepth)
68
+ );
67
69
  return state;
68
70
  }
69
71
  }
@@ -1743,6 +1743,9 @@ module.exports = class SplitChunksPlugin {
1743
1743
  );
1744
1744
  chunk.split(newPart);
1745
1745
  newPart.chunkReason = chunk.chunkReason;
1746
+ if (chunk.filenameTemplate) {
1747
+ newPart.filenameTemplate = chunk.filenameTemplate;
1748
+ }
1746
1749
  // Add all modules to the new chunk
1747
1750
  for (const module of group.items) {
1748
1751
  if (!module.chunkCondition(newPart, compilation)) {
@@ -72,7 +72,7 @@ class AutoPublicPathRuntimeModule extends RuntimeModule {
72
72
  "// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration",
73
73
  '// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.',
74
74
  'if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");',
75
- 'scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\\?.*$/, "").replace(/\\/[^\\/]+$/, "/");',
75
+ 'scriptUrl = scriptUrl.replace(/^blob:/, "").replace(/#.*$/, "").replace(/\\?.*$/, "").replace(/\\/[^\\/]+$/, "/");',
76
76
  !undoPath
77
77
  ? `${RuntimeGlobals.publicPath} = scriptUrl;`
78
78
  : `${RuntimeGlobals.publicPath} = scriptUrl + ${JSON.stringify(
@@ -1852,7 +1852,7 @@ const spaceLimited = (
1852
1852
  // So it should always end up being smaller
1853
1853
  const headerSize = group.filteredChildren ? 2 : 1;
1854
1854
  const limited = spaceLimited(
1855
- /** @type {Children<T>} */ (group.children),
1855
+ /** @type {Children<T>[]} */ (group.children),
1856
1856
  maxGroupSize -
1857
1857
  // we should use ceil to always feet in max
1858
1858
  Math.ceil(oversize / groups.length) -
@@ -259,15 +259,25 @@ module.exports.parseRange = str => {
259
259
  const items = str.split(/\s+-\s+/);
260
260
 
261
261
  if (items.length === 1) {
262
- const items =
263
- /** @type {SemVerRangeItem[][]} */
264
- (
265
- str
266
- .trim()
267
- .split(/(?<=[-0-9A-Za-z])\s+/g)
268
- .map(parseSimple)
269
- );
262
+ str = str.trim();
270
263
 
264
+ /** @type {SemVerRangeItem[][]} */
265
+ const items = [];
266
+ const r = /[-0-9A-Za-z]\s+/g;
267
+ var start = 0;
268
+ var match;
269
+ while ((match = r.exec(str))) {
270
+ const end = match.index + 1;
271
+ items.push(
272
+ /** @type {SemVerRangeItem[]} */
273
+ (parseSimple(str.slice(start, end).trim()))
274
+ );
275
+ start = end;
276
+ }
277
+ items.push(
278
+ /** @type {SemVerRangeItem[]} */
279
+ (parseSimple(str.slice(start).trim()))
280
+ );
271
281
  return combine(items, 2);
272
282
  }
273
283
 
@@ -87,7 +87,7 @@ const validateSchema = (schema, options, validationConfiguration) => {
87
87
  children.some(
88
88
  child =>
89
89
  child.keyword === "absolutePath" &&
90
- child.dataPath === ".output.filename"
90
+ child.instancePath === "/output/filename"
91
91
  )
92
92
  ) {
93
93
  return `${formattedError}\nPlease use output.path to specify absolute path and output.filename for the file name.`;
@@ -97,7 +97,7 @@ const validateSchema = (schema, options, validationConfiguration) => {
97
97
  children &&
98
98
  children.some(
99
99
  child =>
100
- child.keyword === "pattern" && child.dataPath === ".devtool"
100
+ child.keyword === "pattern" && child.instancePath === "/devtool"
101
101
  )
102
102
  ) {
103
103
  return (
@@ -108,10 +108,7 @@ const validateSchema = (schema, options, validationConfiguration) => {
108
108
  }
109
109
 
110
110
  if (error.keyword === "additionalProperties") {
111
- const params =
112
- /** @type {import("ajv").AdditionalPropertiesParams} */ (
113
- error.params
114
- );
111
+ const params = error.params;
115
112
  if (
116
113
  Object.prototype.hasOwnProperty.call(
117
114
  DID_YOU_MEAN,
@@ -136,7 +133,7 @@ const validateSchema = (schema, options, validationConfiguration) => {
136
133
  }?`;
137
134
  }
138
135
 
139
- if (!error.dataPath) {
136
+ if (!error.instancePath) {
140
137
  if (params.additionalProperty === "debug") {
141
138
  return (
142
139
  `${formattedError}\n` +
@@ -99,7 +99,7 @@ class EnableWasmLoadingPlugin {
99
99
  new ReadFileCompileWasmPlugin({
100
100
  mangleImports: compiler.options.optimization.mangleWasmImports,
101
101
  import:
102
- compiler.options.output.environment.module &&
102
+ compiler.options.output.module &&
103
103
  compiler.options.output.environment.dynamicImport
104
104
  }).apply(compiler);
105
105
  }
@@ -108,7 +108,7 @@ class EnableWasmLoadingPlugin {
108
108
  const ReadFileCompileAsyncWasmPlugin = require("../node/ReadFileCompileAsyncWasmPlugin");
109
109
  new ReadFileCompileAsyncWasmPlugin({
110
110
  import:
111
- compiler.options.output.environment.module &&
111
+ compiler.options.output.module &&
112
112
  compiler.options.output.environment.dynamicImport
113
113
  }).apply(compiler);
114
114
  }
@@ -11,7 +11,7 @@ const Generator = require("../Generator");
11
11
  const { tryRunOrWebpackError } = require("../HookWebpackError");
12
12
  const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants");
13
13
  const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
14
- const { compareModulesByIdentifier } = require("../util/comparators");
14
+ const { compareModulesByIdOrIdentifier } = require("../util/comparators");
15
15
  const memoize = require("../util/memoize");
16
16
 
17
17
  /** @typedef {import("webpack-sources").Source} Source */
@@ -146,7 +146,7 @@ class AsyncWebAssemblyModulesPlugin {
146
146
 
147
147
  for (const module of chunkGraph.getOrderedChunkModulesIterable(
148
148
  chunk,
149
- compareModulesByIdentifier
149
+ compareModulesByIdOrIdentifier(chunkGraph)
150
150
  )) {
151
151
  if (module.type === WEBASSEMBLY_MODULE_TYPE_ASYNC) {
152
152
  const filenameTemplate =
@@ -9,7 +9,7 @@ const Generator = require("../Generator");
9
9
  const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants");
10
10
  const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency");
11
11
  const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
12
- const { compareModulesByIdentifier } = require("../util/comparators");
12
+ const { compareModulesByIdOrIdentifier } = require("../util/comparators");
13
13
  const memoize = require("../util/memoize");
14
14
  const WebAssemblyInInitialChunkError = require("./WebAssemblyInInitialChunkError");
15
15
 
@@ -89,7 +89,7 @@ class WebAssemblyModulesPlugin {
89
89
 
90
90
  for (const module of chunkGraph.getOrderedChunkModulesIterable(
91
91
  chunk,
92
- compareModulesByIdentifier
92
+ compareModulesByIdOrIdentifier(chunkGraph)
93
93
  )) {
94
94
  if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) {
95
95
  const filenameTemplate =