webpack 4.10.1 → 4.10.2

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 (87) hide show
  1. package/lib/AmdMainTemplatePlugin.js +3 -1
  2. package/lib/BannerPlugin.js +3 -1
  3. package/lib/BasicEvaluatedExpression.js +14 -11
  4. package/lib/CachePlugin.js +12 -5
  5. package/lib/Chunk.js +44 -16
  6. package/lib/ChunkGroup.js +13 -5
  7. package/lib/Compilation.js +70 -28
  8. package/lib/Compiler.js +22 -10
  9. package/lib/ConstPlugin.js +25 -9
  10. package/lib/ContextModule.js +88 -36
  11. package/lib/ContextModuleFactory.js +18 -7
  12. package/lib/ContextReplacementPlugin.js +14 -7
  13. package/lib/DefinePlugin.js +15 -6
  14. package/lib/DependenciesBlock.js +3 -1
  15. package/lib/DependenciesBlockVariable.js +2 -1
  16. package/lib/DllPlugin.js +4 -2
  17. package/lib/DynamicEntryPlugin.js +4 -2
  18. package/lib/ErrorHelpers.js +5 -2
  19. package/lib/EvalSourceMapDevToolPlugin.js +2 -1
  20. package/lib/FlagDependencyUsagePlugin.js +11 -5
  21. package/lib/FunctionModuleTemplatePlugin.js +8 -6
  22. package/lib/HotModuleReplacement.runtime.js +7 -3
  23. package/lib/HotModuleReplacementPlugin.js +13 -6
  24. package/lib/JavascriptGenerator.js +2 -1
  25. package/lib/JavascriptModulesPlugin.js +4 -9
  26. package/lib/JsonParser.js +2 -1
  27. package/lib/LibraryTemplatePlugin.js +2 -1
  28. package/lib/LoaderOptionsPlugin.js +2 -1
  29. package/lib/MainTemplate.js +2 -1
  30. package/lib/Module.js +9 -5
  31. package/lib/ModuleFilenameHelpers.js +20 -8
  32. package/lib/MultiCompiler.js +19 -7
  33. package/lib/MultiModule.js +5 -2
  34. package/lib/NodeStuffPlugin.js +2 -1
  35. package/lib/NormalModule.js +11 -4
  36. package/lib/NormalModuleFactory.js +30 -12
  37. package/lib/OptionsDefaulter.js +7 -3
  38. package/lib/Parser.js +137 -59
  39. package/lib/ParserHelpers.js +5 -2
  40. package/lib/ProgressPlugin.js +2 -2
  41. package/lib/RawModule.js +4 -2
  42. package/lib/RecordIdsPlugin.js +11 -7
  43. package/lib/RequestShortener.js +13 -6
  44. package/lib/RuleSet.js +39 -18
  45. package/lib/RuntimeTemplate.js +21 -10
  46. package/lib/SourceMapDevToolPlugin.js +4 -3
  47. package/lib/Stats.js +64 -28
  48. package/lib/Template.js +4 -2
  49. package/lib/TemplatedPathPlugin.js +6 -3
  50. package/lib/UmdMainTemplatePlugin.js +8 -3
  51. package/lib/WarnCaseSensitiveModulesPlugin.js +2 -1
  52. package/lib/Watching.js +3 -2
  53. package/lib/WebpackOptionsApply.js +32 -16
  54. package/lib/WebpackOptionsDefaulter.js +7 -4
  55. package/lib/WebpackOptionsValidationError.js +48 -19
  56. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +17 -8
  57. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +6 -3
  58. package/lib/dependencies/HarmonyDetectionParserPlugin.js +4 -2
  59. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +7 -3
  60. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +6 -3
  61. package/lib/dependencies/ImportParserPlugin.js +2 -1
  62. package/lib/dependencies/LoaderPlugin.js +12 -7
  63. package/lib/dependencies/LocalModulesHelpers.js +13 -6
  64. package/lib/dependencies/RequireContextPlugin.js +4 -2
  65. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +8 -4
  66. package/lib/formatLocation.js +15 -7
  67. package/lib/node/NodeMainTemplateAsync.runtime.js +1 -1
  68. package/lib/node/NodeMainTemplatePlugin.js +6 -3
  69. package/lib/node/NodeSourcePlugin.js +9 -5
  70. package/lib/node/NodeWatchFileSystem.js +29 -12
  71. package/lib/optimize/AggressiveSplittingPlugin.js +12 -6
  72. package/lib/optimize/ConcatenatedModule.js +19 -8
  73. package/lib/optimize/MergeDuplicateChunksPlugin.js +6 -3
  74. package/lib/optimize/ModuleConcatenationPlugin.js +23 -10
  75. package/lib/optimize/OccurrenceOrderPlugin.js +11 -4
  76. package/lib/optimize/RemoveParentModulesPlugin.js +17 -7
  77. package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
  78. package/lib/optimize/SplitChunksPlugin.js +33 -20
  79. package/lib/util/SortableSet.js +5 -2
  80. package/lib/util/StackedSetMap.js +12 -5
  81. package/lib/wasm/WasmMainTemplatePlugin.js +4 -2
  82. package/lib/wasm/WebAssemblyGenerator.js +7 -0
  83. package/lib/web/JsonpMainTemplate.runtime.js +2 -1
  84. package/lib/web/JsonpMainTemplatePlugin.js +2 -1
  85. package/lib/webpack.js +2 -1
  86. package/lib/webworker/WebWorkerMainTemplate.runtime.js +2 -1
  87. package/package.json +9 -9
