webpack 5.58.2 → 5.61.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.

@@ -9,7 +9,9 @@ exports.keepAlive = function (options) {
9
9
  var active = options.active;
10
10
  var module = options.module;
11
11
  var response;
12
- var request = require("http").request(
12
+ var request = (
13
+ urlBase.startsWith("https") ? require("https") : require("http")
14
+ ).request(
13
15
  urlBase + data,
14
16
  {
15
17
  agent: false,
@@ -1883,7 +1883,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1883
1883
  creatingModuleDuringBuildSet
1884
1884
  );
1885
1885
  }
1886
- creatingModuleDuringBuildSet.add(originModule);
1886
+ creatingModuleDuringBuildSet.add(module);
1887
1887
 
1888
1888
  // When building is blocked by another module
1889
1889
  // search for a cycle, cancel the cycle by throwing
@@ -4687,21 +4687,18 @@ This prevents using hashes of each other and should be avoided.`);
4687
4687
  * @returns {void}
4688
4688
  */
4689
4689
  (module, push, callback) => {
4690
- this.addModuleQueue.waitFor(module, err => {
4690
+ this.buildQueue.waitFor(module, err => {
4691
4691
  if (err) return callback(err);
4692
- this.buildQueue.waitFor(module, err => {
4692
+ this.processDependenciesQueue.waitFor(module, err => {
4693
4693
  if (err) return callback(err);
4694
- this.processDependenciesQueue.waitFor(module, err => {
4695
- if (err) return callback(err);
4696
- for (const {
4697
- module: m
4698
- } of this.moduleGraph.getOutgoingConnections(module)) {
4699
- const size = modules.size;
4700
- modules.add(m);
4701
- if (modules.size !== size) push(m);
4702
- }
4703
- callback();
4704
- });
4694
+ for (const { module: m } of this.moduleGraph.getOutgoingConnections(
4695
+ module
4696
+ )) {
4697
+ const size = modules.size;
4698
+ modules.add(m);
4699
+ if (modules.size !== size) push(m);
4700
+ }
4701
+ callback();
4705
4702
  });
4706
4703
  });
4707
4704
  },
package/lib/Compiler.js CHANGED
@@ -219,9 +219,9 @@ class Compiler {
219
219
  /** @type {string|null} */
220
220
  this.recordsOutputPath = null;
221
221
  this.records = {};
222
- /** @type {Set<string>} */
222
+ /** @type {Set<string | RegExp>} */
223
223
  this.managedPaths = new Set();
224
- /** @type {Set<string>} */
224
+ /** @type {Set<string | RegExp>} */
225
225
  this.immutablePaths = new Set();
226
226
 
227
227
  /** @type {ReadonlySet<string>} */
@@ -151,7 +151,7 @@ const stringifyObj = (
151
151
  case false:
152
152
  return arr ? `;${code}` : `;(${code})`;
153
153
  default:
154
- return `Object(${code})`;
154
+ return `/*#__PURE__*/Object(${code})`;
155
155
  }
156
156
  };
157
157
 
@@ -853,8 +853,8 @@ class FileSystemInfo {
853
853
  /**
854
854
  * @param {InputFileSystem} fs file system
855
855
  * @param {Object} options options
856
- * @param {Iterable<string>=} options.managedPaths paths that are only managed by a package manager
857
- * @param {Iterable<string>=} options.immutablePaths paths that are immutable
856
+ * @param {Iterable<string | RegExp>=} options.managedPaths paths that are only managed by a package manager
857
+ * @param {Iterable<string | RegExp>=} options.immutablePaths paths that are immutable
858
858
  * @param {Logger=} options.logger logger used to log invalid snapshots
859
859
  * @param {string | Hash=} options.hashFunction the hash function to use
860
860
  */
@@ -996,12 +996,19 @@ class FileSystemInfo {
996
996
  processor: this._getManagedItemDirectoryInfo.bind(this)
997
997
  });
998
998
  this.managedPaths = Array.from(managedPaths);
999
- this.managedPathsWithSlash = this.managedPaths.map(p =>
1000
- join(fs, p, "_").slice(0, -1)
999
+ this.managedPathsWithSlash = /** @type {string[]} */ (
1000
+ this.managedPaths.filter(p => typeof p === "string")
1001
+ ).map(p => join(fs, p, "_").slice(0, -1));
1002
+
1003
+ this.managedPathsRegExps = /** @type {RegExp[]} */ (
1004
+ this.managedPaths.filter(p => typeof p !== "string")
1001
1005
  );
1002
1006
  this.immutablePaths = Array.from(immutablePaths);
1003
- this.immutablePathsWithSlash = this.immutablePaths.map(p =>
1004
- join(fs, p, "_").slice(0, -1)
1007
+ this.immutablePathsWithSlash = /** @type {string[]} */ (
1008
+ this.immutablePaths.filter(p => typeof p === "string")
1009
+ ).map(p => join(fs, p, "_").slice(0, -1));
1010
+ this.immutablePathsRegExps = /** @type {RegExp[]} */ (
1011
+ this.immutablePaths.filter(p => typeof p !== "string")
1005
1012
  );
1006
1013
 
1007
1014
  this._cachedDeprecatedFileTimestamps = undefined;
@@ -1966,12 +1973,29 @@ class FileSystemInfo {
1966
1973
  }
1967
1974
  };
1968
1975
  const checkManaged = (path, managedSet) => {
1976
+ for (const immutablePath of this.immutablePathsRegExps) {
1977
+ if (immutablePath.test(path)) {
1978
+ managedSet.add(path);
1979
+ return true;
1980
+ }
1981
+ }
1969
1982
  for (const immutablePath of this.immutablePathsWithSlash) {
1970
1983
  if (path.startsWith(immutablePath)) {
1971
1984
  managedSet.add(path);
1972
1985
  return true;
1973
1986
  }
1974
1987
  }
1988
+ for (const managedPath of this.managedPathsRegExps) {
1989
+ const match = managedPath.exec(path);
1990
+ if (match) {
1991
+ const managedItem = getManagedItem(match[1], path);
1992
+ if (managedItem) {
1993
+ managedItems.add(managedItem);
1994
+ managedSet.add(path);
1995
+ return true;
1996
+ }
1997
+ }
1998
+ }
1975
1999
  for (const managedPath of this.managedPathsWithSlash) {
1976
2000
  if (path.startsWith(managedPath)) {
1977
2001
  const managedItem = getManagedItem(managedPath, path);
@@ -2923,10 +2947,29 @@ class FileSystemInfo {
2923
2947
  files,
2924
2948
  (file, callback) => {
2925
2949
  const child = join(this.fs, path, file);
2950
+ for (const immutablePath of this.immutablePathsRegExps) {
2951
+ if (immutablePath.test(path)) {
2952
+ // ignore any immutable path for timestamping
2953
+ return callback(null, fromImmutablePath(path));
2954
+ }
2955
+ }
2926
2956
  for (const immutablePath of this.immutablePathsWithSlash) {
2927
2957
  if (path.startsWith(immutablePath)) {
2928
2958
  // ignore any immutable path for timestamping
2929
- return callback(null, fromImmutablePath(immutablePath));
2959
+ return callback(null, fromImmutablePath(path));
2960
+ }
2961
+ }
2962
+ for (const managedPath of this.managedPathsRegExps) {
2963
+ const match = managedPath.exec(path);
2964
+ if (match) {
2965
+ const managedItem = getManagedItem(match[1], path);
2966
+ if (managedItem) {
2967
+ // construct timestampHash from managed info
2968
+ return this.managedItemQueue.add(managedItem, (err, info) => {
2969
+ if (err) return callback(err);
2970
+ return callback(null, fromManagedItem(info));
2971
+ });
2972
+ }
2930
2973
  }
2931
2974
  }
2932
2975
  for (const managedPath of this.managedPathsWithSlash) {
@@ -187,6 +187,8 @@ makeSerializable(
187
187
  * @typedef {Object} NormalModuleCompilationHooks
188
188
  * @property {SyncHook<[object, NormalModule]>} loader
189
189
  * @property {SyncHook<[LoaderItem[], NormalModule, object]>} beforeLoaders
190
+ * @property {SyncHook<[NormalModule]>} beforeParse
191
+ * @property {SyncHook<[NormalModule]>} beforeSnapshot
190
192
  * @property {HookMap<AsyncSeriesBailHook<[string, NormalModule], string | Buffer>>} readResourceForScheme
191
193
  * @property {HookMap<AsyncSeriesBailHook<[object], string | Buffer>>} readResource
192
194
  * @property {AsyncSeriesBailHook<[NormalModule, NeedBuildContext], boolean>} needBuild
@@ -211,6 +213,8 @@ class NormalModule extends Module {
211
213
  hooks = {
212
214
  loader: new SyncHook(["loaderContext", "module"]),
213
215
  beforeLoaders: new SyncHook(["loaders", "module", "loaderContext"]),
216
+ beforeParse: new SyncHook(["module"]),
217
+ beforeSnapshot: new SyncHook(["module"]),
214
218
  // TODO webpack 6 deprecate
215
219
  readResourceForScheme: new HookMap(scheme => {
216
220
  const hook = hooks.readResource.for(scheme);
@@ -387,6 +391,7 @@ class NormalModule extends Module {
387
391
  this.generator = m.generator;
388
392
  this.generatorOptions = m.generatorOptions;
389
393
  this.resource = m.resource;
394
+ this.resourceResolveData = m.resourceResolveData;
390
395
  this.context = m.context;
391
396
  this.matchResource = m.matchResource;
392
397
  this.loaders = m.loaders;
@@ -488,9 +493,10 @@ class NormalModule extends Module {
488
493
  * @param {WebpackOptions} options webpack options
489
494
  * @param {Compilation} compilation the compilation
490
495
  * @param {InputFileSystem} fs file system from reading
496
+ * @param {NormalModuleCompilationHooks} hooks the hooks
491
497
  * @returns {NormalModuleLoaderContext} loader context
492
498
  */
493
- createLoaderContext(resolver, options, compilation, fs) {
499
+ _createLoaderContext(resolver, options, compilation, fs, hooks) {
494
500
  const { requestShortener } = compilation.runtimeTemplate;
495
501
  const getCurrentLoaderName = () => {
496
502
  const currentLoader = this.getCurrentLoader(loaderContext);
@@ -532,6 +538,9 @@ class NormalModule extends Module {
532
538
  return context === this.context
533
539
  ? getContextifyInContext()(request)
534
540
  : getContextify()(context, request);
541
+ },
542
+ createHash: type => {
543
+ return createHash(type || compilation.outputOptions.hashFunction);
535
544
  }
536
545
  };
537
546
  const loaderContext = {
@@ -659,10 +668,7 @@ class NormalModule extends Module {
659
668
 
660
669
  Object.assign(loaderContext, options.loader);
661
670
 
662
- NormalModule.getCompilationHooks(compilation).loader.call(
663
- loaderContext,
664
- this
665
- );
671
+ hooks.loader.call(loaderContext, this);
666
672
 
667
673
  return loaderContext;
668
674
  }
@@ -723,15 +729,17 @@ class NormalModule extends Module {
723
729
  * @param {Compilation} compilation the compilation
724
730
  * @param {ResolverWithOptions} resolver the resolver
725
731
  * @param {InputFileSystem} fs the file system
732
+ * @param {NormalModuleCompilationHooks} hooks the hooks
726
733
  * @param {function(WebpackError=): void} callback callback function
727
734
  * @returns {void}
728
735
  */
729
- doBuild(options, compilation, resolver, fs, callback) {
730
- const loaderContext = this.createLoaderContext(
736
+ _doBuild(options, compilation, resolver, fs, hooks, callback) {
737
+ const loaderContext = this._createLoaderContext(
731
738
  resolver,
732
739
  options,
733
740
  compilation,
734
- fs
741
+ fs,
742
+ hooks
735
743
  );
736
744
 
737
745
  const processResult = (err, result) => {
@@ -785,21 +793,22 @@ class NormalModule extends Module {
785
793
  return callback();
786
794
  };
787
795
 
788
- const hooks = NormalModule.getCompilationHooks(compilation);
789
-
790
796
  this.buildInfo.fileDependencies = new LazySet();
791
797
  this.buildInfo.contextDependencies = new LazySet();
792
798
  this.buildInfo.missingDependencies = new LazySet();
793
- if (this.loaders.length > 0) {
794
- this.buildInfo.buildDependencies = new LazySet();
795
- }
796
799
  this.buildInfo.cacheable = true;
800
+
797
801
  try {
798
802
  hooks.beforeLoaders.call(this.loaders, this, loaderContext);
799
803
  } catch (err) {
800
804
  processResult(err);
801
805
  return;
802
806
  }
807
+
808
+ if (this.loaders.length > 0) {
809
+ this.buildInfo.buildDependencies = new LazySet();
810
+ }
811
+
803
812
  runLoaders(
804
813
  {
805
814
  resource: this.resource,
@@ -942,7 +951,9 @@ class NormalModule extends Module {
942
951
 
943
952
  const startTime = compilation.compiler.fsStartTime || Date.now();
944
953
 
945
- return this.doBuild(options, compilation, resolver, fs, err => {
954
+ const hooks = NormalModule.getCompilationHooks(compilation);
955
+
956
+ return this._doBuild(options, compilation, resolver, fs, hooks, err => {
946
957
  // if we have an error mark module as failed and exit
947
958
  if (err) {
948
959
  this.markModuleAsErrored(err);
@@ -974,6 +985,13 @@ class NormalModule extends Module {
974
985
  };
975
986
 
976
987
  const handleBuildDone = () => {
988
+ try {
989
+ hooks.beforeSnapshot.call(this);
990
+ } catch (err) {
991
+ this.markModuleAsErrored(err);
992
+ return callback();
993
+ }
994
+
977
995
  const snapshotOptions = compilation.options.snapshot.module;
978
996
  if (!this.buildInfo.cacheable || !snapshotOptions) {
979
997
  return callback();
@@ -1038,6 +1056,14 @@ class NormalModule extends Module {
1038
1056
  );
1039
1057
  };
1040
1058
 
1059
+ try {
1060
+ hooks.beforeParse.call(this);
1061
+ } catch (err) {
1062
+ this.markModuleAsErrored(err);
1063
+ this._initBuildHash(compilation);
1064
+ return callback();
1065
+ }
1066
+
1041
1067
  // check if this module should !not! be parsed.
1042
1068
  // if so, exit here;
1043
1069
  const noParseRule = options.module && options.module.noParse;
@@ -807,7 +807,7 @@ class RuntimeTemplate {
807
807
  ? `(0,${access})`
808
808
  : asiSafe === false
809
809
  ? `;(0,${access})`
810
- : `Object(${access})`;
810
+ : `/*#__PURE__*/Object(${access})`;
811
811
  }
812
812
  return access;
813
813
  } else {
@@ -261,15 +261,18 @@ class WebpackOptionsApply extends OptionsApply {
261
261
  : null;
262
262
  new LazyCompilationPlugin({
263
263
  backend:
264
- (lazyOptions && lazyOptions.backend) ||
265
- require("./hmr/lazyCompilationBackend"),
266
- client:
267
- (lazyOptions && lazyOptions.client) ||
268
- require.resolve(
269
- `../hot/lazy-compilation-${
270
- options.externalsPresets.node ? "node" : "web"
271
- }.js`
272
- ),
264
+ typeof lazyOptions.backend === "function"
265
+ ? lazyOptions.backend
266
+ : require("./hmr/lazyCompilationBackend")({
267
+ ...lazyOptions.backend,
268
+ client:
269
+ (lazyOptions.backend && lazyOptions.backend.client) ||
270
+ require.resolve(
271
+ `../hot/lazy-compilation-${
272
+ options.externalsPresets.node ? "node" : "web"
273
+ }.js`
274
+ )
275
+ }),
273
276
  entries: !lazyOptions || lazyOptions.entries !== false,
274
277
  imports: !lazyOptions || lazyOptions.imports !== false,
275
278
  test: (lazyOptions && lazyOptions.test) || undefined
@@ -279,8 +282,6 @@ class WebpackOptionsApply extends OptionsApply {
279
282
  if (options.experiments.buildHttp) {
280
283
  const HttpUriPlugin = require("./schemes/HttpUriPlugin");
281
284
  const httpOptions = options.experiments.buildHttp;
282
- if (httpOptions === true)
283
- throw new Error("Unexpected due to normalization");
284
285
  new HttpUriPlugin(httpOptions).apply(compiler);
285
286
  }
286
287
 
@@ -9,8 +9,8 @@
9
9
 
10
10
  class AddManagedPathsPlugin {
11
11
  /**
12
- * @param {Iterable<string>} managedPaths list of managed paths
13
- * @param {Iterable<string>} immutablePaths list of immutable paths
12
+ * @param {Iterable<string | RegExp>} managedPaths list of managed paths
13
+ * @param {Iterable<string | RegExp>} immutablePaths list of immutable paths
14
14
  */
15
15
  constructor(managedPaths, immutablePaths) {
16
16
  this.managedPaths = new Set(managedPaths);
@@ -370,8 +370,8 @@ class Pack {
370
370
  for (const identifier of content.items) {
371
371
  mergedItems.add(identifier);
372
372
  }
373
- for (const identifer of content.used) {
374
- mergedUsedItems.add(identifer);
373
+ for (const identifier of content.used) {
374
+ mergedUsedItems.add(identifier);
375
375
  }
376
376
  addToMergedMap.push(async map => {
377
377
  // unpack existing content
@@ -991,7 +991,10 @@ class PackFileCacheStrategy {
991
991
  allowCollectingMemory,
992
992
  compression
993
993
  }) {
994
- this.fileSerializer = createFileSerializer(fs);
994
+ this.fileSerializer = createFileSerializer(
995
+ fs,
996
+ compiler.options.output.hashFunction
997
+ );
995
998
  this.fileSystemInfo = new FileSystemInfo(fs, {
996
999
  managedPaths: snapshot.managedPaths,
997
1000
  immutablePaths: snapshot.immutablePaths,
@@ -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,
@@ -32,6 +32,12 @@ const { registerNotSerializable } = require("../util/serialization");
32
32
  /** @typedef {import("../util/Hash")} Hash */
33
33
  /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
34
34
 
35
+ /**
36
+ * @typedef {Object} BackendApi
37
+ * @property {function(Error=): void} dispose
38
+ * @property {function(Module): { client: string, data: string, active: boolean }} module
39
+ */
40
+
35
41
  const IGNORED_DEPENDENCY_TYPES = new Set([
36
42
  "import.meta.webpackHot.accept",
37
43
  "import.meta.webpackHot.decline",
@@ -303,15 +309,13 @@ class LazyCompilationDependencyFactory extends ModuleFactory {
303
309
  class LazyCompilationPlugin {
304
310
  /**
305
311
  * @param {Object} options options
306
- * @param {(function(Compiler, string, function(Error?, any?): void): void) | function(Compiler, string): Promise<any>} options.backend the backend
307
- * @param {string} options.client the client reference
312
+ * @param {(function(Compiler, function(Error?, BackendApi?): void): void) | function(Compiler): Promise<BackendApi>} options.backend the backend
308
313
  * @param {boolean} options.entries true, when entries are lazy compiled
309
314
  * @param {boolean} options.imports true, when import() modules are lazy compiled
310
315
  * @param {RegExp | string | (function(Module): boolean)} options.test additional filter for lazy compiled entrypoint modules
311
316
  */
312
- constructor({ backend, client, entries, imports, test }) {
317
+ constructor({ backend, entries, imports, test }) {
313
318
  this.backend = backend;
314
- this.client = client;
315
319
  this.entries = entries;
316
320
  this.imports = imports;
317
321
  this.test = test;
@@ -327,7 +331,7 @@ class LazyCompilationPlugin {
327
331
  "LazyCompilationPlugin",
328
332
  (params, callback) => {
329
333
  if (backend !== undefined) return callback();
330
- const promise = this.backend(compiler, this.client, (err, result) => {
334
+ const promise = this.backend(compiler, (err, result) => {
331
335
  if (err) return callback(err);
332
336
  backend = result;
333
337
  callback();