webpack 4.10.1 → 4.12.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.
Files changed (118) hide show
  1. package/lib/AmdMainTemplatePlugin.js +3 -1
  2. package/lib/AsyncDependencyToInitialChunkError.js +4 -4
  3. package/lib/BannerPlugin.js +3 -1
  4. package/lib/BasicEvaluatedExpression.js +14 -11
  5. package/lib/CachePlugin.js +12 -5
  6. package/lib/CaseSensitiveModulesWarning.js +41 -45
  7. package/lib/Chunk.js +56 -19
  8. package/lib/ChunkGroup.js +14 -6
  9. package/lib/CommentCompilationWarning.js +22 -0
  10. package/lib/Compilation.js +72 -29
  11. package/lib/Compiler.js +22 -10
  12. package/lib/ConstPlugin.js +25 -9
  13. package/lib/ContextModule.js +88 -36
  14. package/lib/ContextModuleFactory.js +18 -7
  15. package/lib/ContextReplacementPlugin.js +14 -7
  16. package/lib/DefinePlugin.js +15 -6
  17. package/lib/DependenciesBlock.js +3 -1
  18. package/lib/DependenciesBlockVariable.js +2 -1
  19. package/lib/DllPlugin.js +4 -2
  20. package/lib/DynamicEntryPlugin.js +4 -2
  21. package/lib/EntryModuleNotFoundError.js +21 -22
  22. package/lib/ErrorHelpers.js +5 -2
  23. package/lib/EvalSourceMapDevToolPlugin.js +2 -1
  24. package/lib/FlagDependencyUsagePlugin.js +11 -5
  25. package/lib/FunctionModuleTemplatePlugin.js +8 -6
  26. package/lib/HarmonyLinkingError.js +1 -2
  27. package/lib/HotModuleReplacement.runtime.js +13 -4
  28. package/lib/HotModuleReplacementPlugin.js +13 -6
  29. package/lib/JavascriptGenerator.js +2 -1
  30. package/lib/JavascriptModulesPlugin.js +4 -9
  31. package/lib/JsonParser.js +2 -1
  32. package/lib/LibraryTemplatePlugin.js +2 -1
  33. package/lib/LoaderOptionsPlugin.js +2 -1
  34. package/lib/MainTemplate.js +2 -1
  35. package/lib/Module.js +13 -5
  36. package/lib/ModuleBuildError.js +22 -12
  37. package/lib/ModuleDependencyError.js +4 -4
  38. package/lib/ModuleDependencyWarning.js +4 -4
  39. package/lib/ModuleError.js +13 -5
  40. package/lib/ModuleFilenameHelpers.js +20 -8
  41. package/lib/ModuleNotFoundError.js +23 -26
  42. package/lib/ModuleParseError.js +27 -14
  43. package/lib/ModuleWarning.js +13 -7
  44. package/lib/MultiCompiler.js +19 -7
  45. package/lib/MultiModule.js +5 -2
  46. package/lib/NodeStuffPlugin.js +2 -1
  47. package/lib/NormalModule.js +80 -16
  48. package/lib/NormalModuleFactory.js +67 -24
  49. package/lib/OptionsDefaulter.js +7 -3
  50. package/lib/Parser.js +182 -75
  51. package/lib/ParserHelpers.js +6 -3
  52. package/lib/ProgressPlugin.js +17 -2
  53. package/lib/RawModule.js +4 -2
  54. package/lib/RecordIdsPlugin.js +77 -9
  55. package/lib/RemovedPluginError.js +1 -3
  56. package/lib/RequestShortener.js +15 -6
  57. package/lib/RuleSet.js +51 -18
  58. package/lib/RuntimeTemplate.js +21 -10
  59. package/lib/SourceMapDevToolPlugin.js +4 -3
  60. package/lib/Stats.js +74 -31
  61. package/lib/Template.js +7 -4
  62. package/lib/TemplatedPathPlugin.js +6 -3
  63. package/lib/UmdMainTemplatePlugin.js +8 -3
  64. package/lib/UnsupportedFeatureWarning.js +22 -21
  65. package/lib/WarnCaseSensitiveModulesPlugin.js +2 -1
  66. package/lib/Watching.js +3 -2
  67. package/lib/WebpackOptionsApply.js +51 -23
  68. package/lib/WebpackOptionsDefaulter.js +15 -9
  69. package/lib/WebpackOptionsValidationError.js +63 -34
  70. package/lib/debug/ProfilingPlugin.js +11 -2
  71. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +17 -8
  72. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +8 -4
  73. package/lib/dependencies/HarmonyDetectionParserPlugin.js +4 -2
  74. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +7 -3
  75. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +6 -3
  76. package/lib/dependencies/ImportParserPlugin.js +42 -11
  77. package/lib/dependencies/LoaderPlugin.js +12 -7
  78. package/lib/dependencies/LocalModulesHelpers.js +13 -6
  79. package/lib/dependencies/RequireContextPlugin.js +4 -2
  80. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +8 -4
  81. package/lib/dependencies/SystemPlugin.js +6 -6
  82. package/lib/dependencies/WebAssemblyExportImportedDependency.js +29 -0
  83. package/lib/dependencies/WebAssemblyImportDependency.js +1 -1
  84. package/lib/formatLocation.js +15 -7
  85. package/lib/node/NodeMainTemplateAsync.runtime.js +1 -1
  86. package/lib/node/NodeMainTemplatePlugin.js +6 -3
  87. package/lib/node/NodeSourcePlugin.js +9 -5
  88. package/lib/node/NodeWatchFileSystem.js +29 -12
  89. package/lib/node/ReadFileCompileWasmTemplatePlugin.js +11 -2
  90. package/lib/optimize/AggressiveSplittingPlugin.js +12 -6
  91. package/lib/optimize/ConcatenatedModule.js +19 -8
  92. package/lib/optimize/MergeDuplicateChunksPlugin.js +6 -3
  93. package/lib/optimize/ModuleConcatenationPlugin.js +23 -10
  94. package/lib/optimize/OccurrenceOrderPlugin.js +11 -4
  95. package/lib/optimize/RemoveParentModulesPlugin.js +17 -7
  96. package/lib/optimize/SideEffectsFlagPlugin.js +14 -3
  97. package/lib/optimize/SplitChunksPlugin.js +33 -20
  98. package/lib/performance/AssetsOverSizeLimitWarning.js +7 -7
  99. package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -7
  100. package/lib/performance/NoAsyncChunksWarning.js +5 -5
  101. package/lib/util/SortableSet.js +5 -2
  102. package/lib/util/StackedSetMap.js +12 -5
  103. package/lib/wasm/UnsupportedWebAssemblyFeatureError.js +1 -2
  104. package/lib/wasm/WasmFinalizeExportsPlugin.js +66 -0
  105. package/lib/wasm/WasmMainTemplatePlugin.js +87 -43
  106. package/lib/wasm/WebAssemblyGenerator.js +117 -74
  107. package/lib/wasm/WebAssemblyJavascriptGenerator.js +92 -49
  108. package/lib/wasm/WebAssemblyModulesPlugin.js +11 -1
  109. package/lib/wasm/WebAssemblyParser.js +96 -24
  110. package/lib/wasm/WebAssemblyUtils.js +17 -6
  111. package/lib/web/FetchCompileWasmTemplatePlugin.js +13 -1
  112. package/lib/web/JsonpChunkTemplatePlugin.js +7 -0
  113. package/lib/web/JsonpMainTemplate.runtime.js +2 -1
  114. package/lib/web/JsonpMainTemplatePlugin.js +68 -63
  115. package/lib/webpack.js +2 -1
  116. package/lib/webworker/WebWorkerMainTemplate.runtime.js +2 -1
  117. package/package.json +12 -11
  118. package/schemas/WebpackOptions.json +8 -0
