webpack 5.90.1 → 5.90.2
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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/lib/buildChunkGraph.js +49 -16
- package/lib/dependencies/ExportsInfoDependency.js +6 -12
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +1 -1
- package/lib/dependencies/ImportParserPlugin.js +1 -0
- package/lib/hmr/HotModuleReplacement.runtime.js +1 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +1 -1
- package/lib/util/numberHash.js +4 -15
- package/package.json +2 -2
package/lib/buildChunkGraph.js
CHANGED
@@ -44,7 +44,7 @@ const { getEntryRuntime, mergeRuntime } = require("./util/runtime");
|
|
44
44
|
* @property {boolean | undefined} minAvailableModulesOwned true, if minAvailableModules is owned and can be modified
|
45
45
|
* @property {ModuleSetPlus[]} availableModulesToBeMerged enqueued updates to the minimal set of available modules
|
46
46
|
* @property {Set<Module>=} skippedItems modules that were skipped because module is already available in parent chunks (need to reconsider when minAvailableModules is shrinking)
|
47
|
-
* @property {Set<[Module,
|
47
|
+
* @property {Set<[Module, ModuleGraphConnection[]]>=} skippedModuleConnections referenced modules that where skipped because they were not active in this runtime
|
48
48
|
* @property {ModuleSetPlus | undefined} resultingAvailableModules set of modules available including modules from this chunk group
|
49
49
|
* @property {Set<ChunkGroupInfo> | undefined} children set of children chunk groups, that will be revisited when availableModules shrink
|
50
50
|
* @property {Set<ChunkGroupInfo> | undefined} availableSources set of chunk groups that are the source for minAvailableModules
|
@@ -73,6 +73,25 @@ const bySetSize = (a, b) => {
|
|
73
73
|
return b.size + b.plus.size - a.size - a.plus.size;
|
74
74
|
};
|
75
75
|
|
76
|
+
/**
|
77
|
+
* @param {ModuleGraphConnection[]} connections list of connections
|
78
|
+
* @param {RuntimeSpec} runtime for which runtime
|
79
|
+
* @returns {ConnectionState} connection state
|
80
|
+
*/
|
81
|
+
const getActiveStateOfConnections = (connections, runtime) => {
|
82
|
+
let merged = connections[0].getActiveState(runtime);
|
83
|
+
if (merged === true) return true;
|
84
|
+
for (let i = 1; i < connections.length; i++) {
|
85
|
+
const c = connections[i];
|
86
|
+
merged = ModuleGraphConnection.addConnectionStates(
|
87
|
+
merged,
|
88
|
+
c.getActiveState(runtime)
|
89
|
+
);
|
90
|
+
if (merged === true) return true;
|
91
|
+
}
|
92
|
+
return merged;
|
93
|
+
};
|
94
|
+
|
76
95
|
const extractBlockModules = (module, moduleGraph, runtime, blockModulesMap) => {
|
77
96
|
let blockCache;
|
78
97
|
let modules;
|
@@ -99,9 +118,6 @@ const extractBlockModules = (module, moduleGraph, runtime, blockModulesMap) => {
|
|
99
118
|
if (!m) continue;
|
100
119
|
// We skip weak connections
|
101
120
|
if (connection.weak) continue;
|
102
|
-
const state = connection.getActiveState(runtime);
|
103
|
-
// We skip inactive connections
|
104
|
-
if (state === false) continue;
|
105
121
|
|
106
122
|
const block = moduleGraph.getParentBlock(d);
|
107
123
|
let index = moduleGraph.getParentBlockIndex(d);
|
@@ -115,41 +131,47 @@ const extractBlockModules = (module, moduleGraph, runtime, blockModulesMap) => {
|
|
115
131
|
modules = blockModulesMap.get((blockCache = block));
|
116
132
|
}
|
117
133
|
|
118
|
-
const i = index
|
134
|
+
const i = index * 3;
|
119
135
|
modules[i] = m;
|
120
|
-
modules[i + 1] =
|
136
|
+
modules[i + 1] = connection.getActiveState(runtime);
|
137
|
+
modules[i + 2] = connection;
|
121
138
|
}
|
122
139
|
|
123
140
|
for (const modules of arrays) {
|
124
141
|
if (modules.length === 0) continue;
|
125
142
|
let indexMap;
|
126
143
|
let length = 0;
|
127
|
-
outer: for (let j = 0; j < modules.length; j +=
|
144
|
+
outer: for (let j = 0; j < modules.length; j += 3) {
|
128
145
|
const m = modules[j];
|
129
146
|
if (m === undefined) continue;
|
130
147
|
const state = modules[j + 1];
|
148
|
+
const connection = modules[j + 2];
|
131
149
|
if (indexMap === undefined) {
|
132
150
|
let i = 0;
|
133
|
-
for (; i < length; i +=
|
151
|
+
for (; i < length; i += 3) {
|
134
152
|
if (modules[i] === m) {
|
135
153
|
const merged = modules[i + 1];
|
154
|
+
modules[i + 2].push(connection);
|
136
155
|
if (merged === true) continue outer;
|
137
156
|
modules[i + 1] = ModuleGraphConnection.addConnectionStates(
|
138
157
|
merged,
|
139
158
|
state
|
140
159
|
);
|
160
|
+
continue outer;
|
141
161
|
}
|
142
162
|
}
|
143
163
|
modules[length] = m;
|
144
164
|
length++;
|
145
165
|
modules[length] = state;
|
146
166
|
length++;
|
167
|
+
modules[length] = [connection];
|
168
|
+
length++;
|
147
169
|
if (length > 30) {
|
148
170
|
// To avoid worse case performance, we will use an index map for
|
149
171
|
// linear cost access, which allows to maintain O(n) complexity
|
150
172
|
// while keeping allocations down to a minimum
|
151
173
|
indexMap = new Map();
|
152
|
-
for (let i = 0; i < length; i +=
|
174
|
+
for (let i = 0; i < length; i += 3) {
|
153
175
|
indexMap.set(modules[i], i + 1);
|
154
176
|
}
|
155
177
|
}
|
@@ -157,6 +179,7 @@ const extractBlockModules = (module, moduleGraph, runtime, blockModulesMap) => {
|
|
157
179
|
const idx = indexMap.get(m);
|
158
180
|
if (idx !== undefined) {
|
159
181
|
const merged = modules[idx];
|
182
|
+
modules[idx + 1].push(connection);
|
160
183
|
if (merged === true) continue outer;
|
161
184
|
modules[idx] = ModuleGraphConnection.addConnectionStates(
|
162
185
|
merged,
|
@@ -168,6 +191,8 @@ const extractBlockModules = (module, moduleGraph, runtime, blockModulesMap) => {
|
|
168
191
|
modules[length] = state;
|
169
192
|
indexMap.set(m, length);
|
170
193
|
length++;
|
194
|
+
modules[length] = [connection];
|
195
|
+
length++;
|
171
196
|
}
|
172
197
|
}
|
173
198
|
}
|
@@ -207,7 +232,7 @@ const visitModules = (
|
|
207
232
|
*
|
208
233
|
* @param {DependenciesBlock} block block
|
209
234
|
* @param {RuntimeSpec} runtime runtime
|
210
|
-
* @returns {(Module | ConnectionState)[]} block modules in flatten tuples
|
235
|
+
* @returns {(Module | ConnectionState | ModuleGraphConnection[])[]} block modules in flatten tuples
|
211
236
|
*/
|
212
237
|
const getBlockModules = (block, runtime) => {
|
213
238
|
if (blockModulesMapRuntime !== runtime) {
|
@@ -382,7 +407,7 @@ const visitModules = (
|
|
382
407
|
/** @type {QueueItem[]} */
|
383
408
|
let queueDelayed = [];
|
384
409
|
|
385
|
-
/** @type {[Module,
|
410
|
+
/** @type {[Module, ModuleGraphConnection[]][]} */
|
386
411
|
const skipConnectionBuffer = [];
|
387
412
|
/** @type {Module[]} */
|
388
413
|
const skipBuffer = [];
|
@@ -582,7 +607,7 @@ const visitModules = (
|
|
582
607
|
const { minAvailableModules } = chunkGroupInfo;
|
583
608
|
// Buffer items because order need to be reversed to get indices correct
|
584
609
|
// Traverse all referenced modules
|
585
|
-
for (let i = 0; i < blockModules.length; i +=
|
610
|
+
for (let i = 0; i < blockModules.length; i += 3) {
|
586
611
|
const refModule = /** @type {Module} */ (blockModules[i]);
|
587
612
|
if (chunkGraph.isModuleInChunk(refModule, chunk)) {
|
588
613
|
// skip early if already connected
|
@@ -592,7 +617,11 @@ const visitModules = (
|
|
592
617
|
blockModules[i + 1]
|
593
618
|
);
|
594
619
|
if (activeState !== true) {
|
595
|
-
|
620
|
+
const connections = /** @type {ModuleGraphConnection[]} */ (
|
621
|
+
blockModules[i + 2]
|
622
|
+
);
|
623
|
+
skipConnectionBuffer.push([refModule, connections]);
|
624
|
+
// We skip inactive connections
|
596
625
|
if (activeState === false) continue;
|
597
626
|
}
|
598
627
|
if (
|
@@ -666,7 +695,7 @@ const visitModules = (
|
|
666
695
|
|
667
696
|
if (blockModules !== undefined) {
|
668
697
|
// Traverse all referenced modules
|
669
|
-
for (let i = 0; i < blockModules.length; i +=
|
698
|
+
for (let i = 0; i < blockModules.length; i += 3) {
|
670
699
|
const refModule = /** @type {Module} */ (blockModules[i]);
|
671
700
|
const activeState = /** @type {ConnectionState} */ (
|
672
701
|
blockModules[i + 1]
|
@@ -1172,7 +1201,11 @@ const visitModules = (
|
|
1172
1201
|
/** @type {ModuleSetPlus} */
|
1173
1202
|
(info.minAvailableModules);
|
1174
1203
|
for (const entry of info.skippedModuleConnections) {
|
1175
|
-
const [module,
|
1204
|
+
const [module, connections] = entry;
|
1205
|
+
const activeState = getActiveStateOfConnections(
|
1206
|
+
connections,
|
1207
|
+
info.runtime
|
1208
|
+
);
|
1176
1209
|
if (activeState === false) continue;
|
1177
1210
|
if (activeState === true) {
|
1178
1211
|
info.skippedModuleConnections.delete(entry);
|
@@ -1286,7 +1319,7 @@ const visitModules = (
|
|
1286
1319
|
return;
|
1287
1320
|
}
|
1288
1321
|
|
1289
|
-
for (let i = 0; i < blockModules.length; i +=
|
1322
|
+
for (let i = 0; i < blockModules.length; i += 3) {
|
1290
1323
|
const refModule = /** @type {Module} */ (blockModules[i]);
|
1291
1324
|
const activeState = /** @type {ConnectionState} */ (
|
1292
1325
|
blockModules[i + 1]
|
@@ -25,7 +25,7 @@ const NullDependency = require("./NullDependency");
|
|
25
25
|
/**
|
26
26
|
* @param {ModuleGraph} moduleGraph the module graph
|
27
27
|
* @param {Module} module the module
|
28
|
-
* @param {string | null} exportName name of the export if any
|
28
|
+
* @param {string[] | null} exportName name of the export if any
|
29
29
|
* @param {string | null} property name of the requested property
|
30
30
|
* @param {RuntimeSpec} runtime for which runtime
|
31
31
|
* @returns {any} value of the property
|
@@ -51,23 +51,19 @@ const getProperty = (moduleGraph, module, exportName, property, runtime) => {
|
|
51
51
|
switch (property) {
|
52
52
|
case "canMangle": {
|
53
53
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
54
|
-
const exportInfo = exportsInfo.getExportInfo(
|
55
|
-
/** @type {string} */ (exportName)
|
56
|
-
);
|
54
|
+
const exportInfo = exportsInfo.getExportInfo(exportName[0]);
|
57
55
|
if (exportInfo) return exportInfo.canMangle;
|
58
56
|
return exportsInfo.otherExportsInfo.canMangle;
|
59
57
|
}
|
60
58
|
case "used":
|
61
59
|
return (
|
62
|
-
moduleGraph
|
63
|
-
.getExportsInfo(module)
|
64
|
-
.getUsed(/** @type {string} */ (exportName), runtime) !==
|
60
|
+
moduleGraph.getExportsInfo(module).getUsed(exportName, runtime) !==
|
65
61
|
UsageState.Unused
|
66
62
|
);
|
67
63
|
case "useInfo": {
|
68
64
|
const state = moduleGraph
|
69
65
|
.getExportsInfo(module)
|
70
|
-
.getUsed(
|
66
|
+
.getUsed(exportName, runtime);
|
71
67
|
switch (state) {
|
72
68
|
case UsageState.Used:
|
73
69
|
case UsageState.OnlyPropertiesUsed:
|
@@ -83,9 +79,7 @@ const getProperty = (moduleGraph, module, exportName, property, runtime) => {
|
|
83
79
|
}
|
84
80
|
}
|
85
81
|
case "provideInfo":
|
86
|
-
return moduleGraph
|
87
|
-
.getExportsInfo(module)
|
88
|
-
.isExportProvided(/** @type {string} */ (exportName));
|
82
|
+
return moduleGraph.getExportsInfo(module).isExportProvided(exportName);
|
89
83
|
}
|
90
84
|
return undefined;
|
91
85
|
};
|
@@ -93,7 +87,7 @@ const getProperty = (moduleGraph, module, exportName, property, runtime) => {
|
|
93
87
|
class ExportsInfoDependency extends NullDependency {
|
94
88
|
/**
|
95
89
|
* @param {Range} range range
|
96
|
-
* @param {
|
90
|
+
* @param {string[] | null} exportName export name
|
97
91
|
* @param {string | null} property property
|
98
92
|
*/
|
99
93
|
constructor(range, exportName, property) {
|
@@ -192,7 +192,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
192
192
|
for (const key of this.referencedPropertiesInDestructuring) {
|
193
193
|
refs.push({
|
194
194
|
name: ids ? ids.concat([key]) : [key],
|
195
|
-
canMangle:
|
195
|
+
canMangle: Array.isArray(ids) && ids.length > 0
|
196
196
|
});
|
197
197
|
}
|
198
198
|
return refs;
|
@@ -215,7 +215,7 @@ module.exports = function () {
|
|
215
215
|
for (var i = 0; i < registeredStatusHandlers.length; i++)
|
216
216
|
results[i] = registeredStatusHandlers[i].call(null, newStatus);
|
217
217
|
|
218
|
-
return Promise.all(results);
|
218
|
+
return Promise.all(results).then(function () {});
|
219
219
|
}
|
220
220
|
|
221
221
|
function unblock() {
|
@@ -56,7 +56,7 @@ class AutoPublicPathRuntimeModule extends RuntimeModule {
|
|
56
56
|
"if(scripts.length) {",
|
57
57
|
Template.indent([
|
58
58
|
"var i = scripts.length - 1;",
|
59
|
-
"while (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src;"
|
59
|
+
"while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;"
|
60
60
|
]),
|
61
61
|
"}"
|
62
62
|
]),
|
package/lib/util/numberHash.js
CHANGED
@@ -47,14 +47,9 @@ const FNV_PRIME_64 = BigInt("0x100000001B3");
|
|
47
47
|
function fnv1a32(str) {
|
48
48
|
let hash = FNV_OFFSET_32;
|
49
49
|
for (let i = 0, len = str.length; i < len; i++) {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
hash = (hash * FNV_PRIME_32) | 0;
|
54
|
-
code >>= 8;
|
55
|
-
}
|
56
|
-
hash ^= code;
|
57
|
-
hash = (hash * FNV_PRIME_32) | 0;
|
50
|
+
hash ^= str.charCodeAt(i);
|
51
|
+
// Use Math.imul to do c-style 32-bit multiplication and keep only the 32 least significant bits
|
52
|
+
hash = Math.imul(hash, FNV_PRIME_32);
|
58
53
|
}
|
59
54
|
// Force the result to be positive
|
60
55
|
return hash & MASK_31;
|
@@ -69,13 +64,7 @@ function fnv1a32(str) {
|
|
69
64
|
function fnv1a64(str) {
|
70
65
|
let hash = FNV_OFFSET_64;
|
71
66
|
for (let i = 0, len = str.length; i < len; i++) {
|
72
|
-
|
73
|
-
if (code > 0xff) {
|
74
|
-
hash ^= BigInt(code & 0xff);
|
75
|
-
hash = BigInt.asUintN(64, hash * FNV_PRIME_64);
|
76
|
-
code >>= 8;
|
77
|
-
}
|
78
|
-
hash ^= BigInt(code);
|
67
|
+
hash ^= BigInt(str.charCodeAt(i));
|
79
68
|
hash = BigInt.asUintN(64, hash * FNV_PRIME_64);
|
80
69
|
}
|
81
70
|
return hash;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.90.
|
3
|
+
"version": "5.90.2",
|
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",
|
@@ -57,7 +57,7 @@
|
|
57
57
|
"eslint": "^8.48.0",
|
58
58
|
"eslint-config-prettier": "^9.1.0",
|
59
59
|
"eslint-plugin-jest": "^27.6.3",
|
60
|
-
"eslint-plugin-jsdoc": "^
|
60
|
+
"eslint-plugin-jsdoc": "^48.1.0",
|
61
61
|
"eslint-plugin-n": "^16.6.2",
|
62
62
|
"eslint-plugin-prettier": "^5.1.3",
|
63
63
|
"file-loader": "^6.0.0",
|