webpack 4.29.3 → 4.30.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.
@@ -246,11 +246,13 @@ export type FilterItemTypes = RegExp | string | Function;
246
246
 
247
247
  export interface WebpackOptions {
248
248
  /**
249
- * Set the value of `require.amd` and `define.amd`.
249
+ * Set the value of `require.amd` and `define.amd`. Or disable AMD support.
250
250
  */
251
- amd?: {
252
- [k: string]: any;
253
- };
251
+ amd?:
252
+ | false
253
+ | {
254
+ [k: string]: any;
255
+ };
254
256
  /**
255
257
  * Report the first error as a hard error instead of tolerating it.
256
258
  */
@@ -1120,7 +1122,8 @@ export interface OutputOptions {
1120
1122
  | "amd-require"
1121
1123
  | "umd"
1122
1124
  | "umd2"
1123
- | "jsonp";
1125
+ | "jsonp"
1126
+ | "system";
1124
1127
  /**
1125
1128
  * The output directory as **absolute path** (required).
1126
1129
  */
package/lib/APIPlugin.js CHANGED
@@ -58,12 +58,12 @@ class APIPlugin {
58
58
  REPLACEMENTS[key]
59
59
  )
60
60
  );
61
- parser.hooks.evaluateTypeof
62
- .for(key)
63
- .tap(
64
- "APIPlugin",
65
- ParserHelpers.evaluateToString(REPLACEMENT_TYPES[key])
66
- );
61
+ const type = REPLACEMENT_TYPES[key];
62
+ if (type) {
63
+ parser.hooks.evaluateTypeof
64
+ .for(key)
65
+ .tap("APIPlugin", ParserHelpers.evaluateToString(type));
66
+ }
67
67
  });
68
68
  };
69
69
 
package/lib/Chunk.js CHANGED
@@ -517,7 +517,7 @@ class Chunk {
517
517
  * @param {Object} options the size display options
518
518
  * @returns {number} the chunk size
519
519
  */
520
- size(options) {
520
+ size(options = {}) {
521
521
  return this.addMultiplierAndOverhead(this.modulesSize(), options);
522
522
  }
523
523
 
@@ -238,8 +238,8 @@ class Compilation extends Tapable {
238
238
  "module"
239
239
  ]),
240
240
 
241
- /** @type {SyncHook<Module[]>} */
242
- finishModules: new SyncHook(["modules"]),
241
+ /** @type {AsyncSeriesHook<Module[]>} */
242
+ finishModules: new AsyncSeriesHook(["modules"]),
243
243
  /** @type {SyncHook<Module>} */
244
244
  finishRebuildingModule: new SyncHook(["module"]),
245
245
  /** @type {SyncHook} */
@@ -1158,14 +1158,18 @@ class Compilation extends Tapable {
1158
1158
  });
1159
1159
  }
1160
1160
 
