webpack 5.90.3 → 5.92.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/README.md +5 -5
- package/bin/webpack.js +6 -3
- package/lib/APIPlugin.js +14 -6
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +3 -1
- package/lib/Cache.js +8 -2
- package/lib/CacheFacade.js +3 -3
- package/lib/Chunk.js +7 -4
- package/lib/ChunkGraph.js +52 -25
- package/lib/ChunkGroup.js +23 -17
- package/lib/CleanPlugin.js +8 -6
- package/lib/Compilation.js +295 -120
- package/lib/Compiler.js +223 -87
- package/lib/ConcatenationScope.js +3 -3
- package/lib/ConditionalInitFragment.js +4 -5
- package/lib/ContextModule.js +95 -41
- package/lib/ContextModuleFactory.js +4 -2
- package/lib/ContextReplacementPlugin.js +3 -2
- package/lib/DefinePlugin.js +18 -6
- package/lib/Dependency.js +12 -10
- package/lib/DependencyTemplate.js +17 -7
- package/lib/DllModule.js +1 -0
- package/lib/DllReferencePlugin.js +7 -3
- package/lib/EntryOptionPlugin.js +4 -1
- package/lib/EntryPlugin.js +6 -1
- package/lib/Entrypoint.js +1 -1
- package/lib/EvalDevToolModulePlugin.js +11 -0
- package/lib/ExportsInfo.js +23 -8
- package/lib/ExternalModule.js +160 -35
- package/lib/ExternalModuleFactoryPlugin.js +37 -2
- package/lib/FileSystemInfo.js +69 -42
- package/lib/FlagDependencyExportsPlugin.js +21 -7
- package/lib/Generator.js +4 -4
- package/lib/HookWebpackError.js +2 -2
- package/lib/HotModuleReplacementPlugin.js +108 -45
- package/lib/IgnorePlugin.js +4 -1
- package/lib/InitFragment.js +5 -3
- package/lib/LibManifestPlugin.js +17 -9
- package/lib/Module.js +41 -14
- package/lib/ModuleFactory.js +3 -3
- package/lib/ModuleFilenameHelpers.js +30 -17
- package/lib/ModuleGraph.js +60 -31
- package/lib/ModuleGraphConnection.js +2 -1
- package/lib/MultiCompiler.js +62 -9
- package/lib/NodeStuffPlugin.js +14 -3
- package/lib/NormalModule.js +13 -13
- package/lib/NormalModuleFactory.js +18 -9
- package/lib/NormalModuleReplacementPlugin.js +5 -1
- package/lib/Parser.js +1 -1
- package/lib/PlatformPlugin.js +39 -0
- package/lib/ProgressPlugin.js +1 -1
- package/lib/ProvidePlugin.js +3 -1
- package/lib/RawModule.js +2 -1
- package/lib/RecordIdsPlugin.js +4 -4
- package/lib/ResolverFactory.js +6 -4
- package/lib/RuntimeModule.js +4 -4
- package/lib/RuntimePlugin.js +1 -0
- package/lib/RuntimeTemplate.js +124 -52
- package/lib/SourceMapDevToolPlugin.js +4 -1
- package/lib/Stats.js +11 -4
- package/lib/Template.js +5 -5
- package/lib/TemplatedPathPlugin.js +48 -7
- package/lib/Watching.js +67 -60
- package/lib/WebpackError.js +6 -6
- package/lib/WebpackOptionsApply.js +18 -5
- package/lib/asset/AssetGenerator.js +15 -0
- package/lib/asset/RawDataUrlModule.js +3 -1
- package/lib/async-modules/AwaitDependenciesInitFragment.js +2 -2
- package/lib/buildChunkGraph.js +120 -67
- package/lib/cache/IdleFileCachePlugin.js +8 -3
- package/lib/cache/MemoryCachePlugin.js +1 -1
- package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
- package/lib/cache/PackFileCacheStrategy.js +51 -18
- package/lib/cache/ResolverCachePlugin.js +22 -14
- package/lib/cache/getLazyHashedEtag.js +2 -2
- package/lib/cli.js +5 -5
- package/lib/config/browserslistTargetHandler.js +7 -1
- package/lib/config/defaults.js +108 -34
- package/lib/config/normalization.js +3 -1
- package/lib/config/target.js +18 -11
- package/lib/container/ContainerEntryDependency.js +2 -1
- package/lib/container/ContainerEntryModule.js +4 -2
- package/lib/container/ContainerPlugin.js +14 -10
- package/lib/container/FallbackModule.js +1 -1
- package/lib/container/RemoteRuntimeModule.js +12 -3
- package/lib/css/CssExportsGenerator.js +68 -25
- package/lib/css/CssGenerator.js +34 -6
- package/lib/css/CssLoadingRuntimeModule.js +217 -98
- package/lib/css/CssModulesPlugin.js +238 -107
- package/lib/css/CssParser.js +24 -15
- package/lib/css/walkCssTokens.js +1 -1
- package/lib/debug/ProfilingPlugin.js +28 -3
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +9 -5
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +2 -1
- package/lib/dependencies/CommonJsExportRequireDependency.js +33 -18
- package/lib/dependencies/CommonJsExportsDependency.js +13 -5
- package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -15
- package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -2
- package/lib/dependencies/ContextDependencyHelpers.js +49 -29
- package/lib/dependencies/ContextElementDependency.js +8 -1
- package/lib/dependencies/CssExportDependency.js +2 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +71 -9
- package/lib/dependencies/CssUrlDependency.js +10 -7
- package/lib/dependencies/ExportsInfoDependency.js +5 -4
- package/lib/dependencies/ExternalModuleDependency.js +4 -2
- package/lib/dependencies/ExternalModuleInitFragment.js +5 -3
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -4
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +43 -23
- package/lib/dependencies/HarmonyExportHeaderDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +73 -32
- package/lib/dependencies/HarmonyExportInitFragment.js +10 -2
- package/lib/dependencies/HarmonyImportDependency.js +28 -12
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +70 -19
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +7 -6
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +47 -35
- package/lib/dependencies/ImportDependency.js +9 -2
- package/lib/dependencies/ImportEagerDependency.js +4 -2
- package/lib/dependencies/ImportMetaContextDependency.js +7 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +25 -14
- package/lib/dependencies/ImportMetaPlugin.js +1 -1
- package/lib/dependencies/ImportParserPlugin.js +15 -5
- package/lib/dependencies/ImportWeakDependency.js +4 -2
- package/lib/dependencies/LoaderDependency.js +2 -1
- package/lib/dependencies/LoaderImportDependency.js +2 -1
- package/lib/dependencies/LoaderPlugin.js +2 -2
- package/lib/dependencies/ModuleDependency.js +4 -5
- package/lib/dependencies/PureExpressionDependency.js +64 -47
- package/lib/dependencies/RequireContextPlugin.js +1 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +26 -14
- package/lib/dependencies/RequireEnsureDependency.js +1 -1
- package/lib/dependencies/URLDependency.js +7 -4
- package/lib/dependencies/WorkerDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -1
- package/lib/dependencies/getFunctionExpression.js +3 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -3
- package/lib/hmr/LazyCompilationPlugin.js +2 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +1 -1
- package/lib/ids/DeterministicChunkIdsPlugin.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/IdHelpers.js +6 -6
- package/lib/ids/NamedChunkIdsPlugin.js +1 -1
- package/lib/ids/NamedModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +2 -2
- package/lib/index.js +11 -0
- package/lib/javascript/BasicEvaluatedExpression.js +2 -2
- package/lib/javascript/ChunkHelpers.js +2 -2
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +0 -1
- package/lib/javascript/JavascriptModulesPlugin.js +174 -17
- package/lib/javascript/JavascriptParser.js +204 -71
- package/lib/javascript/JavascriptParserHelpers.js +1 -1
- package/lib/javascript/StartupHelpers.js +22 -5
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +2 -2
- package/lib/library/AssignLibraryPlugin.js +3 -3
- package/lib/library/ExportPropertyLibraryPlugin.js +2 -2
- package/lib/library/JsonpLibraryPlugin.js +2 -2
- package/lib/library/ModuleLibraryPlugin.js +2 -2
- package/lib/library/SystemLibraryPlugin.js +2 -2
- package/lib/library/UmdLibraryPlugin.js +33 -12
- package/lib/logging/Logger.js +27 -2
- package/lib/logging/createConsoleLogger.js +13 -9
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeEnvironmentPlugin.js +14 -8
- package/lib/node/NodeTemplatePlugin.js +1 -1
- package/lib/node/NodeWatchFileSystem.js +37 -26
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -1
- package/lib/node/nodeConsole.js +24 -1
- package/lib/optimize/AggressiveMergingPlugin.js +1 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +1 -0
- package/lib/optimize/ConcatenatedModule.js +140 -121
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
- package/lib/optimize/InnerGraph.js +8 -3
- package/lib/optimize/InnerGraphPlugin.js +36 -13
- package/lib/optimize/LimitChunkCountPlugin.js +1 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +13 -3
- package/lib/optimize/RealContentHashPlugin.js +3 -3
- package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
- package/lib/optimize/RuntimeChunkPlugin.js +6 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +48 -17
- package/lib/optimize/SplitChunksPlugin.js +10 -10
- package/lib/performance/SizeLimitsPlugin.js +13 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +15 -1
- package/lib/rules/RuleSetCompiler.js +9 -7
- package/lib/runtime/EnsureChunkRuntimeModule.js +2 -1
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +2 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +1 -1
- package/lib/runtime/StartupChunkDependenciesPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +4 -4
- package/lib/serialization/FileMiddleware.js +4 -3
- package/lib/serialization/NullPrototypeObjectSerializer.js +2 -2
- package/lib/serialization/ObjectMiddleware.js +8 -5
- package/lib/serialization/PlainObjectSerializer.js +2 -2
- package/lib/serialization/Serializer.js +19 -0
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/serialization/SingleItemMiddleware.js +2 -2
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +2 -2
- package/lib/sharing/ConsumeSharedPlugin.js +17 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -2
- package/lib/sharing/ProvideSharedPlugin.js +13 -6
- package/lib/sharing/resolveMatchedConfigs.js +3 -3
- package/lib/sharing/utils.js +13 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +20 -20
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/stats/StatsFactory.js +2 -2
- package/lib/stats/StatsPrinter.js +6 -6
- package/lib/util/ArrayQueue.js +14 -21
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Queue.js +8 -2
- package/lib/util/SortableSet.js +16 -4
- package/lib/util/StackedCacheMap.js +26 -0
- package/lib/util/TupleQueue.js +8 -2
- package/lib/util/WeakTupleMap.js +57 -13
- package/lib/util/binarySearchBounds.js +1 -1
- package/lib/util/cleverMerge.js +26 -13
- package/lib/util/comparators.js +37 -15
- package/lib/util/conventions.js +129 -0
- package/lib/util/createHash.js +3 -5
- package/lib/util/deprecation.js +3 -3
- package/lib/util/deterministicGrouping.js +2 -2
- package/lib/util/findGraphRoots.js +1 -1
- package/lib/util/fs.js +383 -69
- package/lib/util/hash/BatchedHash.js +3 -0
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +5 -5
- package/lib/util/mergeScope.js +79 -0
- package/lib/util/runtime.js +2 -17
- package/lib/util/semver.js +3 -0
- package/lib/util/smartGrouping.js +3 -3
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +4 -2
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -2
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +16 -7
- package/lib/wasm-sync/WebAssemblyGenerator.js +40 -19
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
- package/lib/wasm-sync/WebAssemblyParser.js +7 -4
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -1
- package/lib/web/FetchCompileWasmPlugin.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +3 -2
- package/lib/webpack.js +19 -6
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -1
- package/package.json +40 -39
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +97 -8
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +5 -1
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/types.d.ts +1826 -639
@@ -28,13 +28,16 @@ const {
|
|
28
28
|
/** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
|
29
29
|
|
30
30
|
/** @typedef {Map<string, string | false>} ResolveResults */
|
31
|
+
/** @typedef {Set<string>} Items */
|
32
|
+
/** @typedef {Set<string>} BuildDependencies */
|
33
|
+
/** @typedef {Map<string, PackItemInfo>} ItemInfo */
|
31
34
|
|
32
35
|
class PackContainer {
|
33
36
|
/**
|
34
|
-
* @param {
|
37
|
+
* @param {object} data stored data
|
35
38
|
* @param {string} version version identifier
|
36
39
|
* @param {Snapshot} buildSnapshot snapshot of all build dependencies
|
37
|
-
* @param {
|
40
|
+
* @param {BuildDependencies} buildDependencies list of all unresolved build dependencies captured
|
38
41
|
* @param {ResolveResults} resolveResults result of the resolved build dependencies
|
39
42
|
* @param {Snapshot} resolveBuildDependenciesSnapshot snapshot of the dependencies of the build dependencies resolving
|
40
43
|
*/
|
@@ -54,13 +57,17 @@ class PackContainer {
|
|
54
57
|
this.resolveBuildDependenciesSnapshot = resolveBuildDependenciesSnapshot;
|
55
58
|
}
|
56
59
|
|
60
|
+
/**
|
61
|
+
* @param {ObjectSerializerContext} context context
|
62
|
+
*/
|
57
63
|
serialize({ write, writeLazy }) {
|
58
64
|
write(this.version);
|
59
65
|
write(this.buildSnapshot);
|
60
66
|
write(this.buildDependencies);
|
61
67
|
write(this.resolveResults);
|
62
68
|
write(this.resolveBuildDependenciesSnapshot);
|
63
|
-
writeLazy
|
69
|
+
/** @type {NonNullable<ObjectSerializerContext["writeLazy"]>} */
|
70
|
+
(writeLazy)(this.data);
|
64
71
|
}
|
65
72
|
|
66
73
|
/**
|
@@ -104,13 +111,17 @@ class PackItemInfo {
|
|
104
111
|
}
|
105
112
|
|
106
113
|
class Pack {
|
114
|
+
/**
|
115
|
+
* @param {Logger} logger a logger
|
116
|
+
* @param {number} maxAge max age of cache items
|
117
|
+
*/
|
107
118
|
constructor(logger, maxAge) {
|
108
|
-
/** @type {
|
119
|
+
/** @type {ItemInfo} */
|
109
120
|
this.itemInfo = new Map();
|
110
121
|
/** @type {(string | undefined)[]} */
|
111
122
|
this.requests = [];
|
112
123
|
this.requestsTimeout = undefined;
|
113
|
-
/** @type {
|
124
|
+
/** @type {ItemInfo} */
|
114
125
|
this.freshContent = new Map();
|
115
126
|
/** @type {(undefined | PackContent)[]} */
|
116
127
|
this.content = [];
|
@@ -224,12 +235,18 @@ class Pack {
|
|
224
235
|
return i;
|
225
236
|
}
|
226
237
|
|
238
|
+
/**
|
239
|
+
* @private
|
240
|
+
* @param {Items} items items
|
241
|
+
* @param {Items} usedItems used items
|
242
|
+
* @param {number} newLoc new location
|
243
|
+
*/
|
227
244
|
_gcAndUpdateLocation(items, usedItems, newLoc) {
|
228
245
|
let count = 0;
|
229
246
|
let lastGC;
|
230
247
|
const now = Date.now();
|
231
248
|
for (const identifier of items) {
|
232
|
-
const info = this.itemInfo.get(identifier);
|
249
|
+
const info = /** @type {PackItemInfo} */ (this.itemInfo.get(identifier));
|
233
250
|
if (now - info.lastAccess > this.maxAge) {
|
234
251
|
this.itemInfo.delete(identifier);
|
235
252
|
items.delete(identifier);
|
@@ -263,7 +280,7 @@ class Pack {
|
|
263
280
|
const loc = this._findLocation();
|
264
281
|
this.content[loc] = null; // reserve
|
265
282
|
const pack = {
|
266
|
-
/** @type {
|
283
|
+
/** @type {Items} */
|
267
284
|
items: new Set(),
|
268
285
|
/** @type {Map<string, any>} */
|
269
286
|
map: new Map(),
|
@@ -372,9 +389,9 @@ class Pack {
|
|
372
389
|
}
|
373
390
|
|
374
391
|
// 4. Determine merged items
|
375
|
-
/** @type {
|
392
|
+
/** @type {Items} */
|
376
393
|
const mergedItems = new Set();
|
377
|
-
/** @type {
|
394
|
+
/** @type {Items} */
|
378
395
|
const mergedUsedItems = new Set();
|
379
396
|
/** @type {(function(Map<string, any>): Promise<void>)[]} */
|
380
397
|
const addToMergedMap = [];
|
@@ -544,6 +561,9 @@ class Pack {
|
|
544
561
|
}
|
545
562
|
}
|
546
563
|
|
564
|
+
/**
|
565
|
+
* @param {ObjectSerializerContext} context context
|
566
|
+
*/
|
547
567
|
serialize({ write, writeSeparate }) {
|
548
568
|
this._persistFreshContent();
|
549
569
|
this._optimizeSmallContent();
|
@@ -571,6 +591,9 @@ class Pack {
|
|
571
591
|
write(null); // null as marker of the end of items
|
572
592
|
}
|
573
593
|
|
594
|
+
/**
|
595
|
+
* @param {ObjectDeserializerContext & { logger: Logger }} context context
|
596
|
+
*/
|
574
597
|
deserialize({ read, logger }) {
|
575
598
|
this.logger = logger;
|
576
599
|
{
|
@@ -629,6 +652,9 @@ class PackContentItems {
|
|
629
652
|
this.map = map;
|
630
653
|
}
|
631
654
|
|
655
|
+
/**
|
656
|
+
* @param {ObjectSerializerContext & { snapshot: TODO, rollback: TODO, logger: Logger, profile: boolean | undefined }} context context
|
657
|
+
*/
|
632
658
|
serialize({ write, snapshot, rollback, logger, profile }) {
|
633
659
|
if (profile) {
|
634
660
|
write(false);
|
@@ -695,6 +721,9 @@ class PackContentItems {
|
|
695
721
|
}
|
696
722
|
}
|
697
723
|
|
724
|
+
/**
|
725
|
+
* @param {ObjectDeserializerContext & { logger: Logger, profile: boolean | undefined }} context context
|
726
|
+
*/
|
698
727
|
deserialize({ read, logger, profile }) {
|
699
728
|
if (read()) {
|
700
729
|
this.map = read();
|
@@ -760,17 +789,17 @@ class PackContent {
|
|
760
789
|
*/
|
761
790
|
|
762
791
|
/**
|
763
|
-
* @param {
|
764
|
-
* @param {
|
792
|
+
* @param {Items} items keys
|
793
|
+
* @param {Items} usedItems used keys
|
765
794
|
* @param {PackContentItems | function(): Promise<PackContentItems>} dataOrFn sync or async content
|
766
795
|
* @param {Logger=} logger logger for logging
|
767
796
|
* @param {string=} lazyName name of dataOrFn for logging
|
768
797
|
*/
|
769
798
|
constructor(items, usedItems, dataOrFn, logger, lazyName) {
|
770
799
|
this.items = items;
|
771
|
-
/** @type {function(): Promise<PackContentItems> | PackContentItems} */
|
800
|
+
/** @type {(function(): Promise<PackContentItems> | PackContentItems) | undefined} */
|
772
801
|
this.lazy = typeof dataOrFn === "function" ? dataOrFn : undefined;
|
773
|
-
/** @type {Map<string, any>} */
|
802
|
+
/** @type {Map<string, any> | undefined} */
|
774
803
|
this.content = typeof dataOrFn === "function" ? undefined : dataOrFn.map;
|
775
804
|
this.outdated = false;
|
776
805
|
this.used = usedItems;
|
@@ -778,6 +807,10 @@ class PackContent {
|
|
778
807
|
this.lazyName = lazyName;
|
779
808
|
}
|
780
809
|
|
810
|
+
/**
|
811
|
+
* @param {string} identifier identifier
|
812
|
+
* @returns {string | Promise<string>} result
|
813
|
+
*/
|
781
814
|
get(identifier) {
|
782
815
|
this.used.add(identifier);
|
783
816
|
if (this.content) {
|
@@ -994,7 +1027,7 @@ const allowCollectingMemory = buf => {
|
|
994
1027
|
|
995
1028
|
class PackFileCacheStrategy {
|
996
1029
|
/**
|
997
|
-
* @param {
|
1030
|
+
* @param {object} options options
|
998
1031
|
* @param {Compiler} options.compiler the compiler
|
999
1032
|
* @param {IntermediateFileSystem} options.fs the filesystem
|
1000
1033
|
* @param {string} options.context the context directory
|
@@ -1049,7 +1082,7 @@ class PackFileCacheStrategy {
|
|
1049
1082
|
? ".pack.gz"
|
1050
1083
|
: ".pack";
|
1051
1084
|
this.snapshot = snapshot;
|
1052
|
-
/** @type {
|
1085
|
+
/** @type {BuildDependencies} */
|
1053
1086
|
this.buildDependencies = new Set();
|
1054
1087
|
/** @type {LazySet<string>} */
|
1055
1088
|
this.newBuildDependencies = new LazySet();
|
@@ -1081,9 +1114,9 @@ class PackFileCacheStrategy {
|
|
1081
1114
|
const { logger, profile, cacheLocation, version } = this;
|
1082
1115
|
/** @type {Snapshot} */
|
1083
1116
|
let buildSnapshot;
|
1084
|
-
/** @type {
|
1117
|
+
/** @type {BuildDependencies} */
|
1085
1118
|
let buildDependencies;
|
1086
|
-
/** @type {
|
1119
|
+
/** @type {BuildDependencies} */
|
1087
1120
|
let newBuildDependencies;
|
1088
1121
|
/** @type {Snapshot} */
|
1089
1122
|
let resolveBuildDependenciesSnapshot;
|
@@ -1272,7 +1305,7 @@ class PackFileCacheStrategy {
|
|
1272
1305
|
}
|
1273
1306
|
|
1274
1307
|
/**
|
1275
|
-
* @param {LazySet<string>} dependencies dependencies to store
|
1308
|
+
* @param {LazySet<string> | Iterable<string>} dependencies dependencies to store
|
1276
1309
|
*/
|
1277
1310
|
storeBuildDependencies(dependencies) {
|
1278
1311
|
if (this.readonly) return;
|
@@ -8,7 +8,7 @@
|
|
8
8
|
const LazySet = require("../util/LazySet");
|
9
9
|
const makeSerializable = require("../util/makeSerializable");
|
10
10
|
|
11
|
-
/** @typedef {import("enhanced-resolve
|
11
|
+
/** @typedef {import("enhanced-resolve").Resolver} Resolver */
|
12
12
|
/** @typedef {import("../CacheFacade").ItemCacheFacade} ItemCacheFacade */
|
13
13
|
/** @typedef {import("../Compiler")} Compiler */
|
14
14
|
/** @typedef {import("../FileSystemInfo")} FileSystemInfo */
|
@@ -50,7 +50,7 @@ const addAllToSet = (set, otherSet) => {
|
|
50
50
|
};
|
51
51
|
|
52
52
|
/**
|
53
|
-
* @param {
|
53
|
+
* @param {object} object an object
|
54
54
|
* @param {boolean} excludeContext if true, context is not included in string
|
55
55
|
* @returns {string} stringified version
|
56
56
|
*/
|
@@ -104,9 +104,9 @@ class ResolverCachePlugin {
|
|
104
104
|
/**
|
105
105
|
* @param {ItemCacheFacade} itemCache cache
|
106
106
|
* @param {Resolver} resolver the resolver
|
107
|
-
* @param {
|
108
|
-
* @param {
|
109
|
-
* @param {function((Error | null)=,
|
107
|
+
* @param {object} resolveContext context for resolving meta info
|
108
|
+
* @param {object} request the request info object
|
109
|
+
* @param {function((Error | null)=, object=): void} callback callback function
|
110
110
|
* @returns {void}
|
111
111
|
*/
|
112
112
|
const doRealResolve = (
|
@@ -188,16 +188,16 @@ class ResolverCachePlugin {
|
|
188
188
|
};
|
189
189
|
compiler.resolverFactory.hooks.resolver.intercept({
|
190
190
|
factory(type, hook) {
|
191
|
-
/** @type {Map<string, (function(Error=,
|
191
|
+
/** @type {Map<string, (function(Error=, object=): void)[]>} */
|
192
192
|
const activeRequests = new Map();
|
193
|
-
/** @type {Map<string, [function(Error=,
|
193
|
+
/** @type {Map<string, [function(Error=, object=): void, function(Error=, object=): void][]>} */
|
194
194
|
const activeRequestsWithYield = new Map();
|
195
195
|
hook.tap(
|
196
196
|
"ResolverCachePlugin",
|
197
197
|
/**
|
198
198
|
* @param {Resolver} resolver the resolver
|
199
|
-
* @param {
|
200
|
-
* @param {
|
199
|
+
* @param {object} options resolve options
|
200
|
+
* @param {object} userOptions resolve options passed by the user
|
201
201
|
* @returns {void}
|
202
202
|
*/
|
203
203
|
(resolver, options, userOptions) => {
|
@@ -213,7 +213,10 @@ class ResolverCachePlugin {
|
|
213
213
|
stage: -100
|
214
214
|
},
|
215
215
|
(request, resolveContext, callback) => {
|
216
|
-
if (
|
216
|
+
if (
|
217
|
+
/** @type {TODO} */ (request)._ResolverCachePluginCacheMiss ||
|
218
|
+
!fileSystemInfo
|
219
|
+
) {
|
217
220
|
return callback();
|
218
221
|
}
|
219
222
|
const withYield = typeof resolveContext.yield === "function";
|
@@ -225,7 +228,9 @@ class ResolverCachePlugin {
|
|
225
228
|
const activeRequest = activeRequestsWithYield.get(identifier);
|
226
229
|
if (activeRequest) {
|
227
230
|
activeRequest[0].push(callback);
|
228
|
-
activeRequest[1].push(
|
231
|
+
activeRequest[1].push(
|
232
|
+
/** @type {TODO} */ (resolveContext.yield)
|
233
|
+
);
|
229
234
|
return;
|
230
235
|
}
|
231
236
|
} else {
|
@@ -303,19 +308,22 @@ class ResolverCachePlugin {
|
|
303
308
|
cachedResolves++;
|
304
309
|
if (resolveContext.missingDependencies) {
|
305
310
|
addAllToSet(
|
306
|
-
|
311
|
+
/** @type {LazySet<string>} */
|
312
|
+
(resolveContext.missingDependencies),
|
307
313
|
snapshot.getMissingIterable()
|
308
314
|
);
|
309
315
|
}
|
310
316
|
if (resolveContext.fileDependencies) {
|
311
317
|
addAllToSet(
|
312
|
-
|
318
|
+
/** @type {LazySet<string>} */
|
319
|
+
(resolveContext.fileDependencies),
|
313
320
|
snapshot.getFileIterable()
|
314
321
|
);
|
315
322
|
}
|
316
323
|
if (resolveContext.contextDependencies) {
|
317
324
|
addAllToSet(
|
318
|
-
|
325
|
+
/** @type {LazySet<string>} */
|
326
|
+
(resolveContext.contextDependencies),
|
319
327
|
snapshot.getContextIterable()
|
320
328
|
);
|
321
329
|
}
|
@@ -11,7 +11,7 @@ const createHash = require("../util/createHash");
|
|
11
11
|
/** @typedef {typeof import("../util/Hash")} HashConstructor */
|
12
12
|
|
13
13
|
/**
|
14
|
-
* @typedef {
|
14
|
+
* @typedef {object} HashableObject
|
15
15
|
* @property {function(Hash): void} updateHash
|
16
16
|
*/
|
17
17
|
|
@@ -47,7 +47,7 @@ const mapObjects = new WeakMap();
|
|
47
47
|
|
48
48
|
/**
|
49
49
|
* @param {HashableObject} obj object with updateHash method
|
50
|
-
* @param {string | HashConstructor} hashFunction the hash function to use
|
50
|
+
* @param {(string | HashConstructor)=} hashFunction the hash function to use
|
51
51
|
* @returns {LazyHashedEtag} etag
|
52
52
|
*/
|
53
53
|
const getter = (obj, hashFunction = "md4") => {
|
package/lib/cli.js
CHANGED
@@ -10,7 +10,7 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
|
|
10
10
|
|
11
11
|
// TODO add originPath to PathItem for better errors
|
12
12
|
/**
|
13
|
-
* @typedef {
|
13
|
+
* @typedef {object} PathItem
|
14
14
|
* @property {any} schema the part of the schema
|
15
15
|
* @property {string} path the path in the config
|
16
16
|
*/
|
@@ -18,7 +18,7 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
|
|
18
18
|
/** @typedef {"unknown-argument" | "unexpected-non-array-in-path" | "unexpected-non-object-in-path" | "multiple-values-unexpected" | "invalid-value"} ProblemType */
|
19
19
|
|
20
20
|
/**
|
21
|
-
* @typedef {
|
21
|
+
* @typedef {object} Problem
|
22
22
|
* @property {ProblemType} type
|
23
23
|
* @property {string} path
|
24
24
|
* @property {string} argument
|
@@ -28,14 +28,14 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
|
|
28
28
|
*/
|
29
29
|
|
30
30
|
/**
|
31
|
-
* @typedef {
|
31
|
+
* @typedef {object} LocalProblem
|
32
32
|
* @property {ProblemType} type
|
33
33
|
* @property {string} path
|
34
34
|
* @property {string=} expected
|
35
35
|
*/
|
36
36
|
|
37
37
|
/**
|
38
|
-
* @typedef {
|
38
|
+
* @typedef {object} ArgumentConfig
|
39
39
|
* @property {string} description
|
40
40
|
* @property {string} [negatedDescription]
|
41
41
|
* @property {string} path
|
@@ -45,7 +45,7 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
|
|
45
45
|
*/
|
46
46
|
|
47
47
|
/**
|
48
|
-
* @typedef {
|
48
|
+
* @typedef {object} Argument
|
49
49
|
* @property {string} description
|
50
50
|
* @property {"string"|"number"|"boolean"} simpleType
|
51
51
|
* @property {boolean} multiple
|
@@ -16,7 +16,7 @@ const path = require("path");
|
|
16
16
|
const inputRx = /^(?:((?:[A-Z]:)?[/\\].*?))?(?::(.+?))?$/i;
|
17
17
|
|
18
18
|
/**
|
19
|
-
* @typedef {
|
19
|
+
* @typedef {object} BrowserslistHandlerConfig
|
20
20
|
* @property {string=} configPath
|
21
21
|
* @property {string=} env
|
22
22
|
* @property {string=} query
|
@@ -344,6 +344,12 @@ const resolve = browsers => {
|
|
344
344
|
importScripts: false,
|
345
345
|
importScriptsInWorker: true,
|
346
346
|
nodeBuiltins: nodeProperty,
|
347
|
+
nodePrefixForCoreModules:
|
348
|
+
nodeProperty &&
|
349
|
+
!browsers.some(b => /^node 15/.test(b)) &&
|
350
|
+
rawChecker({
|
351
|
+
node: [14, 18]
|
352
|
+
}),
|
347
353
|
require: nodeProperty
|
348
354
|
};
|
349
355
|
};
|