webpack 4.44.0 → 4.46.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 +9 -1
- package/lib/WebpackOptionsDefaulter.js +11 -1
- package/lib/buildChunkGraph.js +44 -56
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +4 -3
- package/lib/optimize/SplitChunksPlugin.js +8 -4
- package/package.json +10 -2
- package/schemas/WebpackOptions.json +9 -1
@@ -683,6 +683,10 @@ export interface ResolveOptions {
|
|
683
683
|
fileSystem?: {
|
684
684
|
[k: string]: any;
|
685
685
|
};
|
686
|
+
/**
|
687
|
+
* Enable to ignore fatal errors happening during resolving of 'resolve.roots'. Usually such errors should not happen, but this option is provided for backward-compatibility.
|
688
|
+
*/
|
689
|
+
ignoreRootsErrors?: boolean;
|
686
690
|
/**
|
687
691
|
* Field names from the description file (package.json) which are used to find the default entry point
|
688
692
|
*/
|
@@ -703,6 +707,10 @@ export interface ResolveOptions {
|
|
703
707
|
* Plugins for the resolver
|
704
708
|
*/
|
705
709
|
plugins?: (WebpackPluginInstance | WebpackPluginFunction)[];
|
710
|
+
/**
|
711
|
+
* Prefer to resolve server-relative URLs (starting with '/') as absolute paths before falling back to resolve in 'resolve.roots'.
|
712
|
+
*/
|
713
|
+
preferAbsolute?: boolean;
|
706
714
|
/**
|
707
715
|
* Custom resolver
|
708
716
|
*/
|
@@ -710,7 +718,7 @@ export interface ResolveOptions {
|
|
710
718
|
[k: string]: any;
|
711
719
|
};
|
712
720
|
/**
|
713
|
-
* A list of directories in which requests that are server-relative URLs (starting with '/') are resolved.
|
721
|
+
* A list of directories in which requests that are server-relative URLs (starting with '/') are resolved.
|
714
722
|
*/
|
715
723
|
roots?: string[];
|
716
724
|
/**
|
@@ -356,13 +356,23 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
|
|
356
356
|
options.resolve.plugins.length > 0
|
357
357
|
);
|
358
358
|
});
|
359
|
+
this.set(
|
360
|
+
"resolve.preferAbsolute",
|
361
|
+
"make",
|
362
|
+
options => !options.resolve.roots || options.resolve.roots.length === 0
|
363
|
+
);
|
364
|
+
this.set(
|
365
|
+
"resolve.ignoreRootsErrors",
|
366
|
+
"make",
|
367
|
+
options => !options.resolve.roots || options.resolve.roots.length === 0
|
368
|
+
);
|
369
|
+
this.set("resolve.roots", "make", options => [options.context]);
|
359
370
|
|
360
371
|
this.set("resolveLoader", "call", value => Object.assign({}, value));
|
361
372
|
this.set("resolveLoader.unsafeCache", true);
|
362
373
|
this.set("resolveLoader.mainFields", ["loader", "main"]);
|
363
374
|
this.set("resolveLoader.extensions", [".js", ".json"]);
|
364
375
|
this.set("resolveLoader.mainFiles", ["index"]);
|
365
|
-
this.set("resolveLoader.roots", "make", options => [options.context]);
|
366
376
|
this.set("resolveLoader.cacheWithContext", "make", options => {
|
367
377
|
return (
|
368
378
|
Array.isArray(options.resolveLoader.plugins) &&
|
package/lib/buildChunkGraph.js
CHANGED
@@ -38,8 +38,8 @@ const GraphHelpers = require("./GraphHelpers");
|
|
38
38
|
*/
|
39
39
|
|
40
40
|
/**
|
41
|
-
* @typedef {Object}
|
42
|
-
* @property {
|
41
|
+
* @typedef {Object} BlockChunkGroupConnection
|
42
|
+
* @property {ChunkGroupInfo} originChunkGroupInfo origin chunk group
|
43
43
|
* @property {ChunkGroup} chunkGroup referenced chunk group
|
44
44
|
*/
|
45
45
|
|
@@ -143,7 +143,7 @@ const extraceBlockInfoMap = compilation => {
|
|
143
143
|
* @param {Compilation} compilation the compilation
|
144
144
|
* @param {Entrypoint[]} inputChunkGroups input groups
|
145
145
|
* @param {Map<ChunkGroup, ChunkGroupInfo>} chunkGroupInfoMap mapping from chunk group to available modules
|
146
|
-
* @param {Map<
|
146
|
+
* @param {Map<AsyncDependenciesBlock, BlockChunkGroupConnection[]>} blockConnections connection for blocks
|
147
147
|
* @param {Set<DependenciesBlock>} blocksWithNestedBlocks flag for blocks that have nested blocks
|
148
148
|
* @param {Set<ChunkGroup>} allCreatedChunkGroups filled with all chunk groups that are created here
|
149
149
|
*/
|
@@ -151,7 +151,7 @@ const visitModules = (
|
|
151
151
|
compilation,
|
152
152
|
inputChunkGroups,
|
153
153
|
chunkGroupInfoMap,
|
154
|
-
|
154
|
+
blockConnections,
|
155
155
|
blocksWithNestedBlocks,
|
156
156
|
allCreatedChunkGroups
|
157
157
|
) => {
|
@@ -229,6 +229,8 @@ const visitModules = (
|
|
229
229
|
let chunk;
|
230
230
|
/** @type {ChunkGroup} */
|
231
231
|
let chunkGroup;
|
232
|
+
/** @type {ChunkGroupInfo} */
|
233
|
+
let chunkGroupInfo;
|
232
234
|
/** @type {DependenciesBlock} */
|
233
235
|
let block;
|
234
236
|
/** @type {Set<Module>} */
|
@@ -263,17 +265,17 @@ const visitModules = (
|
|
263
265
|
blockChunkGroups.set(b, c);
|
264
266
|
allCreatedChunkGroups.add(c);
|
265
267
|
}
|
268
|
+
blockConnections.set(b, []);
|
266
269
|
} else {
|
267
270
|
// TODO webpack 5 remove addOptions check
|
268
271
|
if (c.addOptions) c.addOptions(b.groupOptions);
|
269
272
|
c.addOrigin(module, b.loc, b.request);
|
270
273
|
}
|
271
274
|
|
272
|
-
// 2. We store the
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
block: b,
|
275
|
+
// 2. We store the connection for the block
|
276
|
+
// to connect it later if needed
|
277
|
+
blockConnections.get(b).push({
|
278
|
+
originChunkGroupInfo: chunkGroupInfo,
|
277
279
|
chunkGroup: c
|
278
280
|
});
|
279
281
|
|
@@ -306,7 +308,7 @@ const visitModules = (
|
|
306
308
|
chunk = queueItem.chunk;
|
307
309
|
if (chunkGroup !== queueItem.chunkGroup) {
|
308
310
|
chunkGroup = queueItem.chunkGroup;
|
309
|
-
|
311
|
+
chunkGroupInfo = chunkGroupInfoMap.get(chunkGroup);
|
310
312
|
minAvailableModules = chunkGroupInfo.minAvailableModules;
|
311
313
|
skippedItems = chunkGroupInfo.skippedItems;
|
312
314
|
}
|
@@ -583,17 +585,14 @@ const visitModules = (
|
|
583
585
|
/**
|
584
586
|
*
|
585
587
|
* @param {Set<DependenciesBlock>} blocksWithNestedBlocks flag for blocks that have nested blocks
|
586
|
-
* @param {Map<
|
588
|
+
* @param {Map<AsyncDependenciesBlock, BlockChunkGroupConnection[]>} blockConnections connection for blocks
|
587
589
|
* @param {Map<ChunkGroup, ChunkGroupInfo>} chunkGroupInfoMap mapping from chunk group to available modules
|
588
590
|
*/
|
589
591
|
const connectChunkGroups = (
|
590
592
|
blocksWithNestedBlocks,
|
591
|
-
|
593
|
+
blockConnections,
|
592
594
|
chunkGroupInfoMap
|
593
595
|
) => {
|
594
|
-
/** @type {Set<Module>} */
|
595
|
-
let resultingAvailableModules;
|
596
|
-
|
597
596
|
/**
|
598
597
|
* Helper function to check if all modules of a chunk are available
|
599
598
|
*
|
@@ -611,49 +610,38 @@ const connectChunkGroups = (
|
|
611
610
|
};
|
612
611
|
|
613
612
|
// For each edge in the basic chunk graph
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
613
|
+
for (const [block, connections] of blockConnections) {
|
614
|
+
// 1. Check if connection is needed
|
615
|
+
// When none of the dependencies need to be connected
|
616
|
+
// we can skip all of them
|
617
|
+
// It's not possible to filter each item so it doesn't create inconsistent
|
618
|
+
// connections and modules can only create one version
|
619
|
+
// TODO maybe decide this per runtime
|
620
|
+
if (
|
621
|
+
// TODO is this needed?
|
622
|
+
!blocksWithNestedBlocks.has(block) &&
|
623
|
+
connections.every(({ chunkGroup, originChunkGroupInfo }) =>
|
624
|
+
areModulesAvailable(
|
625
|
+
chunkGroup,
|
626
|
+
originChunkGroupInfo.resultingAvailableModules
|
627
|
+
)
|
628
|
+
)
|
629
|
+
) {
|
630
|
+
continue;
|
625
631
|
}
|
626
|
-
return true;
|
627
|
-
};
|
628
|
-
|
629
|
-
// For all deps, check if chunk groups need to be connected
|
630
|
-
for (const [chunkGroup, deps] of chunkDependencies) {
|
631
|
-
if (deps.length === 0) continue;
|
632
|
-
|
633
|
-
// 1. Get info from chunk group info map
|
634
|
-
const info = chunkGroupInfoMap.get(chunkGroup);
|
635
|
-
resultingAvailableModules = info.resultingAvailableModules;
|
636
632
|
|
637
633
|
// 2. Foreach edge
|
638
|
-
for (let i = 0; i <
|
639
|
-
const
|
634
|
+
for (let i = 0; i < connections.length; i++) {
|
635
|
+
const { chunkGroup, originChunkGroupInfo } = connections[i];
|
640
636
|
|
641
|
-
//
|
642
|
-
|
643
|
-
if (!filterFn(dep)) {
|
644
|
-
continue;
|
645
|
-
}
|
646
|
-
const depChunkGroup = dep.chunkGroup;
|
647
|
-
const depBlock = dep.block;
|
637
|
+
// 3. Connect block with chunk
|
638
|
+
GraphHelpers.connectDependenciesBlockAndChunkGroup(block, chunkGroup);
|
648
639
|
|
649
|
-
//
|
650
|
-
GraphHelpers.
|
651
|
-
|
652
|
-
|
640
|
+
// 4. Connect chunk with parent
|
641
|
+
GraphHelpers.connectChunkGroupParentAndChild(
|
642
|
+
originChunkGroupInfo.chunkGroup,
|
643
|
+
chunkGroup
|
653
644
|
);
|
654
|
-
|
655
|
-
// 6. Connect chunk with parent
|
656
|
-
GraphHelpers.connectChunkGroupParentAndChild(chunkGroup, depChunkGroup);
|
657
645
|
}
|
658
646
|
}
|
659
647
|
};
|
@@ -685,8 +673,8 @@ const cleanupUnconnectedGroups = (compilation, allCreatedChunkGroups) => {
|
|
685
673
|
const buildChunkGraph = (compilation, inputChunkGroups) => {
|
686
674
|
// SHARED STATE
|
687
675
|
|
688
|
-
/** @type {Map<
|
689
|
-
const
|
676
|
+
/** @type {Map<AsyncDependenciesBlock, BlockChunkGroupConnection[]>} */
|
677
|
+
const blockConnections = new Map();
|
690
678
|
|
691
679
|
/** @type {Set<ChunkGroup>} */
|
692
680
|
const allCreatedChunkGroups = new Set();
|
@@ -703,7 +691,7 @@ const buildChunkGraph = (compilation, inputChunkGroups) => {
|
|
703
691
|
compilation,
|
704
692
|
inputChunkGroups,
|
705
693
|
chunkGroupInfoMap,
|
706
|
-
|
694
|
+
blockConnections,
|
707
695
|
blocksWithNestedBlocks,
|
708
696
|
allCreatedChunkGroups
|
709
697
|
);
|
@@ -712,7 +700,7 @@ const buildChunkGraph = (compilation, inputChunkGroups) => {
|
|
712
700
|
|
713
701
|
connectChunkGroups(
|
714
702
|
blocksWithNestedBlocks,
|
715
|
-
|
703
|
+
blockConnections,
|
716
704
|
chunkGroupInfoMap
|
717
705
|
);
|
718
706
|
|
@@ -215,6 +215,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
215
215
|
const mode = new ExportMode("dynamic-reexport");
|
216
216
|
mode.module = importedModule;
|
217
217
|
mode.ignored = new Set([
|
218
|
+
"default",
|
218
219
|
...this.activeExports,
|
219
220
|
...activeFromOtherStarExports
|
220
221
|
]);
|
@@ -586,7 +587,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
586
587
|
.join("");
|
587
588
|
|
588
589
|
case "dynamic-reexport": {
|
589
|
-
const
|
590
|
+
const ignoredExports = mode.ignored;
|
590
591
|
let content =
|
591
592
|
"/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in " +
|
592
593
|
importVar +
|
@@ -594,10 +595,10 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
594
595
|
|
595
596
|
// Filter out exports which are defined by other exports
|
596
597
|
// and filter out default export because it cannot be reexported with *
|
597
|
-
if (
|
598
|
+
if (ignoredExports.size > 0) {
|
598
599
|
content +=
|
599
600
|
"if(" +
|
600
|
-
JSON.stringify(Array.from(
|
601
|
+
JSON.stringify(Array.from(ignoredExports)) +
|
601
602
|
".indexOf(__WEBPACK_IMPORT_KEY__) < 0) ";
|
602
603
|
} else {
|
603
604
|
content += "if(__WEBPACK_IMPORT_KEY__ !== 'default') ";
|
@@ -76,7 +76,7 @@ const compareEntries = (a, b) => {
|
|
76
76
|
const diffSizeReduce = aSizeReduce - bSizeReduce;
|
77
77
|
if (diffSizeReduce) return diffSizeReduce;
|
78
78
|
// 4. by cache group index
|
79
|
-
const indexDiff =
|
79
|
+
const indexDiff = b.cacheGroupIndex - a.cacheGroupIndex;
|
80
80
|
if (indexDiff) return indexDiff;
|
81
81
|
// 5. by number of modules (to be able to compare by identifier)
|
82
82
|
const modulesA = a.modules;
|
@@ -523,10 +523,14 @@ module.exports = class SplitChunksPlugin {
|
|
523
523
|
})
|
524
524
|
);
|
525
525
|
}
|
526
|
+
const oldSize = info.modules.size;
|
526
527
|
info.modules.add(module);
|
527
|
-
info.size
|
528
|
-
|
529
|
-
|
528
|
+
if (info.modules.size !== oldSize) {
|
529
|
+
info.size += module.size();
|
530
|
+
}
|
531
|
+
const oldChunksKeysSize = info.chunksKeys.size;
|
532
|
+
info.chunksKeys.add(selectedChunksKey);
|
533
|
+
if (oldChunksKeysSize !== info.chunksKeys.size) {
|
530
534
|
for (const chunk of selectedChunks) {
|
531
535
|
info.chunks.add(chunk);
|
532
536
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.46.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",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
"ajv": "^6.10.2",
|
14
14
|
"ajv-keywords": "^3.4.1",
|
15
15
|
"chrome-trace-event": "^1.0.2",
|
16
|
-
"enhanced-resolve": "^4.
|
16
|
+
"enhanced-resolve": "^4.5.0",
|
17
17
|
"eslint-scope": "^4.0.3",
|
18
18
|
"json-parse-better-errors": "^1.0.2",
|
19
19
|
"loader-runner": "^2.4.0",
|
@@ -29,6 +29,14 @@
|
|
29
29
|
"watchpack": "^1.7.4",
|
30
30
|
"webpack-sources": "^1.4.1"
|
31
31
|
},
|
32
|
+
"peerDependenciesMeta": {
|
33
|
+
"webpack-cli": {
|
34
|
+
"optional": true
|
35
|
+
},
|
36
|
+
"webpack-command": {
|
37
|
+
"optional": true
|
38
|
+
}
|
39
|
+
},
|
32
40
|
"devDependencies": {
|
33
41
|
"@babel/core": "^7.7.2",
|
34
42
|
"@types/node": "^10.12.21",
|
@@ -1179,6 +1179,10 @@
|
|
1179
1179
|
"fileSystem": {
|
1180
1180
|
"description": "Filesystem for the resolver"
|
1181
1181
|
},
|
1182
|
+
"ignoreRootsErrors": {
|
1183
|
+
"description": "Enable to ignore fatal errors happening during resolving of 'resolve.roots'. Usually such errors should not happen, but this option is provided for backward-compatibility.",
|
1184
|
+
"type": "boolean"
|
1185
|
+
},
|
1182
1186
|
"mainFields": {
|
1183
1187
|
"description": "Field names from the description file (package.json) which are used to find the default entry point",
|
1184
1188
|
"anyOf": [
|
@@ -1226,11 +1230,15 @@
|
|
1226
1230
|
]
|
1227
1231
|
}
|
1228
1232
|
},
|
1233
|
+
"preferAbsolute": {
|
1234
|
+
"description": "Prefer to resolve server-relative URLs (starting with '/') as absolute paths before falling back to resolve in 'resolve.roots'.",
|
1235
|
+
"type": "boolean"
|
1236
|
+
},
|
1229
1237
|
"resolver": {
|
1230
1238
|
"description": "Custom resolver"
|
1231
1239
|
},
|
1232
1240
|
"roots": {
|
1233
|
-
"description": "A list of directories in which requests that are server-relative URLs (starting with '/') are resolved.
|
1241
|
+
"description": "A list of directories in which requests that are server-relative URLs (starting with '/') are resolved.",
|
1234
1242
|
"type": "array",
|
1235
1243
|
"items": {
|
1236
1244
|
"description": "Directory in which requests that are server-relative URLs (starting with '/') are resolved.",
|