package/lib/RuleSet.js CHANGED
@@ -117,7 +117,7 @@ module.exports = class RuleSet {
117
117
  }
118
118
 
119
119
  static normalizeRule(rule, refs, ident) {
120
- if (typeof rule === "string")
120
+ if (typeof rule === "string") {
121
121
  return {
122
122
  use: [
123
123
  {
@@ -125,9 +125,11 @@ module.exports = class RuleSet {
125
125
  }
126
126
  ]
127
127
  };
128
- if (!rule)
128
+ }
129
+ if (!rule) {
129
130
  throw new Error("Unexcepted null when object was expected as rule");
130
- if (typeof rule !== "object")
131
+ }
132
+ if (typeof rule !== "object") {
131
133
  throw new Error(
132
134
  "Unexcepted " +
133
135
  typeof rule +
@@ -135,6 +137,7 @@ module.exports = class RuleSet {
135
137
  rule +
136
138
  ")"
137
139
  );
140
+ }
138
141
 
139
142
  const newRule = {};
140
143
  let useSource;
@@ -142,7 +145,7 @@ module.exports = class RuleSet {
142
145
  let condition;
143
146
 
144
147
  const checkUseSource = newSource => {
145
- if (useSource && useSource !== newSource)
148
+ if (useSource && useSource !== newSource) {
146
149
  throw new Error(
147
150
  RuleSet.buildErrorMessage(
148
151
  rule,
@@ -155,11 +158,12 @@ module.exports = class RuleSet {
155
158
  )
156
159
  )
157
160
  );
161
+ }
158
162
  useSource = newSource;
159
163
  };
160
164
 
161
165
  const checkResourceSource = newSource => {
162
- if (resourceSource && resourceSource !== newSource)
166
+ if (resourceSource && resourceSource !== newSource) {
163
167
  throw new Error(
164
168
  RuleSet.buildErrorMessage(
165
169
  rule,
@@ -172,6 +176,7 @@ module.exports = class RuleSet {
172
176
  )
173
177
  )
174
178
  );
179
+ }
175
180
  resourceSource = newSource;
176
181
  };
177
182
 
@@ -222,7 +227,7 @@ module.exports = class RuleSet {
222
227
  }
223
228
  }
224
229
 
225
- if (rule.loader && rule.loaders)
230
+ if (rule.loader && rule.loaders) {
226
231
  throw new Error(
227
232
  RuleSet.buildErrorMessage(
228
233
  rule,
@@ -231,6 +236,7 @@ module.exports = class RuleSet {
231
236
  )
232
237
  )
233
238
  );
239
+ }
234
240
 
235
241
  const loader = rule.loaders || rule.loader;
236
242
  if (typeof loader === "string" && !rule.options && !rule.query) {
@@ -274,19 +280,21 @@ module.exports = class RuleSet {
274
280
  newRule.use = RuleSet.normalizeUse(rule.use, ident);
275
281
  }
276
282
 
277
- if (rule.rules)
283
+ if (rule.rules) {
278
284
  newRule.rules = RuleSet.normalizeRules(
279
285
  rule.rules,
280
286
  refs,
281
287
  `${ident}-rules`
282
288
  );
289
+ }
283
290
 
284
- if (rule.oneOf)
291
+ if (rule.oneOf) {
285
292
  newRule.oneOf = RuleSet.normalizeRules(
286
293
  rule.oneOf,
287
294
  refs,
288
295
  `${ident}-oneOf`
289
296
  );
297
+ }
290
298
 
291
299
  const keys = Object.keys(rule).filter(key => {
292
300
  return ![
@@ -365,16 +373,22 @@ module.exports = class RuleSet {
365
373
 
366
374
  const newItem = {};
367
375
 
368
- if (item.options && item.query)
376
+ if (item.options && item.query) {
369
377
  throw new Error("Provided options and query in use");
378
+ }
370
379
 
371
- if (!item.loader) throw new Error("No loader specified");
380
+ if (!item.loader) {
381
+ throw new Error("No loader specified");
382
+ }
372
383
 
373
384
  newItem.options = item.options || item.query;
374
385
 
375
386
  if (typeof newItem.options === "object" && newItem.options) {
376
- if (newItem.options.ident) newItem.ident = newItem.options.ident;
377
- else newItem.ident = ident;
387
+ if (newItem.options.ident) {
388
+ newItem.ident = newItem.options.ident;
389
+ } else {
390
+ newItem.ident = ident;
391
+ }
378
392
  }
379
393
 
380
394
  const keys = Object.keys(item).filter(function(key) {
@@ -403,7 +417,7 @@ module.exports = class RuleSet {
403
417
  const items = condition.map(c => RuleSet.normalizeCondition(c));
404
418
  return orMatcher(items);
405
419
  }
406
- if (typeof condition !== "object")
420
+ if (typeof condition !== "object") {
407
421
  throw Error(
408
422
  "Unexcepted " +
409
423
  typeof condition +
@@ -411,6 +425,7 @@ module.exports = class RuleSet {
411
425
  condition +
412
426
  ")"
413
427
  );
428
+ }
414
429
 
415
430
  const matchers = [];
416
431
  Object.keys(condition).forEach(key => {
@@ -438,9 +453,12 @@ module.exports = class RuleSet {
438
453
  throw new Error("Unexcepted property " + key + " in condition");
439
454
  }
440
455
  });
441
- if (matchers.length === 0)
456
+ if (matchers.length === 0) {
442
457
  throw new Error("Excepted condition but got " + condition);
443
- if (matchers.length === 1) return matchers[0];
458
+ }
459
+ if (matchers.length === 1) {
460
+ return matchers[0];
461
+ }
444
462
  return andMatcher(matchers);
445
463
  }
446
464
 
@@ -468,10 +486,12 @@ module.exports = class RuleSet {
468
486
  data.resourceQuery &&
469
487
  rule.resourceQuery &&
470
488
  !rule.resourceQuery(data.resourceQuery)
471
- )
489
+ ) {
472
490
  return false;
473
- if (data.compiler && rule.compiler && !rule.compiler(data.compiler))
491
+ }
492
+ if (data.compiler && rule.compiler && !rule.compiler(data.compiler)) {
474
493
  return false;
494
+ }
475
495
 
476
496
  // apply
477
497
  const keys = Object.keys(rule).filter(key => {
@@ -527,8 +547,9 @@ module.exports = class RuleSet {
527
547
 
528
548
  findOptionsByIdent(ident) {
529
549
  const options = this.references[ident];
530
- if (!options)
550
+ if (!options) {
531
551
  throw new Error("Can't find options with ident '" + ident + "'");
552
+ }
532
553
  return options;
533
554
  }
534
555
  };
@@ -79,10 +79,11 @@ module.exports = class RuntimeTemplate {
79
79
  }
80
80
 
81
81
  moduleRaw({ module, request }) {
82
- if (!module)
82
+ if (!module) {
83
83
  return this.missingModule({
84
84
  request
85
85
  });
86
+ }
86
87
  return `__webpack_require__(${this.moduleId({ module, request })})`;
87
88
  }
88
89
 
@@ -94,10 +95,11 @@ module.exports = class RuntimeTemplate {
94
95
  }
95
96
 
96
97
  moduleNamespace({ module, request, strict }) {
97
- if (!module)
98
+ if (!module) {
98
99
  return this.missingModule({
99
100
  request
100
101
  });
102
+ }
101
103
  const moduleId = this.moduleId({
102
104
  module,
103
105
  request
@@ -205,10 +207,11 @@ module.exports = class RuntimeTemplate {
205
207
  content += `/* harmony import */ ${optDeclaration}${importVar}_default = /*#__PURE__*/__webpack_require__.n(${importVar});\n`;
206
208
  }
207
209
  if (exportsType === "named") {
208
- if (Array.isArray(module.buildMeta.providedExports))
210
+ if (Array.isArray(module.buildMeta.providedExports)) {
209
211
  content += `${optDeclaration}${importVar}_namespace = /*#__PURE__*/__webpack_require__.t(${moduleId}, 1);\n`;
210
- else
212
+ } else {
211
213
  content += `${optDeclaration}${importVar}_namespace = /*#__PURE__*/__webpack_require__.t(${moduleId});\n`;
214
+ }
212
215
  }
213
216
  return content;
214
217
  }
@@ -223,18 +226,23 @@ module.exports = class RuntimeTemplate {
223
226
  callContext,
224
227
  importVar
225
228
  }) {
226
- if (!module)
229
+ if (!module) {
227
230
  return this.missingModule({
228
231
  request
229
232
  });
233
+ }
230
234
  const exportsType = module.buildMeta && module.buildMeta.exportsType;
231
235
 
232
236
  if (!exportsType) {
233
237
  if (exportName === "default") {
234
238
  if (!originModule.buildMeta.strictHarmonyModule) {
235
- if (isCall) return `${importVar}_default()`;
236
- else if (asiSafe) return `(${importVar}_default())`;
237
- else return `${importVar}_default.a`;
239
+ if (isCall) {
240
+ return `${importVar}_default()`;
241
+ } else if (asiSafe) {
242
+ return `(${importVar}_default())`;
243
+ } else {
244
+ return `${importVar}_default.a`;
245
+ }
238
246
  } else {
239
247
  return importVar;
240
248
  }
@@ -261,8 +269,11 @@ module.exports = class RuntimeTemplate {
261
269
  used !== exportName ? Template.toNormalComment(exportName) + " " : "";
262
270
  const access = `${importVar}[${comment}${JSON.stringify(used)}]`;
263
271
  if (isCall) {
264
- if (callContext === false && asiSafe) return `(0,${access})`;
265
- else if (callContext === false) return `Object(${access})`;
272
+ if (callContext === false && asiSafe) {
273
+ return `(0,${access})`;
274
+ } else if (callContext === false) {
275
+ return `Object(${access})`;
276
+ }
266
277
  }
267
278
  return access;
268
279
  } else {
@@ -53,10 +53,11 @@ const getTaskForFile = (file, chunk, options, compilation) => {
53
53
 
54
54
  class SourceMapDevToolPlugin {
55
55
  constructor(options) {
56
- if (arguments.length > 1)
56
+ if (arguments.length > 1) {
57
57
  throw new Error(
58
58
  "SourceMapDevToolPlugin only takes one argument (pass an options object)"
59
59
  );
60
+ }
60
61
 
61
62
  validateOptions(schema, options || {}, "SourceMap DevTool Plugin");
62
63
 
@@ -121,7 +122,7 @@ class SourceMapDevToolPlugin {
121
122
  const tasks = [];
122
123
  files.forEach(({ file, chunk }, idx) => {
123
124
  reportProgress(
124
- 0.5 * idx / files.length,
125
+ (0.5 * idx) / files.length,
125
126
  file,
126
127
  "generate SourceMap"
127
128
  );
@@ -205,7 +206,7 @@ class SourceMapDevToolPlugin {
205
206
  }
206
207
  tasks.forEach((task, index) => {
207
208
  reportProgress(
208
- 0.5 + 0.5 * index / tasks.length,
209
+ 0.5 + (0.5 * index) / tasks.length,
209
210
  task.file,
210
211
  "attach SourceMap"
211
212
  );
package/lib/Stats.js CHANGED
@@ -114,10 +114,15 @@ class Stats {
114
114
  ); // eslint-disable-line no-useless-escape
115
115
  return ident => regExp.test(ident);
116
116
  }
117
- if (item && typeof item === "object" && typeof item.test === "function")
117
+ if (item && typeof item === "object" && typeof item.test === "function") {
118
118
  return ident => item.test(ident);
119
- if (typeof item === "function") return item;
120
- if (typeof item === "boolean") return () => item;
119
+ }
120
+ if (typeof item === "function") {
121
+ return item;
122
+ }
123
+ if (typeof item === "boolean") {
124
+ return () => item;
125
+ }
121
126
  };
122
127
 
123
128
  const compilation = this.compilation;
@@ -260,10 +265,9 @@ class Stats {
260
265
 
261
266
  const formatError = e => {
262
267
  let text = "";
263
- if (typeof e === "string")
264
- e = {
265
- message: e
266
- };
268
+ if (typeof e === "string") {
269
+ e = { message: e };
270
+ }
267
271
  if (e.chunk) {
268
272
  text += `chunk ${e.chunk.name || e.chunk.id}${
269
273
  e.chunk.hasRuntime()
@@ -286,9 +290,12 @@ class Stats {
286
290
  );
287
291
  }
288
292
  text += e.message;
289
- if (showErrorDetails && e.details) text += `\n${e.details}`;
290
- if (showErrorDetails && e.missing)
293
+ if (showErrorDetails && e.details) {
294
+ text += `\n${e.details}`;
295
+ }
296
+ if (showErrorDetails && e.missing) {
291
297
  text += e.missing.map(item => `\n[${item}]`).join("");
298
+ }
292
299
  if (showModuleTrace && e.origin) {
293
300
  text += `\n @ ${e.origin.readableIdentifier(requestShortener)}`;
294
301
  if (typeof e.originLoc === "object") {
@@ -392,11 +399,13 @@ class Stats {
392
399
  }
393
400
  if (chunk.name) {
394
401
  assetsByFile[asset].chunkNames.push(chunk.name);
395
- if (obj.assetsByChunkName[chunk.name])
402
+ if (obj.assetsByChunkName[chunk.name]) {
396
403
  obj.assetsByChunkName[chunk.name] = []
397
404
  .concat(obj.assetsByChunkName[chunk.name])
398
405
  .concat([asset]);
399
- else obj.assetsByChunkName[chunk.name] = asset;
406
+ } else {
407
+ obj.assetsByChunkName[chunk.name] = asset;
408
+ }
400
409
  }
401
410
  }
402
411
  }
@@ -520,15 +529,20 @@ class Stats {
520
529
  };
521
530
  if (reason.dependency) {
522
531
  const locInfo = formatLocation(reason.dependency.loc);
523
- if (locInfo) obj.loc = locInfo;
532
+ if (locInfo) {
533
+ obj.loc = locInfo;
534
+ }
524
535
  }
525
536
  return obj;
526
537
  })
527
538
  .sort((a, b) => a.moduleId - b.moduleId);
528
539
  }
529
540
  if (showUsedExports) {
530
- if (module.used === true) obj.usedExports = module.usedExports;
531
- else if (module.used === false) obj.usedExports = false;
541
+ if (module.used === true) {
542
+ obj.usedExports = module.usedExports;
543
+ } else if (module.used === false) {
544
+ obj.usedExports = false;
545
+ }
532
546
  }
533
547
  if (showProvidedExports) {
534
548
  obj.providedExports = Array.isArray(module.buildMeta.providedExports)
@@ -662,12 +676,13 @@ class Stats {
662
676
  const obj = new Stats(child).toJson(childOptions, forToString);
663
677
  delete obj.hash;
664
678
  delete obj.version;
665
- if (child.name)
679
+ if (child.name) {
666
680
  obj.name = identifierUtils.makePathsRelative(
667
681
  context,
668
682
  child.name,
669
683
  compilation.cache
670
684
  );
685
+ }
671
686
  return obj;
672
687
  });
673
688
  }
@@ -745,7 +760,9 @@ class Stats {
745
760
  const rows = array.length;
746
761
  const cols = array[0].length;
747
762
  const colSizes = new Array(cols);
748
- for (let col = 0; col < cols; col++) colSizes[col] = 0;
763
+ for (let col = 0; col < cols; col++) {
764
+ colSizes[col] = 0;
765
+ }
749
766
  for (let row = 0; row < rows; row++) {
750
767
  for (let col = 0; col < cols; col++) {
751
768
  const value = `${getText(array, row, col)}`;
@@ -759,11 +776,18 @@ class Stats {
759
776
  const format = array[row][col].color;
760
777
  const value = `${getText(array, row, col)}`;
761
778
  let l = value.length;
762
- if (align[col] === "l") format(value);
763
- for (; l < colSizes[col] && col !== cols - 1; l++) colors.normal(" ");
764
- if (align[col] === "r") format(value);
765
- if (col + 1 < cols && colSizes[col] !== 0)
779
+ if (align[col] === "l") {
780
+ format(value);
781
+ }
782
+ for (; l < colSizes[col] && col !== cols - 1; l++) {
783
+ colors.normal(" ");
784
+ }
785
+ if (align[col] === "r") {
786
+ format(value);
787
+ }
788
+ if (col + 1 < cols && colSizes[col] !== 0) {
766
789
  colors.normal(splitter || " ");
790
+ }
767
791
  }
768
792
  newline();
769
793
  }
@@ -981,21 +1005,26 @@ class Stats {
981
1005
  colors.magenta(" [prefetched]");
982
1006
  }
983
1007
  if (module.failed) colors.red(" [failed]");
984
- if (module.warnings)
1008
+ if (module.warnings) {
985
1009
  colors.yellow(
986
1010
  ` [${module.warnings} warning${module.warnings === 1 ? "" : "s"}]`
987
1011
  );
988
- if (module.errors)
1012
+ }
1013
+ if (module.errors) {
989
1014
  colors.red(
990
1015
  ` [${module.errors} error${module.errors === 1 ? "" : "s"}]`
991
1016
  );
1017
+ }
992
1018
  };
993
1019
 
994
1020
  const processModuleContent = (module, prefix) => {
995
1021
  if (Array.isArray(module.providedExports)) {
996
1022
  colors.normal(prefix);
997
- if (module.providedExports.length === 0) colors.cyan("[no exports]");
998
- else colors.cyan(`[exports: ${module.providedExports.join(", ")}]`);
1023
+ if (module.providedExports.length === 0) {
1024
+ colors.cyan("[no exports]");
1025
+ } else {
1026
+ colors.cyan(`[exports: ${module.providedExports.join(", ")}]`);
1027
+ }
999
1028
  newline();
1000
1029
  }
1001
1030
  if (module.usedExports !== undefined) {
@@ -1285,7 +1314,9 @@ class Stats {
1285
1314
  );
1286
1315
  }
1287
1316
 
1288
- while (buf[buf.length - 1] === "\n") buf.pop();
1317
+ while (buf[buf.length - 1] === "\n") {
1318
+ buf.pop();
1319
+ }
1289
1320
  return buf.join("");
1290
1321
  }
1291
1322
 
@@ -1356,13 +1387,18 @@ class Stats {
1356
1387
  static getChildOptions(options, idx) {
1357
1388
  let innerOptions;
1358
1389
  if (Array.isArray(options.children)) {
1359
- if (idx < options.children.length) innerOptions = options.children[idx];
1390
+ if (idx < options.children.length) {
1391
+ innerOptions = options.children[idx];
1392
+ }
1360
1393
  } else if (typeof options.children === "object" && options.children) {
1361
1394
  innerOptions = options.children;
1362
1395
  }
1363
- if (typeof innerOptions === "boolean" || typeof innerOptions === "string")
1396
+ if (typeof innerOptions === "boolean" || typeof innerOptions === "string") {
1364
1397
  innerOptions = Stats.presetToOptions(innerOptions);
1365
- if (!innerOptions) return options;
1398
+ }
1399
+ if (!innerOptions) {
1400
+ return options;
1401
+ }
1366
1402
  const childOptions = Object.assign({}, options);
1367
1403
  delete childOptions.children; // do not inherit children
1368
1404
  return Object.assign(childOptions, innerOptions);
package/lib/Template.js CHANGED
@@ -114,13 +114,15 @@ class Template {
114
114
  */
115
115
  static numberToIdentifer(n) {
116
116
  // lower case
117
- if (n < DELTA_A_TO_Z)
117
+ if (n < DELTA_A_TO_Z) {
118
118
  return String.fromCharCode(START_LOWERCASE_ALPHABET_CODE + n);
119
+ }
119
120
 
120
121
  // upper case
121
122
  n -= DELTA_A_TO_Z;
122
- if (n < DELTA_A_TO_Z)
123
+ if (n < DELTA_A_TO_Z) {
123
124
  return String.fromCharCode(START_UPPERCASE_ALPHABET_CODE + n);
125
+ }
124
126
 
125
127
  // use multiple letters
126
128
  return (
@@ -39,10 +39,11 @@ const getReplacer = (value, allowEmpty) => {
39
39
  // last argument in replacer is the entire input string
40
40
  const input = args[args.length - 1];
41
41
  if (value === null || value === undefined) {
42
- if (!allowEmpty)
42
+ if (!allowEmpty) {
43
43
  throw new Error(
44
44
  `Path variable ${match} not implemented in this context: ${input}`
45
45
  );
46
+ }
46
47
  return "";
47
48
  } else {
48
49
  return `${value}`;
@@ -150,8 +151,9 @@ class TemplatedPathPlugin {
150
151
  const outputOptions = mainTemplate.outputOptions;
151
152
  const chunkFilename =
152
153
  outputOptions.chunkFilename || outputOptions.filename;
153
- if (REGEXP_CHUNKHASH_FOR_TEST.test(chunkFilename))
154
+ if (REGEXP_CHUNKHASH_FOR_TEST.test(chunkFilename)) {
154
155
  hash.update(JSON.stringify(chunk.getChunkMaps(true).hash));
156
+ }
155
157
  if (REGEXP_CONTENTHASH_FOR_TEST.test(chunkFilename)) {
156
158
  hash.update(
157
159
  JSON.stringify(
@@ -159,8 +161,9 @@ class TemplatedPathPlugin {
159
161
  )
160
162
  );
161
163
  }
162
- if (REGEXP_NAME_FOR_TEST.test(chunkFilename))
164
+ if (REGEXP_NAME_FOR_TEST.test(chunkFilename)) {
163
165
  hash.update(JSON.stringify(chunk.getChunkMaps(true).name));
166
+ }
164
167
  }
165
168
  );
166
169
  });
@@ -144,16 +144,21 @@ class UmdMainTemplatePlugin {
144
144
  .map(m => {
145
145
  let expr;
146
146
  let request = m.request;
147
- if (typeof request === "object") request = request[type];
148
- if (typeof request === "undefined")
147
+ if (typeof request === "object") {
148
+ request = request[type];
149
+ }
150
+ if (typeof request === "undefined") {
149
151
  throw new Error(
150
152
  "Missing external configuration for type:" + type
151
153
  );
154
+ }
152
155
  if (Array.isArray(request)) {
153
156
  expr = `require(${JSON.stringify(
154
157
  request[0]
155
158
  )})${accessorToObjectAccess(request.slice(1))}`;
156
- } else expr = `require(${JSON.stringify(request)})`;
159
+ } else {
160
+ expr = `require(${JSON.stringify(request)})`;
161
+ }
157
162
  if (m.optional) {
158
163
  expr = `(function webpackLoadOptionalExternalModule() { try { return ${expr}; } catch(e) {} }())`;
159
164
  }
@@ -24,8 +24,9 @@ class WarnCaseSensitiveModulesPlugin {
24
24
  }
25
25
  for (const pair of moduleWithoutCase) {
26
26
  const array = pair[1];
27
- if (array.length > 1)
27
+ if (array.length > 1) {
28
28
  compilation.warnings.push(new CaseSensitiveModulesWarning(array));
29
+ }
29
30
  }
30
31
  });
31
32
  }
package/lib/Watching.js CHANGED
@@ -128,8 +128,9 @@ class Watching {
128
128
  ) => {
129
129
  this.pausedWatcher = this.watcher;
130
130
  this.watcher = null;
131
- if (err) return this.handler(err);
132
-
131
+ if (err) {
132
+ return this.handler(err);
133
+ }
133
134
  this.compiler.fileTimestamps = fileTimestamps;
134
135
  this.compiler.contextTimestamps = contextTimestamps;
135
136
  this._invalidate();
@@ -298,38 +298,53 @@ class WebpackOptionsApply extends OptionsApply {
298
298
  new ImportPlugin(options.module).apply(compiler);
299
299
  new SystemPlugin(options.module).apply(compiler);
300
300
 
301
- if (typeof options.mode !== "string")
301
+ if (typeof options.mode !== "string") {
302
302
  new WarnNoModeSetPlugin().apply(compiler);
303
+ }
303
304
 
304
305
  new EnsureChunkConditionsPlugin().apply(compiler);
305
- if (options.optimization.removeAvailableModules)
306
+ if (options.optimization.removeAvailableModules) {
306
307
  new RemoveParentModulesPlugin().apply(compiler);
307
- if (options.optimization.removeEmptyChunks)
308
+ }
309
+ if (options.optimization.removeEmptyChunks) {
308
310
  new RemoveEmptyChunksPlugin().apply(compiler);
309
- if (options.optimization.mergeDuplicateChunks)
311
+ }
312
+ if (options.optimization.mergeDuplicateChunks) {
310
313
  new MergeDuplicateChunksPlugin().apply(compiler);
311
- if (options.optimization.flagIncludedChunks)
314
+ }
315
+ if (options.optimization.flagIncludedChunks) {
312
316
  new FlagIncludedChunksPlugin().apply(compiler);
313
- if (options.optimization.occurrenceOrder)
317
+ }
318
+ if (options.optimization.occurrenceOrder) {
314
319
  new OccurrenceOrderPlugin(true).apply(compiler);
315
- if (options.optimization.sideEffects)
320
+ }
321
+ if (options.optimization.sideEffects) {
316
322
  new SideEffectsFlagPlugin().apply(compiler);
317
- if (options.optimization.providedExports)
323
+ }
324
+ if (options.optimization.providedExports) {
318
325
  new FlagDependencyExportsPlugin().apply(compiler);
319
- if (options.optimization.usedExports)
326
+ }
327
+ if (options.optimization.usedExports) {
320
328
  new FlagDependencyUsagePlugin().apply(compiler);
321
- if (options.optimization.concatenateModules)
329
+ }
330
+ if (options.optimization.concatenateModules) {
322
331
  new ModuleConcatenationPlugin().apply(compiler);
323
- if (options.optimization.splitChunks)
332
+ }
333
+ if (options.optimization.splitChunks) {
324
334
  new SplitChunksPlugin(options.optimization.splitChunks).apply(compiler);
325
- if (options.optimization.runtimeChunk)
335
+ }
336
+ if (options.optimization.runtimeChunk) {
326
337
  new RuntimeChunkPlugin(options.optimization.runtimeChunk).apply(compiler);
327
- if (options.optimization.noEmitOnErrors)
338
+ }
339
+ if (options.optimization.noEmitOnErrors) {
328
340
  new NoEmitOnErrorsPlugin().apply(compiler);
329
- if (options.optimization.namedModules)
341
+ }
342
+ if (options.optimization.namedModules) {
330
343
  new NamedModulesPlugin().apply(compiler);
331
- if (options.optimization.namedChunks)
344
+ }
345
+ if (options.optimization.namedChunks) {
332
346
  new NamedChunksPlugin().apply(compiler);
347
+ }
333
348
  if (options.optimization.nodeEnv) {
334
349
  new DefinePlugin({
335
350
  "process.env.NODE_ENV": JSON.stringify(options.optimization.nodeEnv)
@@ -361,8 +376,9 @@ class WebpackOptionsApply extends OptionsApply {
361
376
  }
362
377
 
363
378
  compiler.hooks.afterPlugins.call(compiler);
364
- if (!compiler.inputFileSystem)
379
+ if (!compiler.inputFileSystem) {
365
380
  throw new Error("No input filesystem provided");
381
+ }
366
382
  compiler.resolverFactory.hooks.resolveOptions
367
383
  .for("normal")
368
384
  .tap("WebpackOptionsApply", resolveOptions => {