webpack 4.14.0 → 4.15.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 (60) hide show
  1. package/bin/webpack.js +7 -2
  2. package/lib/AsyncDependenciesBlock.js +44 -0
  3. package/lib/AutomaticPrefetchPlugin.js +1 -1
  4. package/lib/Chunk.js +53 -3
  5. package/lib/ChunkGroup.js +1 -1
  6. package/lib/ChunkTemplate.js +14 -2
  7. package/lib/CommentCompilationWarning.js +2 -2
  8. package/lib/Compilation.js +435 -34
  9. package/lib/Compiler.js +57 -4
  10. package/lib/ContextModule.js +3 -15
  11. package/lib/DelegatedModule.js +9 -1
  12. package/lib/DependenciesBlock.js +36 -3
  13. package/lib/DependenciesBlockVariable.js +22 -0
  14. package/lib/Dependency.js +25 -4
  15. package/lib/DllEntryPlugin.js +4 -1
  16. package/lib/DynamicEntryPlugin.js +21 -1
  17. package/lib/EntryOptionPlugin.js +12 -0
  18. package/lib/ExtendedAPIPlugin.js +8 -4
  19. package/lib/ExternalModuleFactoryPlugin.js +1 -1
  20. package/lib/GraphHelpers.js +2 -1
  21. package/lib/HotModuleReplacement.runtime.js +8 -5
  22. package/lib/HotModuleReplacementPlugin.js +114 -116
  23. package/lib/MainTemplate.js +19 -4
  24. package/lib/Module.js +9 -3
  25. package/lib/ModuleReason.js +8 -0
  26. package/lib/MultiEntryPlugin.js +25 -3
  27. package/lib/NormalModule.js +5 -23
  28. package/lib/RuleSet.js +3 -3
  29. package/lib/SingleEntryPlugin.js +14 -0
  30. package/lib/Stats.js +2 -1
  31. package/lib/Template.js +4 -1
  32. package/lib/UmdMainTemplatePlugin.js +12 -12
  33. package/lib/WebpackError.js +4 -0
  34. package/lib/WebpackOptionsDefaulter.js +3 -0
  35. package/lib/WebpackOptionsValidationError.js +0 -1
  36. package/lib/compareLocations.js +13 -17
  37. package/lib/debug/ProfilingPlugin.js +5 -7
  38. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +4 -6
  39. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +0 -2
  40. package/lib/dependencies/LoaderDependency.js +3 -0
  41. package/lib/dependencies/LoaderPlugin.js +3 -1
  42. package/lib/dependencies/ModuleDependency.js +3 -0
  43. package/lib/dependencies/MultiEntryDependency.js +5 -0
  44. package/lib/dependencies/SingleEntryDependency.js +3 -0
  45. package/lib/node/NodeMainTemplateAsync.runtime.js +1 -1
  46. package/lib/optimize/ConcatenatedModule.js +1 -0
  47. package/lib/optimize/SplitChunksPlugin.js +142 -2
  48. package/lib/util/Semaphore.js +12 -0
  49. package/lib/util/SetHelpers.js +4 -4
  50. package/lib/util/SortableSet.js +1 -1
  51. package/lib/util/createHash.js +15 -0
  52. package/lib/util/deterministicGrouping.js +251 -0
  53. package/lib/util/identifier.js +27 -0
  54. package/lib/wasm/WasmMainTemplatePlugin.js +10 -4
  55. package/lib/wasm/WebAssemblyGenerator.js +12 -12
  56. package/lib/wasm/WebAssemblyInInitialChunkError.js +88 -0
  57. package/lib/wasm/WebAssemblyModulesPlugin.js +28 -0
  58. package/lib/webpack.web.js +2 -2
  59. package/package.json +8 -7
  60. package/schemas/WebpackOptions.json +37 -1
@@ -35,6 +35,118 @@ module.exports = class HotModuleReplacementPlugin {
35
35
  return callback();
36
36
  }