@@ -71,7 +71,9 @@ class AmdMainTemplatePlugin {
71
71
  }
72
72
 
73
73
  mainTemplate.hooks.globalHashPaths.tap("AmdMainTemplatePlugin", paths => {
74
- if (this.name) paths.push(this.name);
74
+ if (this.name) {
75
+ paths.push(this.name);
76
+ }
75
77
  return paths;
76
78
  });
77
79
 
@@ -16,13 +16,13 @@ class AsyncDependencyToInitialChunkError extends WebpackError {
16
16
  * @param {TODO} loc location of dependency
17
17
  */
18
18
  constructor(chunkName, module, loc) {
19
- super();
19
+ super(
20
+ `It's not allowed to load an initial chunk on demand. The chunk name "${chunkName}" is already used by an entrypoint.`
21
+ );
20
22
 
21
23
  this.name = "AsyncDependencyToInitialChunkError";
22
- this.message = `It's not allowed to load an initial chunk on demand. The chunk name "${chunkName}" is already used by an entrypoint.`;
23
24
  this.module = module;
24
- this.origin = module;
25
- this.originLoc = loc;
25
+ this.loc = loc;
26
26
 
27
27
  Error.captureStackTrace(this, this.constructor);
28
28
  }
@@ -13,7 +13,9 @@ const validateOptions = require("schema-utils");
13
13
  const schema = require("../schemas/plugins/BannerPlugin.json");
14
14
 
15
15
  const wrapComment = str => {
16
- if (!str.includes("\n")) return Template.toComment(str);
16
+ if (!str.includes("\n")) {
17
+ return Template.toComment(str);
18
+ }
17
19
  return `/*!\n * ${str
18
20
  .replace(/\*\//g, "* /")
19
21
  .split("\n")
@@ -90,20 +90,21 @@ class BasicEvaluatedExpression {
90
90
 
91
91
  asBool() {
92
92
  if (this.truthy) return true;
93
- else if (this.falsy) return false;
94
- else if (this.isBoolean()) return this.bool;
95
- else if (this.isNull()) return false;
96
- else if (this.isString()) return this.string !== "";
97
- else if (this.isNumber()) return this.number !== 0;
98
- else if (this.isRegExp()) return true;
99
- else if (this.isArray()) return true;
100
- else if (this.isConstArray()) return true;
101
- else if (this.isWrapped())
93
+ if (this.falsy) return false;
94
+ if (this.isBoolean()) return this.bool;
95
+ if (this.isNull()) return false;
96
+ if (this.isString()) return this.string !== "";
97
+ if (this.isNumber()) return this.number !== 0;
98
+ if (this.isRegExp()) return true;
99
+ if (this.isArray()) return true;
100
+ if (this.isConstArray()) return true;
101
+ if (this.isWrapped()) {
102
102
  return (this.prefix && this.prefix.asBool()) ||
103
103
  (this.postfix && this.postfix.asBool())
104
104
  ? true
105
105
  : undefined;
106
- else if (this.isTemplateString()) {
106
+ }
107
+ if (this.isTemplateString()) {
107
108
  for (const quasi of this.quasis) {
108
109
  if (quasi.asBool()) return true;
109
110
  }
@@ -165,7 +166,9 @@ class BasicEvaluatedExpression {
165
166
  this.type = TypeConditional;
166
167
  this.options = [];
167
168
  }
168
- for (const item of options) this.options.push(item);
169
+ for (const item of options) {
170
+ this.options.push(item);
171
+ }
169
172
  return this;
170
173
  }
171
174
 
@@ -26,12 +26,17 @@ class CachePlugin {
26
26
  (childCompiler, compilerName, compilerIndex) => {
27
27
  if (cache) {
28
28
  let childCache;
29
- if (!cache.children) cache.children = {};
30
- if (!cache.children[compilerName])
29
+ if (!cache.children) {
30
+ cache.children = {};
31
+ }
32
+ if (!cache.children[compilerName]) {
31
33
  cache.children[compilerName] = [];
32
- if (cache.children[compilerName][compilerIndex])
34
+ }
35
+ if (cache.children[compilerName][compilerIndex]) {
33
36
  childCache = cache.children[compilerName][compilerIndex];
34
- else cache.children[compilerName].push((childCache = {}));
37
+ } else {
38
+ cache.children[compilerName].push((childCache = {}));
39
+ }
35
40
  registerCacheToCompiler(childCompiler, childCache);
36
41
  }
37
42
  }
@@ -43,7 +48,9 @@ class CachePlugin {
43
48
  this.watching = true;
44
49
  });
45
50
  compiler.hooks.run.tapAsync("CachePlugin", (compiler, callback) => {
46
- if (!compiler._lastCompilationFileDependencies) return callback();
51
+ if (!compiler._lastCompilationFileDependencies) {
52
+ return callback();
53
+ }
47
54
  const fs = compiler.inputFileSystem;
48
55
  const fileTs = (compiler.fileTimestamps = new Map());
49
56
  asyncLib.forEach(
@@ -8,64 +8,60 @@ const WebpackError = require("./WebpackError");
8
8
 
9
9
  /** @typedef {import("./Module")} Module */
10
10
 
11
+ /**
12
+ * @param {Module[]} modules the modules to be sorted
13
+ * @returns {Module[]} sorted version of original modules
14
+ */
15
+ const sortModules = modules => {
16
+ return modules.slice().sort((a, b) => {
17
+ const aIdent = a.identifier();
18
+ const bIdent = b.identifier();
19
+ /* istanbul ignore next */
20
+ if (aIdent < bIdent) return -1;
21
+ /* istanbul ignore next */
22
+ if (aIdent > bIdent) return 1;
23
+ /* istanbul ignore next */
24
+ return 0;
25
+ });
26
+ };
27
+
28
+ /**
29
+ * @param {Module[]} modules each module from throw
30
+ * @returns {string} each message from provided moduels
31
+ */
32
+ const createModulesListMessage = modules => {
33
+ return modules
34
+ .map(m => {
35
+ let message = `* ${m.identifier()}`;
36
+ const validReasons = m.reasons.filter(reason => reason.module);
37
+
38
+ if (validReasons.length > 0) {
39
+ message += `\n Used by ${validReasons.length} module(s), i. e.`;
40
+ message += `\n ${validReasons[0].module.identifier()}`;
41
+ }
42
+ return message;
43
+ })
44
+ .join("\n");
45
+ };
46
+
11
47
  class CaseSensitiveModulesWarning extends WebpackError {
12
48
  /**
13
49
  * Creates an instance of CaseSensitiveModulesWarning.
14
50
  * @param {Module[]} modules modules that were detected
15
51
  */
16
52
  constructor(modules) {
17
- super();
18
-
19
- this.name = "CaseSensitiveModulesWarning";
20
- const sortedModules = this._sort(modules);
21
- const modulesList = this._moduleMessages(sortedModules);
22
- this.message = `There are multiple modules with names that only differ in casing.
53
+ const sortedModules = sortModules(modules);
54
+ const modulesList = createModulesListMessage(sortedModules);
55
+ super(`There are multiple modules with names that only differ in casing.
23
56
  This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
24
57
  Use equal casing. Compare these module identifiers:
25
- ${modulesList}`;
58
+ ${modulesList}`);
26
59
 
60
+ this.name = "CaseSensitiveModulesWarning";
27
61
  this.origin = this.module = sortedModules[0];
28
62
 
29
63
  Error.captureStackTrace(this, this.constructor);
30
64
  }
31
-
32
- /**
33
- * @private
34
- * @param {Module[]} modules the modules to be sorted
35
- * @returns {Module[]} sorted version of original modules
36
- */
37
- _sort(modules) {
38
- return modules.slice().sort((a, b) => {
39
- a = a.identifier();
40
- b = b.identifier();
41
- /* istanbul ignore next */
42
- if (a < b) return -1;
43
- /* istanbul ignore next */
44
- if (a > b) return 1;
45
- /* istanbul ignore next */
46
- return 0;
47
- });
48
- }
49
-
50
- /**
51
- * @private
52
- * @param {Module[]} modules each module from throw
53
- * @returns {string} each message from provided moduels
54
- */
55
- _moduleMessages(modules) {
56
- return modules
57
- .map(m => {
58
- let message = `* ${m.identifier()}`;
59
- const validReasons = m.reasons.filter(reason => reason.module);
60
-
61
- if (validReasons.length > 0) {
62
- message += `\n Used by ${validReasons.length} module(s), i. e.`;
63
- message += `\n ${validReasons[0].module.identifier()}`;
64
- }
65
- return message;
66
- })
67
- .join("\n");
68
- }
69
65
  }
70
66
 
71
67
  module.exports = CaseSensitiveModulesWarning;
package/lib/Chunk.js CHANGED
@@ -69,7 +69,7 @@ const getModulesIdent = set => {
69
69
  };
70
70
 
71
71
  /**
72
- * @template {T}
72
+ * @template T
73
73
  * @param {Set<T>} set the set to convert to array
74
74
  * @returns {Array<T>} the array returned from Array.from(set)
75
75
  */
@@ -378,13 +378,14 @@ class Chunk {
378
378
  otherChunk._groups.clear();
379
379
 
380
380
  if (this.name && otherChunk.name) {
381
- if (this.name.length !== otherChunk.name.length)
381
+ if (this.name.length !== otherChunk.name.length) {
382
382
  this.name =
383
383
  this.name.length < otherChunk.name.length
384
384
  ? this.name
385
385
  : otherChunk.name;
386
- else
386
+ } else {
387
387
  this.name = this.name < otherChunk.name ? this.name : otherChunk.name;
388
+ }
388
389
  }
389
390
 
390
391
  return true;
@@ -420,12 +421,16 @@ class Chunk {
420
421
  for (const chunkGroup of queue) {
421
422
  if (a.isInGroup(chunkGroup)) continue;
422
423
  if (chunkGroup.isInitial()) return false;
423
- for (const parent of chunkGroup.parentsIterable) queue.add(parent);
424
+ for (const parent of chunkGroup.parentsIterable) {
425
+ queue.add(parent);
426
+ }
424
427
  }
425
428
  return true;
426
429
  };
427
430
 
428
- if (this.preventIntegration || otherChunk.preventIntegration) return false;
431
+ if (this.preventIntegration || otherChunk.preventIntegration) {
432
+ return false;
433
+ }
429
434
 
430
435
  if (this.hasRuntime() !== otherChunk.hasRuntime()) {
431
436
  if (this.hasRuntime()) {
@@ -436,7 +441,11 @@ class Chunk {
436
441
  return false;
437
442
  }
438
443
  }
439
- if (this.hasEntryModule() || otherChunk.hasEntryModule()) return false;
444
+
445
+ if (this.hasEntryModule() || otherChunk.hasEntryModule()) {
446
+ return false;
447
+ }
448
+
440
449
  return true;
441
450
  }
442
451
 
@@ -509,14 +518,20 @@ class Chunk {
509
518
  );
510
519
 
511
520
  for (const chunkGroup of this.groupsIterable) {
512
- for (const child of chunkGroup.childrenIterable) queue.add(child);
521
+ for (const child of chunkGroup.childrenIterable) {
522
+ queue.add(child);
523
+ }
513
524
  }
514
525
 
515
526
  for (const chunkGroup of queue) {
516
527
  for (const chunk of chunkGroup.chunks) {
517
- if (!initialChunks.has(chunk)) chunks.add(chunk);
528
+ if (!initialChunks.has(chunk)) {
529
+ chunks.add(chunk);
530
+ }
531
+ }
532
+ for (const child of chunkGroup.childrenIterable) {
533
+ queue.add(child);
518
534
  }
519
- for (const child of chunkGroup.childrenIterable) queue.add(child);
520
535
  }
521
536
 
522
537
  return chunks;
@@ -530,11 +545,14 @@ class Chunk {
530
545
  for (const chunk of this.getAllAsyncChunks()) {
531
546
  chunkHashMap[chunk.id] = realHash ? chunk.hash : chunk.renderedHash;
532
547
  for (const key of Object.keys(chunk.contentHash)) {
533
- if (!chunkContentHashMap[key])
548
+ if (!chunkContentHashMap[key]) {
534
549
  chunkContentHashMap[key] = Object.create(null);
550
+ }
535
551
  chunkContentHashMap[key][chunk.id] = chunk.contentHash[key];
536
552
  }
537
- if (chunk.name) chunkNameMap[chunk.id] = chunk.name;
553
+ if (chunk.name) {
554
+ chunkNameMap[chunk.id] = chunk.name;
555
+ }
538
556
  }
539
557
 
540
558
  return {
@@ -572,12 +590,16 @@ class Chunk {
572
590
  const cmp = b.order - a.order;
573
591
  if (cmp !== 0) return cmp;
574
592
  // TOOD webpack 5 remove this check of compareTo
575
- if (a.group.compareTo) return a.group.compareTo(b.group);
593
+ if (a.group.compareTo) {
594
+ return a.group.compareTo(b.group);
595
+ }
576
596
  return 0;
577
597
  });
578
598
  result[name] = Array.from(
579
599
  list.reduce((set, item) => {
580
- for (const chunk of item.group.chunks) set.add(chunk.id);
600
+ for (const chunk of item.group.chunks) {
601
+ set.add(chunk.id);
602
+ }
581
603
  return set;
582
604
  }, new Set())
583
605
  );
@@ -585,18 +607,28 @@ class Chunk {
585
607
  return result;
586
608
  }
587
609
 
588
- getChildIdsByOrdersMap() {
610
+ getChildIdsByOrdersMap(includeDirectChildren) {
589
611
  const chunkMaps = Object.create(null);
590
612
 
591
- for (const chunk of this.getAllAsyncChunks()) {
613
+ const addChildIdsByOrdersToMap = chunk => {
592
614
  const data = chunk.getChildIdsByOrders();
593
615
  for (const key of Object.keys(data)) {
594
616
  let chunkMap = chunkMaps[key];
595
- if (chunkMap === undefined)
617
+ if (chunkMap === undefined) {
596
618
  chunkMaps[key] = chunkMap = Object.create(null);
619
+ }
597
620
  chunkMap[chunk.id] = data[key];
598
621
  }
622
+ };
623
+
624
+ if (includeDirectChildren) {
625
+ addChildIdsByOrdersToMap(this);
599
626
  }
627
+
628
+ for (const chunk of this.getAllAsyncChunks()) {
629
+ addChildIdsByOrdersToMap(chunk);
630
+ }
631
+
600
632
  return chunkMaps;
601
633
  }
602
634
 
@@ -642,12 +674,17 @@ class Chunk {
642
674
  if (!chunksProcessed.has(chunk)) {
643
675
  chunksProcessed.add(chunk);
644
676
  if (!filterChunkFn || filterChunkFn(chunk)) {
645
- for (const module of chunk.modulesIterable)
646
- if (filterFn(module)) return true;
677
+ for (const module of chunk.modulesIterable) {
678
+ if (filterFn(module)) {
679
+ return true;
680
+ }
681
+ }
647
682
  }
648
683
  }
649
684
  }
650
- for (const child of chunkGroup.childrenIterable) queue.add(child);
685
+ for (const child of chunkGroup.childrenIterable) {
686
+ queue.add(child);
687
+ }
651
688
  }
652
689
  return false;
653
690
  }
package/lib/ChunkGroup.js CHANGED
@@ -18,7 +18,7 @@ const compareLocations = require("./compareLocations");
18
18
  let debugId = 5000;
19
19
 
20
20
  /**
21
- * @template {T}
21
+ * @template T
22
22
  * @param {Set<T>} set set to convert to array.
23
23
  * @returns {T[]} the array format of existing set
24
24
  */
@@ -259,7 +259,9 @@ class ChunkGroup {
259
259
 
260
260
  setParents(newParents) {
261
261
  this._parents.clear();
262
- for (const p of newParents) this._parents.add(p);
262
+ for (const p of newParents) {
263
+ this._parents.add(p);
264
+ }
263
265
  }
264
266
 
265
267
  getNumberOfParents() {
@@ -418,7 +420,9 @@ class ChunkGroup {
418
420
  if (key.endsWith("Order")) {
419
421
  const name = key.substr(0, key.length - "Order".length);
420
422
  let list = lists.get(name);
421
- if (list === undefined) lists.set(name, (list = []));
423
+ if (list === undefined) {
424
+ lists.set(name, (list = []));
425
+ }
422
426
  list.push({
423
427
  order: childGroup.options[key],
424
428
  group: childGroup
@@ -433,7 +437,9 @@ class ChunkGroup {
433
437
  const cmp = b.order - a.order;
434
438
  if (cmp !== 0) return cmp;
435
439
  // TOOD webpack 5 remove this check of compareTo
436
- if (a.group.compareTo) return a.group.compareTo(b.group);
440
+ if (a.group.compareTo) {
441
+ return a.group.compareTo(b.group);
442
+ }
437
443
  return 0;
438
444
  });
439
445
  result[name] = list.map(i => i.group);
@@ -444,20 +450,22 @@ class ChunkGroup {
444
450
  checkConstraints() {
445
451
  const chunk = this;
446
452
  for (const child of chunk._children) {
447
- if (!child._parents.has(chunk))
453
+ if (!child._parents.has(chunk)) {
448
454
  throw new Error(
449
455
  `checkConstraints: child missing parent ${chunk.debugId} -> ${
450
456
  child.debugId
451
457
  }`
452
458
  );
459
+ }
453
460
  }
454
461
  for (const parentChunk of chunk._parents) {
455
- if (!parentChunk._children.has(chunk))
462
+ if (!parentChunk._children.has(chunk)) {
456
463
  throw new Error(
457
464
  `checkConstraints: parent missing child ${parentChunk.debugId} <- ${
458
465
  chunk.debugId
459
466
  }`
460
467
  );
468
+ }
461
469
  }
462
470
  }
463
471
  }
@@ -0,0 +1,22 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+ "use strict";
6
+
7
+ const WebpackError = require("./WebpackError");
8
+
9
+ class CommentCompilationWarning extends WebpackError {
10
+ constructor(message, module, loc) {
11
+ super(message);
12
+
13
+ this.name = "CommentCompilationWarning";
14
+
15
+ this.module = module;
16
+ this.loc = loc;
17
+
18
+ Error.captureStackTrace(this, this.constructor);
19
+ }
20
+ }
21
+
22
+ module.exports = CommentCompilationWarning;