webpack 4.29.6 → 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.
- package/declarations/WebpackOptions.d.ts +8 -5
- package/lib/Chunk.js +1 -1
- package/lib/Compilation.js +12 -8
- package/lib/Compiler.js +7 -5
- package/lib/ExternalModule.js +1 -0
- package/lib/FunctionModuleTemplatePlugin.js +5 -3
- package/lib/LibraryTemplatePlugin.js +7 -0
- package/lib/Parser.js +16 -2
- package/lib/SystemMainTemplatePlugin.js +131 -0
- package/lib/WebpackOptionsApply.js +28 -28
- package/lib/optimize/ModuleConcatenationPlugin.js +3 -1
- package/lib/optimize/SplitChunksPlugin.js +21 -12
- package/package.json +1 -1
- package/schemas/WebpackOptions.json +13 -2
@@ -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
|
-
|
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/Chunk.js
CHANGED
package/lib/Compilation.js
CHANGED
@@ -238,8 +238,8 @@ class Compilation extends Tapable {
|
|
238
238
|
"module"
|
239
239
|
]),
|
240
240
|
|
241
|
-
/** @type {
|
242
|
-
finishModules: new
|
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.
|
1163
|
+
this.hooks.finishModules.callAsync(modules, err => {
|
1164
|
+
if (err) return callback(err);
|
1164
1165
|
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
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
|
-
|
625
|
+
compilation.seal(err => {
|
628
626
|
if (err) return callback(err);
|
629
627
|
|
630
|
-
|
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
|
});
|
package/lib/ExternalModule.js
CHANGED
@@ -41,9 +41,11 @@ class FunctionModuleTemplatePlugin {
|
|
41
41
|
const req = module.readableIdentifier(
|
42
42
|
moduleTemplate.runtimeTemplate.requestShortener
|
43
43
|
);
|
44
|
-
|
45
|
-
|
46
|
-
source.add("
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
|
@@ -61,7 +61,7 @@ class ModuleConcatenationPlugin {
|
|
61
61
|
|
62
62
|
compilation.hooks.optimizeChunkModules.tap(
|
63
63
|
"ModuleConcatenationPlugin",
|
64
|
-
(
|
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
|
-
|
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
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
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
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "4.
|
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",
|
@@ -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.",
|