webpack 5.58.1 → 5.60.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/hot/lazy-compilation-node.js +3 -1
- package/lib/Compilation.js +174 -108
- package/lib/Compiler.js +2 -2
- package/lib/DefinePlugin.js +1 -1
- package/lib/FileSystemInfo.js +112 -30
- package/lib/NormalModule.js +37 -14
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/WebpackOptionsApply.js +12 -11
- package/lib/cache/AddManagedPathsPlugin.js +2 -2
- package/lib/cache/PackFileCacheStrategy.js +6 -3
- package/lib/config/defaults.js +65 -43
- package/lib/config/normalization.js +6 -1
- package/lib/hmr/LazyCompilationPlugin.js +9 -5
- package/lib/hmr/lazyCompilationBackend.js +42 -10
- package/lib/optimize/ConcatenatedModule.js +1 -1
- package/lib/optimize/SplitChunksPlugin.js +57 -4
- package/lib/schemes/HttpUriPlugin.js +108 -31
- package/lib/serialization/Serializer.js +2 -4
- package/lib/util/fs.js +2 -0
- package/lib/util/propertyAccess.js +2 -2
- package/package.json +1 -1
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +324 -55
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.json +28 -0
- package/types.d.ts +140 -89
package/lib/FileSystemInfo.js
CHANGED
@@ -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
|
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 =
|
1001
|
-
|
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 =
|
1005
|
-
|
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,
|
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
|
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
|
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
|
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.
|
2731
|
+
this._resolveContextTimestamp(cache, callback);
|
2684
2732
|
} else {
|
2685
|
-
this.
|
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(
|
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 = [];
|
package/lib/NormalModule.js
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
730
|
-
const loaderContext = this.
|
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,21 +790,22 @@ 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();
|
793
|
-
if (this.loaders.length > 0) {
|
794
|
-
this.buildInfo.buildDependencies = new LazySet();
|
795
|
-
}
|
796
796
|
this.buildInfo.cacheable = true;
|
797
|
+
|
797
798
|
try {
|
798
799
|
hooks.beforeLoaders.call(this.loaders, this, loaderContext);
|
799
800
|
} catch (err) {
|
800
801
|
processResult(err);
|
801
802
|
return;
|
802
803
|
}
|
804
|
+
|
805
|
+
if (this.loaders.length > 0) {
|
806
|
+
this.buildInfo.buildDependencies = new LazySet();
|
807
|
+
}
|
808
|
+
|
803
809
|
runLoaders(
|
804
810
|
{
|
805
811
|
resource: this.resource,
|
@@ -942,7 +948,9 @@ class NormalModule extends Module {
|
|
942
948
|
|
943
949
|
const startTime = compilation.compiler.fsStartTime || Date.now();
|
944
950
|
|
945
|
-
|
951
|
+
const hooks = NormalModule.getCompilationHooks(compilation);
|
952
|
+
|
953
|
+
return this._doBuild(options, compilation, resolver, fs, hooks, err => {
|
946
954
|
// if we have an error mark module as failed and exit
|
947
955
|
if (err) {
|
948
956
|
this.markModuleAsErrored(err);
|
@@ -974,6 +982,13 @@ class NormalModule extends Module {
|
|
974
982
|
};
|
975
983
|
|
976
984
|
const handleBuildDone = () => {
|
985
|
+
try {
|
986
|
+
hooks.beforeSnapshot.call(this);
|
987
|
+
} catch (err) {
|
988
|
+
this.markModuleAsErrored(err);
|
989
|
+
return callback();
|
990
|
+
}
|
991
|
+
|
977
992
|
const snapshotOptions = compilation.options.snapshot.module;
|
978
993
|
if (!this.buildInfo.cacheable || !snapshotOptions) {
|
979
994
|
return callback();
|
@@ -1038,6 +1053,14 @@ class NormalModule extends Module {
|
|
1038
1053
|
);
|
1039
1054
|
};
|
1040
1055
|
|
1056
|
+
try {
|
1057
|
+
hooks.beforeParse.call(this);
|
1058
|
+
} catch (err) {
|
1059
|
+
this.markModuleAsErrored(err);
|
1060
|
+
this._initBuildHash(compilation);
|
1061
|
+
return callback();
|
1062
|
+
}
|
1063
|
+
|
1041
1064
|
// check if this module should !not! be parsed.
|
1042
1065
|
// if so, exit here;
|
1043
1066
|
const noParseRule = options.module && options.module.noParse;
|
package/lib/RuntimeTemplate.js
CHANGED
@@ -261,15 +261,18 @@ class WebpackOptionsApply extends OptionsApply {
|
|
261
261
|
: null;
|
262
262
|
new LazyCompilationPlugin({
|
263
263
|
backend:
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
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
|
374
|
-
mergedUsedItems.add(
|
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(
|
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,
|