webpack 5.101.3 → 5.102.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/README.md +21 -26
- package/lib/APIPlugin.js +30 -36
- package/lib/AsyncDependenciesBlock.js +1 -4
- package/lib/BannerPlugin.js +0 -1
- package/lib/Cache.js +7 -6
- package/lib/CacheFacade.js +0 -1
- package/lib/Chunk.js +49 -31
- package/lib/ChunkGraph.js +35 -25
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +2 -1
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +204 -185
- package/lib/Compiler.js +36 -35
- package/lib/ConcatenationScope.js +6 -1
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +6 -5
- package/lib/ContextExclusionPlugin.js +0 -1
- package/lib/ContextModule.js +22 -20
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +4 -8
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +1 -3
- package/lib/DllModule.js +1 -7
- package/lib/DllReferencePlugin.js +2 -4
- package/lib/DynamicEntryPlugin.js +0 -2
- package/lib/EntryOptionPlugin.js +0 -5
- package/lib/EnvironmentNotSupportAsyncWarning.js +0 -3
- package/lib/EvalDevToolModulePlugin.js +4 -3
- package/lib/EvalSourceMapDevToolPlugin.js +3 -4
- package/lib/ExportsInfo.js +50 -49
- package/lib/ExternalModule.js +84 -52
- package/lib/ExternalModuleFactoryPlugin.js +27 -7
- package/lib/ExternalsPlugin.js +24 -17
- package/lib/FileSystemInfo.js +96 -78
- package/lib/FlagDependencyUsagePlugin.js +3 -4
- package/lib/Generator.js +2 -13
- package/lib/GraphHelpers.js +0 -3
- package/lib/HookWebpackError.js +0 -2
- package/lib/HotModuleReplacementPlugin.js +22 -24
- package/lib/HotUpdateChunk.js +0 -3
- package/lib/IgnorePlugin.js +5 -2
- package/lib/InitFragment.js +41 -29
- package/lib/InvalidDependenciesModuleWarning.js +0 -1
- package/lib/LibManifestPlugin.js +4 -6
- package/lib/LoaderOptionsPlugin.js +1 -10
- package/lib/MainTemplate.js +8 -19
- package/lib/Module.js +32 -20
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleFilenameHelpers.js +41 -24
- package/lib/ModuleGraph.js +30 -16
- package/lib/ModuleInfoHeaderPlugin.js +0 -1
- package/lib/ModuleTemplate.js +0 -2
- package/lib/ModuleTypeConstants.js +11 -1
- package/lib/MultiCompiler.js +23 -15
- package/lib/MultiWatching.js +6 -10
- package/lib/NodeStuffPlugin.js +2 -10
- package/lib/NormalModule.js +145 -88
- package/lib/NormalModuleFactory.js +59 -40
- package/lib/OptionsApply.js +1 -1
- package/lib/Parser.js +1 -1
- package/lib/ProgressPlugin.js +6 -10
- package/lib/ProvidePlugin.js +5 -7
- package/lib/RawModule.js +1 -6
- package/lib/RecordIdsPlugin.js +10 -6
- package/lib/ResolverFactory.js +0 -2
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimeModule.js +1 -3
- package/lib/RuntimePlugin.js +26 -22
- package/lib/RuntimeTemplate.js +12 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +6 -11
- package/lib/Stats.js +0 -1
- package/lib/Template.js +6 -11
- package/lib/TemplatedPathPlugin.js +2 -1
- package/lib/WatchIgnorePlugin.js +2 -3
- package/lib/Watching.js +15 -15
- package/lib/WebpackIsIncludedPlugin.js +0 -2
- package/lib/WebpackOptionsApply.js +74 -107
- package/lib/asset/AssetBytesGenerator.js +166 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +20 -34
- package/lib/asset/AssetModulesPlugin.js +34 -16
- package/lib/asset/AssetParser.js +7 -3
- package/lib/asset/AssetSourceGenerator.js +1 -1
- package/lib/asset/RawDataUrlModule.js +3 -2
- package/lib/async-modules/AsyncModuleHelpers.js +6 -4
- package/lib/buildChunkGraph.js +0 -1
- package/lib/cache/MemoryCachePlugin.js +0 -2
- package/lib/cache/MemoryWithGcCachePlugin.js +0 -2
- package/lib/cache/PackFileCacheStrategy.js +14 -1
- package/lib/cache/ResolverCachePlugin.js +9 -15
- package/lib/config/defaults.js +155 -21
- package/lib/config/normalization.js +18 -3
- package/lib/container/ContainerEntryDependency.js +0 -1
- package/lib/container/ContainerEntryModule.js +3 -7
- package/lib/container/ContainerPlugin.js +1 -2
- package/lib/container/ContainerReferencePlugin.js +0 -1
- package/lib/container/FallbackDependency.js +2 -1
- package/lib/container/FallbackModule.js +6 -7
- package/lib/container/ModuleFederationPlugin.js +0 -1
- package/lib/container/RemoteModule.js +8 -8
- package/lib/container/RemoteRuntimeModule.js +2 -2
- package/lib/css/CssGenerator.js +3 -6
- package/lib/css/CssLoadingRuntimeModule.js +6 -9
- package/lib/css/CssModulesPlugin.js +11 -13
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +1 -1
- package/lib/debug/ProfilingPlugin.js +35 -8
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
- package/lib/dependencies/AMDPlugin.js +2 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/CachedConstDependency.js +0 -4
- package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
- package/lib/dependencies/CommonJsExportsDependency.js +2 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
- package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +9 -4
- package/lib/dependencies/ContextDependencyHelpers.js +2 -2
- package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
- package/lib/dependencies/ContextElementDependency.js +22 -11
- package/lib/dependencies/CssIcssImportDependency.js +0 -2
- package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
- package/lib/dependencies/CssImportDependency.js +0 -8
- package/lib/dependencies/CssLocalIdentifierDependency.js +3 -4
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssUrlDependency.js +0 -6
- package/lib/dependencies/ExportsInfoDependency.js +7 -9
- package/lib/dependencies/ExternalModuleDependency.js +0 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
- package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
- package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
- package/lib/dependencies/HarmonyImportDependency.js +30 -14
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
- package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
- package/lib/dependencies/ImportDependency.js +18 -6
- package/lib/dependencies/ImportEagerDependency.js +2 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
- package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
- package/lib/dependencies/ImportMetaPlugin.js +2 -1
- package/lib/dependencies/ImportParserPlugin.js +288 -45
- package/lib/dependencies/ImportWeakDependency.js +2 -3
- package/lib/dependencies/JsonExportsDependency.js +0 -1
- package/lib/dependencies/LoaderDependency.js +0 -3
- package/lib/dependencies/LoaderImportDependency.js +0 -3
- package/lib/dependencies/LoaderPlugin.js +11 -5
- package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
- package/lib/dependencies/ModuleDependency.js +3 -9
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/ProvidedDependency.js +6 -8
- package/lib/dependencies/PureExpressionDependency.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/RequireIncludeDependency.js +2 -2
- package/lib/dependencies/RequireResolveDependency.js +2 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
- package/lib/dependencies/StaticExportsDependency.js +3 -5
- package/lib/dependencies/URLDependency.js +2 -7
- package/lib/dependencies/URLPlugin.js +1 -2
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
- package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
- package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
- package/lib/dependencies/WorkerDependency.js +2 -3
- package/lib/dependencies/WorkerPlugin.js +3 -9
- package/lib/dependencies/processExportInfo.js +2 -3
- package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
- package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
- package/lib/hmr/LazyCompilationPlugin.js +6 -4
- package/lib/hmr/lazyCompilationBackend.js +13 -10
- package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
- package/lib/ids/NamedChunkIdsPlugin.js +1 -6
- package/lib/ids/NamedModuleIdsPlugin.js +1 -5
- package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
- package/lib/ids/SyncModuleIdsPlugin.js +4 -3
- package/lib/index.js +8 -7
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
- package/lib/javascript/BasicEvaluatedExpression.js +13 -6
- package/lib/javascript/ChunkFormatHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
- package/lib/javascript/JavascriptGenerator.js +2 -3
- package/lib/javascript/JavascriptModulesPlugin.js +44 -21
- package/lib/javascript/JavascriptParser.js +119 -54
- package/lib/javascript/JavascriptParserHelpers.js +2 -2
- package/lib/javascript/StartupHelpers.js +2 -4
- package/lib/json/JsonData.js +1 -1
- package/lib/json/JsonGenerator.js +4 -5
- package/lib/json/JsonModulesPlugin.js +0 -3
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +0 -1
- package/lib/library/AssignLibraryPlugin.js +23 -12
- package/lib/library/EnableLibraryPlugin.js +7 -11
- package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
- package/lib/library/JsonpLibraryPlugin.js +5 -2
- package/lib/library/ModuleLibraryPlugin.js +88 -43
- package/lib/library/SystemLibraryPlugin.js +0 -1
- package/lib/library/UmdLibraryPlugin.js +12 -18
- package/lib/logging/Logger.js +12 -10
- package/lib/logging/createConsoleLogger.js +15 -14
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeWatchFileSystem.js +4 -4
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
- package/lib/node/nodeConsole.js +2 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
- package/lib/optimize/ConcatenatedModule.js +142 -100
- package/lib/optimize/InnerGraph.js +17 -11
- package/lib/optimize/InnerGraphPlugin.js +0 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
- package/lib/optimize/RuntimeChunkPlugin.js +0 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
- package/lib/optimize/SplitChunksPlugin.js +46 -40
- package/lib/performance/SizeLimitsPlugin.js +2 -1
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
- package/lib/rules/BasicMatcherRulePlugin.js +0 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
- package/lib/rules/RuleSetCompiler.js +8 -6
- package/lib/runtime/BaseUriRuntimeModule.js +2 -2
- package/lib/runtime/CompatRuntimeModule.js +0 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
- package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
- package/lib/runtime/PublicPathRuntimeModule.js +2 -2
- package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
- package/lib/runtime/SystemContextRuntimeModule.js +0 -2
- package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
- package/lib/schemes/DataUriPlugin.js +2 -28
- package/lib/schemes/FileUriPlugin.js +5 -2
- package/lib/schemes/HttpUriPlugin.js +4 -2
- package/lib/schemes/VirtualUrlPlugin.js +11 -11
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +30 -19
- package/lib/serialization/SerializerMiddleware.js +1 -3
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +3 -5
- package/lib/sharing/ConsumeSharedPlugin.js +2 -4
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
- package/lib/sharing/ProvideSharedModule.js +3 -7
- package/lib/sharing/SharePlugin.js +0 -2
- package/lib/sharing/ShareRuntimeModule.js +4 -1
- package/lib/sharing/resolveMatchedConfigs.js +14 -6
- package/lib/sharing/utils.js +0 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +178 -94
- package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
- package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
- package/lib/stats/StatsFactory.js +14 -11
- package/lib/url/URLParserPlugin.js +2 -4
- package/lib/util/ArrayHelpers.js +4 -4
- package/lib/util/AsyncQueue.js +1 -0
- package/lib/util/LazySet.js +2 -2
- package/lib/util/StackedCacheMap.js +0 -2
- package/lib/util/TupleSet.js +9 -4
- package/lib/util/URLAbsoluteSpecifier.js +0 -1
- package/lib/util/WeakTupleMap.js +1 -1
- package/lib/util/chainedImports.js +3 -1
- package/lib/util/cleverMerge.js +15 -18
- package/lib/util/comparators.js +2 -4
- package/lib/util/compileBooleanMatcher.js +11 -9
- package/lib/util/concatenate.js +1 -2
- package/lib/util/create-schema-validation.js +0 -1
- package/lib/util/dataURL.js +39 -0
- package/lib/util/deprecation.js +29 -31
- package/lib/util/deterministicGrouping.js +34 -30
- package/lib/util/extractSourceMap.js +319 -0
- package/lib/util/findGraphRoots.js +15 -5
- package/lib/util/fs.js +29 -8
- package/lib/util/semver.js +9 -8
- package/lib/util/smartGrouping.js +41 -26
- package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
- package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
- package/lib/wasm-sync/WebAssemblyParser.js +1 -4
- package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/web/JsonpTemplatePlugin.js +0 -1
- package/lib/webpack.js +21 -8
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +12 -12
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +77 -93
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +4 -0
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +5 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1129 -530
- package/SECURITY.md +0 -9
|
@@ -21,7 +21,6 @@ const formatLocation = require("../formatLocation");
|
|
|
21
21
|
/** @typedef {import("estree").ModuleDeclaration} ModuleDeclaration */
|
|
22
22
|
/** @typedef {import("estree").Statement} Statement */
|
|
23
23
|
/** @typedef {import("../Compiler")} Compiler */
|
|
24
|
-
/** @typedef {import("../Dependency")} Dependency */
|
|
25
24
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
|
26
25
|
/** @typedef {import("../Module")} Module */
|
|
27
26
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
@@ -37,11 +36,7 @@ const formatLocation = require("../formatLocation");
|
|
|
37
36
|
* @property {boolean} checked if the export is conditional
|
|
38
37
|
*/
|
|
39
38
|
|
|
40
|
-
/**
|
|
41
|
-
* @typedef {object} ReexportInfo
|
|
42
|
-
* @property {Map<string, ExportInModule[]>} static
|
|
43
|
-
* @property {Map<Module, Set<string>>} dynamic
|
|
44
|
-
*/
|
|
39
|
+
/** @typedef {string | boolean | string[] | undefined} SideEffectsFlagValue */
|
|
45
40
|
|
|
46
41
|
/** @typedef {Map<string, RegExp>} CacheItem */
|
|
47
42
|
|
|
@@ -105,9 +100,7 @@ class SideEffectsFlagPlugin {
|
|
|
105
100
|
}
|
|
106
101
|
const hasSideEffects = SideEffectsFlagPlugin.moduleHasSideEffects(
|
|
107
102
|
resolveData.relativePath,
|
|
108
|
-
/** @type {
|
|
109
|
-
sideEffects
|
|
110
|
-
),
|
|
103
|
+
/** @type {SideEffectsFlagValue} */ (sideEffects),
|
|
111
104
|
/** @type {CacheItem} */ (cache)
|
|
112
105
|
);
|
|
113
106
|
module.factoryMeta.sideEffectFree = !hasSideEffects;
|
|
@@ -397,7 +390,7 @@ class SideEffectsFlagPlugin {
|
|
|
397
390
|
|
|
398
391
|
/**
|
|
399
392
|
* @param {string} moduleName the module name
|
|
400
|
-
* @param {
|
|
393
|
+
* @param {SideEffectsFlagValue} flagValue the flag value
|
|
401
394
|
* @param {Map<string, RegExp>} cache cache for glob to regexp
|
|
402
395
|
* @returns {boolean | undefined} true, when the module has side effects, undefined or false when not
|
|
403
396
|
*/
|
|
@@ -21,12 +21,11 @@ const { makePathsRelative } = require("../util/identifier");
|
|
|
21
21
|
const memoize = require("../util/memoize");
|
|
22
22
|
const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
23
23
|
|
|
24
|
-
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
|
|
25
24
|
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksCacheGroup} OptimizationSplitChunksCacheGroup */
|
|
26
25
|
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksGetCacheGroups} OptimizationSplitChunksGetCacheGroups */
|
|
27
26
|
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksOptions} OptimizationSplitChunksOptions */
|
|
28
27
|
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksSizes} OptimizationSplitChunksSizes */
|
|
29
|
-
/** @typedef {import("
|
|
28
|
+
/** @typedef {import("../config/defaults").OutputNormalizedWithDefaults} OutputOptions */
|
|
30
29
|
/** @typedef {import("../Chunk").ChunkName} ChunkName */
|
|
31
30
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
32
31
|
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
|
@@ -37,10 +36,8 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
|
37
36
|
/** @typedef {import("../util/deterministicGrouping").GroupedItems<Module>} DeterministicGroupingGroupedItemsForModule */
|
|
38
37
|
/** @typedef {import("../util/deterministicGrouping").Options<Module>} DeterministicGroupingOptionsForModule */
|
|
39
38
|
|
|
40
|
-
/** @typedef {Record<string, number>} SplitChunksSizes */
|
|
41
|
-
|
|
42
39
|
/**
|
|
43
|
-
* @callback
|
|
40
|
+
* @callback ChunkFilterFn
|
|
44
41
|
* @param {Chunk} chunk
|
|
45
42
|
* @returns {boolean | undefined}
|
|
46
43
|
*/
|
|
@@ -52,12 +49,17 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
|
52
49
|
* @returns {number}
|
|
53
50
|
*/
|
|
54
51
|
|
|
52
|
+
/** @typedef {string} SourceType */
|
|
53
|
+
/** @typedef {SourceType[]} SourceTypes */
|
|
54
|
+
/** @typedef {SourceType[]} DefaultSizeTypes */
|
|
55
|
+
/** @typedef {Record<SourceType, number>} SplitChunksSizes */
|
|
56
|
+
|
|
55
57
|
/**
|
|
56
58
|
* @typedef {object} CacheGroupSource
|
|
57
59
|
* @property {string} key
|
|
58
60
|
* @property {number=} priority
|
|
59
|
-
* @property {
|
|
60
|
-
* @property {
|
|
61
|
+
* @property {GetNameFn=} getName
|
|
62
|
+
* @property {ChunkFilterFn=} chunksFilter
|
|
61
63
|
* @property {boolean=} enforce
|
|
62
64
|
* @property {SplitChunksSizes} minSize
|
|
63
65
|
* @property {SplitChunksSizes} minSizeReduction
|
|
@@ -79,8 +81,8 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
|
79
81
|
* @typedef {object} CacheGroup
|
|
80
82
|
* @property {string} key
|
|
81
83
|
* @property {number} priority
|
|
82
|
-
* @property {
|
|
83
|
-
* @property {
|
|
84
|
+
* @property {GetNameFn=} getName
|
|
85
|
+
* @property {ChunkFilterFn} chunksFilter
|
|
84
86
|
* @property {SplitChunksSizes} minSize
|
|
85
87
|
* @property {SplitChunksSizes} minSizeReduction
|
|
86
88
|
* @property {SplitChunksSizes} minRemainingSize
|
|
@@ -103,7 +105,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
|
103
105
|
|
|
104
106
|
/**
|
|
105
107
|
* @typedef {object} FallbackCacheGroup
|
|
106
|
-
* @property {
|
|
108
|
+
* @property {ChunkFilterFn} chunksFilter
|
|
107
109
|
* @property {SplitChunksSizes} minSize
|
|
108
110
|
* @property {SplitChunksSizes} maxAsyncSize
|
|
109
111
|
* @property {SplitChunksSizes} maxInitialSize
|
|
@@ -124,17 +126,17 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
|
124
126
|
*/
|
|
125
127
|
|
|
126
128
|
/**
|
|
127
|
-
* @callback
|
|
129
|
+
* @callback GetNameFn
|
|
128
130
|
* @param {Module} module
|
|
129
131
|
* @param {Chunk[]} chunks
|
|
130
132
|
* @param {string} key
|
|
131
|
-
* @returns {string
|
|
133
|
+
* @returns {string | undefined}
|
|
132
134
|
*/
|
|
133
135
|
|
|
134
136
|
/**
|
|
135
137
|
* @typedef {object} SplitChunksOptions
|
|
136
|
-
* @property {
|
|
137
|
-
* @property {
|
|
138
|
+
* @property {ChunkFilterFn} chunksFilter
|
|
139
|
+
* @property {DefaultSizeTypes} defaultSizeTypes
|
|
138
140
|
* @property {SplitChunksSizes} minSize
|
|
139
141
|
* @property {SplitChunksSizes} minSizeReduction
|
|
140
142
|
* @property {SplitChunksSizes} minRemainingSize
|
|
@@ -148,7 +150,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
|
148
150
|
* @property {TemplatePath=} filename
|
|
149
151
|
* @property {string} automaticNameDelimiter
|
|
150
152
|
* @property {GetCacheGroups} getCacheGroups
|
|
151
|
-
* @property {
|
|
153
|
+
* @property {GetNameFn} getName
|
|
152
154
|
* @property {boolean} usedExports
|
|
153
155
|
* @property {FallbackCacheGroup} fallbackCacheGroup
|
|
154
156
|
*/
|
|
@@ -159,13 +161,13 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
|
159
161
|
* @property {CacheGroup} cacheGroup
|
|
160
162
|
* @property {number} cacheGroupIndex
|
|
161
163
|
* @property {string=} name
|
|
162
|
-
* @property {Record<
|
|
164
|
+
* @property {Record<SourceType, number>} sizes
|
|
163
165
|
* @property {Set<Chunk>} chunks
|
|
164
166
|
* @property {Set<Chunk>} reusableChunks
|
|
165
167
|
* @property {Set<bigint | Chunk>} chunksKeys
|
|
166
168
|
*/
|
|
167
169
|
|
|
168
|
-
/** @type {
|
|
170
|
+
/** @type {GetNameFn} */
|
|
169
171
|
const defaultGetName = () => undefined;
|
|
170
172
|
|
|
171
173
|
const deterministicGroupingForModules =
|
|
@@ -184,7 +186,7 @@ const hashFilename = (name, outputOptions) => {
|
|
|
184
186
|
const digest =
|
|
185
187
|
/** @type {string} */
|
|
186
188
|
(
|
|
187
|
-
createHash(
|
|
189
|
+
createHash(outputOptions.hashFunction)
|
|
188
190
|
.update(name)
|
|
189
191
|
.digest(outputOptions.hashDigest)
|
|
190
192
|
);
|
|
@@ -286,7 +288,7 @@ const ALL_CHUNK_FILTER = (_chunk) => true;
|
|
|
286
288
|
|
|
287
289
|
/**
|
|
288
290
|
* @param {OptimizationSplitChunksSizes | undefined} value the sizes
|
|
289
|
-
* @param {
|
|
291
|
+
* @param {DefaultSizeTypes} defaultSizeTypes the default size types
|
|
290
292
|
* @returns {SplitChunksSizes} normalized representation
|
|
291
293
|
*/
|
|
292
294
|
const normalizeSizes = (value, defaultSizeTypes) => {
|
|
@@ -379,7 +381,7 @@ const checkMinSizeReduction = (sizes, minSizeReduction, chunkCount) => {
|
|
|
379
381
|
/**
|
|
380
382
|
* @param {SplitChunksSizes} sizes the sizes
|
|
381
383
|
* @param {SplitChunksSizes} minSize the min sizes
|
|
382
|
-
* @returns {undefined |
|
|
384
|
+
* @returns {undefined | SourceTypes} list of size types that are below min size
|
|
383
385
|
*/
|
|
384
386
|
const getViolatingMinSizes = (sizes, minSize) => {
|
|
385
387
|
let list;
|
|
@@ -408,20 +410,20 @@ const totalSize = (sizes) => {
|
|
|
408
410
|
|
|
409
411
|
/**
|
|
410
412
|
* @param {OptimizationSplitChunksCacheGroup["name"]} name the chunk name
|
|
411
|
-
* @returns {
|
|
413
|
+
* @returns {GetNameFn | undefined} a function to get the name of the chunk
|
|
412
414
|
*/
|
|
413
415
|
const normalizeName = (name) => {
|
|
414
416
|
if (typeof name === "string") {
|
|
415
417
|
return () => name;
|
|
416
418
|
}
|
|
417
419
|
if (typeof name === "function") {
|
|
418
|
-
return /** @type {
|
|
420
|
+
return /** @type {GetNameFn} */ (name);
|
|
419
421
|
}
|
|
420
422
|
};
|
|
421
423
|
|
|
422
424
|
/**
|
|
423
425
|
* @param {OptimizationSplitChunksCacheGroup["chunks"]} chunks the chunk filter option
|
|
424
|
-
* @returns {
|
|
426
|
+
* @returns {ChunkFilterFn | undefined} the chunk filter function
|
|
425
427
|
*/
|
|
426
428
|
const normalizeChunksFilter = (chunks) => {
|
|
427
429
|
if (chunks === "initial") {
|
|
@@ -443,7 +445,7 @@ const normalizeChunksFilter = (chunks) => {
|
|
|
443
445
|
|
|
444
446
|
/**
|
|
445
447
|
* @param {undefined | GetCacheGroups | Record<string, false | string | RegExp | OptimizationSplitChunksGetCacheGroups | OptimizationSplitChunksCacheGroup>} cacheGroups the cache group options
|
|
446
|
-
* @param {
|
|
448
|
+
* @param {DefaultSizeTypes} defaultSizeTypes the default size types
|
|
447
449
|
* @returns {GetCacheGroups} a function to get the cache groups
|
|
448
450
|
*/
|
|
449
451
|
const normalizeCacheGroups = (cacheGroups, defaultSizeTypes) => {
|
|
@@ -586,7 +588,7 @@ const checkModuleLayer = (test, module) => {
|
|
|
586
588
|
/**
|
|
587
589
|
* @param {OptimizationSplitChunksCacheGroup} options the group options
|
|
588
590
|
* @param {string} key key of cache group
|
|
589
|
-
* @param {
|
|
591
|
+
* @param {DefaultSizeTypes} defaultSizeTypes the default size types
|
|
590
592
|
* @returns {CacheGroupSource} the normalized cached group
|
|
591
593
|
*/
|
|
592
594
|
const createCacheGroupSource = (options, key, defaultSizeTypes) => {
|
|
@@ -653,7 +655,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
653
655
|
/** @type {SplitChunksOptions} */
|
|
654
656
|
this.options = {
|
|
655
657
|
chunksFilter:
|
|
656
|
-
/** @type {
|
|
658
|
+
/** @type {ChunkFilterFn} */
|
|
657
659
|
(normalizeChunksFilter(options.chunks || "all")),
|
|
658
660
|
defaultSizeTypes,
|
|
659
661
|
minSize,
|
|
@@ -684,13 +686,13 @@ module.exports = class SplitChunksPlugin {
|
|
|
684
686
|
defaultSizeTypes
|
|
685
687
|
),
|
|
686
688
|
getName: options.name
|
|
687
|
-
? /** @type {
|
|
689
|
+
? /** @type {GetNameFn} */ (normalizeName(options.name))
|
|
688
690
|
: defaultGetName,
|
|
689
691
|
automaticNameDelimiter: options.automaticNameDelimiter || "-",
|
|
690
692
|
usedExports: options.usedExports || false,
|
|
691
693
|
fallbackCacheGroup: {
|
|
692
694
|
chunksFilter:
|
|
693
|
-
/** @type {
|
|
695
|
+
/** @type {ChunkFilterFn} */
|
|
694
696
|
(
|
|
695
697
|
normalizeChunksFilter(
|
|
696
698
|
fallbackCacheGroup.chunks || options.chunks || "all"
|
|
@@ -947,15 +949,17 @@ module.exports = class SplitChunksPlugin {
|
|
|
947
949
|
return { chunkSetsInGraph, singleChunkSets };
|
|
948
950
|
});
|
|
949
951
|
|
|
952
|
+
/** @typedef {Map<number, Set<Chunk>[]>} ChunkSetsByCount */
|
|
953
|
+
|
|
950
954
|
// group these set of chunks by count
|
|
951
955
|
// to allow to check less sets via isSubset
|
|
952
956
|
// (only smaller sets can be subset)
|
|
953
957
|
/**
|
|
954
958
|
* @param {IterableIterator<Set<Chunk>>} chunkSets set of sets of chunks
|
|
955
|
-
* @returns {
|
|
959
|
+
* @returns {ChunkSetsByCount} map of sets of chunks by count
|
|
956
960
|
*/
|
|
957
961
|
const groupChunkSetsByCount = (chunkSets) => {
|
|
958
|
-
/** @type {
|
|
962
|
+
/** @type {ChunkSetsByCount} */
|
|
959
963
|
const chunkSetsByCount = new Map();
|
|
960
964
|
for (const chunksSet of chunkSets) {
|
|
961
965
|
const count = chunksSet.size;
|
|
@@ -979,19 +983,21 @@ module.exports = class SplitChunksPlugin {
|
|
|
979
983
|
)
|
|
980
984
|
);
|
|
981
985
|
|
|
986
|
+
/** @typedef {(Set<Chunk> | Chunk)[]} Combinations */
|
|
987
|
+
|
|
982
988
|
// Create a list of possible combinations
|
|
983
989
|
/**
|
|
984
990
|
* @param {Map<bigint | Chunk, Set<Chunk>>} chunkSets chunk sets
|
|
985
991
|
* @param {Set<Chunk>} singleChunkSets single chunks sets
|
|
986
992
|
* @param {Map<number, Set<Chunk>[]>} chunkSetsByCount chunk sets by count
|
|
987
|
-
* @returns {(key: bigint | Chunk) =>
|
|
993
|
+
* @returns {(key: bigint | Chunk) => Combinations} combinations
|
|
988
994
|
*/
|
|
989
995
|
const createGetCombinations = (
|
|
990
996
|
chunkSets,
|
|
991
997
|
singleChunkSets,
|
|
992
998
|
chunkSetsByCount
|
|
993
999
|
) => {
|
|
994
|
-
/** @type {Map<bigint | Chunk,
|
|
1000
|
+
/** @type {Map<bigint | Chunk, Combinations>} */
|
|
995
1001
|
const combinationsCache = new Map();
|
|
996
1002
|
|
|
997
1003
|
return (key) => {
|
|
@@ -1005,7 +1011,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
1005
1011
|
const chunksSet =
|
|
1006
1012
|
/** @type {Set<Chunk>} */
|
|
1007
1013
|
(chunkSets.get(key));
|
|
1008
|
-
/** @type {
|
|
1014
|
+
/** @type {Combinations} */
|
|
1009
1015
|
const array = [chunksSet];
|
|
1010
1016
|
for (const [count, setArray] of chunkSetsByCount) {
|
|
1011
1017
|
// "equal" is not needed because they would have been merge in the first step
|
|
@@ -1038,7 +1044,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
1038
1044
|
|
|
1039
1045
|
/**
|
|
1040
1046
|
* @param {bigint | Chunk} key key
|
|
1041
|
-
* @returns {
|
|
1047
|
+
* @returns {Combinations} combinations by key
|
|
1042
1048
|
*/
|
|
1043
1049
|
const getCombinations = (key) => getCombinationsFactory()(key);
|
|
1044
1050
|
|
|
@@ -1053,7 +1059,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
1053
1059
|
});
|
|
1054
1060
|
/**
|
|
1055
1061
|
* @param {bigint | Chunk} key key
|
|
1056
|
-
* @returns {
|
|
1062
|
+
* @returns {Combinations} exports combinations by key
|
|
1057
1063
|
*/
|
|
1058
1064
|
const getExportsCombinations = (key) =>
|
|
1059
1065
|
getExportsCombinationsFactory()(key);
|
|
@@ -1064,14 +1070,14 @@ module.exports = class SplitChunksPlugin {
|
|
|
1064
1070
|
* @property {bigint | Chunk} key a key of the list
|
|
1065
1071
|
*/
|
|
1066
1072
|
|
|
1067
|
-
/** @type {WeakMap<Set<Chunk> | Chunk, WeakMap<
|
|
1073
|
+
/** @type {WeakMap<Set<Chunk> | Chunk, WeakMap<ChunkFilterFn, SelectedChunksResult>>} */
|
|
1068
1074
|
const selectedChunksCacheByChunksSet = new WeakMap();
|
|
1069
1075
|
|
|
1070
1076
|
/**
|
|
1071
1077
|
* get list and key by applying the filter function to the list
|
|
1072
1078
|
* It is cached for performance reasons
|
|
1073
1079
|
* @param {Set<Chunk> | Chunk} chunks list of chunks
|
|
1074
|
-
* @param {
|
|
1080
|
+
* @param {ChunkFilterFn} chunkFilter filter function for chunks
|
|
1075
1081
|
* @returns {SelectedChunksResult} list and key
|
|
1076
1082
|
*/
|
|
1077
1083
|
const getSelectedChunks = (chunks, chunkFilter) => {
|
|
@@ -1132,7 +1138,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
1132
1138
|
// Determine name for split chunk
|
|
1133
1139
|
|
|
1134
1140
|
const name =
|
|
1135
|
-
/** @type {
|
|
1141
|
+
/** @type {GetNameFn} */
|
|
1136
1142
|
(cacheGroup.getName)(module, selectedChunks, cacheGroup.key);
|
|
1137
1143
|
// Check if the name is ok
|
|
1138
1144
|
const existingChunk = name && compilation.namedChunks.get(name);
|
|
@@ -1294,7 +1300,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
1294
1300
|
const { chunks: selectedChunks, key: selectedChunksKey } =
|
|
1295
1301
|
getSelectedChunks(
|
|
1296
1302
|
chunkCombination,
|
|
1297
|
-
/** @type {
|
|
1303
|
+
/** @type {ChunkFilterFn} */
|
|
1298
1304
|
(cacheGroup.chunksFilter)
|
|
1299
1305
|
);
|
|
1300
1306
|
|
|
@@ -1316,7 +1322,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
1316
1322
|
|
|
1317
1323
|
/**
|
|
1318
1324
|
* @param {ChunksInfoItem} info entry
|
|
1319
|
-
* @param {
|
|
1325
|
+
* @param {SourceTypes} sourceTypes source types to be removed
|
|
1320
1326
|
*/
|
|
1321
1327
|
const removeModulesWithSourceType = (info, sourceTypes) => {
|
|
1322
1328
|
for (const module of info.modules) {
|
|
@@ -31,6 +31,7 @@ const NoAsyncChunksWarning = require("./NoAsyncChunksWarning");
|
|
|
31
31
|
* @property {string[]} files
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
|
+
/** @type {WeakSet<Entrypoint | ChunkGroup | Source>} */
|
|
34
35
|
const isOverSizeLimitSet = new WeakSet();
|
|
35
36
|
|
|
36
37
|
/**
|
|
@@ -55,7 +56,7 @@ module.exports = class SizeLimitsPlugin {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
/**
|
|
58
|
-
* @param {ChunkGroup | Source} thing the resource to test
|
|
59
|
+
* @param {Entrypoint | ChunkGroup | Source} thing the resource to test
|
|
59
60
|
* @returns {boolean} true if over the limit
|
|
60
61
|
*/
|
|
61
62
|
static isOverSizeLimit(thing) {
|
|
@@ -8,17 +8,15 @@ const RuntimeModule = require("../RuntimeModule");
|
|
|
8
8
|
const Template = require("../Template");
|
|
9
9
|
|
|
10
10
|
/** @typedef {import("../Compilation")} Compilation */
|
|
11
|
-
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
12
11
|
|
|
13
12
|
class ChunkPrefetchFunctionRuntimeModule extends RuntimeModule {
|
|
14
13
|
/**
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {string} runtimeFunction
|
|
17
|
-
* @param {string} runtimeHandlers
|
|
14
|
+
* @param {"prefetch" | "preload"} type "prefetch" or "preload" chunk type function
|
|
15
|
+
* @param {string} runtimeFunction the runtime function name
|
|
16
|
+
* @param {string} runtimeHandlers the runtime handlers
|
|
18
17
|
*/
|
|
19
|
-
constructor(
|
|
20
|
-
super(`chunk ${
|
|
21
|
-
this.childType = childType;
|
|
18
|
+
constructor(type, runtimeFunction, runtimeHandlers) {
|
|
19
|
+
super(`chunk ${type} function`);
|
|
22
20
|
this.runtimeFunction = runtimeFunction;
|
|
23
21
|
this.runtimeHandlers = runtimeHandlers;
|
|
24
22
|
}
|
|
@@ -11,8 +11,6 @@ const ChunkPrefetchStartupRuntimeModule = require("./ChunkPrefetchStartupRuntime
|
|
|
11
11
|
const ChunkPrefetchTriggerRuntimeModule = require("./ChunkPrefetchTriggerRuntimeModule");
|
|
12
12
|
const ChunkPreloadTriggerRuntimeModule = require("./ChunkPreloadTriggerRuntimeModule");
|
|
13
13
|
|
|
14
|
-
/** @typedef {import("../Chunk")} Chunk */
|
|
15
|
-
/** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */
|
|
16
14
|
/** @typedef {import("../Compiler")} Compiler */
|
|
17
15
|
|
|
18
16
|
const PLUGIN_NAME = "ChunkPrefetchPreloadPlugin";
|
|
@@ -10,7 +10,6 @@ const Template = require("../Template");
|
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("../Chunk")} Chunk */
|
|
12
12
|
/** @typedef {import("../Compilation")} Compilation */
|
|
13
|
-
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
14
13
|
|
|
15
14
|
class ChunkPrefetchStartupRuntimeModule extends RuntimeModule {
|
|
16
15
|
/**
|
|
@@ -9,11 +9,11 @@ const RuntimeModule = require("../RuntimeModule");
|
|
|
9
9
|
const Template = require("../Template");
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("../Compilation")} Compilation */
|
|
12
|
-
/** @typedef {import("../
|
|
12
|
+
/** @typedef {import("../Chunk").ChunkChildIdsByOrdersMap} ChunkChildIdsByOrdersMap */
|
|
13
13
|
|
|
14
14
|
class ChunkPrefetchTriggerRuntimeModule extends RuntimeModule {
|
|
15
15
|
/**
|
|
16
|
-
* @param {
|
|
16
|
+
* @param {ChunkChildIdsByOrdersMap} chunkMap map from chunk to
|
|
17
17
|
*/
|
|
18
18
|
constructor(chunkMap) {
|
|
19
19
|
super("chunk prefetch trigger", RuntimeModule.STAGE_TRIGGER);
|
|
@@ -9,11 +9,11 @@ const RuntimeModule = require("../RuntimeModule");
|
|
|
9
9
|
const Template = require("../Template");
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("../Compilation")} Compilation */
|
|
12
|
-
/** @typedef {import("../
|
|
12
|
+
/** @typedef {import("../Chunk").ChunkChildIdsByOrdersMap} ChunkChildIdsByOrdersMap */
|
|
13
13
|
|
|
14
14
|
class ChunkPreloadTriggerRuntimeModule extends RuntimeModule {
|
|
15
15
|
/**
|
|
16
|
-
* @param {
|
|
16
|
+
* @param {ChunkChildIdsByOrdersMap} chunkMap map from chunk to chunks
|
|
17
17
|
*/
|
|
18
18
|
constructor(chunkMap) {
|
|
19
19
|
super("chunk preload trigger", RuntimeModule.STAGE_TRIGGER);
|
|
@@ -7,10 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetConditionOrConditions} RuleSetConditionOrConditions */
|
|
9
9
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetConditionOrConditionsAbsolute} RuleSetConditionOrConditionsAbsolute */
|
|
10
|
-
/** @typedef {import("../../declarations/WebpackOptions").RuleSetLoaderOptions} RuleSetLoaderOptions */
|
|
11
10
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
|
12
11
|
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
|
13
|
-
/** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */
|
|
14
12
|
|
|
15
13
|
/**
|
|
16
14
|
* @template T
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
|
10
10
|
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
|
11
11
|
/** @typedef {import("./RuleSetCompiler").EffectData} EffectData */
|
|
12
|
-
/** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */
|
|
13
12
|
/** @typedef {import("./RuleSetCompiler").RuleConditionFunction} RuleConditionFunction */
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
const { SyncHook } = require("tapable");
|
|
9
9
|
|
|
10
|
+
/** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
|
|
10
11
|
/** @typedef {import("../../declarations/WebpackOptions").Falsy} Falsy */
|
|
11
12
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetLoaderOptions} RuleSetLoaderOptions */
|
|
12
13
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
|
13
|
-
/** @typedef {import("../NormalModule").LoaderItem} LoaderItem */
|
|
14
14
|
|
|
15
15
|
/** @typedef {(Falsy | RuleSetRule)[]} RuleSetRules */
|
|
16
16
|
|
|
@@ -38,10 +38,10 @@ const { SyncHook } = require("tapable");
|
|
|
38
38
|
* @property {string=} resourceQuery
|
|
39
39
|
* @property {string=} resourceFragment
|
|
40
40
|
* @property {string=} scheme
|
|
41
|
-
* @property {ImportAttributes=}
|
|
41
|
+
* @property {ImportAttributes=} attributes
|
|
42
42
|
* @property {string=} mimetype
|
|
43
43
|
* @property {string} dependency
|
|
44
|
-
* @property {
|
|
44
|
+
* @property {ResolveRequest["descriptionFileData"]=} descriptionData
|
|
45
45
|
* @property {string=} compiler
|
|
46
46
|
* @property {string} issuer
|
|
47
47
|
* @property {string} issuerLayer
|
|
@@ -85,6 +85,8 @@ const { SyncHook } = require("tapable");
|
|
|
85
85
|
* @typedef {({ [P in keyof Required<T>]: Required<T>[P] extends V ? P : never })[keyof T]} KeysOfTypes
|
|
86
86
|
*/
|
|
87
87
|
|
|
88
|
+
/** @typedef {Set<string>} UnhandledProperties */
|
|
89
|
+
|
|
88
90
|
/** @typedef {{ apply: (ruleSetCompiler: RuleSetCompiler) => void }} RuleSetPlugin */
|
|
89
91
|
|
|
90
92
|
class RuleSetCompiler {
|
|
@@ -93,7 +95,7 @@ class RuleSetCompiler {
|
|
|
93
95
|
*/
|
|
94
96
|
constructor(plugins) {
|
|
95
97
|
this.hooks = Object.freeze({
|
|
96
|
-
/** @type {SyncHook<[string, RuleSetRule,
|
|
98
|
+
/** @type {SyncHook<[string, RuleSetRule, UnhandledProperties, CompiledRule, References]>} */
|
|
97
99
|
rule: new SyncHook([
|
|
98
100
|
"path",
|
|
99
101
|
"rule",
|
|
@@ -127,7 +129,7 @@ class RuleSetCompiler {
|
|
|
127
129
|
for (const condition of rule.conditions) {
|
|
128
130
|
const p = condition.property;
|
|
129
131
|
if (Array.isArray(p)) {
|
|
130
|
-
/** @type {
|
|
132
|
+
/** @type {EXPECTED_ANY} */
|
|
131
133
|
let current = data;
|
|
132
134
|
for (const subProperty of p) {
|
|
133
135
|
if (
|
|
@@ -219,7 +221,7 @@ class RuleSetCompiler {
|
|
|
219
221
|
* @returns {CompiledRule} normalized and compiled rule for processing
|
|
220
222
|
*/
|
|
221
223
|
compileRule(path, rule, refs) {
|
|
222
|
-
/** @type {
|
|
224
|
+
/** @type {UnhandledProperties} */
|
|
223
225
|
const unhandledProperties = new Set(
|
|
224
226
|
Object.keys(rule).filter(
|
|
225
227
|
(key) => rule[/** @type {keyof RuleSetRule} */ (key)] !== undefined
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
9
9
|
const RuntimeModule = require("../RuntimeModule");
|
|
10
10
|
|
|
11
|
-
/** @typedef {import("../../declarations/WebpackOptions").EntryDescriptionNormalized}
|
|
11
|
+
/** @typedef {import("../../declarations/WebpackOptions").EntryDescriptionNormalized} EntryDescription */
|
|
12
12
|
/** @typedef {import("../Chunk")} Chunk */
|
|
13
13
|
|
|
14
14
|
class BaseUriRuntimeModule extends RuntimeModule {
|
|
@@ -22,7 +22,7 @@ class BaseUriRuntimeModule extends RuntimeModule {
|
|
|
22
22
|
generate() {
|
|
23
23
|
const chunk = /** @type {Chunk} */ (this.chunk);
|
|
24
24
|
const options =
|
|
25
|
-
/** @type {
|
|
25
|
+
/** @type {EntryDescription} */
|
|
26
26
|
(chunk.getEntryOptions());
|
|
27
27
|
return `${RuntimeGlobals.baseURI} = ${
|
|
28
28
|
options.baseUri === undefined
|
|
@@ -10,7 +10,6 @@ const RuntimeModule = require("../RuntimeModule");
|
|
|
10
10
|
/** @typedef {import("../Chunk")} Chunk */
|
|
11
11
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
12
12
|
/** @typedef {import("../Compilation")} Compilation */
|
|
13
|
-
/** @typedef {import("../MainTemplate")} MainTemplate */
|
|
14
13
|
|
|
15
14
|
class CompatRuntimeModule extends RuntimeModule {
|
|
16
15
|
constructor() {
|
|
@@ -13,7 +13,6 @@ const { first } = require("../util/SetHelpers");
|
|
|
13
13
|
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
|
14
14
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
15
15
|
/** @typedef {import("../Compilation")} Compilation */
|
|
16
|
-
/** @typedef {import("../Compilation").AssetInfo} AssetInfo */
|
|
17
16
|
/** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
|
|
18
17
|
|
|
19
18
|
class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
@@ -125,7 +124,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
125
124
|
*/
|
|
126
125
|
const addStaticUrl = (c, chunkFilename) => {
|
|
127
126
|
/**
|
|
128
|
-
* @param {
|
|
127
|
+
* @param {ChunkId} value a value
|
|
129
128
|
* @returns {string} string to put in quotes
|
|
130
129
|
*/
|
|
131
130
|
const unquotedStringify = (value) => {
|
|
@@ -194,10 +193,10 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
194
193
|
* @returns {string} code with static mapping of results of fn
|
|
195
194
|
*/
|
|
196
195
|
const createMap = (fn) => {
|
|
197
|
-
/** @type {Record<
|
|
196
|
+
/** @type {Record<ChunkId, ChunkId>} */
|
|
198
197
|
const obj = {};
|
|
199
198
|
let useId = false;
|
|
200
|
-
/** @type {
|
|
199
|
+
/** @type {ChunkId | undefined} */
|
|
201
200
|
let lastKey;
|
|
202
201
|
let entries = 0;
|
|
203
202
|
for (const c of dynamicUrlChunks) {
|
|
@@ -205,8 +204,8 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
205
204
|
if (value === c.id) {
|
|
206
205
|
useId = true;
|
|
207
206
|
} else {
|
|
208
|
-
obj[/** @type {
|
|
209
|
-
lastKey = /** @type {
|
|
207
|
+
obj[/** @type {ChunkId} */ (c.id)] = value;
|
|
208
|
+
lastKey = /** @type {ChunkId} */ (c.id);
|
|
210
209
|
entries++;
|
|
211
210
|
}
|
|
212
211
|
}
|
|
@@ -214,9 +213,9 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
214
213
|
if (entries === 1) {
|
|
215
214
|
return useId
|
|
216
215
|
? `(chunkId === ${JSON.stringify(lastKey)} ? ${JSON.stringify(
|
|
217
|
-
obj[/** @type {
|
|
216
|
+
obj[/** @type {ChunkId} */ (lastKey)]
|
|
218
217
|
)} : chunkId)`
|
|
219
|
-
: JSON.stringify(obj[/** @type {
|
|
218
|
+
: JSON.stringify(obj[/** @type {ChunkId} */ (lastKey)]);
|
|
220
219
|
}
|
|
221
220
|
return useId
|
|
222
221
|
? `(${JSON.stringify(obj)}[chunkId] || chunkId)`
|
|
@@ -248,7 +247,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
|
|
|
248
247
|
hashWithLength: mapExprWithLength(
|
|
249
248
|
(c) => /** @type {string} */ (c.renderedHash)
|
|
250
249
|
),
|
|
251
|
-
name: mapExpr((c) => c.name || /** @type {
|
|
250
|
+
name: mapExpr((c) => c.name || /** @type {ChunkId} */ (c.id)),
|
|
252
251
|
contentHash: {
|
|
253
252
|
[contentType]: mapExpr((c) => c.contentHash[contentType])
|
|
254
253
|
},
|
|
@@ -11,7 +11,6 @@ const Template = require("../Template");
|
|
|
11
11
|
const HelperRuntimeModule = require("./HelperRuntimeModule");
|
|
12
12
|
|
|
13
13
|
/** @typedef {import("../Chunk")} Chunk */
|
|
14
|
-
/** @typedef {import("../Compiler")} Compiler */
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* @typedef {object} LoadScriptCompilationHooks
|
|
@@ -74,7 +73,6 @@ class LoadScriptRuntimeModule extends HelperRuntimeModule {
|
|
|
74
73
|
"script = document.createElement('script');",
|
|
75
74
|
scriptType ? `script.type = ${JSON.stringify(scriptType)};` : "",
|
|
76
75
|
charset ? "script.charset = 'utf-8';" : "",
|
|
77
|
-
`script.timeout = ${/** @type {number} */ (loadTimeout) / 1000};`,
|
|
78
76
|
`if (${RuntimeGlobals.scriptNonce}) {`,
|
|
79
77
|
Template.indent(
|
|
80
78
|
`script.setAttribute("nonce", ${RuntimeGlobals.scriptNonce});`
|
|
@@ -174,7 +174,7 @@ class MakeDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {
|
|
|
174
174
|
])},`,
|
|
175
175
|
`ownKeys: ${runtimeTemplate.basicFunction("", [
|
|
176
176
|
init,
|
|
177
|
-
`var keys = Reflect.ownKeys(ns).filter(${runtimeTemplate.expressionFunction('x !== "then"', "x")}).concat([Symbol.toStringTag]);`,
|
|
177
|
+
`var keys = Reflect.ownKeys(ns).filter(${runtimeTemplate.expressionFunction('x !== "then" && x !== Symbol.toStringTag', "x")}).concat([Symbol.toStringTag]);`,
|
|
178
178
|
"return keys;"
|
|
179
179
|
])},`,
|
|
180
180
|
`getOwnPropertyDescriptor: ${runtimeTemplate.basicFunction("_, name", [
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
8
8
|
const RuntimeModule = require("../RuntimeModule");
|
|
9
9
|
|
|
10
|
-
/** @typedef {import("../../declarations/WebpackOptions").
|
|
10
|
+
/** @typedef {import("../../declarations/WebpackOptions").PublicPath} PublicPath */
|
|
11
11
|
/** @typedef {import("../Compilation")} Compilation */
|
|
12
12
|
|
|
13
13
|
class PublicPathRuntimeModule extends RuntimeModule {
|
|
14
14
|
/**
|
|
15
|
-
* @param {
|
|
15
|
+
* @param {PublicPath} publicPath public path
|
|
16
16
|
*/
|
|
17
17
|
constructor(publicPath) {
|
|
18
18
|
super("publicPath", RuntimeModule.STAGE_BASIC);
|