webpack 5.101.3 → 5.102.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +37 -27
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +3 -2
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +209 -196
- 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 +25 -21
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +5 -9
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +2 -4
- 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 +105 -90
- 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 +42 -25
- 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 +146 -89
- package/lib/NormalModuleFactory.js +132 -42
- 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 +22 -12
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +11 -18
- 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 +167 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +22 -37
- 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/cache/getLazyHashedEtag.js +1 -1
- package/lib/config/browserslistTargetHandler.js +77 -76
- package/lib/config/defaults.js +162 -23
- package/lib/config/normalization.js +18 -3
- package/lib/config/target.js +1 -1
- 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 +13 -19
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +2 -2
- 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 +4 -7
- 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 +33 -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/ImportContextDependency.js +13 -0
- 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 +3 -2
- 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 +4 -12
- 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/HashedModuleIdsPlugin.js +5 -7
- package/lib/ids/IdHelpers.js +1 -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 +46 -24
- package/lib/javascript/JavascriptParser.js +120 -55
- 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 +15 -6
- 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/RealContentHashPlugin.js +5 -3
- 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/FileMiddleware.js +1 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +31 -20
- 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 +179 -95
- 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/Hash.js +35 -5
- 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 +1 -2
- package/lib/util/createHash.js +85 -15
- 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/hash/BatchedHash.js +47 -8
- package/lib/util/hash/wasm-hash.js +53 -13
- 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 -10
- 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 -13
- 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 +21 -21
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +93 -96
- 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/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
- package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1699 -706
- package/SECURITY.md +0 -9
- package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +0 -7
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
package/lib/ChunkGraph.js
CHANGED
|
@@ -31,6 +31,8 @@ const {
|
|
|
31
31
|
|
|
32
32
|
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
|
33
33
|
/** @typedef {import("./Chunk")} Chunk */
|
|
34
|
+
/** @typedef {import("./Chunk").Chunks} Chunks */
|
|
35
|
+
/** @typedef {import("./Chunk").Entrypoints} Entrypoints */
|
|
34
36
|
/** @typedef {import("./Chunk").ChunkId} ChunkId */
|
|
35
37
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
36
38
|
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
|
|
@@ -79,7 +81,7 @@ class ModuleHashInfo {
|
|
|
79
81
|
const getArray = (set) => [...set];
|
|
80
82
|
|
|
81
83
|
/**
|
|
82
|
-
* @param {
|
|
84
|
+
* @param {SortableChunks} chunks the chunks
|
|
83
85
|
* @returns {RuntimeSpecSet} runtimes
|
|
84
86
|
*/
|
|
85
87
|
const getModuleRuntimes = (chunks) => {
|
|
@@ -91,7 +93,7 @@ const getModuleRuntimes = (chunks) => {
|
|
|
91
93
|
};
|
|
92
94
|
|
|
93
95
|
/**
|
|
94
|
-
* @param {
|
|
96
|
+
* @param {SourceTypesByModule | undefined} sourceTypesByModule sourceTypesByModule
|
|
95
97
|
* @returns {(set: SortableSet<Module>) => Map<string, SortableSet<Module>>} modules by source type
|
|
96
98
|
*/
|
|
97
99
|
const modulesBySourceType = (sourceTypesByModule) => (set) => {
|
|
@@ -192,13 +194,14 @@ const isAvailableChunk = (a, b) => {
|
|
|
192
194
|
return true;
|
|
193
195
|
};
|
|
194
196
|
|
|
197
|
+
/** @typedef {SortableSet<Chunk>} SortableChunks */
|
|
195
198
|
/** @typedef {Set<Chunk>} EntryInChunks */
|
|
196
199
|
/** @typedef {Set<Chunk>} RuntimeInChunks */
|
|
197
200
|
/** @typedef {string | number} ModuleId */
|
|
198
201
|
|
|
199
202
|
class ChunkGraphModule {
|
|
200
203
|
constructor() {
|
|
201
|
-
/** @type {
|
|
204
|
+
/** @type {SortableChunks} */
|
|
202
205
|
this.chunks = new SortableSet();
|
|
203
206
|
/** @type {EntryInChunks | undefined} */
|
|
204
207
|
this.entryInChunks = undefined;
|
|
@@ -217,13 +220,16 @@ class ChunkGraphModule {
|
|
|
217
220
|
}
|
|
218
221
|
}
|
|
219
222
|
|
|
223
|
+
/** @typedef {WeakMap<Module, Set<string>>} SourceTypesByModule */
|
|
224
|
+
/** @typedef {Map<Module, Entrypoint>} EntryModules */
|
|
225
|
+
|
|
220
226
|
class ChunkGraphChunk {
|
|
221
227
|
constructor() {
|
|
222
228
|
/** @type {SortableSet<Module>} */
|
|
223
229
|
this.modules = new SortableSet();
|
|
224
|
-
/** @type {
|
|
230
|
+
/** @type {SourceTypesByModule | undefined} */
|
|
225
231
|
this.sourceTypesByModule = undefined;
|
|
226
|
-
/** @type {
|
|
232
|
+
/** @type {EntryModules} */
|
|
227
233
|
this.entryModules = new Map();
|
|
228
234
|
/** @type {SortableSet<RuntimeModule>} */
|
|
229
235
|
this.runtimeModules = new SortableSet();
|
|
@@ -231,7 +237,7 @@ class ChunkGraphChunk {
|
|
|
231
237
|
this.fullHashModules = undefined;
|
|
232
238
|
/** @type {Set<RuntimeModule> | undefined} */
|
|
233
239
|
this.dependentHashModules = undefined;
|
|
234
|
-
/** @type {
|
|
240
|
+
/** @type {RuntimeRequirements | undefined} */
|
|
235
241
|
this.runtimeRequirements = undefined;
|
|
236
242
|
/** @type {Set<string>} */
|
|
237
243
|
this.runtimeRequirementsInTree = new Set();
|
|
@@ -240,6 +246,11 @@ class ChunkGraphChunk {
|
|
|
240
246
|
}
|
|
241
247
|
}
|
|
242
248
|
|
|
249
|
+
/** @typedef {string | number} RuntimeId */
|
|
250
|
+
/** @typedef {Record<ModuleId, string>} IdToHashMap */
|
|
251
|
+
/** @typedef {Record<ChunkId, IdToHashMap>} ChunkModuleHashMap */
|
|
252
|
+
/** @typedef {Record<ChunkId, ModuleId[]>} ChunkModuleIdMap */
|
|
253
|
+
|
|
243
254
|
/** @typedef {(a: Module, b: Module) => -1 | 0 | 1} ModuleComparator */
|
|
244
255
|
|
|
245
256
|
class ChunkGraph {
|
|
@@ -265,7 +276,7 @@ class ChunkGraph {
|
|
|
265
276
|
this._blockChunkGroups = new WeakMap();
|
|
266
277
|
/**
|
|
267
278
|
* @private
|
|
268
|
-
* @type {Map<string,
|
|
279
|
+
* @type {Map<string, RuntimeId>}
|
|
269
280
|
*/
|
|
270
281
|
this._runtimeIds = new Map();
|
|
271
282
|
/** @type {ModuleGraph} */
|
|
@@ -452,7 +463,7 @@ class ChunkGraph {
|
|
|
452
463
|
for (const chunk of oldCgm.entryInChunks) {
|
|
453
464
|
const cgc = this._getChunkGraphChunk(chunk);
|
|
454
465
|
const old = /** @type {Entrypoint} */ (cgc.entryModules.get(oldModule));
|
|
455
|
-
/** @type {
|
|
466
|
+
/** @type {EntryModules} */
|
|
456
467
|
const newEntryModules = new Map();
|
|
457
468
|
for (const [m, cg] of cgc.entryModules) {
|
|
458
469
|
if (m === oldModule) {
|
|
@@ -740,16 +751,16 @@ class ChunkGraph {
|
|
|
740
751
|
* @param {Chunk} chunk the chunk
|
|
741
752
|
* @param {ModuleFilterPredicate} filterFn function used to filter modules
|
|
742
753
|
* @param {boolean} includeAllChunks all chunks or only async chunks
|
|
743
|
-
* @returns {
|
|
754
|
+
* @returns {ChunkModuleIdMap} chunk to module ids object
|
|
744
755
|
*/
|
|
745
756
|
getChunkModuleIdMap(chunk, filterFn, includeAllChunks = false) {
|
|
746
|
-
/** @type {
|
|
757
|
+
/** @type {ChunkModuleIdMap} */
|
|
747
758
|
const chunkModuleIdMap = Object.create(null);
|
|
748
759
|
|
|
749
760
|
for (const asyncChunk of includeAllChunks
|
|
750
761
|
? chunk.getAllReferencedChunks()
|
|
751
762
|
: chunk.getAllAsyncChunks()) {
|
|
752
|
-
/** @type {
|
|
763
|
+
/** @type {ModuleId[] | undefined} */
|
|
753
764
|
let array;
|
|
754
765
|
for (const module of this.getOrderedChunkModulesIterable(
|
|
755
766
|
asyncChunk,
|
|
@@ -774,7 +785,7 @@ class ChunkGraph {
|
|
|
774
785
|
* @param {ModuleFilterPredicate} filterFn function used to filter modules
|
|
775
786
|
* @param {number} hashLength length of the hash
|
|
776
787
|
* @param {boolean} includeAllChunks all chunks or only async chunks
|
|
777
|
-
* @returns {
|
|
788
|
+
* @returns {ChunkModuleHashMap} chunk to module id to module hash object
|
|
778
789
|
*/
|
|
779
790
|
getChunkModuleRenderedHashMap(
|
|
780
791
|
chunk,
|
|
@@ -782,11 +793,9 @@ class ChunkGraph {
|
|
|
782
793
|
hashLength = 0,
|
|
783
794
|
includeAllChunks = false
|
|
784
795
|
) {
|
|
785
|
-
/** @type {
|
|
796
|
+
/** @type {ChunkModuleHashMap} */
|
|
786
797
|
const chunkModuleHashMap = Object.create(null);
|
|
787
798
|
|
|
788
|
-
/** @typedef {Record<string|number, string>} IdToHashMap */
|
|
789
|
-
|
|
790
799
|
for (const asyncChunk of includeAllChunks
|
|
791
800
|
? chunk.getAllReferencedChunks()
|
|
792
801
|
: chunk.getAllAsyncChunks()) {
|
|
@@ -800,7 +809,8 @@ class ChunkGraph {
|
|
|
800
809
|
if (idToHashMap === undefined) {
|
|
801
810
|
idToHashMap = Object.create(null);
|
|
802
811
|
chunkModuleHashMap[/** @type {ChunkId} */ (asyncChunk.id)] =
|
|
803
|
-
/** @type {IdToHashMap} */
|
|
812
|
+
/** @type {IdToHashMap} */
|
|
813
|
+
(idToHashMap);
|
|
804
814
|
}
|
|
805
815
|
const moduleId = this.getModuleId(module);
|
|
806
816
|
const hash = this.getRenderedModuleHash(module, asyncChunk.runtime);
|
|
@@ -818,7 +828,7 @@ class ChunkGraph {
|
|
|
818
828
|
/**
|
|
819
829
|
* @param {Chunk} chunk the chunk
|
|
820
830
|
* @param {ChunkFilterPredicate} filterFn function used to filter chunks
|
|
821
|
-
* @returns {Record<
|
|
831
|
+
* @returns {Record<ChunkId, boolean>} chunk map
|
|
822
832
|
*/
|
|
823
833
|
getChunkConditionMap(chunk, filterFn) {
|
|
824
834
|
const map = Object.create(null);
|
|
@@ -1219,7 +1229,7 @@ class ChunkGraph {
|
|
|
1219
1229
|
* @returns {Iterable<Chunk>} iterable of chunks
|
|
1220
1230
|
*/
|
|
1221
1231
|
getChunkEntryDependentChunksIterable(chunk) {
|
|
1222
|
-
/** @type {
|
|
1232
|
+
/** @type {Chunks} */
|
|
1223
1233
|
const set = new Set();
|
|
1224
1234
|
for (const chunkGroup of chunk.groupsIterable) {
|
|
1225
1235
|
if (chunkGroup instanceof Entrypoint) {
|
|
@@ -1243,10 +1253,10 @@ class ChunkGraph {
|
|
|
1243
1253
|
* @returns {Iterable<Chunk>} iterable of chunks and include chunks from children entrypoints
|
|
1244
1254
|
*/
|
|
1245
1255
|
getRuntimeChunkDependentChunksIterable(chunk) {
|
|
1246
|
-
/** @type {
|
|
1256
|
+
/** @type {Chunks} */
|
|
1247
1257
|
const set = new Set();
|
|
1248
1258
|
|
|
1249
|
-
/** @type {
|
|
1259
|
+
/** @type {Entrypoints} */
|
|
1250
1260
|
const entrypoints = new Set();
|
|
1251
1261
|
|
|
1252
1262
|
for (const chunkGroup of chunk.groupsIterable) {
|
|
@@ -1423,15 +1433,15 @@ class ChunkGraph {
|
|
|
1423
1433
|
|
|
1424
1434
|
/**
|
|
1425
1435
|
* @param {string} runtime runtime
|
|
1426
|
-
* @returns {
|
|
1436
|
+
* @returns {RuntimeId} the id of the runtime
|
|
1427
1437
|
*/
|
|
1428
1438
|
getRuntimeId(runtime) {
|
|
1429
|
-
return /** @type {
|
|
1439
|
+
return /** @type {RuntimeId} */ (this._runtimeIds.get(runtime));
|
|
1430
1440
|
}
|
|
1431
1441
|
|
|
1432
1442
|
/**
|
|
1433
1443
|
* @param {string} runtime runtime
|
|
1434
|
-
* @param {
|
|
1444
|
+
* @param {RuntimeId} id the id of the runtime
|
|
1435
1445
|
* @returns {void}
|
|
1436
1446
|
*/
|
|
1437
1447
|
setRuntimeId(runtime, id) {
|
|
@@ -1531,7 +1541,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
1531
1541
|
/**
|
|
1532
1542
|
* @param {Module} module the module
|
|
1533
1543
|
* @param {RuntimeSpec} runtime the runtime
|
|
1534
|
-
* @param {
|
|
1544
|
+
* @param {RuntimeRequirements} items runtime requirements to be added (ownership of this Set is given to ChunkGraph when transferOwnership not false)
|
|
1535
1545
|
* @param {boolean} transferOwnership true: transfer ownership of the items object, false: items is immutable and shared and won't be modified
|
|
1536
1546
|
* @returns {void}
|
|
1537
1547
|
*/
|
|
@@ -1565,7 +1575,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
1565
1575
|
|
|
1566
1576
|
/**
|
|
1567
1577
|
* @param {Chunk} chunk the chunk
|
|
1568
|
-
* @param {
|
|
1578
|
+
* @param {RuntimeRequirements} items runtime requirements to be added (ownership of this Set is given to ChunkGraph)
|
|
1569
1579
|
* @returns {void}
|
|
1570
1580
|
*/
|
|
1571
1581
|
addChunkRuntimeRequirements(chunk, items) {
|
|
@@ -1660,7 +1670,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
1660
1670
|
for (const type of sourceTypes) hash.update(type);
|
|
1661
1671
|
}
|
|
1662
1672
|
this.moduleGraph.getExportsInfo(module).updateHash(hash, runtime);
|
|
1663
|
-
return BigInt(`0x${
|
|
1673
|
+
return BigInt(`0x${hash.digest("hex")}`);
|
|
1664
1674
|
});
|
|
1665
1675
|
return graphHash;
|
|
1666
1676
|
}
|
|
@@ -1798,7 +1808,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
1798
1808
|
}
|
|
1799
1809
|
}
|
|
1800
1810
|
hash.update(graphHash);
|
|
1801
|
-
return
|
|
1811
|
+
return hash.digest("hex");
|
|
1802
1812
|
});
|
|
1803
1813
|
}
|
|
1804
1814
|
|
package/lib/ChunkGroup.js
CHANGED
|
@@ -21,8 +21,7 @@ const {
|
|
|
21
21
|
/** @typedef {import("./Module")} Module */
|
|
22
22
|
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
|
23
23
|
|
|
24
|
-
/** @typedef {{
|
|
25
|
-
/** @typedef {{module: Module | null, loc: DependencyLocation, request: string}} OriginRecord */
|
|
24
|
+
/** @typedef {{ module: Module | null, loc: DependencyLocation, request: string }} OriginRecord */
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
27
|
* @typedef {object} RawChunkGroupOptions
|
|
@@ -114,13 +113,12 @@ class ChunkGroup {
|
|
|
114
113
|
* @returns {void}
|
|
115
114
|
*/
|
|
116
115
|
addOptions(options) {
|
|
117
|
-
for (const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
(_key);
|
|
116
|
+
for (const key of /** @type {(keyof ChunkGroupOptions)[]} */ (
|
|
117
|
+
Object.keys(options)
|
|
118
|
+
)) {
|
|
121
119
|
if (this.options[key] === undefined) {
|
|
122
|
-
/** @type {
|
|
123
|
-
(this.options
|
|
120
|
+
/** @type {ChunkGroupOptions[keyof ChunkGroupOptions]} */
|
|
121
|
+
(this.options[key]) = options[key];
|
|
124
122
|
} else if (this.options[key] !== options[key]) {
|
|
125
123
|
if (key.endsWith("Order")) {
|
|
126
124
|
const orderKey =
|
|
@@ -144,7 +142,7 @@ class ChunkGroup {
|
|
|
144
142
|
|
|
145
143
|
/**
|
|
146
144
|
* returns the name of current ChunkGroup
|
|
147
|
-
* @returns {
|
|
145
|
+
* @returns {ChunkGroupOptions["name"]} returns the ChunkGroup name
|
|
148
146
|
*/
|
|
149
147
|
get name() {
|
|
150
148
|
return this.options.name;
|
|
@@ -373,7 +371,7 @@ class ChunkGroup {
|
|
|
373
371
|
}
|
|
374
372
|
|
|
375
373
|
/**
|
|
376
|
-
* @returns {
|
|
374
|
+
* @returns {AsyncDependenciesBlock[]} an array containing the blocks
|
|
377
375
|
*/
|
|
378
376
|
getBlocks() {
|
|
379
377
|
return this._blocks.getFromCache(getArray);
|
package/lib/ChunkTemplate.js
CHANGED
|
@@ -9,7 +9,7 @@ const util = require("util");
|
|
|
9
9
|
const memoize = require("./util/memoize");
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("tapable").Tap} Tap */
|
|
12
|
-
/** @typedef {import("
|
|
12
|
+
/** @typedef {import("./config/defaults").OutputNormalizedWithDefaults} OutputOptions */
|
|
13
13
|
/** @typedef {import("./Chunk")} Chunk */
|
|
14
14
|
/** @typedef {import("./Compilation")} Compilation */
|
|
15
15
|
/** @typedef {import("./Compilation").ChunkHashContext} ChunkHashContext */
|
package/lib/CleanPlugin.js
CHANGED
|
@@ -30,7 +30,7 @@ const processAsyncTree = require("./util/processAsyncTree");
|
|
|
30
30
|
/**
|
|
31
31
|
* @callback KeepFn
|
|
32
32
|
* @param {string} path path
|
|
33
|
-
* @returns {boolean |
|
|
33
|
+
* @returns {boolean | undefined} true, if the path should be kept
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
36
|
const validate = createSchemaValidation(
|
|
@@ -170,7 +170,7 @@ const doStat = (fs, filename, callback) => {
|
|
|
170
170
|
* @param {boolean} dry only log instead of fs modification
|
|
171
171
|
* @param {Logger} logger logger
|
|
172
172
|
* @param {Diff} diff filenames of the assets that shouldn't be there
|
|
173
|
-
* @param {
|
|
173
|
+
* @param {KeepFn} isKept check if the entry is ignored
|
|
174
174
|
* @param {(err?: Error, assets?: Assets) => void} callback callback
|
|
175
175
|
* @returns {void}
|
|
176
176
|
*/
|
|
@@ -436,7 +436,7 @@ class CleanPlugin {
|
|
|
436
436
|
|
|
437
437
|
/**
|
|
438
438
|
* @param {string} path path
|
|
439
|
-
* @returns {boolean |
|
|
439
|
+
* @returns {boolean | undefined} true, if needs to be kept
|
|
440
440
|
*/
|
|
441
441
|
const isKept = (path) => {
|
|
442
442
|
const result = hooks.keep.call(path);
|
|
@@ -14,6 +14,7 @@ const { RuntimeSpecMap, runtimeToString } = require("./util/runtime");
|
|
|
14
14
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
15
15
|
/** @typedef {import("./Module")} Module */
|
|
16
16
|
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
|
17
|
+
/** @typedef {import("./Module").CodeGenerationResultData} CodeGenerationResultData */
|
|
17
18
|
/** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
|
18
19
|
/** @typedef {typeof import("./util/Hash")} Hash */
|
|
19
20
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
|
@@ -117,7 +118,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
117
118
|
* @param {Module} module the module
|
|
118
119
|
* @param {RuntimeSpec} runtime runtime(s)
|
|
119
120
|
* @param {string} key data key
|
|
120
|
-
* @returns {
|
|
121
|
+
* @returns {ReturnType<CodeGenerationResultData["get"]>} data generated by code generation
|
|
121
122
|
*/
|
|
122
123
|
getData(module, runtime, key) {
|
|
123
124
|
const data = this.get(module, runtime).data;
|
|
@@ -140,7 +141,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
140
141
|
if (info.runtimeRequirements) {
|
|
141
142
|
for (const rr of info.runtimeRequirements) hash.update(rr);
|
|
142
143
|
}
|
|
143
|
-
return (info.hash =
|
|
144
|
+
return (info.hash = hash.digest("hex"));
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
/**
|
|
@@ -16,9 +16,22 @@ const ConstDependency = require("./dependencies/ConstDependency");
|
|
|
16
16
|
/** @typedef {import("estree").CallExpression} CallExpression */
|
|
17
17
|
/** @typedef {import("./Compiler")} Compiler */
|
|
18
18
|
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
|
19
|
+
/** @typedef {import("./dependencies/ContextDependency")} ContextDependency */
|
|
19
20
|
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
|
20
21
|
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
|
|
21
|
-
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {object} CompatibilitySettingsDeclaration
|
|
25
|
+
* @property {boolean} updated
|
|
26
|
+
* @property {DependencyLocation} loc
|
|
27
|
+
* @property {Range} range
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {object} CompatibilitySettings
|
|
32
|
+
* @property {string} name
|
|
33
|
+
* @property {CompatibilitySettingsDeclaration} declaration
|
|
34
|
+
*/
|
|
22
35
|
|
|
23
36
|
const nestedWebpackIdentifierTag = Symbol("nested webpack identifier");
|
|
24
37
|
const PLUGIN_NAME = "CompatibilityPlugin";
|
|
@@ -67,9 +80,12 @@ class CompatibilityPlugin {
|
|
|
67
80
|
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
68
81
|
if (parser.state.current.dependencies.length > 0) {
|
|
69
82
|
const last =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
83
|
+
/** @type {ContextDependency} */
|
|
84
|
+
(
|
|
85
|
+
parser.state.current.dependencies[
|
|
86
|
+
parser.state.current.dependencies.length - 1
|
|
87
|
+
]
|
|
88
|
+
);
|
|
73
89
|
if (
|
|
74
90
|
last.critical &&
|
|
75
91
|
last.options &&
|
|
@@ -99,7 +115,8 @@ class CompatibilityPlugin {
|
|
|
99
115
|
statement.id.name === RuntimeGlobals.require
|
|
100
116
|
) {
|
|
101
117
|
const newName = `__nested_webpack_require_${
|
|
102
|
-
/** @type {Range} */
|
|
118
|
+
/** @type {Range} */
|
|
119
|
+
(statement.range)[0]
|
|
103
120
|
}__`;
|
|
104
121
|
parser.tagVariable(
|
|
105
122
|
statement.id.name,
|
|
@@ -108,8 +125,8 @@ class CompatibilityPlugin {
|
|
|
108
125
|
name: newName,
|
|
109
126
|
declaration: {
|
|
110
127
|
updated: false,
|
|
111
|
-
loc: statement.id.loc,
|
|
112
|
-
range: statement.id.range
|
|
128
|
+
loc: /** @type {DependencyLocation} */ (statement.id.loc),
|
|
129
|
+
range: /** @type {Range} */ (statement.id.range)
|
|
113
130
|
}
|
|
114
131
|
}
|
|
115
132
|
);
|
|
@@ -126,8 +143,8 @@ class CompatibilityPlugin {
|
|
|
126
143
|
name: newName,
|
|
127
144
|
declaration: {
|
|
128
145
|
updated: false,
|
|
129
|
-
loc: pattern.loc,
|
|
130
|
-
range: pattern.range
|
|
146
|
+
loc: /** @type {DependencyLocation} */ (pattern.loc),
|
|
147
|
+
range: /** @type {Range} */ (pattern.range)
|
|
131
148
|
}
|
|
132
149
|
});
|
|
133
150
|
return true;
|
|
@@ -139,8 +156,8 @@ class CompatibilityPlugin {
|
|
|
139
156
|
name: "__nested_webpack_exports__",
|
|
140
157
|
declaration: {
|
|
141
158
|
updated: false,
|
|
142
|
-
loc: pattern.loc,
|
|
143
|
-
range: pattern.range
|
|
159
|
+
loc: /** @type {DependencyLocation} */ (pattern.loc),
|
|
160
|
+
range: /** @type {Range} */ (pattern.range)
|
|
144
161
|
}
|
|
145
162
|
});
|
|
146
163
|
return true;
|
|
@@ -149,7 +166,7 @@ class CompatibilityPlugin {
|
|
|
149
166
|
.for(nestedWebpackIdentifierTag)
|
|
150
167
|
.tap(PLUGIN_NAME, (expr) => {
|
|
151
168
|
const { name, declaration } =
|
|
152
|
-
/** @type {
|
|
169
|
+
/** @type {CompatibilitySettings} */
|
|
153
170
|
(parser.currentTagData);
|
|
154
171
|
if (!declaration.updated) {
|
|
155
172
|
const dep = new ConstDependency(name, declaration.range);
|