37
37
  );
38
+
39
+ const addParserPlugins = (parser, parserOptions) => {
40
+ parser.hooks.expression
41
+ .for("__webpack_hash__")
42
+ .tap(
43
+ "HotModuleReplacementPlugin",
44
+ ParserHelpers.toConstantDependencyWithWebpackRequire(
45
+ parser,
46
+ "__webpack_require__.h()"
47
+ )
48
+ );
49
+ parser.hooks.evaluateTypeof
50
+ .for("__webpack_hash__")
51
+ .tap(
52
+ "HotModuleReplacementPlugin",
53
+ ParserHelpers.evaluateToString("string")
54
+ );
55
+ parser.hooks.evaluateIdentifier.for("module.hot").tap(
56
+ {
57
+ name: "HotModuleReplacementPlugin",
58
+ before: "NodeStuffPlugin"
59
+ },
60
+ expr => {
61
+ return ParserHelpers.evaluateToIdentifier(
62
+ "module.hot",
63
+ !!parser.state.compilation.hotUpdateChunkTemplate
64
+ )(expr);
65
+ }
66
+ );
67
+ // TODO webpack 5: refactor this, no custom hooks
68
+ if (!parser.hooks.hotAcceptCallback) {
69
+ parser.hooks.hotAcceptCallback = new SyncBailHook([
70
+ "expression",
71
+ "requests"
72
+ ]);
73
+ }
74
+ if (!parser.hooks.hotAcceptWithoutCallback) {
75
+ parser.hooks.hotAcceptWithoutCallback = new SyncBailHook([
76
+ "expression",
77
+ "requests"
78
+ ]);
79
+ }
80
+ parser.hooks.call
81
+ .for("module.hot.accept")
82
+ .tap("HotModuleReplacementPlugin", expr => {
83
+ if (!parser.state.compilation.hotUpdateChunkTemplate) {
84
+ return false;
85
+ }
86
+ if (expr.arguments.length >= 1) {
87
+ const arg = parser.evaluateExpression(expr.arguments[0]);
88
+ let params = [];
89
+ let requests = [];
90
+ if (arg.isString()) {
91
+ params = [arg];
92
+ } else if (arg.isArray()) {
93
+ params = arg.items.filter(param => param.isString());
94
+ }
95
+ if (params.length > 0) {
96
+ params.forEach((param, idx) => {
97
+ const request = param.string;
98
+ const dep = new ModuleHotAcceptDependency(request, param.range);
99
+ dep.optional = true;
100
+ dep.loc = Object.create(expr.loc);
101
+ dep.loc.index = idx;
102
+ parser.state.module.addDependency(dep);
103
+ requests.push(request);
104
+ });
105
+ if (expr.arguments.length > 1) {
106
+ parser.hooks.hotAcceptCallback.call(
107
+ expr.arguments[1],
108
+ requests
109
+ );
110
+ parser.walkExpression(expr.arguments[1]); // other args are ignored
111
+ return true;
112
+ } else {
113
+ parser.hooks.hotAcceptWithoutCallback.call(expr, requests);
114
+ return true;
115
+ }
116
+ }
117
+ }
118
+ });
119
+ parser.hooks.call
120
+ .for("module.hot.decline")
121
+ .tap("HotModuleReplacementPlugin", expr => {
122
+ if (!parser.state.compilation.hotUpdateChunkTemplate) {
123
+ return false;
124
+ }
125
+ if (expr.arguments.length === 1) {
126
+ const arg = parser.evaluateExpression(expr.arguments[0]);
127
+ let params = [];
128
+ if (arg.isString()) {
129
+ params = [arg];
130
+ } else if (arg.isArray()) {
131
+ params = arg.items.filter(param => param.isString());
132
+ }
133
+ params.forEach((param, idx) => {
134
+ const dep = new ModuleHotDeclineDependency(
135
+ param.string,
136
+ param.range
137
+ );
138
+ dep.optional = true;
139
+ dep.loc = Object.create(expr.loc);
140
+ dep.loc.index = idx;
141
+ parser.state.module.addDependency(dep);
142
+ });
143
+ }
144
+ });
145
+ parser.hooks.expression
146
+ .for("module.hot")
147
+ .tap("HotModuleReplacementPlugin", ParserHelpers.skipTraversal);
148
+ };
149
+
38
150
  compiler.hooks.compilation.tap(
39
151
  "HotModuleReplacementPlugin",
40
152
  (compilation, { normalModuleFactory }) => {
@@ -275,127 +387,13 @@ module.exports = class HotModuleReplacementPlugin {
275
387
  }
276
388
  );
277
389
 
278
- const handler = (parser, parserOptions) => {
279
- parser.hooks.expression
280
- .for("__webpack_hash__")
281
- .tap(
282
- "HotModuleReplacementPlugin",
283
- ParserHelpers.toConstantDependencyWithWebpackRequire(
284
- parser,
285
- "__webpack_require__.h()"
286
- )
287
- );
288
- parser.hooks.evaluateTypeof
289
- .for("__webpack_hash__")
290
- .tap(
291
- "HotModuleReplacementPlugin",
292
- ParserHelpers.evaluateToString("string")
293
- );
294
- parser.hooks.evaluateIdentifier.for("module.hot").tap(
295
- {
296
- name: "HotModuleReplacementPlugin",
297
- before: "NodeStuffPlugin"
298
- },
299
- expr => {
300
- return ParserHelpers.evaluateToIdentifier(
301
- "module.hot",
302
- !!parser.state.compilation.hotUpdateChunkTemplate
303
- )(expr);
304
- }
305
- );
306
- // TODO webpack 5: refactor this, no custom hooks
307
- if (!parser.hooks.hotAcceptCallback) {
308
- parser.hooks.hotAcceptCallback = new SyncBailHook([
309
- "expression",
310
- "requests"
311
- ]);
312
- }
313
- if (!parser.hooks.hotAcceptWithoutCallback) {
314
- parser.hooks.hotAcceptWithoutCallback = new SyncBailHook([
315
- "expression",
316
- "requests"
317
- ]);
318
- }
319
- parser.hooks.call
320
- .for("module.hot.accept")
321
- .tap("HotModuleReplacementPlugin", expr => {
322
- if (!parser.state.compilation.hotUpdateChunkTemplate) {
323
- return false;
324
- }
325
- if (expr.arguments.length >= 1) {
326
- const arg = parser.evaluateExpression(expr.arguments[0]);
327
- let params = [];
328
- let requests = [];
329
- if (arg.isString()) {
330
- params = [arg];
331
- } else if (arg.isArray()) {
332
- params = arg.items.filter(param => param.isString());
333
- }
334
- if (params.length > 0) {
335
- params.forEach((param, idx) => {
336
- const request = param.string;
337
- const dep = new ModuleHotAcceptDependency(
338
- request,
339
- param.range
340
- );
341
- dep.optional = true;
342
- dep.loc = Object.create(expr.loc);
343
- dep.loc.index = idx;
344
- parser.state.module.addDependency(dep);
345
- requests.push(request);
346
- });
347
- if (expr.arguments.length > 1) {
348
- parser.hooks.hotAcceptCallback.call(
349
- expr.arguments[1],
350
- requests
351
- );
352
- parser.walkExpression(expr.arguments[1]); // other args are ignored
353
- return true;
354
- } else {
355
- parser.hooks.hotAcceptWithoutCallback.call(expr, requests);
356
- return true;
357
- }
358
- }
359
- }
360
- });
361
- parser.hooks.call
362
- .for("module.hot.decline")
363
- .tap("HotModuleReplacementPlugin", expr => {
364
- if (!parser.state.compilation.hotUpdateChunkTemplate) {
365
- return false;
366
- }
367
- if (expr.arguments.length === 1) {
368
- const arg = parser.evaluateExpression(expr.arguments[0]);
369
- let params = [];
370
- if (arg.isString()) {
371
- params = [arg];
372
- } else if (arg.isArray()) {
373
- params = arg.items.filter(param => param.isString());
374
- }
375
- params.forEach((param, idx) => {
376
- const dep = new ModuleHotDeclineDependency(
377
- param.string,
378
- param.range
379
- );
380
- dep.optional = true;
381
- dep.loc = Object.create(expr.loc);
382
- dep.loc.index = idx;
383
- parser.state.module.addDependency(dep);
384
- });
385
- }
386
- });
387
- parser.hooks.expression
388
- .for("module.hot")
389
- .tap("HotModuleReplacementPlugin", ParserHelpers.skipTraversal);
390
- };
391
-
392
390
  // TODO add HMR support for javascript/esm
393
391
  normalModuleFactory.hooks.parser
394
392
  .for("javascript/auto")
395
- .tap("HotModuleReplacementPlugin", handler);
393
+ .tap("HotModuleReplacementPlugin", addParserPlugins);
396
394
  normalModuleFactory.hooks.parser
397
395
  .for("javascript/dynamic")
398
- .tap("HotModuleReplacementPlugin", handler);
396
+ .tap("HotModuleReplacementPlugin", addParserPlugins);
399
397
 
400
398
  compilation.hooks.normalModuleLoader.tap(
401
399
  "HotModuleReplacementPlugin",
@@ -19,15 +19,17 @@ const {
19
19
  const Template = require("./Template");
20
20
 
21
21
  /** @typedef {import("webpack-sources").ConcatSource} ConcatSource */
22
+ /** @typedef {import("webpack-sources").Source} Source */
22
23
  /** @typedef {import("./ModuleTemplate")} ModuleTemplate */
23
24
  /** @typedef {import("./Chunk")} Chunk */
24
25
  /** @typedef {import("./Module")} Module} */
25
- /** @typedef {import("crypto").Hash} Hash} */
26
+ /** @typedef {import("./util/createHash").Hash} Hash} */
27
+ /** @typedef {import("./Dependency").DependencyTemplate} DependencyTemplate} */
26
28
 
27
29
  /**
28
30
  * @typedef {Object} RenderManifestOptions
29
31
  * @property {Chunk} chunk the chunk used to render
30
- * @property {Hash} hash
32
+ * @property {string} hash
31
33
  * @property {string} fullHash
32
34
  * @property {TODO} outputOptions
33
35
  * @property {{javascript: ModuleTemplate, webassembly: ModuleTemplate}} moduleTemplates
@@ -92,7 +94,9 @@ module.exports = class MainTemplate extends Tapable {
92
94
  localVars: new SyncWaterfallHook(["source", "chunk", "hash"]),
93
95
  require: new SyncWaterfallHook(["source", "chunk", "hash"]),
94
96
  requireExtensions: new SyncWaterfallHook(["source", "chunk", "hash"]),
97
+ /** @type {SyncWaterfallHook<string, Chunk, string>} */
95
98
  beforeStartup: new SyncWaterfallHook(["source", "chunk", "hash"]),
99
+ /** @type {SyncWaterfallHook<string, Chunk, string>} */
96
100
  startup: new SyncWaterfallHook(["source", "chunk", "hash"]),
97
101
  render: new SyncWaterfallHook([
98
102
  "source",
@@ -361,7 +365,7 @@ module.exports = class MainTemplate extends Tapable {
361
365
  * @param {string} hash hash to be used for render call
362
366
  * @param {Chunk} chunk Chunk instance
363
367
  * @param {ModuleTemplate} moduleTemplate ModuleTemplate instance for render
364
- * @param {TODO} dependencyTemplates DependencyTemplate[]s
368
+ * @param {Map<Function, DependencyTemplate>} dependencyTemplates dependency templates
365
369
  * @returns {ConcatSource} the newly generated source from rendering
366
370
  */
367
371
  render(hash, chunk, moduleTemplate, dependencyTemplates) {
@@ -447,7 +451,7 @@ module.exports = class MainTemplate extends Tapable {
447
451
  /**
448
452
  *
449
453
  * @param {string} hash string hash
450
- * @param {number} length length
454
+ * @param {number=} length length
451
455
  * @returns {string} call hook return
452
456
  */
453
457
  renderCurrentHashCode(hash, length) {
@@ -474,6 +478,11 @@ module.exports = class MainTemplate extends Tapable {
474
478
  return this.hooks.assetPath.call(path, options);
475
479
  }
476
480
 
481
+ /**
482
+ * Updates hash with information from this template
483
+ * @param {Hash} hash the hash to update
484
+ * @returns {void}
485
+ */
477
486
  updateHash(hash) {
478
487
  hash.update("maintemplate");
479
488
  hash.update("3");
@@ -481,6 +490,12 @@ module.exports = class MainTemplate extends Tapable {
481
490
  this.hooks.hash.call(hash);
482
491
  }
483
492
 
493
+ /**
494
+ * Updates hash with chunk-specific information from this template
495
+ * @param {Hash} hash the hash to update
496
+ * @param {Chunk} chunk the chunk
497
+ * @returns {void}
498
+ */
484
499
  updateHashForChunk(hash, chunk) {
485
500
  this.updateHash(hash);
486
501
  this.hooks.hashForChunk.call(hash, chunk);
package/lib/Module.js CHANGED
@@ -13,6 +13,7 @@ const Template = require("./Template");
13
13
 
14
14
  /** @typedef {import("./Chunk")} Chunk */
15
15
  /** @typedef {import("./RequestShortener")} RequestShortener */
16
+ /** @typedef {import("./WebpackError")} WebpackError */
16
17
 
17
18
  const EMPTY_RESOLVE_OPTIONS = {};
18
19
 
@@ -47,15 +48,15 @@ class Module extends DependenciesBlock {
47
48
  this.renderedHash = undefined;
48
49
 
49
50
  // Info from Factory
50
- /** @type {object} */
51
+ /** @type {TODO} */
51
52
  this.resolveOptions = EMPTY_RESOLVE_OPTIONS;
52
53
  /** @type {object} */
53
54
  this.factoryMeta = {};
54
55
 
55
56
  // Info from Build
56
- /** @type {Error[]} */
57
+ /** @type {WebpackError[]} */
57
58
  this.warnings = [];
58
- /** @type {Error[]} */
59
+ /** @type {WebpackError[]} */
59
60
  this.errors = [];
60
61
  /** @type {object} */
61
62
  this.buildMeta = undefined;
@@ -181,6 +182,9 @@ class Module extends DependenciesBlock {
181
182
  );
182
183
  }
183
184
 
185
+ /**
186
+ * @returns {Chunk[]} all chunks which contain the module
187
+ */
184
188
  getChunks() {
185
189
  return Array.from(this._chunks);
186
190
  }
@@ -380,6 +384,8 @@ Module.prototype.build = null;
380
384
  Module.prototype.source = null;
381
385
  Module.prototype.size = null;
382
386
  Module.prototype.nameForCondition = null;
387
+ /** @type {null | function(Chunk): boolean} */
388
+ Module.prototype.chunkCondition = null;
383
389
  Module.prototype.updateCacheModule = null;
384
390
 
385
391
  module.exports = Module;
@@ -4,7 +4,15 @@
4
4
  */
5
5
  "use strict";
6
6
 
7
+ /** @typedef {import("./Module")} Module */
8
+ /** @typedef {import("./Dependency")} Dependency */
9
+
7
10
  class ModuleReason {
11
+ /**
12
+ * @param {Module} module the referencing module
13
+ * @param {Dependency} dependency the referencing dependency
14
+ * @param {string=} explanation some extra detail
15
+ */
8
16
  constructor(module, dependency, explanation) {
9
17
  this.module = module;
10
18
  this.dependency = dependency;
@@ -8,13 +8,25 @@ const MultiEntryDependency = require("./dependencies/MultiEntryDependency");
8
8
  const SingleEntryDependency = require("./dependencies/SingleEntryDependency");
9
9
  const MultiModuleFactory = require("./MultiModuleFactory");
10
10
 
11
- module.exports = class MultiEntryPlugin {
11
+ /** @typedef {import("./Compiler")} Compiler */
12
+
13
+ class MultiEntryPlugin {
14
+ /**
15
+ * The MultiEntryPlugin is invoked whenever this.options.entry value is an array of paths
16
+ * @param {string} context context path
17
+ * @param {string[]} entries array of entry paths
18
+ * @param {string} name entry key name
19
+ */
12
20
  constructor(context, entries, name) {
13
21
  this.context = context;
14
22
  this.entries = entries;
15
23
  this.name = name;
16
24
  }
17
25
 
26
+ /**
27
+ * @param {Compiler} compiler the compiler instance
28
+ * @returns {void}
29
+ */
18
30
  apply(compiler) {
19
31
  compiler.hooks.compilation.tap(
20
32
  "MultiEntryPlugin",
@@ -43,16 +55,26 @@ module.exports = class MultiEntryPlugin {
43
55
  );
44
56
  }
45
57
 
58
+ /**
59
+ * @param {string[]} entries each entry path string
60
+ * @param {string} name name of the entry
61
+ * @returns {MultiEntryDependency} returns a constructed Dependency
62
+ */
46
63
  static createDependency(entries, name) {
47
64
  return new MultiEntryDependency(
48
65
  entries.map((e, idx) => {
49
66
  const dep = new SingleEntryDependency(e);
50
67
  // Because entrypoints are not dependencies found in an
51
68
  // existing module, we give it a synthetic id
52
- dep.loc = `${name}:${100000 + idx}`;
69
+ dep.loc = {
70
+ name,
71
+ index: idx
72
+ };
53
73
  return dep;
54
74
  }),
55
75
  name
56
76
  );
57
77
  }
58
- };
78
+ }
79
+
80
+ module.exports = MultiEntryPlugin;
@@ -4,7 +4,6 @@
4
4
  */
5
5
  "use strict";
6
6
 
7
- const path = require("path");
8
7
  const NativeModule = require("module");
9
8
 
10
9
  const {
@@ -23,6 +22,7 @@ const ModuleBuildError = require("./ModuleBuildError");
23
22
  const ModuleError = require("./ModuleError");
24
23
  const ModuleWarning = require("./ModuleWarning");
25
24
  const createHash = require("./util/createHash");
25
+ const contextify = require("./util/identifier").contextify;
26
26
 
27
27
  const asString = buf => {
28
28
  if (Buffer.isBuffer(buf)) {
@@ -38,28 +38,6 @@ const asBuffer = str => {
38
38
  return str;
39
39
  };
40
40
 
41
- const contextify = (context, request) => {
42
- return request
43
- .split("!")
44
- .map(r => {
45
- const splitPath = r.split("?");
46
- if (/^[a-zA-Z]:\\/.test(splitPath[0])) {
47
- splitPath[0] = path.win32.relative(context, splitPath[0]);
48
- if (!/^[a-zA-Z]:\\/.test(splitPath[0])) {
49
- splitPath[0] = splitPath[0].replace(/\\/g, "/");
50
- }
51
- }
52
- if (/^\//.test(splitPath[0])) {
53
- splitPath[0] = path.posix.relative(context, splitPath[0]);
54
- }
55
- if (!/^(\.\.\/|\/|[a-zA-Z]:\\)/.test(splitPath[0])) {
56
- splitPath[0] = "./" + splitPath[0];
57
- }
58
- return splitPath.join("?");
59
- })
60
- .join("!");
61
- };
62
-
63
41
  class NonErrorEmittedError extends WebpackError {
64
42
  constructor(error) {
65
43
  super();
@@ -191,6 +169,7 @@ class NormalModule extends Module {
191
169
  })
192
170
  );
193
171
  },
172
+ // TODO remove in webpack 5
194
173
  exec: (code, filename) => {
195
174
  // @ts-ignore Argument of type 'this' is not assignable to parameter of type 'Module'.
196
175
  const module = new NativeModule(filename, this);
@@ -265,6 +244,8 @@ class NormalModule extends Module {
265
244
  }
266
245
 
267
246
  if (Buffer.isBuffer(source)) {
247
+ // @ts-ignore
248
+ // TODO We need to fix @types/webpack-sources to allow RawSource to take a Buffer | string
268
249
  return new RawSource(source);
269
250
  }
270
251
 
@@ -486,6 +467,7 @@ class NormalModule extends Module {
486
467
  }
487
468
 
488
469
  getHashDigest(dependencyTemplates) {
470
+ // TODO webpack 5 refactor
489
471
  let dtHash = dependencyTemplates.get("hash");
490
472
  return `${this.hash}-${dtHash}`;
491
473
  }
package/lib/RuleSet.js CHANGED
@@ -75,13 +75,13 @@ normalized:
75
75
  "use strict";
76
76
 
77
77
  const notMatcher = matcher => {
78
- return function(str) {
78
+ return str => {
79
79
  return !matcher(str);
80
80
  };
81
81
  };
82
82
 
83
83
  const orMatcher = items => {
84
- return function(str) {
84
+ return str => {
85
85
  for (let i = 0; i < items.length; i++) {
86
86
  if (items[i](str)) return true;
87
87
  }
@@ -90,7 +90,7 @@ const orMatcher = items => {
90
90
  };
91
91
 
92
92
  const andMatcher = items => {
93
- return function(str) {
93
+ return str => {
94
94
  for (let i = 0; i < items.length; i++) {
95
95
  if (!items[i](str)) return false;
96
96
  }
@@ -5,13 +5,27 @@
5
5
  "use strict";
6
6
  const SingleEntryDependency = require("./dependencies/SingleEntryDependency");
7
7
 
8
+ /** @typedef {import("./Compiler")} Compiler */
9
+
8
10
  class SingleEntryPlugin {
11
+ /**
12
+ * An entry plugin which will handle
13
+ * creation of the SingleEntryDependency
14
+ *
15
+ * @param {string} context context path
16
+ * @param {string} entry entry path
17
+ * @param {string} name entry key name
18
+ */
9
19
  constructor(context, entry, name) {
10
20
  this.context = context;
11
21
  this.entry = entry;
12
22
  this.name = name;
13
23
  }
14
24
 
25
+ /**
26
+ * @param {Compiler} compiler the compiler instance
27
+ * @returns {void}
28
+ */
15
29
  apply(compiler) {
16
30
  compiler.hooks.compilation.tap(
17
31
  "SingleEntryPlugin",
package/lib/Stats.js CHANGED
@@ -108,10 +108,11 @@ class Stats {
108
108
  if (typeof item === "string") {
109
109
  const regExp = new RegExp(
110
110
  `[\\\\/]${item.replace(
111
+ // eslint-disable-next-line no-useless-escape
111
112
  /[-[\]{}()*+?.\\^$|]/g,
112
113
  "\\$&"
113
114
  )}([\\\\/]|$|!|\\?)`
114
- ); // eslint-disable-line no-useless-escape
115
+ );
115
116
  return ident => regExp.test(ident);
116
117
  }
117
118
  if (item && typeof item === "object" && typeof item.test === "function") {
package/lib/Template.js CHANGED
@@ -22,6 +22,8 @@ const COMMENT_END_REGEX = /\*\//g;
22
22
  const PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-zA-Z0-9_!§$()=\-^°]+/g;
23
23
  const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
24
24
 
25
+ /** @typedef {import("webpack-sources").Source} Source */
26
+
25
27
  /**
26
28
  * @typedef {Object} HasId
27
29
  * @property {number | string} id
@@ -230,6 +232,7 @@ class Template {
230
232
  source.add("[]");
231
233
  return source;
232
234
  }
235
+ /** @type {{id: string|number, source: Source|string}[]} */
233
236
  var allModules = modules.map(module => {
234
237
  return {
235
238
  id: module.id,
@@ -241,7 +244,7 @@ class Template {
241
244
  if (removedModules && removedModules.length > 0) {
242
245
  for (const id of removedModules) {
243
246
  allModules.push({
244
- id: id,
247
+ id,
245
248
  source: "false"
246
249
  });
247
250
  }
@@ -107,14 +107,14 @@ class UmdMainTemplatePlugin {
107
107
  requiredExternals = externals;
108
108
  }
109
109
 
110
- function replaceKeys(str) {
110
+ const replaceKeys = str => {
111
111
  return mainTemplate.getAssetPath(str, {
112
112
  hash,
113
113
  chunk
114
114
  });
115
- }
115
+ };
116
116
 
117
- function externalsDepsArray(modules) {
117
+ const externalsDepsArray = modules => {
118
118
  return `[${replaceKeys(
119
119
  modules
120
120
  .map(m =>
@@ -124,9 +124,9 @@ class UmdMainTemplatePlugin {
124
124
  )
125
125
  .join(", ")
126
126
  )}]`;
127
- }
127
+ };
128
128
 
129
- function externalsRootArray(modules) {
129
+ const externalsRootArray = modules => {
130
130
  return replaceKeys(
131
131
  modules
132
132
  .map(m => {
@@ -136,9 +136,9 @@ class UmdMainTemplatePlugin {
136
136
  })
137
137
  .join(", ")
138
138
  );
139
- }
139
+ };
140
140
 
141
- function externalsRequireArray(type) {
141
+ const externalsRequireArray = type => {
142
142
  return replaceKeys(
143
143
  externals
144
144
  .map(m => {
@@ -166,20 +166,20 @@ class UmdMainTemplatePlugin {
166
166
  })
167
167
  .join(", ")
168
168
  );
169
- }
169
+ };
170
170
 
171
- function externalsArguments(modules) {
171
+ const externalsArguments = modules => {
172
172
  return modules
173
173
  .map(
174
174
  m =>
175
175
  `__WEBPACK_EXTERNAL_MODULE_${Template.toIdentifier(`${m.id}`)}__`
176
176
  )
177
177
  .join(", ");
178
- }
178
+ };
179
179
 
180
- function libraryName(library) {
180
+ const libraryName = library => {
181
181
  return JSON.stringify(replaceKeys([].concat(library).pop()));
182
- }
182
+ };
183
183
 
184
184
  let amdFactory;
185
185
  if (optionalExternals.length > 0) {
@@ -13,6 +13,10 @@ class WebpackError extends Error {
13
13
  super(message);
14
14
 
15
15
  this.details = undefined;
16
+ this.missing = undefined;
17
+ this.origin = undefined;
18
+ this.dependencies = undefined;
19
+ this.module = undefined;
16
20
 
17
21
  Error.captureStackTrace(this, this.constructor);
18
22
  }
@@ -215,6 +215,9 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
215
215
  isProductionLikeMode(options)
216
216
  );
217
217
  this.set("optimization.splitChunks", {});
218
+ this.set("optimization.splitChunks.hidePathInfo", "make", options => {
219
+ return isProductionLikeMode(options);
220
+ });
218
221
  this.set("optimization.splitChunks.chunks", "async");
219
222
  this.set("optimization.splitChunks.minSize", "make", options => {
220
223
  return isProductionLikeMode(options) ? 30000 : 10000;