webpack 4.14.0 → 4.16.1

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 (111) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +5 -2
  3. package/bin/webpack.js +7 -2
  4. package/buildin/amd-define.js +3 -3
  5. package/buildin/amd-options.js +2 -2
  6. package/buildin/system.js +7 -7
  7. package/hot/dev-server.js +2 -2
  8. package/hot/emitter.js +2 -2
  9. package/hot/only-dev-server.js +2 -2
  10. package/hot/poll.js +5 -2
  11. package/hot/signal.js +2 -2
  12. package/lib/AsyncDependenciesBlock.js +44 -0
  13. package/lib/AutomaticPrefetchPlugin.js +2 -2
  14. package/lib/Chunk.js +56 -6
  15. package/lib/ChunkGroup.js +2 -2
  16. package/lib/ChunkTemplate.js +14 -2
  17. package/lib/CommentCompilationWarning.js +3 -3
  18. package/lib/CompatibilityPlugin.js +1 -1
  19. package/lib/Compilation.js +442 -37
  20. package/lib/Compiler.js +57 -4
  21. package/lib/ContextModule.js +23 -16
  22. package/lib/DefinePlugin.js +49 -0
  23. package/lib/DelegatedModule.js +9 -1
  24. package/lib/DelegatedModuleFactoryPlugin.js +7 -1
  25. package/lib/DependenciesBlock.js +36 -3
  26. package/lib/DependenciesBlockVariable.js +22 -0
  27. package/lib/Dependency.js +33 -6
  28. package/lib/DllEntryPlugin.js +4 -1
  29. package/lib/DynamicEntryPlugin.js +21 -1
  30. package/lib/EntryOptionPlugin.js +12 -0
  31. package/lib/Entrypoint.js +1 -1
  32. package/lib/EnvironmentPlugin.js +8 -1
  33. package/lib/ExtendedAPIPlugin.js +8 -4
  34. package/lib/ExternalModuleFactoryPlugin.js +1 -1
  35. package/lib/Generator.js +1 -1
  36. package/lib/GraphHelpers.js +2 -1
  37. package/lib/HotModuleReplacement.runtime.js +8 -5
  38. package/lib/HotModuleReplacementPlugin.js +115 -117
  39. package/lib/IgnorePlugin.js +1 -1
  40. package/lib/MainTemplate.js +19 -4
  41. package/lib/MemoryOutputFileSystem.js +5 -5
  42. package/lib/Module.js +9 -3
  43. package/lib/ModuleReason.js +8 -0
  44. package/lib/MultiEntryPlugin.js +25 -3
  45. package/lib/NormalModule.js +5 -23
  46. package/lib/NullFactory.js +12 -12
  47. package/lib/OptionsApply.js +10 -10
  48. package/lib/RuleSet.js +3 -3
  49. package/lib/SingleEntryPlugin.js +20 -1
  50. package/lib/Stats.js +12 -5
  51. package/lib/Template.js +4 -1
  52. package/lib/UmdMainTemplatePlugin.js +12 -12
  53. package/lib/UseStrictPlugin.js +1 -1
  54. package/lib/WebpackError.js +4 -0
  55. package/lib/WebpackOptionsApply.js +92 -10
  56. package/lib/WebpackOptionsDefaulter.js +23 -6
  57. package/lib/WebpackOptionsValidationError.js +0 -1
  58. package/lib/compareLocations.js +13 -17
  59. package/lib/debug/ProfilingPlugin.js +5 -7
  60. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +4 -6
  61. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +0 -2
  62. package/lib/dependencies/AMDRequireItemDependency.js +22 -22
  63. package/lib/dependencies/CommonJsRequireDependency.js +22 -22
  64. package/lib/dependencies/CriticalDependencyWarning.js +20 -20
  65. package/lib/dependencies/DelegatedSourceDependency.js +18 -18
  66. package/lib/dependencies/DllEntryDependency.js +20 -20
  67. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -1
  68. package/lib/dependencies/LoaderDependency.js +3 -0
  69. package/lib/dependencies/LoaderPlugin.js +21 -2
  70. package/lib/dependencies/LocalModule.js +23 -23
  71. package/lib/dependencies/ModuleDependency.js +3 -0
  72. package/lib/dependencies/ModuleHotAcceptDependency.js +23 -23
  73. package/lib/dependencies/ModuleHotDeclineDependency.js +23 -23
  74. package/lib/dependencies/MultiEntryDependency.js +5 -0
  75. package/lib/dependencies/PrefetchDependency.js +18 -18
  76. package/lib/dependencies/RequireEnsureItemDependency.js +21 -21
  77. package/lib/dependencies/RequireResolveDependency.js +22 -22
  78. package/lib/dependencies/SingleEntryDependency.js +3 -0
  79. package/lib/dependencies/SystemPlugin.js +1 -1
  80. package/lib/formatLocation.js +55 -41
  81. package/lib/node/NodeMainTemplateAsync.runtime.js +1 -1
  82. package/lib/node/NodeMainTemplatePlugin.js +2 -2
  83. package/lib/node/NodeOutputFileSystem.js +22 -22
  84. package/lib/node/NodeSourcePlugin.js +1 -1
  85. package/lib/optimize/ConcatenatedModule.js +1 -0
  86. package/lib/optimize/NaturalChunkOrderPlugin.js +41 -0
  87. package/lib/optimize/OccurrenceChunkOrderPlugin.js +61 -0
  88. package/lib/optimize/OccurrenceModuleOrderPlugin.js +103 -0
  89. package/lib/optimize/OccurrenceOrderPlugin.js +4 -2
  90. package/lib/optimize/SplitChunksPlugin.js +168 -18
  91. package/lib/util/Semaphore.js +12 -0
  92. package/lib/util/SetHelpers.js +4 -4
  93. package/lib/util/SortableSet.js +1 -1
  94. package/lib/util/cachedMerge.js +1 -1
  95. package/lib/util/createHash.js +15 -0
  96. package/lib/util/deterministicGrouping.js +251 -0
  97. package/lib/util/identifier.js +27 -0
  98. package/lib/wasm/WasmFinalizeExportsPlugin.js +1 -1
  99. package/lib/wasm/WasmMainTemplatePlugin.js +10 -4
  100. package/lib/wasm/WebAssemblyGenerator.js +12 -12
  101. package/lib/wasm/WebAssemblyInInitialChunkError.js +88 -0
  102. package/lib/wasm/WebAssemblyModulesPlugin.js +28 -0
  103. package/lib/web/JsonpMainTemplatePlugin.js +1 -1
  104. package/lib/web/WebEnvironmentPlugin.js +18 -18
  105. package/lib/webpack.js +4 -0
  106. package/lib/webpack.web.js +2 -2
  107. package/lib/webworker/WebWorkerMainTemplatePlugin.js +1 -1
  108. package/package.json +27 -17
  109. package/schemas/WebpackOptions.json +71 -9
  110. package/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json +10 -0
  111. package/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json +10 -0
