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.

@@ -206,17 +206,17 @@ class Snapshot {
206
206
  this._flags = 0;
207
207
  /** @type {number | undefined} */
208
208
  this.startTime = undefined;
209
- /** @type {Map<string, FileSystemInfoEntry> | undefined} */
209
+ /** @type {Map<string, FileSystemInfoEntry | null> | undefined} */
210
210
  this.fileTimestamps = undefined;
211
- /** @type {Map<string, string> | undefined} */
211
+ /** @type {Map<string, string | null> | undefined} */
212
212
  this.fileHashes = undefined;
213
- /** @type {Map<string, TimestampAndHash | string> | undefined} */
213
+ /** @type {Map<string, TimestampAndHash | string | null> | undefined} */
214
214
  this.fileTshs = undefined;
215
- /** @type {Map<string, ResolvedContextFileSystemInfoEntry> | undefined} */
215
+ /** @type {Map<string, ResolvedContextFileSystemInfoEntry | null> | undefined} */
216
216
  this.contextTimestamps = undefined;
217
- /** @type {Map<string, string> | undefined} */
217
+ /** @type {Map<string, string | null> | undefined} */
218
218
  this.contextHashes = undefined;
219
- /** @type {Map<string, ResolvedContextTimestampAndHash> | undefined} */
219
+ /** @type {Map<string, ResolvedContextTimestampAndHash | null> | undefined} */
220
220
  this.contextTshs = undefined;
221
221
  /** @type {Map<string, boolean> | undefined} */
222
222
  this.missingExistence = undefined;
@@ -823,11 +823,10 @@ const getManagedItem = (managedPath, path) => {
823
823
 
824
824
  /**
825
825
  * @template {ContextFileSystemInfoEntry | ContextTimestampAndHash} T
826
- * @param {T | "ignore"} entry entry
826
+ * @param {T} entry entry
827
827
  * @returns {T["resolved"] | undefined} the resolved entry
828
828
  */
829
829
  const getResolvedTimestamp = entry => {
830
- if (entry === "ignore") return undefined;
831
830
  if (entry === null) return null;
832
831
  if (entry.resolved !== undefined) return entry.resolved;
833
832
  return entry.symlinks === undefined ? entry : undefined;
@@ -854,8 +853,8 @@ class FileSystemInfo {
854
853
  /**
855
854
  * @param {InputFileSystem} fs file system
856
855
  * @param {Object} options options
857
- * @param {Iterable<string>=} options.managedPaths paths that are only managed by a package manager
858
- * @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
859
858
  * @param {Logger=} options.logger logger used to log invalid snapshots
860
859
  * @param {string | Hash=} options.hashFunction the hash function to use
861
860
  */
@@ -997,12 +996,19 @@ class FileSystemInfo {
997
996
  processor: this._getManagedItemDirectoryInfo.bind(this)
998
997
  });
999
998
  this.managedPaths = Array.from(managedPaths);
1000
- this.managedPathsWithSlash = this.managedPaths.map(p =>
1001
- 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")
1002
1005
  );
1003
1006
  this.immutablePaths = Array.from(immutablePaths);
1004
- this.immutablePathsWithSlash = this.immutablePaths.map(p =>
1005
- 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")
1006
1012
  );
1007
1013
 
1008
1014
  this._cachedDeprecatedFileTimestamps = undefined;
@@ -1191,6 +1197,7 @@ class FileSystemInfo {
1191
1197
  getContextTimestamp(path, callback) {
1192
1198
  const cache = this._contextTimestamps.get(path);
1193
1199
  if (cache !== undefined) {
1200
+ if (cache === "ignore") return callback(null, "ignore");
1194
1201
  const resolved = getResolvedTimestamp(cache);
1195
1202
  if (resolved !== undefined) return callback(null, resolved);
1196
1203
  return this._resolveContextTimestamp(cache, callback);
@@ -1876,17 +1883,17 @@ class FileSystemInfo {
1876
1883
  * @returns {void}
1877
1884
  */
1878
1885
  createSnapshot(startTime, files, directories, missing, options, callback) {
1879
- /** @type {Map<string, FileSystemInfoEntry>} */
1886
+ /** @type {Map<string, FileSystemInfoEntry | null>} */
1880
1887
  const fileTimestamps = new Map();
1881
- /** @type {Map<string, string>} */
1888
+ /** @type {Map<string, string | null>} */
1882
1889
  const fileHashes = new Map();
1883
- /** @type {Map<string, TimestampAndHash | string>} */
1890
+ /** @type {Map<string, TimestampAndHash | string | null>} */
1884
1891
  const fileTshs = new Map();
1885
- /** @type {Map<string, FileSystemInfoEntry>} */
1892
+ /** @type {Map<string, FileSystemInfoEntry | null>} */
1886
1893
  const contextTimestamps = new Map();
1887
- /** @type {Map<string, string>} */
1894
+ /** @type {Map<string, string | null>} */
1888
1895
  const contextHashes = new Map();
1889
- /** @type {Map<string, TimestampAndHash | string>} */
1896
+ /** @type {Map<string, ResolvedContextTimestampAndHash | null>} */
1890
1897
  const contextTshs = new Map();
1891
1898
  /** @type {Map<string, boolean>} */
1892
1899
  const missingExistence = new Map();
@@ -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);
@@ -2080,6 +2104,7 @@ class FileSystemInfo {
2080
2104
  this._contextTshsOptimization.optimize(snapshot, capturedDirectories);
2081
2105
  for (const path of capturedDirectories) {
2082
2106
  const cache = this._contextTshs.get(path);
2107
+ /** @type {ResolvedContextTimestampAndHash} */
2083
2108
  let resolved;
2084
2109
  if (
2085
2110
  cache !== undefined &&
@@ -2088,6 +2113,11 @@ class FileSystemInfo {
2088
2113
  contextTshs.set(path, resolved);
2089
2114
  } else {
2090
2115
  jobs++;
2116
+ /**
2117
+ * @param {Error=} err error
2118
+ * @param {ResolvedContextTimestampAndHash=} entry entry
2119
+ * @returns {void}
2120
+ */
2091
2121
  const callback = (err, entry) => {
2092
2122
  if (err) {
2093
2123
  if (this.logger) {
@@ -2152,14 +2182,20 @@ class FileSystemInfo {
2152
2182
  );
2153
2183
  for (const path of capturedDirectories) {
2154
2184
  const cache = this._contextTimestamps.get(path);
2185
+ if (cache === "ignore") continue;
2155
2186
  let resolved;
2156
2187
  if (
2157
2188
  cache !== undefined &&
2158
2189
  (resolved = getResolvedTimestamp(cache)) !== undefined
2159
2190
  ) {
2160
2191
  contextTimestamps.set(path, resolved);
2161
- } else if (cache !== "ignore") {
2192
+ } else {
2162
2193
  jobs++;
2194
+ /**
2195
+ * @param {Error=} err error
2196
+ * @param {ResolvedContextFileSystemInfoEntry=} entry entry
2197
+ * @returns {void}
2198
+ */
2163
2199
  const callback = (err, entry) => {
2164
2200
  if (err) {
2165
2201
  if (this.logger) {
@@ -2572,14 +2608,14 @@ class FileSystemInfo {
2572
2608
  const cache = this._fileTimestamps.get(path);
2573
2609
  if (cache !== undefined) {
2574
2610
  if (cache === "ignore" || !checkFile(path, cache, tsh, false)) {
2575
- processFileHashSnapshot(path, tsh.hash);
2611
+ processFileHashSnapshot(path, tsh && tsh.hash);
2576
2612
  }
2577
2613
  } else {
2578
2614
  jobs++;
2579
2615
  this.fileTimestampQueue.add(path, (err, entry) => {
2580
2616
  if (err) return invalidWithError(path, err);
2581
2617
  if (!checkFile(path, entry, tsh, false)) {
2582
- processFileHashSnapshot(path, tsh.hash);
2618
+ processFileHashSnapshot(path, tsh && tsh.hash);
2583
2619
  }
2584
2620
  jobDone();
2585
2621
  });
@@ -2592,6 +2628,7 @@ class FileSystemInfo {
2592
2628
  this._statTestedEntries += contextTimestamps.size;
2593
2629
  for (const [path, ts] of contextTimestamps) {
2594
2630
  const cache = this._contextTimestamps.get(path);
2631
+ if (cache === "ignore") continue;
2595
2632
  let resolved;
2596
2633
  if (
2597
2634
  cache !== undefined &&
@@ -2601,8 +2638,13 @@ class FileSystemInfo {
2601
2638
  invalid();
2602
2639
  return;
2603
2640
  }
2604
- } else if (cache !== "ignore") {
2641
+ } else {
2605
2642
  jobs++;
2643
+ /**
2644
+ * @param {Error=} err error
2645
+ * @param {ResolvedContextFileSystemInfoEntry=} entry entry
2646
+ * @returns {void}
2647
+ */
2606
2648
  const callback = (err, entry) => {
2607
2649
  if (err) return invalidWithError(path, err);
2608
2650
  if (!checkContext(path, entry, ts)) {
@@ -2662,27 +2704,33 @@ class FileSystemInfo {
2662
2704
  processContextHashSnapshot(path, tsh);
2663
2705
  } else {
2664
2706
  const cache = this._contextTimestamps.get(path);
2707
+ if (cache === "ignore") continue;
2665
2708
  let resolved;
2666
2709
  if (
2667
2710
  cache !== undefined &&
2668
2711
  (resolved = getResolvedTimestamp(cache)) !== undefined
2669
2712
  ) {
2670
2713
  if (!checkContext(path, resolved, tsh, false)) {
2671
- processContextHashSnapshot(path, tsh.hash);
2714
+ processContextHashSnapshot(path, tsh && tsh.hash);
2672
2715
  }
2673
- } else if (cache !== "ignore") {
2716
+ } else {
2674
2717
  jobs++;
2718
+ /**
2719
+ * @param {Error=} err error
2720
+ * @param {ResolvedContextFileSystemInfoEntry=} entry entry
2721
+ * @returns {void}
2722
+ */
2675
2723
  const callback = (err, entry) => {
2676
2724
  if (err) return invalidWithError(path, err);
2677
2725
  if (!checkContext(path, entry, tsh, false)) {
2678
- processContextHashSnapshot(path, tsh.hash);
2726
+ processContextHashSnapshot(path, tsh && tsh.hash);
2679
2727
  }
2680
2728
  jobDone();
2681
2729
  };
2682
2730
  if (cache !== undefined) {
2683
- this._resolveContextTsh(cache, callback);
2731
+ this._resolveContextTimestamp(cache, callback);
2684
2732
  } else {
2685
- this.getContextTsh(path, callback);
2733
+ this.getContextTimestamp(path, callback);
2686
2734
  }
2687
2735
  }
2688
2736
  }
@@ -2899,10 +2947,29 @@ class FileSystemInfo {
2899
2947
  files,
2900
2948
  (file, callback) => {
2901
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
+ }
2902
2956
  for (const immutablePath of this.immutablePathsWithSlash) {
2903
2957
  if (path.startsWith(immutablePath)) {
2904
2958
  // ignore any immutable path for timestamping
2905
- 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
+ }
2906
2973
  }
2907
2974
  }
2908
2975
  for (const managedPath of this.managedPathsWithSlash) {
@@ -3032,6 +3099,11 @@ class FileSystemInfo {
3032
3099
  );
3033
3100
  }
3034
3101
 
3102
+ /**
3103
+ * @param {ContextFileSystemInfoEntry} entry entry
3104
+ * @param {function(Error=, ResolvedContextFileSystemInfoEntry=): void} callback callback
3105
+ * @returns {void}
3106
+ */
3035
3107
  _resolveContextTimestamp(entry, callback) {
3036
3108
  const hashes = [];
3037
3109
  let safeTime = 0;
@@ -3135,6 +3207,11 @@ class FileSystemInfo {
3135
3207
  );
3136
3208
  }
3137
3209
 
3210
+ /**
3211
+ * @param {ContextHash} entry context hash
3212
+ * @param {function(Error=, string=): void} callback callback
3213
+ * @returns {void}
3214
+ */
3138
3215
  _resolveContextHash(entry, callback) {
3139
3216
  const hashes = [];
3140
3217
  processAsyncTree(
@@ -3286,6 +3363,11 @@ class FileSystemInfo {
3286
3363
  }
3287
3364
  }
3288
3365
 
3366
+ /**
3367
+ * @param {ContextTimestampAndHash} entry entry
3368
+ * @param {function(Error=, ResolvedContextTimestampAndHash=): void} callback callback
3369
+ * @returns {void}
3370
+ */
3289
3371
  _resolveContextTsh(entry, callback) {
3290
3372
  const hashes = [];
3291
3373
  const tsHashes = [];
@@ -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);
@@ -659,10 +665,7 @@ class NormalModule extends Module {
659
665
 
660
666
  Object.assign(loaderContext, options.loader);
661
667
 
662
- NormalModule.getCompilationHooks(compilation).loader.call(
663
- loaderContext,
664
- this
665
- );
668
+ hooks.loader.call(loaderContext, this);
666
669
 
667
670
  return loaderContext;
668
671
  }
@@ -723,15 +726,17 @@ class NormalModule extends Module {
723
726
  * @param {Compilation} compilation the compilation
724
727
  * @param {ResolverWithOptions} resolver the resolver
725
728
  * @param {InputFileSystem} fs the file system
729
+ * @param {NormalModuleCompilationHooks} hooks the hooks
726
730
  * @param {function(WebpackError=): void} callback callback function
727
731
  * @returns {void}
728
732
  */
729
- doBuild(options, compilation, resolver, fs, callback) {
730
- const loaderContext = this.createLoaderContext(
733
+ _doBuild(options, compilation, resolver, fs, hooks, callback) {
734
+ const loaderContext = this._createLoaderContext(
731
735
  resolver,
732
736
  options,
733
737
  compilation,
734
- fs
738
+ fs,
739
+ hooks
735
740
  );
736
741
 
737
742
  const processResult = (err, result) => {
@@ -785,8 +790,6 @@ class NormalModule extends Module {
785
790
  return callback();
786
791
  };
787
792
 
788
- const hooks = NormalModule.getCompilationHooks(compilation);
789
-
790
793
  this.buildInfo.fileDependencies = new LazySet();
791
794
  this.buildInfo.contextDependencies = new LazySet();
792
795
  this.buildInfo.missingDependencies = new LazySet();
@@ -942,7 +945,9 @@ class NormalModule extends Module {
942
945
 
943
946
  const startTime = compilation.compiler.fsStartTime || Date.now();
944
947
 
945
- return this.doBuild(options, compilation, resolver, fs, err => {
948
+ const hooks = NormalModule.getCompilationHooks(compilation);
949
+
950
+ return this._doBuild(options, compilation, resolver, fs, hooks, err => {
946
951
  // if we have an error mark module as failed and exit
947
952
  if (err) {
948
953
  this.markModuleAsErrored(err);
@@ -974,6 +979,13 @@ class NormalModule extends Module {
974
979
  };
975
980
 
976
981
  const handleBuildDone = () => {
982
+ try {
983
+ hooks.beforeSnapshot.call(this);
984
+ } catch (err) {
985
+ this.markModuleAsErrored(err);
986
+ return callback();
987
+ }
988
+
977
989
  const snapshotOptions = compilation.options.snapshot.module;
978
990
  if (!this.buildInfo.cacheable || !snapshotOptions) {
979
991
  return callback();
@@ -1038,6 +1050,14 @@ class NormalModule extends Module {
1038
1050
  );
1039
1051
  };
1040
1052
 
1053
+ try {
1054
+ hooks.beforeParse.call(this);
1055
+ } catch (err) {
1056
+ this.markModuleAsErrored(err);
1057
+ this._initBuildHash(compilation);
1058
+ return callback();
1059
+ }
1060
+
1041
1061
  // check if this module should !not! be parsed.
1042
1062
  // if so, exit here;
1043
1063
  const noParseRule = options.module && options.module.noParse;
@@ -466,49 +466,68 @@ class NormalModuleFactory extends ModuleFactory {
466
466
  : "") +
467
467
  stringifyLoadersAndResource(loaders, resourceData.resource);
468
468
 
469
- const resourceDataForRules = matchResourceData || resourceData;
470
- const result = this.ruleSet.exec({
471
- resource: resourceDataForRules.path,
472
- realResource: resourceData.path,
473
- resourceQuery: resourceDataForRules.query,
474
- resourceFragment: resourceDataForRules.fragment,
475
- scheme,
476
- assertions,
477
- mimetype: matchResourceData ? "" : resourceData.data.mimetype || "",
478
- dependency: dependencyType,
479
- descriptionData: matchResourceData
480
- ? undefined
481
- : resourceData.data.descriptionFileData,
482
- issuer: contextInfo.issuer,
483
- compiler: contextInfo.compiler,
484
- issuerLayer: contextInfo.issuerLayer || ""
485
- });
486
469
  const settings = {};
487
470
  const useLoadersPost = [];
488
471
  const useLoaders = [];
489
472
  const useLoadersPre = [];
490
- for (const r of result) {
491
- if (r.type === "use") {
492
- if (!noAutoLoaders && !noPrePostAutoLoaders) {
493
- useLoaders.push(r.value);
494
- }
495
- } else if (r.type === "use-post") {
496
- if (!noPrePostAutoLoaders) {
497
- useLoadersPost.push(r.value);
498
- }
499
- } else if (r.type === "use-pre") {
500
- if (!noPreAutoLoaders && !noPrePostAutoLoaders) {
501
- useLoadersPre.push(r.value);
473
+
474
+ // handle .webpack[] suffix
475
+ let resource;
476
+ let match;
477
+ if (
478
+ matchResourceData &&
479
+ typeof (resource = matchResourceData.resource) === "string" &&
480
+ (match = /\.webpack\[([^\]]+)\]$/.exec(resource))
481
+ ) {
482
+ settings.type = match[1];
483
+ matchResourceData.resource = matchResourceData.resource.slice(
484
+ 0,
485
+ -settings.type.length - 10
486
+ );
487
+ } else {
488
+ settings.type = "javascript/auto";
489
+ const resourceDataForRules = matchResourceData || resourceData;
490
+ const result = this.ruleSet.exec({
491
+ resource: resourceDataForRules.path,
492
+ realResource: resourceData.path,
493
+ resourceQuery: resourceDataForRules.query,
494
+ resourceFragment: resourceDataForRules.fragment,
495
+ scheme,
496
+ assertions,
497
+ mimetype: matchResourceData
498
+ ? ""
499
+ : resourceData.data.mimetype || "",
500
+ dependency: dependencyType,
501
+ descriptionData: matchResourceData
502
+ ? undefined
503
+ : resourceData.data.descriptionFileData,
504
+ issuer: contextInfo.issuer,
505
+ compiler: contextInfo.compiler,
506
+ issuerLayer: contextInfo.issuerLayer || ""
507
+ });
508
+ for (const r of result) {
509
+ if (r.type === "use") {
510
+ if (!noAutoLoaders && !noPrePostAutoLoaders) {
511
+ useLoaders.push(r.value);
512
+ }
513
+ } else if (r.type === "use-post") {
514
+ if (!noPrePostAutoLoaders) {
515
+ useLoadersPost.push(r.value);
516
+ }
517
+ } else if (r.type === "use-pre") {
518
+ if (!noPreAutoLoaders && !noPrePostAutoLoaders) {
519
+ useLoadersPre.push(r.value);
520
+ }
521
+ } else if (
522
+ typeof r.value === "object" &&
523
+ r.value !== null &&
524
+ typeof settings[r.type] === "object" &&
525
+ settings[r.type] !== null
526
+ ) {
527
+ settings[r.type] = cachedCleverMerge(settings[r.type], r.value);
528
+ } else {
529
+ settings[r.type] = r.value;
502
530
  }
503
- } else if (
504
- typeof r.value === "object" &&
505
- r.value !== null &&
506
- typeof settings[r.type] === "object" &&
507
- settings[r.type] !== null
508
- ) {
509
- settings[r.type] = cachedCleverMerge(settings[r.type], r.value);
510
- } else {
511
- settings[r.type] = r.value;
512
531
  }
513
532
  }
514
533
 
@@ -528,23 +547,6 @@ class NormalModuleFactory extends ModuleFactory {
528
547
  }
529
548
  for (const loader of preLoaders) allLoaders.push(loader);
530
549
  let type = settings.type;
531
- if (!type) {
532
- let resource;
533
- let match;
534
- if (
535
- matchResourceData &&
536
- typeof (resource = matchResourceData.resource) === "string" &&
537
- (match = /\.webpack\[([^\]]+)\]$/.exec(resource))
538
- ) {
539
- type = match[1];
540
- matchResourceData.resource = matchResourceData.resource.slice(
541
- 0,
542
- -type.length - 10
543
- );
544
- } else {
545
- type = "javascript/auto";
546
- }
547
- }
548
550
  const resolveOptions = settings.resolve;
549
551
  const layer = settings.layer;
550
552
  if (layer !== undefined && !layers) {
@@ -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 {
@@ -279,8 +279,6 @@ class WebpackOptionsApply extends OptionsApply {
279
279
  if (options.experiments.buildHttp) {
280
280
  const HttpUriPlugin = require("./schemes/HttpUriPlugin");
281
281
  const httpOptions = options.experiments.buildHttp;
282
- if (httpOptions === true)
283
- throw new Error("Unexpected due to normalization");
284
282
  new HttpUriPlugin(httpOptions).apply(compiler);
285
283
  }
286
284
 
@@ -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