1161
- finish() {
1161
+ finish(callback) {
1162
1162
  const modules = this.modules;
1163
- this.hooks.finishModules.call(modules);
1163
+ this.hooks.finishModules.callAsync(modules, err => {
1164
+ if (err) return callback(err);
1164
1165
 
1165
- for (let index = 0; index < modules.length; index++) {
1166
- const module = modules[index];
1167
- this.reportDependencyErrorsAndWarnings(module, [module]);
1168
- }
1166
+ for (let index = 0; index < modules.length; index++) {
1167
+ const module = modules[index];
1168
+ this.reportDependencyErrorsAndWarnings(module, [module]);
1169
+ }
1170
+
1171
+ callback();
1172
+ });
1169
1173
  }
1170
1174
 
1171
1175
  unseal() {
package/lib/Compiler.js CHANGED
@@ -619,15 +619,17 @@ class Compiler extends Tapable {
619
619
  this.hooks.make.callAsync(compilation, err => {
620
620
  if (err) return callback(err);
621
621
 
622
- compilation.finish();
623
-
624
- compilation.seal(err => {
622
+ compilation.finish(err => {
625
623
  if (err) return callback(err);
626
624
 
627
- this.hooks.afterCompile.callAsync(compilation, err => {
625
+ compilation.seal(err => {
628
626
  if (err) return callback(err);
629
627
 
630
- return callback(null, compilation);
628
+ this.hooks.afterCompile.callAsync(compilation, err => {
629
+ if (err) return callback(err);
630
+
631
+ return callback(null, compilation);
632
+ });
631
633
  });
632
634
  });
633
635
  });
@@ -137,6 +137,7 @@ class ExternalModule extends Module {
137
137
  case "amd-require":
138
138
  case "umd":
139
139
  case "umd2":
140
+ case "system":
140
141
  return this.getSourceForAmdOrUmdExternal(
141
142
  this.id,
142
143
  this.optional,
@@ -41,9 +41,11 @@ class FunctionModuleTemplatePlugin {
41
41
  const req = module.readableIdentifier(
42
42
  moduleTemplate.runtimeTemplate.requestShortener
43
43
  );
44
- source.add("/*!****" + req.replace(/./g, "*") + "****!*\\\n");
45
- source.add(" !*** " + req.replace(/\*\//g, "*_/") + " ***!\n");
46
- source.add(" \\****" + req.replace(/./g, "*") + "****/\n");
44
+ const reqStr = req.replace(/\*\//g, "*_/");
45
+ const reqStrStar = "*".repeat(reqStr.length);
46
+ source.add("/*!****" + reqStrStar + "****!*\\\n");
47
+ source.add(" !*** " + reqStr + " ***!\n");
48
+ source.add(" \\****" + reqStrStar + "****/\n");
47
49
  if (
48
50
  Array.isArray(module.buildMeta.providedExports) &&
49
51
  module.buildMeta.providedExports.length === 0
@@ -169,6 +169,13 @@ class LibraryTemplatePlugin {
169
169
  new JsonpExportMainTemplatePlugin(this.name).apply(compilation);
170
170
  break;
171
171
  }
172
+ case "system": {
173
+ const SystemMainTemplatePlugin = require("./SystemMainTemplatePlugin");
174
+ new SystemMainTemplatePlugin({
175
+ name: this.name
176
+ }).apply(compilation);
177
+ break;
178
+ }
172
179
  default:
173
180
  throw new Error(`${this.target} is not a valid Library target`);
174
181
  }
package/lib/Parser.js CHANGED
@@ -1593,7 +1593,14 @@ class Parser extends Tapable {
1593
1593
  walkFunctionExpression(expression) {
1594
1594
  const wasTopLevel = this.scope.topLevelScope;
1595
1595
  this.scope.topLevelScope = false;
1596
- this.inScope(expression.params, () => {
1596
+ const scopeParams = expression.params;
1597
+
1598
+ // Add function name in scope for recursive calls
1599
+ if (expression.id) {
1600
+ scopeParams.push(expression.id.name);
1601
+ }
1602
+
1603
+ this.inScope(scopeParams, () => {
1597
1604
  for (const param of expression.params) {
1598
1605
  this.walkPattern(param);
1599
1606
  }
@@ -1777,7 +1784,14 @@ class Parser extends Tapable {
1777
1784
  const args = options.map(renameArgOrThis);
1778
1785
  const wasTopLevel = this.scope.topLevelScope;
1779
1786
  this.scope.topLevelScope = false;
1780
- this.inScope(params.filter((identifier, idx) => !args[idx]), () => {
1787
+ const scopeParams = params.filter((identifier, idx) => !args[idx]);
1788
+
1789
+ // Add function name in scope for recursive calls
1790
+ if (functionExpression.id) {
1791
+ scopeParams.push(functionExpression.id.name);
1792
+ }
1793
+
1794
+ this.inScope(scopeParams, () => {
1781
1795
  if (renameThis) {
1782
1796
  this.scope.renames.set("this", renameThis);
1783
1797
  }
@@ -0,0 +1,131 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Joel Denning @joeldenning
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const { ConcatSource } = require("webpack-sources");
9
+ const Template = require("./Template");
10
+
11
+ /** @typedef {import("./Compilation")} Compilation */
12
+
13
+ /**
14
+ * @typedef {Object} SystemMainTemplatePluginOptions
15
+ * @param {string=} name the library name
16
+ */
17
+
18
+ class SystemMainTemplatePlugin {
19
+ /**
20
+ * @param {SystemMainTemplatePluginOptions} options the plugin options
21
+ */
22
+ constructor(options) {
23
+ this.name = options.name;
24
+ }
25
+
26
+ /**
27
+ * @param {Compilation} compilation the compilation instance
28
+ * @returns {void}
29
+ */
30
+ apply(compilation) {
31
+ const { mainTemplate, chunkTemplate } = compilation;
32
+
33
+ const onRenderWithEntry = (source, chunk, hash) => {
34
+ const externals = chunk.getModules().filter(m => m.external);
35
+
36
+ // The name this bundle should be registered as with System
37
+ const name = this.name ? `${JSON.stringify(this.name)}, ` : "";
38
+
39
+ // The array of dependencies that are external to webpack and will be provided by System
40
+ const systemDependencies = JSON.stringify(
41
+ externals.map(m =>
42
+ typeof m.request === "object" ? m.request.amd : m.request
43
+ )
44
+ );
45
+
46
+ // The name of the variable provided by System for exporting
47
+ const dynamicExport = "__WEBPACK_DYNAMIC_EXPORT__";
48
+
49
+ // An array of the internal variable names for the webpack externals
50
+ const externalWebpackNames = externals.map(
51
+ m => `__WEBPACK_EXTERNAL_MODULE_${Template.toIdentifier(`${m.id}`)}__`
52
+ );
53
+
54
+ // Declaring variables for the internal variable names for the webpack externals
55
+ const externalVarDeclarations =
56
+ externalWebpackNames.length > 0
57
+ ? `var ${externalWebpackNames.join(", ")};`
58
+ : "";
59
+
60
+ // The system.register format requires an array of setter functions for externals.
61
+ const setters =
62
+ externalWebpackNames.length === 0
63
+ ? ""
64
+ : Template.asString([
65
+ "setters: [",
66
+ Template.indent(
67
+ externalWebpackNames
68
+ .map(external =>
69
+ Template.asString([
70
+ "function(module) {",
71
+ Template.indent(`${external} = module;`),
72
+ "}"
73
+ ])
74
+ )
75
+ .join(",\n")
76
+ ),
77
+ "],"
78
+ ]);
79
+
80
+ return new ConcatSource(
81
+ Template.asString([
82
+ `System.register(${name}${systemDependencies}, function(${dynamicExport}) {`,
83
+ Template.indent([
84
+ externalVarDeclarations,
85
+ "return {",
86
+ Template.indent([
87
+ setters,
88
+ "execute: function() {",
89
+ Template.indent(`${dynamicExport}(`)
90
+ ])
91
+ ])
92
+ ]) + "\n",
93
+ source,
94
+ "\n" +
95
+ Template.asString([
96
+ Template.indent([
97
+ Template.indent([Template.indent([");"]), "}"]),
98
+ "};"
99
+ ]),
100
+ "})"
101
+ ])
102
+ );
103
+ };
104
+
105
+ for (const template of [mainTemplate, chunkTemplate]) {
106
+ template.hooks.renderWithEntry.tap(
107
+ "SystemMainTemplatePlugin",
108
+ onRenderWithEntry
109
+ );
110
+ }
111
+
112
+ mainTemplate.hooks.globalHashPaths.tap(
113
+ "SystemMainTemplatePlugin",
114
+ paths => {
115
+ if (this.name) {
116
+ paths.push(this.name);
117
+ }
118
+ return paths;
119
+ }
120
+ );
121
+
122
+ mainTemplate.hooks.hash.tap("SystemMainTemplatePlugin", hash => {
123
+ hash.update("exports system");
124
+ if (this.name) {
125
+ hash.update(this.name);
126
+ }
127
+ });
128
+ }
129
+ }
130
+
131
+ module.exports = SystemMainTemplatePlugin;
@@ -21,7 +21,6 @@ const RecordIdsPlugin = require("./RecordIdsPlugin");
21
21
 
22
22
  const APIPlugin = require("./APIPlugin");
23
23
  const ConstPlugin = require("./ConstPlugin");
24
- const RequireJsStuffPlugin = require("./RequireJsStuffPlugin");
25
24
  const NodeStuffPlugin = require("./NodeStuffPlugin");
26
25
  const CompatibilityPlugin = require("./CompatibilityPlugin");
27
26
 
@@ -34,35 +33,10 @@ const CommonJsPlugin = require("./dependencies/CommonJsPlugin");
34
33
  const HarmonyModulesPlugin = require("./dependencies/HarmonyModulesPlugin");
35
34
  const SystemPlugin = require("./dependencies/SystemPlugin");
36
35
  const ImportPlugin = require("./dependencies/ImportPlugin");
37
- const AMDPlugin = require("./dependencies/AMDPlugin");
38
36
  const RequireContextPlugin = require("./dependencies/RequireContextPlugin");
39
37
  const RequireEnsurePlugin = require("./dependencies/RequireEnsurePlugin");
40
38
  const RequireIncludePlugin = require("./dependencies/RequireIncludePlugin");
41
39
 
42
- const WarnNoModeSetPlugin = require("./WarnNoModeSetPlugin");
43
-
44
- const EnsureChunkConditionsPlugin = require("./optimize/EnsureChunkConditionsPlugin");
45
- const RemoveParentModulesPlugin = require("./optimize/RemoveParentModulesPlugin");
46
- const RemoveEmptyChunksPlugin = require("./optimize/RemoveEmptyChunksPlugin");
47
- const MergeDuplicateChunksPlugin = require("./optimize/MergeDuplicateChunksPlugin");
48
- const FlagIncludedChunksPlugin = require("./optimize/FlagIncludedChunksPlugin");
49
- const OccurrenceChunkOrderPlugin = require("./optimize/OccurrenceChunkOrderPlugin");
50
- const OccurrenceModuleOrderPlugin = require("./optimize/OccurrenceModuleOrderPlugin");
51
- const NaturalChunkOrderPlugin = require("./optimize/NaturalChunkOrderPlugin");
52
- const SideEffectsFlagPlugin = require("./optimize/SideEffectsFlagPlugin");
53
- const FlagDependencyUsagePlugin = require("./FlagDependencyUsagePlugin");
54
- const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin");
55
- const ModuleConcatenationPlugin = require("./optimize/ModuleConcatenationPlugin");
56
- const SplitChunksPlugin = require("./optimize/SplitChunksPlugin");
57
- const RuntimeChunkPlugin = require("./optimize/RuntimeChunkPlugin");
58
- const NoEmitOnErrorsPlugin = require("./NoEmitOnErrorsPlugin");
59
- const NamedModulesPlugin = require("./NamedModulesPlugin");
60
- const NamedChunksPlugin = require("./NamedChunksPlugin");
61
- const HashedModuleIdsPlugin = require("./HashedModuleIdsPlugin");
62
- const DefinePlugin = require("./DefinePlugin");
63
- const SizeLimitsPlugin = require("./performance/SizeLimitsPlugin");
64
- const WasmFinalizeExportsPlugin = require("./wasm/WasmFinalizeExportsPlugin");
65
-
66
40
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
67
41
  /** @typedef {import("./Compiler")} Compiler */
68
42
 
@@ -308,11 +282,15 @@ class WebpackOptionsApply extends OptionsApply {
308
282
 
309
283
  new CompatibilityPlugin().apply(compiler);
310
284
  new HarmonyModulesPlugin(options.module).apply(compiler);
311
- new AMDPlugin(options.module, options.amd || {}).apply(compiler);
285
+ if (options.amd !== false) {
286
+ const AMDPlugin = require("./dependencies/AMDPlugin");
287
+ const RequireJsStuffPlugin = require("./RequireJsStuffPlugin");
288
+ new AMDPlugin(options.module, options.amd || {}).apply(compiler);
289
+ new RequireJsStuffPlugin().apply(compiler);
290
+ }
312
291
  new CommonJsPlugin(options.module).apply(compiler);
313
292
  new LoaderPlugin().apply(compiler);
314
293
  new NodeStuffPlugin(options.node).apply(compiler);
315
- new RequireJsStuffPlugin().apply(compiler);
316
294
  new APIPlugin().apply(compiler);
317
295
  new ConstPlugin().apply(compiler);
318
296
  new UseStrictPlugin().apply(compiler);
@@ -327,44 +305,58 @@ class WebpackOptionsApply extends OptionsApply {
327
305
  new SystemPlugin(options.module).apply(compiler);
328
306
 
329
307
  if (typeof options.mode !== "string") {
308
+ const WarnNoModeSetPlugin = require("./WarnNoModeSetPlugin");
330
309
  new WarnNoModeSetPlugin().apply(compiler);
331
310
  }
332
311
 
312
+ const EnsureChunkConditionsPlugin = require("./optimize/EnsureChunkConditionsPlugin");
333
313
  new EnsureChunkConditionsPlugin().apply(compiler);
334
314
  if (options.optimization.removeAvailableModules) {
315
+ const RemoveParentModulesPlugin = require("./optimize/RemoveParentModulesPlugin");
335
316
  new RemoveParentModulesPlugin().apply(compiler);
336
317
  }
337
318
  if (options.optimization.removeEmptyChunks) {
319
+ const RemoveEmptyChunksPlugin = require("./optimize/RemoveEmptyChunksPlugin");
338
320
  new RemoveEmptyChunksPlugin().apply(compiler);
339
321
  }
340
322
  if (options.optimization.mergeDuplicateChunks) {
323
+ const MergeDuplicateChunksPlugin = require("./optimize/MergeDuplicateChunksPlugin");
341
324
  new MergeDuplicateChunksPlugin().apply(compiler);
342
325
  }
343
326
  if (options.optimization.flagIncludedChunks) {
327
+ const FlagIncludedChunksPlugin = require("./optimize/FlagIncludedChunksPlugin");
344
328
  new FlagIncludedChunksPlugin().apply(compiler);
345
329
  }
346
330
  if (options.optimization.sideEffects) {
331
+ const SideEffectsFlagPlugin = require("./optimize/SideEffectsFlagPlugin");
347
332
  new SideEffectsFlagPlugin().apply(compiler);
348
333
  }
349
334
  if (options.optimization.providedExports) {
335
+ const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin");
350
336
  new FlagDependencyExportsPlugin().apply(compiler);
351
337
  }
352
338
  if (options.optimization.usedExports) {
339
+ const FlagDependencyUsagePlugin = require("./FlagDependencyUsagePlugin");
353
340
  new FlagDependencyUsagePlugin().apply(compiler);
354
341
  }
355
342
  if (options.optimization.concatenateModules) {
343
+ const ModuleConcatenationPlugin = require("./optimize/ModuleConcatenationPlugin");
356
344
  new ModuleConcatenationPlugin().apply(compiler);
357
345
  }
358
346
  if (options.optimization.splitChunks) {
347
+ const SplitChunksPlugin = require("./optimize/SplitChunksPlugin");
359
348
  new SplitChunksPlugin(options.optimization.splitChunks).apply(compiler);
360
349
  }
361
350
  if (options.optimization.runtimeChunk) {
351
+ const RuntimeChunkPlugin = require("./optimize/RuntimeChunkPlugin");
362
352
  new RuntimeChunkPlugin(options.optimization.runtimeChunk).apply(compiler);
363
353
  }
364
354
  if (options.optimization.noEmitOnErrors) {
355
+ const NoEmitOnErrorsPlugin = require("./NoEmitOnErrorsPlugin");
365
356
  new NoEmitOnErrorsPlugin().apply(compiler);
366
357
  }
367
358
  if (options.optimization.checkWasmTypes) {
359
+ const WasmFinalizeExportsPlugin = require("./wasm/WasmFinalizeExportsPlugin");
368
360
  new WasmFinalizeExportsPlugin().apply(compiler);
369
361
  }
370
362
  let moduleIds = options.optimization.moduleIds;
@@ -384,6 +376,9 @@ class WebpackOptionsApply extends OptionsApply {
384
376
  }
385
377
  }
386
378
  if (moduleIds) {
379
+ const NamedModulesPlugin = require("./NamedModulesPlugin");
380
+ const HashedModuleIdsPlugin = require("./HashedModuleIdsPlugin");
381
+ const OccurrenceModuleOrderPlugin = require("./optimize/OccurrenceModuleOrderPlugin");
387
382
  switch (moduleIds) {
388
383
  case "natural":
389
384
  // TODO webpack 5: see hint in Compilation.sortModules
@@ -426,6 +421,9 @@ class WebpackOptionsApply extends OptionsApply {
426
421
  }
427
422
  }
428
423
  if (chunkIds) {
424
+ const NaturalChunkOrderPlugin = require("./optimize/NaturalChunkOrderPlugin");
425
+ const NamedChunksPlugin = require("./NamedChunksPlugin");
426
+ const OccurrenceChunkOrderPlugin = require("./optimize/OccurrenceChunkOrderPlugin");
429
427
  switch (chunkIds) {
430
428
  case "natural":
431
429
  new NaturalChunkOrderPlugin().apply(compiler);
@@ -456,6 +454,7 @@ class WebpackOptionsApply extends OptionsApply {
456
454
  }
457
455
  }
458
456
  if (options.optimization.nodeEnv) {
457
+ const DefinePlugin = require("./DefinePlugin");
459
458
  new DefinePlugin({
460
459
  "process.env.NODE_ENV": JSON.stringify(options.optimization.nodeEnv)
461
460
  }).apply(compiler);
@@ -471,6 +470,7 @@ class WebpackOptionsApply extends OptionsApply {
471
470
  }
472
471
 
473
472
  if (options.performance) {
473
+ const SizeLimitsPlugin = require("./performance/SizeLimitsPlugin");
474
474
  new SizeLimitsPlugin(options.performance).apply(compiler);
475
475
  }
476
476
 
@@ -34,7 +34,10 @@ HarmonyAcceptDependency.Template = class HarmonyAcceptDependencyTemplate {
34
34
  dep.range[0],
35
35
  `function(__WEBPACK_OUTDATED_DEPENDENCIES__) { ${content}(`
36
36
  );
37
- source.insert(dep.range[1], ")(__WEBPACK_OUTDATED_DEPENDENCIES__); }");
37
+ source.insert(
38
+ dep.range[1],
39
+ ")(__WEBPACK_OUTDATED_DEPENDENCIES__); }.bind(this)"
40
+ );
38
41
  return;
39
42
  }
40
43
 
@@ -61,7 +61,7 @@ class ModuleConcatenationPlugin {
61
61
 
62
62
  compilation.hooks.optimizeChunkModules.tap(
63
63
  "ModuleConcatenationPlugin",
64
- (chunks, modules) => {
64
+ (allChunks, modules) => {
65
65
  const relevantModules = [];
66
66
  const possibleInners = new Set();
67
67
  for (const module of modules) {
@@ -287,6 +287,8 @@ class ModuleConcatenationPlugin {
287
287
  for (const chunk of chunks) {
288
288
  chunk.addModule(newModule);
289
289
  newModule.addChunk(chunk);
290
+ }
291
+ for (const chunk of allChunks) {
290
292
  if (chunk.entryModule === concatConfiguration.rootModule) {
291
293
  chunk.entryModule = newModule;
292
294
  }
@@ -674,11 +674,13 @@ module.exports = class SplitChunksPlugin {
674
674
  // Skip when no chunk selected
675
675
  if (usedChunks.length === 0) continue;
676
676
 
677
+ let validChunks = usedChunks;
678
+
677
679
  if (
678
680
  Number.isFinite(item.cacheGroup.maxInitialRequests) ||
679
681
  Number.isFinite(item.cacheGroup.maxAsyncRequests)
680
682
  ) {
681
- const chunkInLimit = usedChunks.filter(chunk => {
683
+ validChunks = validChunks.filter(chunk => {
682
684
  // respect max requests when not enforced
683
685
  const maxRequests = chunk.isOnlyInitial()
684
686
  ? item.cacheGroup.maxInitialRequests
@@ -692,20 +694,27 @@ module.exports = class SplitChunksPlugin {
692
694
  !isFinite(maxRequests) || getRequests(chunk) < maxRequests
693
695
  );
694
696
  });
697
+ }
695
698
 
696
- if (chunkInLimit.length < usedChunks.length) {
697
- if (chunkInLimit.length >= item.cacheGroup.minChunks) {
698
- for (const module of item.modules) {
699
- addModuleToChunksInfoMap(
700
- item.cacheGroup,
701
- chunkInLimit,
702
- getKey(chunkInLimit),
703
- module
704
- );
705
- }
699
+ validChunks = validChunks.filter(chunk => {
700
+ for (const module of item.modules) {
701
+ if (chunk.containsModule(module)) return true;
702
+ }
703
+ return false;
704
+ });
705
+
706
+ if (validChunks.length < usedChunks.length) {
707
+ if (validChunks.length >= item.cacheGroup.minChunks) {
708
+ for (const module of item.modules) {
709
+ addModuleToChunksInfoMap(
710
+ item.cacheGroup,
711
+ validChunks,
712
+ getKey(validChunks),
713
+ module
714
+ );
706
715
  }
707
- continue;
708
716
  }
717
+ continue;
709
718
  }
710
719
 
711
720
  // Create the new chunk if not reusing one
@@ -177,9 +177,12 @@ const rewriteImportedGlobals = state => bin => {
177
177
 
178
178
  globalType.mutability = "var";
179
179
 
180
- const init = createDefaultInitForGlobal(globalType);
180
+ const init = [
181
+ createDefaultInitForGlobal(globalType),
182
+ t.instruction("end")
183
+ ];
181
184
 
182
- newGlobals.push(t.global(globalType, [init]));
185
+ newGlobals.push(t.global(globalType, init));
183
186
 
184
187
  path.remove();
185
188
  }
@@ -196,7 +199,10 @@ const rewriteImportedGlobals = state => bin => {
196
199
 
197
200
  const initialGlobalidx = init.args[0];
198
201
 
199
- node.init = [createDefaultInitForGlobal(node.globalType)];
202
+ node.init = [
203
+ createDefaultInitForGlobal(node.globalType),
204
+ t.instruction("end")
205
+ ];
200
206
 
201
207
  additionalInitCode.push(
202
208
  /**
@@ -316,6 +322,8 @@ const addInitFunction = ({
316
322
  funcBody.push(instr);
317
323
  }
318
324
 
325
+ funcBody.push(t.instruction("end"));
326
+
319
327
  const funcResults = [];
320
328
 
321
329
  // Code section
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "4.29.3",
3
+ "version": "4.30.0",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
- "@webassemblyjs/ast": "1.7.11",
9
- "@webassemblyjs/helper-module-context": "1.7.11",
10
- "@webassemblyjs/wasm-edit": "1.7.11",
11
- "@webassemblyjs/wasm-parser": "1.7.11",
8
+ "@webassemblyjs/ast": "1.8.5",
9
+ "@webassemblyjs/helper-module-context": "1.8.5",
10
+ "@webassemblyjs/wasm-edit": "1.8.5",
11
+ "@webassemblyjs/wasm-parser": "1.8.5",
12
12
  "acorn": "^6.0.5",
13
13
  "acorn-dynamic-import": "^4.0.0",
14
14
  "ajv": "^6.1.0",
@@ -34,6 +34,7 @@
34
34
  "@types/node": "^10.12.21",
35
35
  "@types/tapable": "^1.0.1",
36
36
  "@types/webpack-sources": "^0.1.4",
37
+ "@yarnpkg/lockfile": "^1.1.0",
37
38
  "benchmark": "^2.1.1",
38
39
  "bundle-loader": "~0.5.0",
39
40
  "coffee-loader": "^0.9.0",
@@ -119,14 +120,14 @@
119
120
  "build:examples": "cd examples && node buildAll.js",
120
121
  "pretest": "yarn lint",
121
122
  "prelint": "yarn setup",
122
- "lint": "yarn code-lint && yarn schema-lint && yarn type-lint && yarn special-lint",
123
+ "lint": "yarn code-lint && yarn jest-lint && yarn type-lint && yarn special-lint",
123
124
  "code-lint": "eslint --cache \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.js\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
124
125
  "type-lint": "tsc --pretty",
125
126
  "special-lint": "node tooling/inherit-types && node tooling/format-schemas && node tooling/compile-to-definitions",
126
127
  "special-lint-fix": "node tooling/inherit-types --write --override && node tooling/format-schemas --write && node tooling/compile-to-definitions --write",
127
128
  "fix": "yarn code-lint --fix && yarn special-lint-fix",
128
129
  "pretty": "prettier --loglevel warn --write \"*.{ts,js,json,yml,yaml}\" \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
129
- "schema-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\" --no-verbose",
130
+ "jest-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\" --no-verbose",
130
131
  "benchmark": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.js\" --runInBand",
131
132
  "cover": "yarn cover:init && yarn cover:all && yarn cover:report",
132
133
  "cover:init": "rimraf coverage",
@@ -986,7 +986,8 @@
986
986
  "amd-require",
987
987
  "umd",
988
988
  "umd2",
989
- "jsonp"
989
+ "jsonp",
990
+ "system"
990
991
  ]
991
992
  },
992
993
  "path": {
@@ -1903,7 +1904,17 @@
1903
1904
  "additionalProperties": false,
1904
1905
  "properties": {
1905
1906
  "amd": {
1906
- "description": "Set the value of `require.amd` and `define.amd`."
1907
+ "description": "Set the value of `require.amd` and `define.amd`. Or disable AMD support.",
1908
+ "anyOf": [
1909
+ {
1910
+ "description": "You can pass `false` to disable AMD support.",
1911
+ "enum": [false]
1912
+ },
1913
+ {
1914
+ "description": "You can pass an object to set the value of `require.amd` and `define.amd`.",
1915
+ "type": "object"
1916
+ }
1917
+ ]
1907
1918
  },
1908
1919
  "bail": {
1909
1920
  "description": "Report the first error as a hard error instead of tolerating it.",