webpack 5.94.0 → 5.95.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/lib/EnvironmentPlugin.js +3 -2
- package/lib/ExternalModule.js +79 -93
- package/lib/NormalModule.js +4 -0
- package/lib/TemplatedPathPlugin.js +9 -3
- package/lib/buildChunkGraph.js +79 -62
- package/lib/config/defaults.js +1 -0
- package/lib/dependencies/ContextDependency.js +6 -1
- package/lib/dependencies/ContextElementDependency.js +33 -6
- package/lib/javascript/JavascriptModulesPlugin.js +43 -18
- package/lib/optimize/ConcatenatedModule.js +1 -3
- package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
- package/lib/util/LazySet.js +12 -0
- package/lib/util/fs.js +1 -1
- package/lib/util/runtime.js +6 -0
- package/package.json +4 -4
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +4 -0
- package/types.d.ts +17 -11
@@ -839,18 +839,25 @@ class JavascriptModulesPlugin {
|
|
839
839
|
startupSource.add(`var ${RuntimeGlobals.exports} = {};\n`);
|
840
840
|
}
|
841
841
|
|
842
|
-
const
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
842
|
+
const avoidEntryIife = compilation.options.optimization.avoidEntryIife;
|
843
|
+
/** @type {Map<Module, Source> | false} */
|
844
|
+
let renamedInlinedModule = false;
|
845
|
+
if (avoidEntryIife) {
|
846
|
+
renamedInlinedModule = this.getRenamedInlineModule(
|
847
|
+
allModules,
|
848
|
+
renderContext,
|
849
|
+
inlinedModules,
|
850
|
+
chunkRenderContext,
|
851
|
+
hooks,
|
852
|
+
allStrict,
|
853
|
+
Boolean(chunkModules)
|
854
|
+
);
|
855
|
+
}
|
849
856
|
|
850
857
|
for (const m of inlinedModules) {
|
851
|
-
const renderedModule =
|
852
|
-
renamedInlinedModule.get(m)
|
853
|
-
this.renderModule(m, chunkRenderContext, hooks, false);
|
858
|
+
const renderedModule = renamedInlinedModule
|
859
|
+
? renamedInlinedModule.get(m)
|
860
|
+
: this.renderModule(m, chunkRenderContext, hooks, false);
|
854
861
|
|
855
862
|
if (renderedModule) {
|
856
863
|
const innerStrict =
|
@@ -868,9 +875,11 @@ class JavascriptModulesPlugin {
|
|
868
875
|
? // TODO check globals and top-level declarations of other entries and chunk modules
|
869
876
|
// to make a better decision
|
870
877
|
"it need to be isolated against other entry modules."
|
871
|
-
:
|
872
|
-
?
|
873
|
-
:
|
878
|
+
: chunkModules && !renamedInlinedModule
|
879
|
+
? "it need to be isolated against other modules in the chunk."
|
880
|
+
: exports && !webpackExports
|
881
|
+
? `it uses a non-standard name for the exports (${m.exportsArgument}).`
|
882
|
+
: hooks.embedInRuntimeBailout.call(m, renderContext);
|
874
883
|
let footer;
|
875
884
|
if (iife !== undefined) {
|
876
885
|
startupSource.add(
|
@@ -1420,25 +1429,41 @@ class JavascriptModulesPlugin {
|
|
1420
1429
|
* @param {Set<Module>} inlinedModules inlinedModules
|
1421
1430
|
* @param {ChunkRenderContext} chunkRenderContext chunkRenderContext
|
1422
1431
|
* @param {CompilationHooks} hooks hooks
|
1423
|
-
* @
|
1432
|
+
* @param {boolean} allStrict allStrict
|
1433
|
+
* @param {boolean} hasChunkModules hasChunkModules
|
1434
|
+
* @returns {Map<Module, Source> | false} renamed inlined modules
|
1424
1435
|
*/
|
1425
|
-
|
1436
|
+
getRenamedInlineModule(
|
1426
1437
|
allModules,
|
1427
1438
|
renderContext,
|
1428
1439
|
inlinedModules,
|
1429
1440
|
chunkRenderContext,
|
1430
|
-
hooks
|
1441
|
+
hooks,
|
1442
|
+
allStrict,
|
1443
|
+
hasChunkModules
|
1431
1444
|
) {
|
1445
|
+
const innerStrict = !allStrict && allModules.every(m => m.buildInfo.strict);
|
1446
|
+
const isMultipleEntries = inlinedModules.size > 1;
|
1447
|
+
const singleEntryWithModules = inlinedModules.size === 1 && hasChunkModules;
|
1448
|
+
|
1449
|
+
// TODO:
|
1450
|
+
// This step is before the IIFE reason calculation. Ideally, it should only be executed when this function can optimize the
|
1451
|
+
// IIFE reason. Otherwise, it should directly return false. There are four reasons now, we have skipped two already, the left
|
1452
|
+
// one is 'it uses a non-standard name for the exports'.
|
1453
|
+
if (isMultipleEntries || innerStrict || !singleEntryWithModules) {
|
1454
|
+
return false;
|
1455
|
+
}
|
1456
|
+
|
1457
|
+
/** @type {Map<Module, Source>} */
|
1458
|
+
const renamedInlinedModules = new Map();
|
1432
1459
|
const { runtimeTemplate } = renderContext;
|
1433
1460
|
|
1434
1461
|
/** @typedef {{ source: Source, ast: any, variables: Set<Variable>, usedInNonInlined: Set<Variable>}} InlinedModulesInfo */
|
1435
|
-
|
1436
1462
|
/** @type {Map<Module, InlinedModulesInfo>} */
|
1437
1463
|
const inlinedModulesToInfo = new Map();
|
1438
1464
|
/** @type {Set<string>} */
|
1439
1465
|
const nonInlinedModuleThroughIdentifiers = new Set();
|
1440
1466
|
/** @type {Map<Module, Source>} */
|
1441
|
-
const renamedInlinedModules = new Map();
|
1442
1467
|
|
1443
1468
|
for (const m of allModules) {
|
1444
1469
|
const isInlinedModule = inlinedModules && inlinedModules.has(m);
|
@@ -1660,9 +1660,7 @@ ${defineGetters}`
|
|
1660
1660
|
switch (info.type) {
|
1661
1661
|
case "concatenated": {
|
1662
1662
|
result.add(
|
1663
|
-
`\n;//
|
1664
|
-
requestShortener
|
1665
|
-
)}\n`
|
1663
|
+
`\n;// ${info.module.readableIdentifier(requestShortener)}\n`
|
1666
1664
|
);
|
1667
1665
|
result.add(info.source);
|
1668
1666
|
if (info.chunkInitFragments) {
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
const {
|
8
|
+
const { STAGE_ADVANCED } = require("../OptimizationStages");
|
9
9
|
const { runtimeEqual } = require("../util/runtime");
|
10
10
|
|
11
11
|
/** @typedef {import("../Compiler")} Compiler */
|
@@ -22,7 +22,7 @@ class MergeDuplicateChunksPlugin {
|
|
22
22
|
compilation.hooks.optimizeChunks.tap(
|
23
23
|
{
|
24
24
|
name: "MergeDuplicateChunksPlugin",
|
25
|
-
stage:
|
25
|
+
stage: STAGE_ADVANCED
|
26
26
|
},
|
27
27
|
chunks => {
|
28
28
|
const { chunkGraph, moduleGraph } = compilation;
|
package/lib/util/LazySet.js
CHANGED
@@ -138,6 +138,9 @@ class LazySet {
|
|
138
138
|
return this._set.delete(value);
|
139
139
|
}
|
140
140
|
|
141
|
+
/**
|
142
|
+
* @returns {IterableIterator<[T, T]>} entries
|
143
|
+
*/
|
141
144
|
entries() {
|
142
145
|
this._deopt = true;
|
143
146
|
if (this._needMerge) this._merge();
|
@@ -165,18 +168,27 @@ class LazySet {
|
|
165
168
|
return this._set.has(item);
|
166
169
|
}
|
167
170
|
|
171
|
+
/**
|
172
|
+
* @returns {IterableIterator<T>} keys
|
173
|
+
*/
|
168
174
|
keys() {
|
169
175
|
this._deopt = true;
|
170
176
|
if (this._needMerge) this._merge();
|
171
177
|
return this._set.keys();
|
172
178
|
}
|
173
179
|
|
180
|
+
/**
|
181
|
+
* @returns {IterableIterator<T>} values
|
182
|
+
*/
|
174
183
|
values() {
|
175
184
|
this._deopt = true;
|
176
185
|
if (this._needMerge) this._merge();
|
177
186
|
return this._set.values();
|
178
187
|
}
|
179
188
|
|
189
|
+
/**
|
190
|
+
* @returns {IterableIterator<T>} iterable iterator
|
191
|
+
*/
|
180
192
|
[Symbol.iterator]() {
|
181
193
|
this._deopt = true;
|
182
194
|
if (this._needMerge) this._merge();
|
package/lib/util/fs.js
CHANGED
@@ -625,7 +625,7 @@ const lstatReadlinkAbsolute = (fs, p, callback) => {
|
|
625
625
|
// we retry 2 times to catch this case before throwing the error
|
626
626
|
return doStat();
|
627
627
|
}
|
628
|
-
if (err
|
628
|
+
if (err) return callback(err);
|
629
629
|
const value = target.toString();
|
630
630
|
callback(null, join(fs, dirname(fs, p), value));
|
631
631
|
});
|
package/lib/util/runtime.js
CHANGED
@@ -618,6 +618,9 @@ class RuntimeSpecMap {
|
|
618
618
|
}
|
619
619
|
}
|
620
620
|
|
621
|
+
/**
|
622
|
+
* @returns {IterableIterator<T>} values
|
623
|
+
*/
|
621
624
|
values() {
|
622
625
|
switch (this._mode) {
|
623
626
|
case 0:
|
@@ -666,6 +669,9 @@ class RuntimeSpecSet {
|
|
666
669
|
return this._map.has(getRuntimeKey(runtime));
|
667
670
|
}
|
668
671
|
|
672
|
+
/**
|
673
|
+
* @returns {IterableIterator<RuntimeSpec>} iterable iterator
|
674
|
+
*/
|
669
675
|
[Symbol.iterator]() {
|
670
676
|
return this._map.values();
|
671
677
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.95.0",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
6
6
|
"license": "MIT",
|
@@ -53,7 +53,7 @@
|
|
53
53
|
"core-js": "^3.6.5",
|
54
54
|
"cspell": "^8.8.4",
|
55
55
|
"css-loader": "^7.1.2",
|
56
|
-
"date-fns": "^
|
56
|
+
"date-fns": "^4.0.0",
|
57
57
|
"es5-ext": "^0.10.53",
|
58
58
|
"es6-promise-polyfill": "^1.2.0",
|
59
59
|
"eslint": "^9.5.0",
|
@@ -103,9 +103,9 @@
|
|
103
103
|
"style-loader": "^4.0.0",
|
104
104
|
"terser": "^5.31.1",
|
105
105
|
"toml": "^3.0.0",
|
106
|
-
"tooling": "webpack/tooling#v1.23.
|
106
|
+
"tooling": "webpack/tooling#v1.23.4",
|
107
107
|
"ts-loader": "^9.5.1",
|
108
|
-
"typescript": "^5.
|
108
|
+
"typescript": "^5.6.2",
|
109
109
|
"url-loader": "^4.1.0",
|
110
110
|
"wast-loader": "^1.12.1",
|
111
111
|
"webassembly-feature": "1.3.0",
|