package/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- Copyright JS Foundation and other contributors
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- 'Software'), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright JS Foundation and other contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -92,16 +92,19 @@ within webpack itself use this plugin interface. This makes webpack very
92
92
 
93
93
  |Name|Status|Install Size|Description|
94
94
  |:--:|:----:|:----------:|:----------|
95
- |[extract-text-webpack-plugin][extract]|![extract-npm]|![extract-size]|Extracts Text (CSS) from your bundles into a separate file (app.bundle.css)|
95
+ |[mini-css-extract-plugin][mini-css]|![mini-css-npm]|![mini-css-size]|Extracts CSS into separate files. It creates a CSS file per JS file which contains CSS.|
96
96
  |[compression-webpack-plugin][compression]|![compression-npm]|![compression-size]|Prepares compressed versions of assets to serve them with Content-Encoding|
97
97
  |[i18n-webpack-plugin][i18n]|![i18n-npm]|![i18n-size]|Adds i18n support to your bundles|
98
98
  |[html-webpack-plugin][html-plugin]|![html-plugin-npm]|![html-plugin-size]| Simplifies creation of HTML files (`index.html`) to serve your bundles|
99
-
99
+ |[extract-text-webpack-plugin][extract]|![extract-npm]|![extract-size]|Extract text from a bundle, or bundles, into a separate file|
100
100
 
101
101
  [common-npm]: https://img.shields.io/npm/v/webpack.svg
102
102
  [extract]: https://github.com/webpack/extract-text-webpack-plugin
103
103
  [extract-npm]: https://img.shields.io/npm/v/extract-text-webpack-plugin.svg
