webpack 5.104.1 → 5.105.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.
- package/bin/webpack.js +6 -3
- package/lib/APIPlugin.js +85 -15
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AsyncDependenciesBlock.js +13 -1
- package/lib/AsyncDependencyToInitialChunkError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +2 -0
- package/lib/CacheFacade.js +2 -2
- package/lib/CaseSensitiveModulesWarning.js +1 -0
- package/lib/Chunk.js +8 -4
- package/lib/ChunkGraph.js +30 -9
- package/lib/ChunkGroup.js +6 -3
- package/lib/ChunkRenderError.js +2 -0
- package/lib/CleanPlugin.js +4 -1
- package/lib/CodeGenerationError.js +7 -1
- package/lib/CodeGenerationResults.js +10 -3
- package/lib/CommentCompilationWarning.js +2 -1
- package/lib/Compilation.js +280 -236
- package/lib/Compiler.js +3 -2
- package/lib/ConcatenationScope.js +2 -1
- package/lib/ConcurrentCompilationError.js +3 -3
- package/lib/ContextModule.js +248 -111
- package/lib/ContextModuleFactory.js +14 -2
- package/lib/DefinePlugin.js +3 -1
- package/lib/DelegatedModule.js +6 -0
- package/lib/DelegatedModuleFactoryPlugin.js +2 -0
- package/lib/Dependency.js +6 -1
- package/lib/DependencyTemplates.js +3 -2
- package/lib/DllModule.js +2 -0
- package/lib/DllReferencePlugin.js +1 -0
- package/lib/DotenvPlugin.js +11 -5
- package/lib/DynamicEntryPlugin.js +1 -0
- package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
- package/lib/EvalSourceMapDevToolPlugin.js +17 -13
- package/lib/ExportsInfo.js +8 -4
- package/lib/ExternalModule.js +16 -0
- package/lib/FalseIIFEUmdWarning.js +1 -0
- package/lib/FileSystemInfo.js +49 -25
- package/lib/FlagDependencyExportsPlugin.js +8 -1
- package/lib/FlagDependencyUsagePlugin.js +9 -7
- package/lib/HarmonyLinkingError.js +1 -0
- package/lib/HookWebpackError.js +2 -0
- package/lib/HotModuleReplacementPlugin.js +16 -2
- package/lib/InitFragment.js +1 -0
- package/lib/InvalidDependenciesModuleWarning.js +1 -0
- package/lib/LibManifestPlugin.js +1 -0
- package/lib/ManifestPlugin.js +4 -1
- package/lib/Module.js +7 -4
- package/lib/ModuleBuildError.js +3 -1
- package/lib/ModuleDependencyError.js +1 -0
- package/lib/ModuleDependencyWarning.js +1 -0
- package/lib/ModuleError.js +2 -1
- package/lib/ModuleFilenameHelpers.js +2 -1
- package/lib/ModuleGraph.js +3 -0
- package/lib/ModuleGraphConnection.js +10 -1
- package/lib/ModuleHashingError.js +2 -0
- package/lib/ModuleInfoHeaderPlugin.js +6 -1
- package/lib/ModuleNotFoundError.js +1 -0
- package/lib/ModuleParseError.js +5 -1
- package/lib/ModuleProfile.js +1 -1
- package/lib/ModuleRestoreError.js +2 -0
- package/lib/ModuleSourceTypeConstants.js +1 -11
- package/lib/ModuleStoreError.js +2 -0
- package/lib/ModuleWarning.js +3 -1
- package/lib/MultiCompiler.js +11 -7
- package/lib/MultiWatching.js +2 -2
- package/lib/NoModeWarning.js +1 -0
- package/lib/NodeStuffInWebError.js +1 -0
- package/lib/NormalModule.js +26 -5
- package/lib/NormalModuleFactory.js +20 -4
- package/lib/OptionsApply.js +3 -1
- package/lib/ProgressPlugin.js +4 -0
- package/lib/RawModule.js +2 -0
- package/lib/RuntimeModule.js +10 -0
- package/lib/RuntimePlugin.js +7 -9
- package/lib/RuntimeTemplate.js +14 -7
- package/lib/SourceMapDevToolPlugin.js +30 -23
- package/lib/Template.js +10 -5
- package/lib/TemplatedPathPlugin.js +4 -2
- package/lib/UnhandledSchemeError.js +1 -0
- package/lib/UnsupportedFeatureWarning.js +1 -0
- package/lib/WarnDeprecatedOptionPlugin.js +1 -0
- package/lib/WatchIgnorePlugin.js +1 -1
- package/lib/Watching.js +5 -0
- package/lib/WebpackError.js +4 -0
- package/lib/WebpackOptionsApply.js +60 -40
- package/lib/asset/AssetBytesGenerator.js +1 -0
- package/lib/asset/AssetGenerator.js +9 -3
- package/lib/asset/AssetModulesPlugin.js +33 -2
- package/lib/asset/AssetSourceGenerator.js +1 -0
- package/lib/asset/RawDataUrlModule.js +4 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
- package/lib/buildChunkGraph.js +31 -2
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +41 -8
- package/lib/cache/getLazyHashedEtag.js +13 -4
- package/lib/cache/mergeEtags.js +3 -1
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +65 -44
- package/lib/config/normalization.js +96 -0
- package/lib/container/ContainerEntryModule.js +4 -0
- package/lib/container/FallbackModule.js +2 -0
- package/lib/container/HoistContainerReferencesPlugin.js +6 -0
- package/lib/container/RemoteModule.js +19 -0
- package/lib/css/CssGenerator.js +31 -4
- package/lib/css/CssModulesPlugin.js +26 -30
- package/lib/css/CssParser.js +12 -9
- package/lib/debug/ProfilingPlugin.js +1 -0
- package/lib/dependencies/AMDDefineDependency.js +3 -1
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -0
- package/lib/dependencies/AMDPlugin.js +1 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +7 -1
- package/lib/dependencies/CachedConstDependency.js +1 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +2 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +1 -0
- package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
- package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -0
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -0
- package/lib/dependencies/ConstDependency.js +1 -0
- package/lib/dependencies/ContextDependencyHelpers.js +11 -4
- package/lib/dependencies/ContextElementDependency.js +1 -0
- package/lib/dependencies/CriticalDependencyWarning.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +5 -4
- package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
- package/lib/dependencies/CssUrlDependency.js +2 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
- package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +1 -0
- package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
- package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +266 -5
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
- package/lib/dependencies/ImportDependency.js +1 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +53 -11
- package/lib/dependencies/ImportParserPlugin.js +7 -12
- package/lib/dependencies/LoaderPlugin.js +3 -0
- package/lib/dependencies/ModuleDecoratorDependency.js +1 -0
- package/lib/dependencies/ModuleDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
- package/lib/dependencies/ProvidedDependency.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +1 -0
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
- package/lib/dependencies/WorkerDependency.js +9 -3
- package/lib/dependencies/WorkerPlugin.js +1 -0
- package/lib/dependencies/getFunctionExpression.js +3 -1
- package/lib/errors/BuildCycleError.js +4 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
- package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +5 -0
- package/lib/hmr/lazyCompilationBackend.js +3 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +2 -0
- package/lib/ids/IdHelpers.js +10 -8
- package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -7
- package/lib/ids/SyncModuleIdsPlugin.js +5 -1
- package/lib/javascript/BasicEvaluatedExpression.js +1 -0
- package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
- package/lib/javascript/JavascriptModulesPlugin.js +29 -8
- package/lib/javascript/JavascriptParser.js +47 -14
- package/lib/json/JsonParser.js +6 -0
- package/lib/library/AbstractLibraryPlugin.js +4 -1
- package/lib/library/AmdLibraryPlugin.js +2 -1
- package/lib/library/AssignLibraryPlugin.js +6 -2
- package/lib/library/EnableLibraryPlugin.js +1 -0
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
- package/lib/library/JsonpLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +130 -13
- package/lib/library/SystemLibraryPlugin.js +4 -1
- package/lib/library/UmdLibraryPlugin.js +4 -3
- package/lib/logging/createConsoleLogger.js +3 -0
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +1 -0
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +3 -0
- package/lib/node/nodeConsole.js +18 -1
- package/lib/optimize/AggressiveMergingPlugin.js +2 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +10 -6
- package/lib/optimize/ConcatenatedModule.js +33 -19
- package/lib/optimize/FlagIncludedChunksPlugin.js +11 -1
- package/lib/optimize/InnerGraph.js +5 -3
- package/lib/optimize/InnerGraphPlugin.js +25 -25
- package/lib/optimize/MangleExportsPlugin.js +14 -2
- package/lib/optimize/MergeDuplicateChunksPlugin.js +3 -0
- package/lib/optimize/MinChunkSizePlugin.js +5 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +19 -4
- package/lib/optimize/RealContentHashPlugin.js +35 -27
- package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
- package/lib/optimize/SplitChunksPlugin.js +14 -3
- package/lib/performance/AssetsOverSizeLimitWarning.js +6 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -2
- package/lib/performance/NoAsyncChunksWarning.js +1 -0
- package/lib/rules/BasicEffectRulePlugin.js +2 -0
- package/lib/rules/BasicMatcherRulePlugin.js +3 -0
- package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
- package/lib/rules/RuleSetCompiler.js +2 -0
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
- package/lib/runtime/CompatRuntimeModule.js +1 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
- package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +15 -32
- package/lib/runtime/PublicPathRuntimeModule.js +1 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
- package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
- package/lib/schemes/HttpUriPlugin.js +27 -7
- package/lib/schemes/VirtualUrlPlugin.js +7 -2
- package/lib/serialization/BinaryMiddleware.js +4 -0
- package/lib/serialization/FileMiddleware.js +9 -4
- package/lib/serialization/ObjectMiddleware.js +34 -11
- package/lib/serialization/PlainObjectSerializer.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +60 -0
- package/lib/sharing/ConsumeSharedPlugin.js +5 -4
- package/lib/sharing/ProvideSharedModule.js +4 -0
- package/lib/sharing/ProvideSharedPlugin.js +24 -25
- package/lib/sharing/resolveMatchedConfigs.js +2 -2
- package/lib/sharing/utils.js +8 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +14 -12
- package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
- package/lib/stats/StatsFactory.js +2 -2
- package/lib/url/URLParserPlugin.js +4 -3
- package/lib/util/AppendOnlyStackedSet.js +57 -0
- package/lib/util/Hash.js +1 -0
- package/lib/util/IterableHelpers.js +1 -0
- package/lib/util/LazyBucketSortedSet.js +1 -0
- package/lib/util/LazySet.js +1 -0
- package/lib/util/ParallelismFactorCalculator.js +1 -0
- package/lib/util/SortableSet.js +1 -0
- package/lib/util/StringXor.js +1 -0
- package/lib/util/binarySearchBounds.js +15 -8
- package/lib/util/chainedImports.js +1 -1
- package/lib/util/cleverMerge.js +6 -1
- package/lib/util/comparators.js +21 -1
- package/lib/util/compileBooleanMatcher.js +3 -3
- package/lib/util/concatenate.js +3 -2
- package/lib/util/conventions.js +3 -2
- package/lib/util/deterministicGrouping.js +13 -1
- package/lib/util/extractSourceMap.js +12 -13
- package/lib/util/fs.js +15 -19
- package/lib/util/hash/BatchedHash.js +3 -0
- package/lib/util/hash/BulkUpdateHash.js +7 -1
- package/lib/util/hash/hash-digest.js +1 -0
- package/lib/util/hash/wasm-hash.js +16 -1
- package/lib/util/identifier.js +7 -2
- package/lib/util/magicComment.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -0
- package/lib/util/runtime.js +15 -1
- package/lib/util/semver.js +1 -0
- package/lib/util/serialization.js +2 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +1 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyParser.js +3 -1
- package/lib/web/FetchCompileWasmPlugin.js +1 -0
- package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
- package/lib/webpack.js +13 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/package.json +20 -28
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +71 -5
- package/types.d.ts +339 -93
|
@@ -22,8 +22,10 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
22
22
|
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
|
23
23
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
|
24
24
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
|
25
|
+
/** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
|
|
25
26
|
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
|
|
26
27
|
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
|
|
28
|
+
/** @typedef {import("../Module").Sources} Sources */
|
|
27
29
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
28
30
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
29
31
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
@@ -114,11 +116,13 @@ class RawDataUrlModule extends Module {
|
|
|
114
116
|
if (this.url === undefined) {
|
|
115
117
|
this.url = /** @type {Buffer} */ (this.urlBuffer).toString();
|
|
116
118
|
}
|
|
119
|
+
/** @type {Sources} */
|
|
117
120
|
const sources = new Map();
|
|
118
121
|
sources.set(
|
|
119
122
|
JAVASCRIPT_TYPE,
|
|
120
123
|
new RawSource(`module.exports = ${JSON.stringify(this.url)};`)
|
|
121
124
|
);
|
|
125
|
+
/** @type {CodeGenerationResultData} */
|
|
122
126
|
const data = new Map();
|
|
123
127
|
data.set("url", {
|
|
124
128
|
javascript: this.url
|
|
@@ -12,12 +12,14 @@ const Template = require("../Template");
|
|
|
12
12
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
13
13
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
|
14
14
|
|
|
15
|
+
/** @typedef {Map<string, string>} Dependencies */
|
|
16
|
+
|
|
15
17
|
/**
|
|
16
18
|
* @extends {InitFragment<GenerateContext>}
|
|
17
19
|
*/
|
|
18
20
|
class AwaitDependenciesInitFragment extends InitFragment {
|
|
19
21
|
/**
|
|
20
|
-
* @param {
|
|
22
|
+
* @param {Dependencies} dependencies maps an import var to an async module that needs to be awaited
|
|
21
23
|
*/
|
|
22
24
|
constructor(dependencies) {
|
|
23
25
|
super(
|
|
@@ -26,6 +28,7 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|
|
26
28
|
0,
|
|
27
29
|
"await-dependencies"
|
|
28
30
|
);
|
|
31
|
+
/** @type {Dependencies} */
|
|
29
32
|
this.dependencies = dependencies;
|
|
30
33
|
}
|
|
31
34
|
|
package/lib/buildChunkGraph.js
CHANGED
|
@@ -50,6 +50,8 @@ const { getEntryRuntime, mergeRuntime } = require("./util/runtime");
|
|
|
50
50
|
* @property {number} postOrderIndex next post order index
|
|
51
51
|
* @property {boolean} chunkLoading has a chunk loading mechanism
|
|
52
52
|
* @property {boolean} asyncChunks create async chunks
|
|
53
|
+
* @property {Module | null} depModule the module that is the dependency of the block
|
|
54
|
+
* @property {boolean} circular Whether to deduplicate to avoid circular references
|
|
53
55
|
*/
|
|
54
56
|
|
|
55
57
|
/**
|
|
@@ -165,6 +167,7 @@ const extractBlockModules = (module, moduleGraph, runtime, blockModulesMap) => {
|
|
|
165
167
|
|
|
166
168
|
for (const modules of arrays) {
|
|
167
169
|
if (modules.length === 0) continue;
|
|
170
|
+
/** @type {undefined | Map<Module | ModuleGraphConnection | ConnectionState, number>} */
|
|
168
171
|
let indexMap;
|
|
169
172
|
let length = 0;
|
|
170
173
|
outer: for (let j = 0; j < modules.length; j += 3) {
|
|
@@ -360,6 +363,9 @@ const visitModules = (
|
|
|
360
363
|
/** @type {NamedChunkGroup} */
|
|
361
364
|
const namedAsyncEntrypoints = new Map();
|
|
362
365
|
|
|
366
|
+
/** @type {Map<Module, ChunkGroupInfo>} */
|
|
367
|
+
const depModuleAsyncEntrypoints = new Map();
|
|
368
|
+
|
|
363
369
|
/** @type {Set<ChunkGroupInfo>} */
|
|
364
370
|
const outdatedOrderIndexChunkGroups = new Set();
|
|
365
371
|
|
|
@@ -373,7 +379,8 @@ const visitModules = (
|
|
|
373
379
|
/** @type {QueueItem[]} */
|
|
374
380
|
let queue = [];
|
|
375
381
|
|
|
376
|
-
/** @
|
|
382
|
+
/** @typedef {Set<[ChunkGroupInfo, QueueItem | null]>} ConnectList */
|
|
383
|
+
/** @type {Map<ChunkGroupInfo, ConnectList>} */
|
|
377
384
|
const queueConnect = new Map();
|
|
378
385
|
/** @type {Set<ChunkGroupInfo>} */
|
|
379
386
|
const chunkGroupsForCombining = new Set();
|
|
@@ -388,6 +395,8 @@ const visitModules = (
|
|
|
388
395
|
);
|
|
389
396
|
/** @type {ChunkGroupInfo} */
|
|
390
397
|
const chunkGroupInfo = {
|
|
398
|
+
depModule: null,
|
|
399
|
+
circular: false,
|
|
391
400
|
initialized: false,
|
|
392
401
|
chunkGroup,
|
|
393
402
|
runtime,
|
|
@@ -496,11 +505,16 @@ const visitModules = (
|
|
|
496
505
|
let c;
|
|
497
506
|
/** @type {Entrypoint | undefined} */
|
|
498
507
|
let entrypoint;
|
|
508
|
+
/** @type {Module | null} */
|
|
509
|
+
const depModule = moduleGraph.getModule(b.dependencies[0]);
|
|
499
510
|
const entryOptions = b.groupOptions && b.groupOptions.entryOptions;
|
|
500
511
|
if (cgi === undefined) {
|
|
501
512
|
const chunkName = (b.groupOptions && b.groupOptions.name) || b.chunkName;
|
|
502
513
|
if (entryOptions) {
|
|
503
514
|
cgi = namedAsyncEntrypoints.get(/** @type {string} */ (chunkName));
|
|
515
|
+
if (!cgi && !b.circular && depModule) {
|
|
516
|
+
cgi = depModuleAsyncEntrypoints.get(depModule);
|
|
517
|
+
}
|
|
504
518
|
if (!cgi) {
|
|
505
519
|
entrypoint = compilation.addAsyncEntrypoint(
|
|
506
520
|
entryOptions,
|
|
@@ -511,6 +525,8 @@ const visitModules = (
|
|
|
511
525
|
maskByChunk.set(entrypoint.chunks[0], ZERO_BIGINT);
|
|
512
526
|
entrypoint.index = nextChunkGroupIndex++;
|
|
513
527
|
cgi = {
|
|
528
|
+
depModule,
|
|
529
|
+
circular: b.circular,
|
|
514
530
|
chunkGroup: entrypoint,
|
|
515
531
|
initialized: false,
|
|
516
532
|
runtime:
|
|
@@ -548,6 +564,12 @@ const visitModules = (
|
|
|
548
564
|
(cgi)
|
|
549
565
|
);
|
|
550
566
|
}
|
|
567
|
+
if (!b.circular && depModule) {
|
|
568
|
+
depModuleAsyncEntrypoints.set(
|
|
569
|
+
depModule,
|
|
570
|
+
/** @type {ChunkGroupInfo} */ (cgi)
|
|
571
|
+
);
|
|
572
|
+
}
|
|
551
573
|
} else {
|
|
552
574
|
entrypoint = /** @type {Entrypoint} */ (cgi.chunkGroup);
|
|
553
575
|
// TODO merge entryOptions
|
|
@@ -590,6 +612,8 @@ const visitModules = (
|
|
|
590
612
|
maskByChunk.set(c.chunks[0], ZERO_BIGINT);
|
|
591
613
|
c.index = nextChunkGroupIndex++;
|
|
592
614
|
cgi = {
|
|
615
|
+
depModule,
|
|
616
|
+
circular: b.circular,
|
|
593
617
|
initialized: false,
|
|
594
618
|
chunkGroup: c,
|
|
595
619
|
runtime: chunkGroupInfo.runtime,
|
|
@@ -651,6 +675,7 @@ const visitModules = (
|
|
|
651
675
|
// 3. We enqueue the chunk group info creation/updating
|
|
652
676
|
let connectList = queueConnect.get(chunkGroupInfo);
|
|
653
677
|
if (connectList === undefined) {
|
|
678
|
+
/** @type {ConnectList} */
|
|
654
679
|
connectList = new Set();
|
|
655
680
|
queueConnect.set(chunkGroupInfo, connectList);
|
|
656
681
|
}
|
|
@@ -665,7 +690,10 @@ const visitModules = (
|
|
|
665
690
|
chunkGroupInfo: /** @type {ChunkGroupInfo} */ (cgi)
|
|
666
691
|
}
|
|
667
692
|
]);
|
|
668
|
-
} else if (
|
|
693
|
+
} else if (
|
|
694
|
+
entrypoint !== undefined &&
|
|
695
|
+
(chunkGroupInfo.circular || chunkGroupInfo.depModule !== depModule)
|
|
696
|
+
) {
|
|
669
697
|
chunkGroupInfo.chunkGroup.addAsyncEntrypoint(entrypoint);
|
|
670
698
|
}
|
|
671
699
|
};
|
|
@@ -1091,6 +1119,7 @@ const visitModules = (
|
|
|
1091
1119
|
for (const cgi of info.children) {
|
|
1092
1120
|
let connectList = queueConnect.get(info);
|
|
1093
1121
|
if (connectList === undefined) {
|
|
1122
|
+
/** @type {ConnectList} */
|
|
1094
1123
|
connectList = new Set();
|
|
1095
1124
|
queueConnect.set(info, connectList);
|
|
1096
1125
|
}
|
|
@@ -43,6 +43,7 @@ class MemoryWithGcCachePlugin {
|
|
|
43
43
|
compiler.hooks.afterDone.tap(PLUGIN_NAME, () => {
|
|
44
44
|
generation++;
|
|
45
45
|
let clearedEntries = 0;
|
|
46
|
+
/** @type {undefined | string} */
|
|
46
47
|
let lastClearedIdentifier;
|
|
47
48
|
// Avoid coverage problems due indirect changes
|
|
48
49
|
/* istanbul ignore next */
|
|
@@ -28,7 +28,7 @@ const {
|
|
|
28
28
|
/** @typedef {import("../logging/Logger").Logger} Logger */
|
|
29
29
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
30
30
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
31
|
-
/** @typedef {
|
|
31
|
+
/** @typedef {import("../util/Hash").HashFunction} HashFunction */
|
|
32
32
|
/** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
|
|
33
33
|
|
|
34
34
|
/** @typedef {Set<string>} Items */
|
|
@@ -134,13 +134,17 @@ class Pack {
|
|
|
134
134
|
this.itemInfo = new Map();
|
|
135
135
|
/** @type {(string | undefined)[]} */
|
|
136
136
|
this.requests = [];
|
|
137
|
+
/** @type {undefined | NodeJS.Timeout} */
|
|
137
138
|
this.requestsTimeout = undefined;
|
|
138
139
|
/** @type {ItemInfo} */
|
|
139
140
|
this.freshContent = new Map();
|
|
140
141
|
/** @type {(undefined | PackContent)[]} */
|
|
141
142
|
this.content = [];
|
|
143
|
+
/** @type {boolean} */
|
|
142
144
|
this.invalid = false;
|
|
145
|
+
/** @type {Logger} */
|
|
143
146
|
this.logger = logger;
|
|
147
|
+
/** @type {number} */
|
|
144
148
|
this.maxAge = maxAge;
|
|
145
149
|
}
|
|
146
150
|
|
|
@@ -243,6 +247,7 @@ class Pack {
|
|
|
243
247
|
* @returns {number} new location of data entries
|
|
244
248
|
*/
|
|
245
249
|
_findLocation() {
|
|
250
|
+
/** @type {number} */
|
|
246
251
|
let i;
|
|
247
252
|
for (i = 0; i < this.content.length && this.content[i] !== undefined; i++);
|
|
248
253
|
return i;
|
|
@@ -256,6 +261,7 @@ class Pack {
|
|
|
256
261
|
*/
|
|
257
262
|
_gcAndUpdateLocation(items, usedItems, newLoc) {
|
|
258
263
|
let count = 0;
|
|
264
|
+
/** @type {undefined | string} */
|
|
259
265
|
let lastGC;
|
|
260
266
|
const now = Date.now();
|
|
261
267
|
for (const identifier of items) {
|
|
@@ -381,6 +387,7 @@ class Pack {
|
|
|
381
387
|
}
|
|
382
388
|
|
|
383
389
|
// 2. Check if minimum number is reached
|
|
390
|
+
/** @type {number[]} */
|
|
384
391
|
let mergedIndices;
|
|
385
392
|
if (
|
|
386
393
|
smallUsedContents.length >= CONTENT_COUNT_TO_MERGE ||
|
|
@@ -505,6 +512,7 @@ class Pack {
|
|
|
505
512
|
|
|
506
513
|
// 5. Determine items for the unused content file
|
|
507
514
|
const unusedItems = new Set(content.items);
|
|
515
|
+
/** @type {Items} */
|
|
508
516
|
const usedOfUnusedItems = new Set();
|
|
509
517
|
for (const identifier of usedItems) {
|
|
510
518
|
unusedItems.delete(identifier);
|
|
@@ -521,6 +529,7 @@ class Pack {
|
|
|
521
529
|
await content.unpack(
|
|
522
530
|
"it should be splitted into used and unused items"
|
|
523
531
|
);
|
|
532
|
+
/** @type {Content} */
|
|
524
533
|
const map = new Map();
|
|
525
534
|
for (const identifier of unusedItems) {
|
|
526
535
|
map.set(
|
|
@@ -579,6 +588,7 @@ class Pack {
|
|
|
579
588
|
await content.unpack(
|
|
580
589
|
"it contains old items that should be garbage collected"
|
|
581
590
|
);
|
|
591
|
+
/** @type {Content} */
|
|
582
592
|
const map = new Map();
|
|
583
593
|
for (const identifier of items) {
|
|
584
594
|
map.set(
|
|
@@ -691,7 +701,7 @@ class PackContentItems {
|
|
|
691
701
|
}
|
|
692
702
|
|
|
693
703
|
/**
|
|
694
|
-
* @param {ObjectSerializerContext & { logger: Logger, profile: boolean | undefined
|
|
704
|
+
* @param {ObjectSerializerContext & { logger: Logger, profile: boolean | undefined }} context context
|
|
695
705
|
*/
|
|
696
706
|
serialize({ write, snapshot, rollback, logger, profile }) {
|
|
697
707
|
if (profile) {
|
|
@@ -774,6 +784,7 @@ class PackContentItems {
|
|
|
774
784
|
if (read()) {
|
|
775
785
|
this.map = read();
|
|
776
786
|
} else if (profile) {
|
|
787
|
+
/** @type {Map<EXPECTED_ANY, EXPECTED_ANY>} */
|
|
777
788
|
const map = new Map();
|
|
778
789
|
let key = read();
|
|
779
790
|
while (key !== null) {
|
|
@@ -799,6 +810,7 @@ class PackContentItems {
|
|
|
799
810
|
}
|
|
800
811
|
this.map = map;
|
|
801
812
|
} else {
|
|
813
|
+
/** @type {Map<EXPECTED_ANY, EXPECTED_ANY>} */
|
|
802
814
|
const map = new Map();
|
|
803
815
|
let key = read();
|
|
804
816
|
while (key !== null) {
|
|
@@ -816,7 +828,7 @@ makeSerializable(
|
|
|
816
828
|
"PackContentItems"
|
|
817
829
|
);
|
|
818
830
|
|
|
819
|
-
/** @typedef {(() => Promise<PackContentItems> | PackContentItems) & Partial<{ options: { size?: number }}>} LazyFunction */
|
|
831
|
+
/** @typedef {(() => Promise<PackContentItems> | PackContentItems) & Partial<{ options: { size?: number } }>} LazyFunction */
|
|
820
832
|
|
|
821
833
|
class PackContent {
|
|
822
834
|
/*
|
|
@@ -846,14 +858,19 @@ class PackContent {
|
|
|
846
858
|
* @param {string=} lazyName name of dataOrFn for logging
|
|
847
859
|
*/
|
|
848
860
|
constructor(items, usedItems, dataOrFn, logger, lazyName) {
|
|
861
|
+
/** @type {Items} */
|
|
849
862
|
this.items = items;
|
|
850
863
|
/** @type {LazyFunction | undefined} */
|
|
851
864
|
this.lazy = typeof dataOrFn === "function" ? dataOrFn : undefined;
|
|
852
865
|
/** @type {Content | undefined} */
|
|
853
866
|
this.content = typeof dataOrFn === "function" ? undefined : dataOrFn.map;
|
|
867
|
+
/** @type {boolean} */
|
|
854
868
|
this.outdated = false;
|
|
869
|
+
/** @type {Items} */
|
|
855
870
|
this.used = usedItems;
|
|
871
|
+
/** @type {Logger | undefined} */
|
|
856
872
|
this.logger = logger;
|
|
873
|
+
/** @type {string | undefined} */
|
|
857
874
|
this.lazyName = lazyName;
|
|
858
875
|
}
|
|
859
876
|
|
|
@@ -1091,10 +1108,10 @@ class PackFileCacheStrategy {
|
|
|
1091
1108
|
* @param {Logger} options.logger a logger
|
|
1092
1109
|
* @param {SnapshotOptions} options.snapshot options regarding snapshotting
|
|
1093
1110
|
* @param {number} options.maxAge max age of cache items
|
|
1094
|
-
* @param {boolean
|
|
1095
|
-
* @param {boolean
|
|
1096
|
-
* @param {false | "gzip" | "brotli"
|
|
1097
|
-
* @param {boolean
|
|
1111
|
+
* @param {boolean=} options.profile track and log detailed timing information for individual cache items
|
|
1112
|
+
* @param {boolean=} options.allowCollectingMemory allow to collect unused memory created during deserialization
|
|
1113
|
+
* @param {false | "gzip" | "brotli"=} options.compression compression used
|
|
1114
|
+
* @param {boolean=} options.readonly disable storing cache into filesystem
|
|
1098
1115
|
*/
|
|
1099
1116
|
constructor({
|
|
1100
1117
|
compiler,
|
|
@@ -1113,31 +1130,44 @@ class PackFileCacheStrategy {
|
|
|
1113
1130
|
/** @type {import("../serialization/Serializer")<PackContainer, null, EXPECTED_OBJECT>} */
|
|
1114
1131
|
this.fileSerializer = createFileSerializer(
|
|
1115
1132
|
fs,
|
|
1116
|
-
/** @type {
|
|
1133
|
+
/** @type {HashFunction} */
|
|
1117
1134
|
(compiler.options.output.hashFunction)
|
|
1118
1135
|
);
|
|
1136
|
+
/** @type {FileSystemInfo} */
|
|
1119
1137
|
this.fileSystemInfo = new FileSystemInfo(fs, {
|
|
1120
1138
|
managedPaths: snapshot.managedPaths,
|
|
1121
1139
|
immutablePaths: snapshot.immutablePaths,
|
|
1122
1140
|
logger: logger.getChildLogger("webpack.FileSystemInfo"),
|
|
1123
1141
|
hashFunction: compiler.options.output.hashFunction
|
|
1124
1142
|
});
|
|
1143
|
+
/** @type {Compiler} */
|
|
1125
1144
|
this.compiler = compiler;
|
|
1145
|
+
/** @type {string} */
|
|
1126
1146
|
this.context = context;
|
|
1147
|
+
/** @type {string} */
|
|
1127
1148
|
this.cacheLocation = cacheLocation;
|
|
1149
|
+
/** @type {string} */
|
|
1128
1150
|
this.version = version;
|
|
1151
|
+
/** @type {Logger} */
|
|
1129
1152
|
this.logger = logger;
|
|
1153
|
+
/** @type {number} */
|
|
1130
1154
|
this.maxAge = maxAge;
|
|
1155
|
+
/** @type {boolean | undefined} */
|
|
1131
1156
|
this.profile = profile;
|
|
1157
|
+
/** @type {boolean | undefined} */
|
|
1132
1158
|
this.readonly = readonly;
|
|
1159
|
+
/** @type {boolean | undefined} */
|
|
1133
1160
|
this.allowCollectingMemory = allowCollectingMemory;
|
|
1161
|
+
/** @type {false | "gzip" | "brotli" | undefined} */
|
|
1134
1162
|
this.compression = compression;
|
|
1163
|
+
/** @type {string} */
|
|
1135
1164
|
this._extension =
|
|
1136
1165
|
compression === "brotli"
|
|
1137
1166
|
? ".pack.br"
|
|
1138
1167
|
: compression === "gzip"
|
|
1139
1168
|
? ".pack.gz"
|
|
1140
1169
|
: ".pack";
|
|
1170
|
+
/** @type {SnapshotOptions} */
|
|
1141
1171
|
this.snapshot = snapshot;
|
|
1142
1172
|
/** @type {BuildDependencies} */
|
|
1143
1173
|
this.buildDependencies = new Set();
|
|
@@ -1151,6 +1181,7 @@ class PackFileCacheStrategy {
|
|
|
1151
1181
|
this.buildSnapshot = undefined;
|
|
1152
1182
|
/** @type {Promise<Pack> | undefined} */
|
|
1153
1183
|
this.packPromise = this._openPack();
|
|
1184
|
+
/** @type {Promise<void>} */
|
|
1154
1185
|
this.storePromise = Promise.resolve();
|
|
1155
1186
|
}
|
|
1156
1187
|
|
|
@@ -1382,7 +1413,9 @@ class PackFileCacheStrategy {
|
|
|
1382
1413
|
if (!pack.invalid) return;
|
|
1383
1414
|
this.packPromise = undefined;
|
|
1384
1415
|
this.logger.log("Storing pack...");
|
|
1416
|
+
/** @type {undefined | Promise<void>} */
|
|
1385
1417
|
let promise;
|
|
1418
|
+
/** @type {Set<string>} */
|
|
1386
1419
|
const newBuildDependencies = new Set();
|
|
1387
1420
|
for (const dep of this.newBuildDependencies) {
|
|
1388
1421
|
if (!this.buildDependencies.has(dep)) {
|
|
@@ -10,6 +10,7 @@ const createHash = require("../util/createHash");
|
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("../util/Hash")} Hash */
|
|
12
12
|
/** @typedef {typeof import("../util/Hash")} HashConstructor */
|
|
13
|
+
/** @typedef {import("../util/Hash").HashFunction} HashFunction */
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* @typedef {object} HashableObject
|
|
@@ -19,11 +20,14 @@ const createHash = require("../util/createHash");
|
|
|
19
20
|
class LazyHashedEtag {
|
|
20
21
|
/**
|
|
21
22
|
* @param {HashableObject} obj object with updateHash method
|
|
22
|
-
* @param {
|
|
23
|
+
* @param {HashFunction} hashFunction the hash function to use
|
|
23
24
|
*/
|
|
24
25
|
constructor(obj, hashFunction = DEFAULTS.HASH_FUNCTION) {
|
|
26
|
+
/** @type {HashableObject} */
|
|
25
27
|
this._obj = obj;
|
|
28
|
+
/** @type {undefined | string} */
|
|
26
29
|
this._hash = undefined;
|
|
30
|
+
/** @type {HashFunction} */
|
|
27
31
|
this._hashFunction = hashFunction;
|
|
28
32
|
}
|
|
29
33
|
|
|
@@ -40,23 +44,27 @@ class LazyHashedEtag {
|
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
/** @
|
|
47
|
+
/** @typedef {WeakMap<HashableObject, LazyHashedEtag>} InnerCache */
|
|
48
|
+
|
|
49
|
+
/** @type {Map<HashFunction, InnerCache>} */
|
|
44
50
|
const mapStrings = new Map();
|
|
45
51
|
|
|
46
|
-
/** @type {WeakMap<HashConstructor,
|
|
52
|
+
/** @type {WeakMap<HashConstructor, InnerCache>} */
|
|
47
53
|
const mapObjects = new WeakMap();
|
|
48
54
|
|
|
49
55
|
/**
|
|
50
56
|
* @param {HashableObject} obj object with updateHash method
|
|
51
|
-
* @param {
|
|
57
|
+
* @param {HashFunction=} hashFunction the hash function to use
|
|
52
58
|
* @returns {LazyHashedEtag} etag
|
|
53
59
|
*/
|
|
54
60
|
const getter = (obj, hashFunction = DEFAULTS.HASH_FUNCTION) => {
|
|
61
|
+
/** @type {undefined | InnerCache} */
|
|
55
62
|
let innerMap;
|
|
56
63
|
if (typeof hashFunction === "string") {
|
|
57
64
|
innerMap = mapStrings.get(hashFunction);
|
|
58
65
|
if (innerMap === undefined) {
|
|
59
66
|
const newHash = new LazyHashedEtag(obj, hashFunction);
|
|
67
|
+
/** @type {InnerCache} */
|
|
60
68
|
innerMap = new WeakMap();
|
|
61
69
|
innerMap.set(obj, newHash);
|
|
62
70
|
mapStrings.set(hashFunction, innerMap);
|
|
@@ -66,6 +74,7 @@ const getter = (obj, hashFunction = DEFAULTS.HASH_FUNCTION) => {
|
|
|
66
74
|
innerMap = mapObjects.get(hashFunction);
|
|
67
75
|
if (innerMap === undefined) {
|
|
68
76
|
const newHash = new LazyHashedEtag(obj, hashFunction);
|
|
77
|
+
/** @type {InnerCache} */
|
|
69
78
|
innerMap = new WeakMap();
|
|
70
79
|
innerMap.set(obj, newHash);
|
|
71
80
|
mapObjects.set(hashFunction, innerMap);
|
package/lib/cache/mergeEtags.js
CHANGED
|
@@ -22,13 +22,15 @@ class MergedEtag {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/** @type {WeakMap<Etag, WeakMap<Etag, MergedEtag>>} */
|
|
25
26
|
const dualObjectMap = new WeakMap();
|
|
27
|
+
/** @type {WeakMap<Etag, WeakMap<Etag, MergedEtag>>} */
|
|
26
28
|
const objectStringMap = new WeakMap();
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
31
|
* @param {Etag} a first
|
|
30
32
|
* @param {Etag} b second
|
|
31
|
-
* @returns {
|
|
33
|
+
* @returns {string | MergedEtag} result
|
|
32
34
|
*/
|
|
33
35
|
const mergeEtags = (a, b) => {
|
|
34
36
|
if (typeof a === "string") {
|
package/lib/cli.js
CHANGED
|
@@ -427,6 +427,7 @@ const getArguments = (schema = webpackSchema) => {
|
|
|
427
427
|
return flags;
|
|
428
428
|
};
|
|
429
429
|
|
|
430
|
+
/** @type {WeakMap<EXPECTED_OBJECT, number>} */
|
|
430
431
|
const cliAddedItems = new WeakMap();
|
|
431
432
|
|
|
432
433
|
/** @typedef {string | number} Property */
|
|
@@ -621,7 +622,7 @@ const parseValueForArgumentConfig = (argConfig, value) => {
|
|
|
621
622
|
break;
|
|
622
623
|
case "number":
|
|
623
624
|
if (typeof value === "number") return value;
|
|
624
|
-
if (typeof value === "string" && /^[+-]?\d*(\.\d*)
|
|
625
|
+
if (typeof value === "string" && /^[+-]?\d*(\.\d*)e\d+$/i) {
|
|
625
626
|
const n = Number(value);
|
|
626
627
|
if (!Number.isNaN(n)) return n;
|
|
627
628
|
}
|
|
@@ -685,6 +686,7 @@ const processArguments = (args, config, values) => {
|
|
|
685
686
|
* @param {number | undefined} i index
|
|
686
687
|
*/
|
|
687
688
|
const processValue = (value, i) => {
|
|
689
|
+
/** @type {Problem[]} */
|
|
688
690
|
const currentProblems = [];
|
|
689
691
|
for (const argConfig of arg.configs) {
|
|
690
692
|
const problem = processArgumentConfig(argConfig, config, value, i);
|