webpack 5.58.0 → 5.59.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/lib/ChunkGraph.js +16 -30
- package/lib/Compilation.js +175 -109
- package/lib/Compiler.js +2 -2
- package/lib/DefinePlugin.js +1 -1
- package/lib/FileSystemInfo.js +112 -30
- package/lib/NormalModule.js +31 -11
- package/lib/NormalModuleFactory.js +57 -55
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/WebpackOptionsApply.js +0 -2
- package/lib/cache/AddManagedPathsPlugin.js +2 -2
- package/lib/cache/PackFileCacheStrategy.js +2 -2
- package/lib/config/defaults.js +65 -43
- package/lib/config/normalization.js +6 -1
- package/lib/optimize/ConcatenatedModule.js +1 -1
- package/lib/optimize/SplitChunksPlugin.js +289 -136
- package/lib/schemes/HttpUriPlugin.js +107 -31
- package/lib/serialization/Serializer.js +2 -4
- package/lib/util/fs.js +2 -0
- package/lib/util/propertyAccess.js +2 -2
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +1 -6
- package/package.json +1 -1
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +258 -55
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.json +28 -0
- package/types.d.ts +110 -101
- package/lib/ChunkCombination.js +0 -187
package/lib/config/defaults.js
CHANGED
@@ -19,6 +19,7 @@ const {
|
|
19
19
|
/** @typedef {import("../../declarations/WebpackOptions").EntryDescription} EntryDescription */
|
20
20
|
/** @typedef {import("../../declarations/WebpackOptions").EntryNormalized} Entry */
|
21
21
|
/** @typedef {import("../../declarations/WebpackOptions").Experiments} Experiments */
|
22
|
+
/** @typedef {import("../../declarations/WebpackOptions").ExperimentsNormalized} ExperimentsNormalized */
|
22
23
|
/** @typedef {import("../../declarations/WebpackOptions").ExternalsPresets} ExternalsPresets */
|
23
24
|
/** @typedef {import("../../declarations/WebpackOptions").ExternalsType} ExternalsType */
|
24
25
|
/** @typedef {import("../../declarations/WebpackOptions").InfrastructureLogging} InfrastructureLogging */
|
@@ -161,6 +162,8 @@ const applyWebpackOptionsDefaults = options => {
|
|
161
162
|
|
162
163
|
applyExperimentsDefaults(options.experiments, { production, development });
|
163
164
|
|
165
|
+
const futureDefaults = options.experiments.futureDefaults;
|
166
|
+
|
164
167
|
F(options, "cache", () =>
|
165
168
|
development ? { type: /** @type {"memory"} */ ("memory") } : false
|
166
169
|
);
|
@@ -172,7 +175,10 @@ const applyWebpackOptionsDefaults = options => {
|
|
172
175
|
});
|
173
176
|
const cache = !!options.cache;
|
174
177
|
|
175
|
-
applySnapshotDefaults(options.snapshot, {
|
178
|
+
applySnapshotDefaults(options.snapshot, {
|
179
|
+
production,
|
180
|
+
futureDefaults
|
181
|
+
});
|
176
182
|
|
177
183
|
applyModuleDefaults(options.module, {
|
178
184
|
cache,
|
@@ -192,7 +198,7 @@ const applyWebpackOptionsDefaults = options => {
|
|
192
198
|
development,
|
193
199
|
entry: options.entry,
|
194
200
|
module: options.module,
|
195
|
-
futureDefaults
|
201
|
+
futureDefaults
|
196
202
|
});
|
197
203
|
|
198
204
|
applyExternalsPresetsDefaults(options.externalsPresets, {
|
@@ -252,7 +258,7 @@ const applyWebpackOptionsDefaults = options => {
|
|
252
258
|
};
|
253
259
|
|
254
260
|
/**
|
255
|
-
* @param {
|
261
|
+
* @param {ExperimentsNormalized} experiments options
|
256
262
|
* @param {Object} options options
|
257
263
|
* @param {boolean} options.production is production
|
258
264
|
* @param {boolean} options.development is development mode
|
@@ -265,14 +271,14 @@ const applyExperimentsDefaults = (experiments, { production, development }) => {
|
|
265
271
|
D(experiments, "outputModule", false);
|
266
272
|
D(experiments, "asset", false);
|
267
273
|
D(experiments, "layers", false);
|
268
|
-
D(experiments, "lazyCompilation",
|
269
|
-
D(experiments, "buildHttp",
|
274
|
+
D(experiments, "lazyCompilation", undefined);
|
275
|
+
D(experiments, "buildHttp", undefined);
|
270
276
|
D(experiments, "futureDefaults", false);
|
271
277
|
D(experiments, "cacheUnaffected", experiments.futureDefaults);
|
272
278
|
|
273
279
|
if (typeof experiments.buildHttp === "object") {
|
274
280
|
D(experiments.buildHttp, "frozen", production);
|
275
|
-
D(experiments.buildHttp, "upgrade",
|
281
|
+
D(experiments.buildHttp, "upgrade", false);
|
276
282
|
}
|
277
283
|
};
|
278
284
|
|
@@ -348,49 +354,65 @@ const applyCacheDefaults = (
|
|
348
354
|
* @param {SnapshotOptions} snapshot options
|
349
355
|
* @param {Object} options options
|
350
356
|
* @param {boolean} options.production is production
|
357
|
+
* @param {boolean} options.futureDefaults is future defaults enabled
|
351
358
|
* @returns {void}
|
352
359
|
*/
|
353
|
-
const applySnapshotDefaults = (snapshot, { production }) => {
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
360
|
+
const applySnapshotDefaults = (snapshot, { production, futureDefaults }) => {
|
361
|
+
if (futureDefaults) {
|
362
|
+
F(snapshot, "managedPaths", () =>
|
363
|
+
process.versions.pnp === "3"
|
364
|
+
? [
|
365
|
+
/^(.+?(?:[\\/]\.yarn[\\/]unplugged[\\/][^\\/]+)?[\\/]node_modules[\\/])/
|
366
|
+
]
|
367
|
+
: [/^(.+?[\\/]node_modules[\\/])/]
|
368
|
+
);
|
369
|
+
F(snapshot, "immutablePaths", () =>
|
370
|
+
process.versions.pnp === "3"
|
371
|
+
? [/^(.+?[\\/]cache[\\/][^\\/]+\.zip[\\/]node_modules[\\/])/]
|
372
|
+
: []
|
373
|
+
);
|
374
|
+
} else {
|
375
|
+
A(snapshot, "managedPaths", () => {
|
376
|
+
if (process.versions.pnp === "3") {
|
377
|
+
const match =
|
378
|
+
/^(.+?)[\\/]cache[\\/]watchpack-npm-[^\\/]+\.zip[\\/]node_modules[\\/]/.exec(
|
379
|
+
require.resolve("watchpack")
|
380
|
+
);
|
381
|
+
if (match) {
|
382
|
+
return [path.resolve(match[1], "unplugged")];
|
383
|
+
}
|
384
|
+
} else {
|
385
|
+
const match = /^(.+?[\\/]node_modules)[\\/]/.exec(
|
386
|
+
// eslint-disable-next-line node/no-extraneous-require
|
378
387
|
require.resolve("watchpack")
|
379
388
|
);
|
380
|
-
|
381
|
-
|
389
|
+
if (match) {
|
390
|
+
return [match[1]];
|
391
|
+
}
|
382
392
|
}
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
393
|
+
return [];
|
394
|
+
});
|
395
|
+
A(snapshot, "immutablePaths", () => {
|
396
|
+
if (process.versions.pnp === "1") {
|
397
|
+
const match =
|
398
|
+
/^(.+?[\\/]v4)[\\/]npm-watchpack-[^\\/]+-[\da-f]{40}[\\/]node_modules[\\/]/.exec(
|
399
|
+
require.resolve("watchpack")
|
400
|
+
);
|
401
|
+
if (match) {
|
402
|
+
return [match[1]];
|
403
|
+
}
|
404
|
+
} else if (process.versions.pnp === "3") {
|
405
|
+
const match =
|
406
|
+
/^(.+?)[\\/]watchpack-npm-[^\\/]+\.zip[\\/]node_modules[\\/]/.exec(
|
407
|
+
require.resolve("watchpack")
|
408
|
+
);
|
409
|
+
if (match) {
|
410
|
+
return [match[1]];
|
411
|
+
}
|
390
412
|
}
|
391
|
-
|
392
|
-
|
393
|
-
}
|
413
|
+
return [];
|
414
|
+
});
|
415
|
+
}
|
394
416
|
F(snapshot, "resolveBuildDependencies", () => ({
|
395
417
|
timestamp: true,
|
396
418
|
hash: true
|
@@ -174,7 +174,12 @@ const getNormalizedWebpackOptions = config => {
|
|
174
174
|
experiments: nestedConfig(config.experiments, experiments => ({
|
175
175
|
...experiments,
|
176
176
|
buildHttp: optionalNestedConfig(experiments.buildHttp, options =>
|
177
|
-
options
|
177
|
+
Array.isArray(options) ? { allowedUris: options } : options
|
178
|
+
),
|
179
|
+
lazyCompilation: optionalNestedConfig(
|
180
|
+
experiments.lazyCompilation,
|
181
|
+
options =>
|
182
|
+
options === true ? {} : options === false ? undefined : options
|
178
183
|
)
|
179
184
|
})),
|
180
185
|
externals: config.externals,
|