104
104
  [extract-size]: https://packagephobia.now.sh/badge?p=extract-text-webpack-plugin
105
+ [mini-css]: https://github.com/webpack-contrib/mini-css-extract-plugin
106
+ [mini-css-npm]: https://img.shields.io/npm/v/mini-css-extract-plugin.svg
107
+ [mini-css-size]: https://packagephobia.now.sh/badge?p=mini-css-extract-plugin
105
108
  [component]: https://github.com/webpack/component-webpack-plugin
106
109
  [component-npm]: https://img.shields.io/npm/v/component-webpack-plugin.svg
107
110
  [component-size]: https://packagephobia.now.sh/badge?p=component-webpack-plugin
package/bin/webpack.js CHANGED
@@ -159,8 +159,13 @@ if (installedClis.length === 0) {
159
159
  } else if (installedClis.length === 1) {
160
160
  const path = require("path");
161
161
  const pkgPath = require.resolve(`${installedClis[0].package}/package.json`);
162
- const pkg = require(pkgPath); // eslint-disable-line
163
- require(path.resolve(path.dirname(pkgPath), pkg.bin[installedClis[0].binName])); // eslint-disable-line
162
+ // eslint-disable-next-line node/no-missing-require
163
+ const pkg = require(pkgPath);
164
+ // eslint-disable-next-line node/no-missing-require
165
+ require(path.resolve(
166
+ path.dirname(pkgPath),
167
+ pkg.bin[installedClis[0].binName]
168
+ ));
164
169
  } else {
165
170
  console.warn(
166
171
  `You have installed ${installedClis
@@ -1,3 +1,3 @@
1
- module.exports = function() {
2
- throw new Error("define cannot be used indirect");
3
- };
1
+ module.exports = function() {
2
+ throw new Error("define cannot be used indirect");
3
+ };
@@ -1,2 +1,2 @@
1
- /* globals __webpack_amd_options__ */
2
- module.exports = __webpack_amd_options__;
1
+ /* globals __webpack_amd_options__ */
2
+ module.exports = __webpack_amd_options__;
package/buildin/system.js CHANGED
@@ -1,7 +1,7 @@
1
- // Provide a "System" global.
2
- module.exports = {
3
- // Make sure import is only used as "System.import"
4
- import: function() {
5
- throw new Error("System.import cannot be used indirectly");
6
- }
7
- };
1
+ // Provide a "System" global.
2
+ module.exports = {
3
+ // Make sure import is only used as "System.import"
4
+ import: function() {
5
+ throw new Error("System.import cannot be used indirectly");
6
+ }
7
+ };
package/hot/dev-server.js CHANGED
@@ -40,10 +40,10 @@ if (module.hot) {
40
40
  "warning",
41
41
  "[HMR] Cannot apply update. Need to do a full reload!"
42
42
  );
43
- log("warning", "[HMR] " + err.stack || err.message);
43
+ log("warning", "[HMR] " + (err.stack || err.message));
44
44
  window.location.reload();
45
45
  } else {
46
- log("warning", "[HMR] Update failed: " + err.stack || err.message);
46
+ log("warning", "[HMR] Update failed: " + (err.stack || err.message));
47
47
  }
48
48
  });
49
49
  };
package/hot/emitter.js CHANGED
@@ -1,2 +1,2 @@
1
- var EventEmitter = require("events");
2
- module.exports = new EventEmitter();
1
+ var EventEmitter = require("events");
2
+ module.exports = new EventEmitter();
@@ -72,11 +72,11 @@ if (module.hot) {
72
72
  "warning",
73
73
  "[HMR] Cannot check for update. Need to do a full reload!"
74
74
  );
75
- log("warning", "[HMR] " + err.stack || err.message);
75
+ log("warning", "[HMR] " + (err.stack || err.message));
76
76
  } else {
77
77
  log(
78
78
  "warning",
79
- "[HMR] Update check failed: " + err.stack || err.message
79
+ "[HMR] Update check failed: " + (err.stack || err.message)
80
80
  );
81
81
  }
82
82
  });
package/hot/poll.js CHANGED
@@ -23,10 +23,13 @@ if (module.hot) {
23
23
  var status = module.hot.status();
24
24
  if (["abort", "fail"].indexOf(status) >= 0) {
25
25
  log("warning", "[HMR] Cannot apply update.");
26
- log("warning", "[HMR] " + err.stack || err.message);
26
+ log("warning", "[HMR] " + (err.stack || err.message));
27
27
  log("warning", "[HMR] You need to restart the application!");
28
28
  } else {
29
- log("warning", "[HMR] Update failed: " + err.stack || err.message);
29
+ log(
30
+ "warning",
31
+ "[HMR] Update failed: " + (err.stack || err.message)
32
+ );
30
33
  }
31
34
  });
32
35
  }
package/hot/signal.js CHANGED
@@ -37,10 +37,10 @@ if (module.hot) {
37
37
  var status = module.hot.status();
38
38
  if (["abort", "fail"].indexOf(status) >= 0) {
39
39
  log("warning", "[HMR] Cannot apply update.");
40
- log("warning", "[HMR] " + err.stack || err.message);
40
+ log("warning", "[HMR] " + (err.stack || err.message));
41
41
  log("warning", "[HMR] You need to restart the application!");
42
42
  } else {
43
- log("warning", "[HMR] Update failed: " + err.stack || err.message);
43
+ log("warning", "[HMR] Update failed: " + (err.stack || err.message));
44
44
  }
45
45
  });
46
46
  };
@@ -3,9 +3,22 @@
3
3
  Author Tobias Koppers @sokra
4
4
  */
5
5
  "use strict";
6
+
6
7
  const DependenciesBlock = require("./DependenciesBlock");
7
8
 
9
+ /** @typedef {import("./ChunkGroup")} ChunkGroup */
10
+ /** @typedef {import("./Module")} Module */
11
+ /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
12
+ /** @typedef {import("./util/createHash").Hash} Hash */
13
+ /** @typedef {TODO} GroupOptions */
14
+
8
15
  module.exports = class AsyncDependenciesBlock extends DependenciesBlock {
16
+ /**
17
+ * @param {GroupOptions} groupOptions options for the group
18
+ * @param {Module} module the Module object
19
+ * @param {DependencyLocation=} loc the line of code
20
+ * @param {TODO=} request the request
21
+ */
9
22
  constructor(groupOptions, module, loc, request) {
10
23
  super();
11
24
  if (typeof groupOptions === "string") {
@@ -14,28 +27,50 @@ module.exports = class AsyncDependenciesBlock extends DependenciesBlock {
14
27
  groupOptions = { name: undefined };
15
28
  }
16
29
  this.groupOptions = groupOptions;
30
+ /** @type {ChunkGroup=} */
17
31
  this.chunkGroup = undefined;
18
32
  this.module = module;
19
33
  this.loc = loc;
20
34
  this.request = request;
35
+ /** @type {DependenciesBlock} */
36
+ this.parent = undefined;
21
37
  }
22
38
 
39
+ /**
40
+ * @returns {string} The name of the chunk
41
+ */
23
42
  get chunkName() {
24
43
  return this.groupOptions.name;
25
44
  }
26
45
 
46
+ /**
47
+ * @param {string} value The new chunk name
48
+ * @returns {void}
49
+ */
27
50
  set chunkName(value) {
28
51
  this.groupOptions.name = value;
29
52
  }
30
53
 
54
+ /**
55
+ * @returns {never} this throws and should never be called
56
+ */
31
57
  get chunks() {
32
58
  throw new Error("Moved to AsyncDependenciesBlock.chunkGroup");
33
59
  }
34
60
 
61
+ /**
62
+ * @param {never} value setter value
63
+ * @returns {never} this is going to throw therefore we should throw type
64
+ * assertions by returning never
65
+ */
35
66
  set chunks(value) {
36
67
  throw new Error("Moved to AsyncDependenciesBlock.chunkGroup");
37
68
  }
38
69
 
70
+ /**
71
+ * @param {Hash} hash the hash used to track block changes, from "crypto" module
72
+ * @returns {void}
73
+ */
39
74
  updateHash(hash) {
40
75
  hash.update(JSON.stringify(this.groupOptions));
41
76
  hash.update(
@@ -50,16 +85,25 @@ module.exports = class AsyncDependenciesBlock extends DependenciesBlock {
50
85
  super.updateHash(hash);
51
86
  }
52
87
 
88
+ /**
89
+ * @returns {void}
90
+ */
53
91
  disconnect() {
54
92
  this.chunkGroup = undefined;
55
93
  super.disconnect();
56
94
  }
57
95
 
96
+ /**
97
+ * @returns {void}
98
+ */
58
99
  unseal() {
59
100
  this.chunkGroup = undefined;
60
101
  super.unseal();
61
102
  }
62
103
 
104
+ /**
105
+ * @returns {void}
106
+ */
63
107
  sortItems() {
64
108
  super.sortItems();
65
109
  }
@@ -8,7 +8,7 @@ const asyncLib = require("neo-async");
8
8
  const PrefetchDependency = require("./dependencies/PrefetchDependency");
9
9
  const NormalModule = require("./NormalModule");
10
10
 
11
- /** @typedef {import("./Compiler.js")} Compiler */
11
+ /** @typedef {import("./Compiler")} Compiler */
12
12
 
13
13
  class AutomaticPrefetchPlugin {
14
14
  /**
@@ -30,7 +30,7 @@ class AutomaticPrefetchPlugin {
30
30
  compiler.hooks.afterCompile.tap("AutomaticPrefetchPlugin", compilation => {
31
31
  lastModules = compilation.modules
32
32
  .filter(m => m instanceof NormalModule)
33
- .map(m => ({
33
+ .map((/** @type {NormalModule} */ m) => ({
34
34
  context: m.context,
35
35
  request: m.request
36
36
  }));
package/lib/Chunk.js CHANGED
@@ -13,10 +13,11 @@ const ERR_CHUNK_ENTRY = "Chunk.entry was removed. Use hasRuntime()";
13
13
  const ERR_CHUNK_INITIAL =
14
14
  "Chunk.initial was removed. Use canBeInitial/isOnlyInitial()";
15
15
 
16
- /** @typedef {import("./Module.js")} Module */
16
+ /** @typedef {import("./Module")} Module */
17
17
  /** @typedef {import("./ChunkGroup")} ChunkGroup */
18
- /** @typedef {import("./ModuleReason.js")} ModuleReason */
18
+ /** @typedef {import("./ModuleReason")} ModuleReason */
19
19
  /** @typedef {import("webpack-sources").Source} Source */
20
+ /** @typedef {import("./util/createHash").Hash} Hash */
20
21
 
21
22
  /**
22
23
  * @typedef {Object} WithId an object who has an id property *
@@ -29,6 +30,12 @@ const ERR_CHUNK_INITIAL =
29
30
  * @param {Module} b module
30
31
  * @returns {-1|0|1} sort value
31
32
  */
33
+
34
+ // TODO use @callback
35
+ /** @typedef {(a: Module, b: Module) => -1|0|1} ModuleSortPredicate */
36
+ /** @typedef {(m: Module) => boolean} ModuleFilterPredicate */
37
+ /** @typedef {(c: Chunk) => boolean} ChunkFilterPredicate */
38
+
32
39
  const sortModuleById = (a, b) => {
33
40
  if (a.id < b.id) return -1;
34
41
  if (b.id < a.id) return 1;
@@ -114,9 +121,14 @@ class Chunk {
114
121
  this.entryModule = undefined;
115
122
  /** @private @type {SortableSet<Module>} */
116
123
  this._modules = new SortableSet(undefined, sortByIdentifier);
124
+ /** @type {string?} */
125
+ this.filenameTemplate = undefined;
126
+
127
+ /** @private */
128
+ this._groups = new SortableSet(undefined, sortChunkGroupById);
117
129
  /** @private @type {SortableSet<ChunkGroup>} */
118
130
  this._groups = new SortableSet(undefined, sortChunkGroupById);
119
- /** @type {Source[]} */
131
+ /** @type {string[]} */
120
132
  this.files = [];
121
133
  /** @type {boolean} */
122
134
  this.rendered = false;
@@ -288,7 +300,7 @@ class Chunk {
288
300
  }
289
301
 
290
302
  /**
291
- * @returns {SortableSet} the chunkGroups that said chunk is referenced in
303
+ * @returns {SortableSet<ChunkGroup>} the chunkGroups that said chunk is referenced in
292
304
  */
293
305
  get groupsIterable() {
294
306
  return this._groups;
@@ -305,7 +317,7 @@ class Chunk {
305
317
  if (this._modules.size < otherChunk._modules.size) return 1;
306
318
  const a = this._modules[Symbol.iterator]();
307
319
  const b = otherChunk._modules[Symbol.iterator]();
308
- // eslint-disable-next-line
320
+ // eslint-disable-next-line no-constant-condition
309
321
  while (true) {
310
322
  const aItem = a.next();
311
323
  const bItem = b.next();
@@ -482,6 +494,11 @@ class Chunk {
482
494
  return this.addMultiplierAndOverhead(this.modulesSize(), options);
483
495
  }
484
496
 
497
+ /**
498
+ * @param {Chunk} otherChunk the other chunk
499
+ * @param {TODO} options the options for this function
500
+ * @returns {number | false} the size, or false if it can't be integrated
501
+ */
485
502
  integratedSize(otherChunk, options) {
486
503
  // Chunk if it's possible to integrate this chunk
487
504
  if (!this.canBeIntegrated(otherChunk)) {
@@ -511,6 +528,9 @@ class Chunk {
511
528
  this.sortModules();
512
529
  }
513
530
 
531
+ /**
532
+ * @returns {Set<Chunk>} a set of all the async chunks
533
+ */
514
534
  getAllAsyncChunks() {
515
535
  const queue = new Set();
516
536
  const chunks = new Set();
@@ -539,9 +559,23 @@ class Chunk {
539
559
  return chunks;
540
560
  }
541
561
 
562
+ /**
563
+ * @typedef {Object} ChunkMaps
564
+ * @property {Record<string|number, string>} hash
565
+ * @property {Record<string|number, Record<string, string>>} contentHash
566
+ * @property {Record<string|number, string>} name
567
+ */
568
+
569
+ /**
570
+ * @param {boolean} realHash should the full hash or the rendered hash be used
571
+ * @returns {ChunkMaps} the chunk map information
572
+ */
542
573
  getChunkMaps(realHash) {
574
+ /** @type {Record<string|number, string>} */
543
575
  const chunkHashMap = Object.create(null);
576
+ /** @type {Record<string|number, Record<string, string>>} */
544
577
  const chunkContentHashMap = Object.create(null);
578
+ /** @type {Record<string|number, string>} */
545
579
  const chunkNameMap = Object.create(null);
546
580
 
547
581
  for (const chunk of this.getAllAsyncChunks()) {
@@ -564,6 +598,9 @@ class Chunk {
564
598
  };
565
599
  }
566
600
 
601
+ /**
602
+ * @returns {Record<string, Set<TODO>[]>} a record object of names to lists of child ids(?)
603
+ */
567
604
  getChildIdsByOrders() {
568
605
  const lists = new Map();
569
606
  for (const group of this.groupsIterable) {
@@ -591,7 +628,7 @@ class Chunk {
591
628
  list.sort((a, b) => {
592
629
  const cmp = b.order - a.order;
593
630
  if (cmp !== 0) return cmp;
594
- // TOOD webpack 5 remove this check of compareTo
631
+ // TODO webpack 5 remove this check of compareTo
595
632
  if (a.group.compareTo) {
596
633
  return a.group.compareTo(b.group);
597
634
  }
@@ -634,11 +671,24 @@ class Chunk {
634
671
  return chunkMaps;
635
672
  }
636
673
 
674
+ /**
675
+ * @typedef {Object} ChunkModuleMaps
676
+ * @property {Record<string|number, (string|number)[]>} id
677
+ * @property {Record<string|number, string>} hash
678
+ */
679
+
680
+ /**
681
+ * @param {ModuleFilterPredicate} filterFn function used to filter modules
682
+ * @returns {ChunkModuleMaps} module map information
683
+ */
637
684
  getChunkModuleMaps(filterFn) {
685
+ /** @type {Record<string|number, (string|number)[]>} */
638
686
  const chunkModuleIdMap = Object.create(null);
687
+ /** @type {Record<string|number, string>} */
639
688
  const chunkModuleHashMap = Object.create(null);
640
689
 
641
690
  for (const chunk of this.getAllAsyncChunks()) {
691
+ /** @type {(string|number)[]} */
642
692
  let array;
643
693
  for (const module of chunk.modulesIterable) {
644
694
  if (filterFn(module)) {
package/lib/ChunkGroup.js CHANGED
@@ -407,7 +407,7 @@ class ChunkGroup {
407
407
  if (this.chunks.length < otherGroup.chunks.length) return 1;
408
408
  const a = this.chunks[Symbol.iterator]();
409
409
  const b = otherGroup.chunks[Symbol.iterator]();
410
- // eslint-disable-next-line
410
+ // eslint-disable-next-line no-constant-condition
411
411
  while (true) {
412
412
  const aItem = a.next();
413
413
  const bItem = b.next();
@@ -442,7 +442,7 @@ class ChunkGroup {
442
442
  list.sort((a, b) => {
443
443
  const cmp = b.order - a.order;
444
444
  if (cmp !== 0) return cmp;
445
- // TOOD webpack 5 remove this check of compareTo
445
+ // TODO webpack 5 remove this check of compareTo
446
446
  if (a.group.compareTo) {
447
447
  return a.group.compareTo(b.group);
448
448
  }
@@ -9,12 +9,12 @@ const { Tapable, SyncWaterfallHook, SyncHook } = require("tapable");
9
9
  /** @typedef {import("./ModuleTemplate")} ModuleTemplate */
10
10
  /** @typedef {import("./Chunk")} Chunk */
11
11
  /** @typedef {import("./Module")} Module} */
12
- /** @typedef {import("crypto").Hash} Hash */
12
+ /** @typedef {import("./util/createHash").Hash} Hash} */
13
13
 
14
14
  /**
15
15
  * @typedef {Object} RenderManifestOptions
16
16
  * @property {Chunk} chunk the chunk used to render
17
- * @property {Hash} hash
17
+ * @property {string} hash
18
18
  * @property {string} fullHash
19
19
  * @property {TODO} outputOptions
20
20
  * @property {{javascript: ModuleTemplate, webassembly: ModuleTemplate}} moduleTemplates
@@ -26,6 +26,7 @@ module.exports = class ChunkTemplate extends Tapable {
26
26
  super();
27
27
  this.outputOptions = outputOptions || {};
28
28
  this.hooks = {
29
+ /** @type {SyncWaterfallHook<TODO[], RenderManifestOptions>} */
29
30
  renderManifest: new SyncWaterfallHook(["result", "options"]),
30
31
  modules: new SyncWaterfallHook([
31
32
  "source",
@@ -58,12 +59,23 @@ module.exports = class ChunkTemplate extends Tapable {
58
59
  return result;
59
60
  }
60
61
 
62
+ /**
63
+ * Updates hash with information from this template
64
+ * @param {Hash} hash the hash to update
65
+ * @returns {void}
66
+ */
61
67
  updateHash(hash) {
62
68
  hash.update("ChunkTemplate");
63
69
  hash.update("2");
64
70
  this.hooks.hash.call(hash);
65
71
  }
66
72
 
73
+ /**
74
+ * Updates hash with chunk-specific information from this template
75
+ * @param {Hash} hash the hash to update
76
+ * @param {Chunk} chunk the chunk
77
+ * @returns {void}
78
+ */
67
79
  updateHashForChunk(hash, chunk) {
68
80
  this.updateHash(hash);
69
81
  this.hooks.hashForChunk.call(hash, chunk);
@@ -6,16 +6,16 @@
6
6
 
7
7
  const WebpackError = require("./WebpackError");
8
8
 
9
- /** @typedef {import("./Module.js")} Module */
9
+ /** @typedef {import("./Module")} Module */
10
10
 
11
- /** @typedef {import("./Dependency.js").Loc} Loc */
11
+ /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
12
12
 
13
13
  class CommentCompilationWarning extends WebpackError {
14
14
  /**
15
15
  *
16
16
  * @param {string} message warning message
17
17
  * @param {Module} module affected module
18
- * @param {Loc} loc affected lines of code
18
+ * @param {DependencyLocation} loc affected lines of code
19
19
  */
20
20
  constructor(message, module, loc) {
21
21
  super(message);
@@ -8,7 +8,7 @@ const ConstDependency = require("./dependencies/ConstDependency");
8
8
 
9
9
  const NullFactory = require("./NullFactory");
10
10
 
11
- /** @typedef {import("./Compiler.js")} Compiler */
11
+ /** @typedef {import("./Compiler")} Compiler */
12
12
 
13
13
  class CompatibilityPlugin {
14
14
  /**