webpack 4.39.2 → 4.39.3
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/README.md +1 -1
- package/lib/CachePlugin.js +12 -14
- package/lib/buildChunkGraph.js +49 -14
- package/lib/wasm/WebAssemblyGenerator.js +13 -7
- package/package.json +3 -3
package/README.md
CHANGED
@@ -347,7 +347,7 @@ If you create a loader or plugin, we would <3 for you to open source it, and put
|
|
347
347
|
|
348
348
|
<h2 align="center">Support</h2>
|
349
349
|
|
350
|
-
We consider webpack to be a low-level tool used not only individually but also layered beneath other awesome tools. Because of its flexibility, webpack isn't always the _easiest_ entry-level solution, however we do believe it is the most powerful. That said, we're always looking for ways improve and simplify the tool without compromising functionality. If you have any ideas on ways to accomplish this, we're all ears!
|
350
|
+
We consider webpack to be a low-level tool used not only individually but also layered beneath other awesome tools. Because of its flexibility, webpack isn't always the _easiest_ entry-level solution, however we do believe it is the most powerful. That said, we're always looking for ways to improve and simplify the tool without compromising functionality. If you have any ideas on ways to accomplish this, we're all ears!
|
351
351
|
|
352
352
|
If you're just getting started, take a look at [our new docs and concepts page](https://webpack.js.org/concepts/). This has a high level overview that is great for beginners!!
|
353
353
|
|
package/lib/CachePlugin.js
CHANGED
@@ -24,21 +24,19 @@ class CachePlugin {
|
|
24
24
|
compilation.hooks.childCompiler.tap(
|
25
25
|
"CachePlugin",
|
26
26
|
(childCompiler, compilerName, compilerIndex) => {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
cache.children = {};
|
31
|
-
}
|
32
|
-
if (!cache.children[compilerName]) {
|
33
|
-
cache.children[compilerName] = [];
|
34
|
-
}
|
35
|
-
if (cache.children[compilerName][compilerIndex]) {
|
36
|
-
childCache = cache.children[compilerName][compilerIndex];
|
37
|
-
} else {
|
38
|
-
cache.children[compilerName].push((childCache = {}));
|
39
|
-
}
|
40
|
-
registerCacheToCompiler(childCompiler, childCache);
|
27
|
+
let childCache;
|
28
|
+
if (!cache.children) {
|
29
|
+
cache.children = {};
|
41
30
|
}
|
31
|
+
if (!cache.children[compilerName]) {
|
32
|
+
cache.children[compilerName] = [];
|
33
|
+
}
|
34
|
+
if (cache.children[compilerName][compilerIndex]) {
|
35
|
+
childCache = cache.children[compilerName][compilerIndex];
|
36
|
+
} else {
|
37
|
+
cache.children[compilerName].push((childCache = {}));
|
38
|
+
}
|
39
|
+
registerCacheToCompiler(childCompiler, childCache);
|
42
40
|
}
|
43
41
|
);
|
44
42
|
});
|
package/lib/buildChunkGraph.js
CHANGED
@@ -28,11 +28,13 @@ const GraphHelpers = require("./GraphHelpers");
|
|
28
28
|
|
29
29
|
/**
|
30
30
|
* @typedef {Object} ChunkGroupInfo
|
31
|
+
* @property {ChunkGroup} chunkGroup the chunk group
|
31
32
|
* @property {Set<Module>} minAvailableModules current minimal set of modules available at this point
|
32
33
|
* @property {boolean} minAvailableModulesOwned true, if minAvailableModules is owned and can be modified
|
33
34
|
* @property {Set<Module>[]} availableModulesToBeMerged enqueued updates to the minimal set of available modules
|
34
35
|
* @property {QueueItem[]} skippedItems queue items that were skipped because module is already available in parent chunks (need to reconsider when minAvailableModules is shrinking)
|
35
36
|
* @property {Set<Module>} resultingAvailableModules set of modules available including modules from this chunk group
|
37
|
+
* @property {Set<ChunkGroup>} children set of children chunk groups, that will be revisited when availableModules shrink
|
36
38
|
*/
|
37
39
|
|
38
40
|
/**
|
@@ -196,11 +198,13 @@ const visitModules = (
|
|
196
198
|
});
|
197
199
|
}
|
198
200
|
chunkGroupInfoMap.set(chunkGroup, {
|
201
|
+
chunkGroup,
|
199
202
|
minAvailableModules: new Set(),
|
200
203
|
minAvailableModulesOwned: true,
|
201
204
|
availableModulesToBeMerged: [],
|
202
205
|
skippedItems: [],
|
203
|
-
resultingAvailableModules: undefined
|
206
|
+
resultingAvailableModules: undefined,
|
207
|
+
children: undefined
|
204
208
|
});
|
205
209
|
return queue;
|
206
210
|
};
|
@@ -418,7 +422,7 @@ const visitModules = (
|
|
418
422
|
}
|
419
423
|
logger.timeEnd("visiting");
|
420
424
|
|
421
|
-
|
425
|
+
while (queueConnect.size > 0) {
|
422
426
|
logger.time("calculating available modules");
|
423
427
|
|
424
428
|
// Figure out new parents for chunk groups
|
@@ -435,17 +439,26 @@ const visitModules = (
|
|
435
439
|
}
|
436
440
|
}
|
437
441
|
info.resultingAvailableModules = resultingAvailableModules;
|
442
|
+
if (info.children === undefined) {
|
443
|
+
info.children = targets;
|
444
|
+
} else {
|
445
|
+
for (const target of targets) {
|
446
|
+
info.children.add(target);
|
447
|
+
}
|
448
|
+
}
|
438
449
|
|
439
450
|
// 2. Update chunk group info
|
440
451
|
for (const target of targets) {
|
441
452
|
let chunkGroupInfo = chunkGroupInfoMap.get(target);
|
442
453
|
if (chunkGroupInfo === undefined) {
|
443
454
|
chunkGroupInfo = {
|
455
|
+
chunkGroup: target,
|
444
456
|
minAvailableModules: undefined,
|
445
457
|
minAvailableModulesOwned: undefined,
|
446
458
|
availableModulesToBeMerged: [],
|
447
459
|
skippedItems: [],
|
448
|
-
resultingAvailableModules: undefined
|
460
|
+
resultingAvailableModules: undefined,
|
461
|
+
children: undefined
|
449
462
|
};
|
450
463
|
chunkGroupInfoMap.set(target, chunkGroupInfo);
|
451
464
|
}
|
@@ -463,7 +476,7 @@ const visitModules = (
|
|
463
476
|
// Execute the merge
|
464
477
|
for (const info of outdatedChunkGroupInfo) {
|
465
478
|
const availableModulesToBeMerged = info.availableModulesToBeMerged;
|
466
|
-
let
|
479
|
+
let cachedMinAvailableModules = info.minAvailableModules;
|
467
480
|
|
468
481
|
// 1. Get minimal available modules
|
469
482
|
// It doesn't make sense to traverse a chunk again with more available modules.
|
@@ -474,29 +487,31 @@ const visitModules = (
|
|
474
487
|
}
|
475
488
|
let changed = false;
|
476
489
|
for (const availableModules of availableModulesToBeMerged) {
|
477
|
-
if (
|
478
|
-
|
479
|
-
info.minAvailableModules =
|
490
|
+
if (cachedMinAvailableModules === undefined) {
|
491
|
+
cachedMinAvailableModules = availableModules;
|
492
|
+
info.minAvailableModules = cachedMinAvailableModules;
|
480
493
|
info.minAvailableModulesOwned = false;
|
481
494
|
changed = true;
|
482
495
|
} else {
|
483
496
|
if (info.minAvailableModulesOwned) {
|
484
497
|
// We own it and can modify it
|
485
|
-
for (const m of
|
498
|
+
for (const m of cachedMinAvailableModules) {
|
486
499
|
if (!availableModules.has(m)) {
|
487
|
-
|
500
|
+
cachedMinAvailableModules.delete(m);
|
488
501
|
changed = true;
|
489
502
|
}
|
490
503
|
}
|
491
504
|
} else {
|
492
|
-
for (const m of
|
505
|
+
for (const m of cachedMinAvailableModules) {
|
493
506
|
if (!availableModules.has(m)) {
|
494
|
-
//
|
507
|
+
// cachedMinAvailableModules need to be modified
|
495
508
|
// but we don't own it
|
496
|
-
// construct a new Set as intersection of
|
509
|
+
// construct a new Set as intersection of cachedMinAvailableModules and availableModules
|
497
510
|
/** @type {Set<Module>} */
|
498
511
|
const newSet = new Set();
|
499
|
-
const iterator =
|
512
|
+
const iterator = cachedMinAvailableModules[
|
513
|
+
Symbol.iterator
|
514
|
+
]();
|
500
515
|
/** @type {IteratorResult<Module>} */
|
501
516
|
let it;
|
502
517
|
while (!(it = iterator.next()).done) {
|
@@ -510,9 +525,16 @@ const visitModules = (
|
|
510
525
|
newSet.add(module);
|
511
526
|
}
|
512
527
|
}
|
513
|
-
|
528
|
+
cachedMinAvailableModules = newSet;
|
514
529
|
info.minAvailableModulesOwned = true;
|
515
530
|
info.minAvailableModules = newSet;
|
531
|
+
|
532
|
+
// Update the cache from the first queue
|
533
|
+
// if the chunkGroup is currently cached
|
534
|
+
if (chunkGroup === info.chunkGroup) {
|
535
|
+
minAvailableModules = cachedMinAvailableModules;
|
536
|
+
}
|
537
|
+
|
516
538
|
changed = true;
|
517
539
|
break;
|
518
540
|
}
|
@@ -528,6 +550,19 @@ const visitModules = (
|
|
528
550
|
queue.push(queueItem);
|
529
551
|
}
|
530
552
|
info.skippedItems.length = 0;
|
553
|
+
|
554
|
+
// 3. Reconsider children chunk groups
|
555
|
+
if (info.children !== undefined) {
|
556
|
+
const chunkGroup = info.chunkGroup;
|
557
|
+
for (const c of info.children) {
|
558
|
+
let connectList = queueConnect.get(chunkGroup);
|
559
|
+
if (connectList === undefined) {
|
560
|
+
connectList = new Set();
|
561
|
+
queueConnect.set(chunkGroup, connectList);
|
562
|
+
}
|
563
|
+
connectList.add(c);
|
564
|
+
}
|
565
|
+
}
|
531
566
|
}
|
532
567
|
outdatedChunkGroupInfo.clear();
|
533
568
|
logger.timeEnd("merging available modules");
|
@@ -70,7 +70,7 @@ const getImportedGlobals = ast => {
|
|
70
70
|
|
71
71
|
t.traverse(ast, {
|
72
72
|
ModuleImport({ node }) {
|
73
|
-
if (t.isGlobalType(node.descr)
|
73
|
+
if (t.isGlobalType(node.descr)) {
|
74
74
|
importedGlobals.push(node);
|
75
75
|
}
|
76
76
|
}
|
@@ -79,12 +79,18 @@ const getImportedGlobals = ast => {
|
|
79
79
|
return importedGlobals;
|
80
80
|
};
|
81
81
|
|
82
|
+
/**
|
83
|
+
* Get the count for imported func
|
84
|
+
*
|
85
|
+
* @param {Object} ast Module's AST
|
86
|
+
* @returns {Number} - count
|
87
|
+
*/
|
82
88
|
const getCountImportedFunc = ast => {
|
83
89
|
let count = 0;
|
84
90
|
|
85
91
|
t.traverse(ast, {
|
86
92
|
ModuleImport({ node }) {
|
87
|
-
if (t.isFuncImportDescr(node.descr)
|
93
|
+
if (t.isFuncImportDescr(node.descr)) {
|
88
94
|
count++;
|
89
95
|
}
|
90
96
|
}
|
@@ -133,7 +139,7 @@ const getNextFuncIndex = (ast, countImportedFunc) => {
|
|
133
139
|
};
|
134
140
|
|
135
141
|
/**
|
136
|
-
*
|
142
|
+
* Creates an init instruction for a global type
|
137
143
|
* @param {t.GlobalType} globalType the global type
|
138
144
|
* @returns {t.Instruction} init expression
|
139
145
|
*/
|
@@ -156,7 +162,7 @@ const createDefaultInitForGlobal = globalType => {
|
|
156
162
|
/**
|
157
163
|
* Rewrite the import globals:
|
158
164
|
* - removes the ModuleImport instruction
|
159
|
-
* - injects at the same offset a mutable global of the same
|
165
|
+
* - injects at the same offset a mutable global of the same type
|
160
166
|
*
|
161
167
|
* Since the imported globals are before the other global declarations, our
|
162
168
|
* indices will be preserved.
|
@@ -172,7 +178,7 @@ const rewriteImportedGlobals = state => bin => {
|
|
172
178
|
|
173
179
|
bin = editWithAST(state.ast, bin, {
|
174
180
|
ModuleImport(path) {
|
175
|
-
if (t.isGlobalType(path.node.descr)
|
181
|
+
if (t.isGlobalType(path.node.descr)) {
|
176
182
|
const globalType = path.node.descr;
|
177
183
|
|
178
184
|
globalType.mutability = "var";
|
@@ -206,8 +212,8 @@ const rewriteImportedGlobals = state => bin => {
|
|
206
212
|
|
207
213
|
additionalInitCode.push(
|
208
214
|
/**
|
209
|
-
* get_global in global
|
210
|
-
* They have the same indices
|
215
|
+
* get_global in global initializer only works for imported globals.
|
216
|
+
* They have the same indices as the init params, so use the
|
211
217
|
* same index.
|
212
218
|
*/
|
213
219
|
t.instruction("get_local", [initialGlobalidx]),
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "4.39.
|
3
|
+
"version": "4.39.3",
|
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",
|
@@ -120,12 +120,12 @@
|
|
120
120
|
"pretest": "yarn lint",
|
121
121
|
"prelint": "yarn setup",
|
122
122
|
"lint": "yarn code-lint && yarn jest-lint && yarn type-lint && yarn special-lint",
|
123
|
-
"code-lint": "eslint --
|
123
|
+
"code-lint": "eslint . --ext '.js' --cache",
|
124
124
|
"type-lint": "tsc --pretty",
|
125
125
|
"special-lint": "node tooling/inherit-types && node tooling/format-schemas && node tooling/compile-to-definitions",
|
126
126
|
"special-lint-fix": "node tooling/inherit-types --write --override && node tooling/format-schemas --write && node tooling/compile-to-definitions --write",
|
127
127
|
"fix": "yarn code-lint --fix && yarn special-lint-fix",
|
128
|
-
"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\"",
|
128
|
+
"pretty": "prettier --loglevel warn --write \"*.{ts,js,json,yml,yaml}\" \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}\" \"test/*.js\" \"test/helpers/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
|
129
129
|
"jest-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\" --no-verbose",
|
130
130
|
"benchmark": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.js\" --runInBand",
|
131
131
|
"cover": "yarn cover:all && yarn cover:report",
|