webpack 5.58.0 → 5.59.1

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.

@@ -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, { production });
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: options.experiments.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 {Experiments} experiments options
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", false);
269
- D(experiments, "buildHttp", false);
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", development);
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
- A(snapshot, "managedPaths", () => {
355
- if (process.versions.pnp === "3") {
356
- const match =
357
- /^(.+?)[\\/]cache[\\/]watchpack-npm-[^\\/]+\.zip[\\/]node_modules[\\/]/.exec(
358
- require.resolve("watchpack")
359
- );
360
- if (match) {
361
- return [path.resolve(match[1], "unplugged")];
362
- }
363
- } else {
364
- const match = /^(.+?[\\/]node_modules)[\\/]/.exec(
365
- // eslint-disable-next-line node/no-extraneous-require
366
- require.resolve("watchpack")
367
- );
368
- if (match) {
369
- return [match[1]];
370
- }
371
- }
372
- return [];
373
- });
374
- A(snapshot, "immutablePaths", () => {
375
- if (process.versions.pnp === "1") {
376
- const match =
377
- /^(.+?[\\/]v4)[\\/]npm-watchpack-[^\\/]+-[\da-f]{40}[\\/]node_modules[\\/]/.exec(
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
- if (match) {
381
- return [match[1]];
389
+ if (match) {
390
+ return [match[1]];
391
+ }
382
392
  }
383
- } else if (process.versions.pnp === "3") {
384
- const match =
385
- /^(.+?)[\\/]watchpack-npm-[^\\/]+\.zip[\\/]node_modules[\\/]/.exec(
386
- require.resolve("watchpack")
387
- );
388
- if (match) {
389
- return [match[1]];
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
- return [];
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 === true ? {} : 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,
@@ -564,7 +564,7 @@ const getFinalName = (
564
564
  ? `(0,${reference})`
565
565
  : asiSafe === false
566
566
  ? `;(0,${reference})`
567
- : `Object(${reference})`;
567
+ : `/*#__PURE__*/Object(${reference})`;
568
568
  }
569
569
  return reference;
570
570
  }