webpack 5.107.2 → 5.108.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/hot/dev-server.js +2 -0
- package/lib/APIPlugin.js +8 -4
- package/lib/CacheFacade.js +7 -0
- package/lib/Chunk.js +4 -0
- package/lib/ChunkGraph.js +30 -9
- package/lib/CircularModulesPlugin.js +190 -0
- package/lib/CleanPlugin.js +2 -1
- package/lib/Compilation.js +396 -65
- package/lib/Compiler.js +25 -11
- package/lib/ConcatenationScope.js +10 -3
- package/lib/ContextExclusionPlugin.js +1 -0
- package/lib/ContextModule.js +92 -47
- package/lib/ContextReplacementPlugin.js +4 -0
- package/lib/DefinePlugin.js +89 -15
- package/lib/Dependency.js +111 -7
- package/lib/EntryOptionPlugin.js +39 -2
- package/lib/EntryPlugin.js +2 -0
- package/lib/ExportsInfo.js +314 -73
- package/lib/ExternalModule.js +82 -34
- package/lib/ExternalModuleFactoryPlugin.js +1 -0
- package/lib/ExternalsPlugin.js +1 -0
- package/lib/FileSystemInfo.js +173 -23
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -5
- package/lib/FlagDependencyExportsPlugin.js +23 -0
- package/lib/FlagDependencyUsagePlugin.js +87 -5
- package/lib/FlagEntryExportAsUsedPlugin.js +2 -0
- package/lib/Generator.js +8 -0
- package/lib/HotModuleReplacementPlugin.js +65 -28
- package/lib/IgnorePlugin.js +1 -0
- package/lib/InitFragment.js +5 -0
- package/lib/JavascriptMetaInfoPlugin.js +7 -5
- package/lib/LazyBarrel.js +361 -0
- package/lib/LoaderTargetPlugin.js +1 -0
- package/lib/Module.js +21 -42
- package/lib/ModuleGraph.js +3 -2
- package/lib/ModuleProfile.js +27 -1
- package/lib/ModuleTemplate.js +2 -0
- package/lib/MultiCompiler.js +2 -0
- package/lib/MultiStats.js +1 -0
- package/lib/MultiWatching.js +2 -0
- package/lib/NodeStuffPlugin.js +22 -17
- package/lib/NormalModule.js +142 -80
- package/lib/NormalModuleReplacementPlugin.js +2 -0
- package/lib/PrefetchPlugin.js +2 -0
- package/lib/ProgressPlugin.js +8 -0
- package/lib/ProvidePlugin.js +1 -0
- package/lib/RawModule.js +20 -16
- package/lib/RecordIdsPlugin.js +1 -0
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimePlugin.js +58 -26
- package/lib/RuntimeTemplate.js +278 -21
- package/lib/SelfModuleFactory.js +1 -0
- package/lib/SourceMapDevToolPlugin.js +3 -5
- package/lib/Stats.js +1 -0
- package/lib/Template.js +8 -2
- package/lib/TemplatedPathPlugin.js +473 -131
- package/lib/WarnCaseSensitiveModulesPlugin.js +1 -0
- package/lib/WarnDeprecatedOptionPlugin.js +4 -0
- package/lib/WarnNoModeSetPlugin.js +1 -0
- package/lib/WatchIgnorePlugin.js +1 -0
- package/lib/Watching.js +9 -0
- package/lib/WebpackOptionsApply.js +50 -5
- package/lib/asset/AssetBytesGenerator.js +11 -3
- package/lib/asset/AssetGenerator.js +47 -22
- package/lib/asset/AssetModule.js +47 -0
- package/lib/asset/AssetModulesPlugin.js +14 -14
- package/lib/asset/AssetParser.js +2 -2
- package/lib/asset/AssetSourceGenerator.js +8 -0
- package/lib/asset/RawDataUrlModule.js +12 -13
- package/lib/buildChunkGraph.js +64 -7
- package/lib/bun/BunTargetPlugin.js +48 -0
- package/lib/cache/AddBuildDependenciesPlugin.js +1 -0
- package/lib/cache/AddManagedPathsPlugin.js +3 -0
- package/lib/cache/IdleFileCachePlugin.js +4 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +1 -0
- package/lib/cache/ResolverCachePlugin.js +2 -0
- package/lib/cache/mergeEtags.js +2 -0
- package/lib/cli.js +109 -19
- package/lib/config/browserslistTargetHandler.js +99 -0
- package/lib/config/defaults.js +147 -7
- package/lib/config/defineConfig.js +31 -0
- package/lib/config/normalization.js +5 -0
- package/lib/config/target.js +181 -2
- package/lib/container/ContainerEntryModule.js +15 -14
- package/lib/container/ContainerExposedDependency.js +2 -2
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackDependency.js +5 -7
- package/lib/container/FallbackModule.js +10 -9
- package/lib/container/RemoteModule.js +20 -10
- package/lib/container/RemoteRuntimeModule.js +14 -12
- package/lib/css/CssGenerator.js +353 -327
- package/lib/css/CssInjectStyleRuntimeModule.js +36 -8
- package/lib/css/CssLoadingRuntimeModule.js +118 -47
- package/lib/css/CssModule.js +52 -23
- package/lib/css/CssModulesPlugin.js +107 -124
- package/lib/css/CssParser.js +2759 -2205
- package/lib/css/syntax.js +2859 -0
- package/lib/debug/ProfilingPlugin.js +2 -0
- package/lib/deno/DenoTargetPlugin.js +47 -0
- package/lib/dependencies/AMDDefineDependency.js +22 -17
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +1 -0
- package/lib/dependencies/AMDRequireArrayDependency.js +7 -11
- package/lib/dependencies/AMDRequireContextDependency.js +7 -11
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -0
- package/lib/dependencies/AMDRequireDependency.js +24 -20
- package/lib/dependencies/CachedConstDependency.js +3 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +1 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +79 -31
- package/lib/dependencies/CommonJsExportsDependency.js +21 -16
- package/lib/dependencies/CommonJsExportsParserPlugin.js +230 -7
- package/lib/dependencies/CommonJsFullRequireDependency.js +27 -19
- package/lib/dependencies/CommonJsImportsParserPlugin.js +51 -16
- package/lib/dependencies/CommonJsPlugin.js +1 -1
- package/lib/dependencies/CommonJsRequireContextDependency.js +10 -13
- package/lib/dependencies/CommonJsRequireDependency.js +42 -11
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +22 -14
- package/lib/dependencies/ConstDependency.js +16 -11
- package/lib/dependencies/ContextDependency.js +4 -0
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +23 -14
- package/lib/dependencies/CreateRequireParserPlugin.js +1 -0
- package/lib/dependencies/CreateScriptUrlDependency.js +5 -7
- package/lib/dependencies/CriticalDependencyWarning.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +512 -574
- package/lib/dependencies/CssIcssImportDependency.js +9 -9
- package/lib/dependencies/CssIcssSymbolDependency.js +22 -15
- package/lib/dependencies/CssImportDependency.js +25 -1
- package/lib/dependencies/CssUrlDependency.js +23 -14
- package/lib/dependencies/DllEntryDependency.js +9 -13
- package/lib/dependencies/ExportBindingInitFragment.js +164 -0
- package/lib/dependencies/ExportsInfoDependency.js +12 -12
- package/lib/dependencies/ExternalModuleDependency.js +8 -5
- package/lib/dependencies/ExternalModuleInitFragment.js +7 -5
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +13 -10
- package/lib/dependencies/HarmonyAcceptDependency.js +11 -11
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +47 -22
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +28 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +46 -22
- package/lib/dependencies/HarmonyExportExpressionDependency.js +107 -30
- package/lib/dependencies/HarmonyExportHeaderDependency.js +7 -9
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +109 -31
- package/lib/dependencies/HarmonyExportInitFragment.js +18 -15
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +83 -18
- package/lib/dependencies/HarmonyExports.js +4 -1
- package/lib/dependencies/HarmonyImportDependency.js +24 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +110 -74
- package/lib/dependencies/HarmonyImportGuard.js +254 -0
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +18 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +118 -14
- package/lib/dependencies/HarmonyLinkingError.js +1 -0
- package/lib/dependencies/HarmonyModulesPlugin.js +1 -0
- package/lib/dependencies/{HtmlScriptSrcDependency.js → HtmlEntryDependency.js} +261 -109
- package/lib/dependencies/HtmlInlineHtmlDependency.js +107 -0
- package/lib/dependencies/HtmlInlineScriptDependency.js +17 -13
- package/lib/dependencies/HtmlInlineStyleDependency.js +45 -11
- package/lib/dependencies/ImportContextDependency.js +5 -9
- package/lib/dependencies/ImportDependency.js +44 -2
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +1 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +74 -30
- package/lib/dependencies/ImportParserPlugin.js +19 -0
- package/lib/dependencies/ImportWeakDependency.js +1 -0
- package/lib/dependencies/JsonExportsDependency.js +9 -9
- package/lib/dependencies/LoaderImportDependency.js +1 -0
- package/lib/dependencies/LocalModule.js +11 -12
- package/lib/dependencies/LocalModuleDependency.js +11 -13
- package/lib/dependencies/ModuleDecoratorDependency.js +9 -9
- package/lib/dependencies/ModuleDependency.js +7 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +15 -11
- package/lib/dependencies/ProvidedDependency.js +31 -27
- package/lib/dependencies/PureExpressionDependency.js +7 -9
- package/lib/dependencies/RequireEnsureDependency.js +12 -13
- package/lib/dependencies/RequireHeaderDependency.js +3 -4
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -0
- package/lib/dependencies/RequireResolveContextDependency.js +7 -11
- package/lib/dependencies/RequireResolveDependency.js +1 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +3 -5
- package/lib/dependencies/RuntimeRequirementsDependency.js +6 -7
- package/lib/dependencies/StaticExportsDependency.js +10 -10
- package/lib/dependencies/SystemPlugin.js +2 -0
- package/lib/dependencies/URLContextDependency.js +5 -7
- package/lib/dependencies/URLDependency.js +14 -16
- package/lib/dependencies/UnsupportedDependency.js +8 -13
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +11 -16
- package/lib/dependencies/WebAssemblyImportDependency.js +14 -16
- package/lib/dependencies/WebpackIsIncludedDependency.js +1 -0
- package/lib/dependencies/WorkerDependency.js +19 -8
- package/lib/dependencies/WorkerPlugin.js +22 -6
- package/lib/dependencies/processExportInfo.js +13 -11
- package/lib/dll/DelegatedModule.js +29 -15
- package/lib/dll/DelegatedModuleFactoryPlugin.js +1 -0
- package/lib/dll/DelegatedPlugin.js +1 -0
- package/lib/dll/DllEntryPlugin.js +3 -0
- package/lib/dll/DllModule.js +3 -2
- package/lib/dll/DllPlugin.js +16 -0
- package/lib/dll/DllReferencePlugin.js +3 -0
- package/lib/dll/LibManifestPlugin.js +1 -0
- package/lib/electron/ElectronTargetPlugin.js +22 -4
- package/lib/errors/ConcurrentCompilationError.js +1 -0
- package/lib/errors/HookWebpackError.js +11 -13
- package/lib/errors/IgnoreErrorModuleFactory.js +1 -0
- package/lib/errors/InvalidDependenciesModuleWarning.js +2 -0
- package/lib/errors/JSONParseError.js +9 -8
- package/lib/errors/ModuleBuildError.js +16 -13
- package/lib/errors/ModuleDependencyError.js +8 -1
- package/lib/errors/ModuleDependencyWarning.js +8 -1
- package/lib/errors/ModuleError.js +5 -11
- package/lib/errors/ModuleHashingError.js +4 -0
- package/lib/errors/ModuleNotFoundError.js +3 -0
- package/lib/errors/ModuleParseError.js +5 -11
- package/lib/errors/ModuleRestoreError.js +2 -0
- package/lib/errors/ModuleStoreError.js +3 -0
- package/lib/errors/ModuleWarning.js +7 -11
- package/lib/errors/NodeStuffInWebError.js +1 -0
- package/lib/errors/NonErrorEmittedError.js +2 -0
- package/lib/errors/UnhandledSchemeError.js +1 -0
- package/lib/esm/ModuleChunkLoadingPlugin.js +0 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +28 -23
- package/lib/hmr/HotModuleReplacement.runtime.js +175 -30
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +7 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +173 -26
- package/lib/hmr/LazyCompilationPlugin.js +30 -6
- package/lib/html/HtmlGenerator.js +217 -23
- package/lib/html/HtmlModule.js +40 -0
- package/lib/html/HtmlModulesPlugin.js +219 -55
- package/lib/html/HtmlParser.js +1108 -1099
- package/lib/html/{walkHtmlTokens.js → syntax.js} +4701 -212
- package/lib/ids/IdHelpers.js +4 -2
- package/lib/index.js +19 -0
- package/lib/javascript/BasicEvaluatedExpression.js +1 -0
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -0
- package/lib/javascript/JavascriptGenerator.js +6 -2
- package/lib/javascript/JavascriptModule.js +54 -0
- package/lib/javascript/JavascriptModulesPlugin.js +257 -102
- package/lib/javascript/JavascriptParser.js +285 -158
- package/lib/json/JsonModule.js +40 -0
- package/lib/json/JsonModulesPlugin.js +7 -0
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AssignLibraryPlugin.js +5 -3
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -0
- package/lib/library/FalseIIFEUmdWarning.js +1 -0
- package/lib/library/ModuleLibraryPlugin.js +24 -5
- package/lib/library/SystemLibraryPlugin.js +3 -3
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +1 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -9
- package/lib/node/RequireChunkLoadingRuntimeModule.js +18 -16
- package/lib/optimize/ConcatenatedModule.js +395 -77
- package/lib/optimize/ConstExportsPlugin.js +211 -0
- package/lib/optimize/InlineExports.js +178 -0
- package/lib/optimize/InnerGraph.js +372 -275
- package/lib/optimize/InnerGraphPlugin.js +196 -99
- package/lib/optimize/ModuleConcatenationPlugin.js +56 -25
- package/lib/optimize/RealContentHashPlugin.js +14 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +234 -64
- package/lib/runtime/AsyncModuleRuntimeModule.js +32 -30
- package/lib/runtime/AutoPublicPathRuntimeModule.js +11 -5
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +1 -1
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +6 -4
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +33 -4
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +82 -3
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +1 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +18 -13
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +39 -26
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -4
- package/lib/runtime/RelativeUrlRuntimeModule.js +3 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -1
- package/lib/runtime/StartupEntrypointRuntimeModule.js +4 -3
- package/lib/runtime/WorkerRuntimeModule.js +33 -0
- package/lib/schemes/HttpUriPlugin.js +3 -2
- package/lib/serialization/AggregateErrorSerializer.js +7 -6
- package/lib/serialization/ArraySerializer.js +4 -8
- package/lib/serialization/BinaryMiddleware.js +538 -468
- package/lib/serialization/DateObjectSerializer.js +2 -2
- package/lib/serialization/ErrorObjectSerializer.js +7 -6
- package/lib/serialization/MapObjectSerializer.js +5 -9
- package/lib/serialization/NullPrototypeObjectSerializer.js +7 -9
- package/lib/serialization/ObjectMiddleware.js +50 -13
- package/lib/serialization/PlainObjectSerializer.js +9 -8
- package/lib/serialization/RegExpObjectSerializer.js +2 -2
- package/lib/serialization/Serializer.js +1 -0
- package/lib/serialization/SetObjectSerializer.js +4 -8
- package/lib/sharing/ConsumeSharedModule.js +6 -7
- package/lib/sharing/ConsumeSharedPlugin.js +1 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +46 -41
- package/lib/sharing/ProvideSharedDependency.js +30 -15
- package/lib/sharing/ProvideSharedModule.js +30 -11
- package/lib/sharing/ProvideSharedPlugin.js +4 -2
- package/lib/sharing/SharePlugin.js +3 -0
- package/lib/sharing/ShareRuntimeModule.js +18 -16
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +4 -6
- package/lib/stats/DefaultStatsPrinterPlugin.js +14 -14
- package/lib/stats/StatsFactory.js +11 -9
- package/lib/stats/StatsPrinter.js +9 -2
- package/lib/url/URLParserPlugin.js +5 -2
- package/lib/util/AsyncQueue.js +10 -0
- package/lib/util/LazyBucketSortedSet.js +5 -0
- package/lib/util/LazySet.js +6 -4
- package/lib/util/LocConverter.js +11 -1
- package/lib/util/Semaphore.js +1 -0
- package/lib/util/SourceProcessor.js +106 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/WeakTupleMap.js +27 -1
- package/lib/util/chainedImports.js +3 -3
- package/lib/util/comparators.js +2 -2
- package/lib/util/concatenate.js +31 -7
- package/lib/util/createHash.js +0 -1
- package/lib/util/deterministicGrouping.js +19 -12
- package/lib/util/extractSourceMap.js +1 -1
- package/lib/util/findGraphRoots.js +2 -0
- package/lib/util/fs.js +10 -5
- package/lib/util/hash/DebugHash.js +1 -0
- package/lib/util/hash/hash-digest.js +24 -15
- package/lib/util/identifier.js +7 -0
- package/lib/util/internalSerializables.js +11 -2
- package/lib/util/magicComment.js +42 -0
- package/lib/util/makeSerializable.js +1 -0
- package/lib/util/nonNumericOnlyHash.js +30 -1
- package/lib/util/property.js +7 -1
- package/lib/util/publicPathPlaceholder.js +64 -0
- package/lib/util/registerExternalSerializer.js +4 -4
- package/lib/wasm-async/AsyncWasmModule.js +77 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -96
- package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +1 -1
- package/lib/wasm-sync/SyncWasmModule.js +39 -0
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +1 -0
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +10 -0
- package/lib/wasm-sync/WebAssemblyParser.js +7 -3
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +45 -39
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +11 -10
- package/package.json +35 -27
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +212 -3
- package/schemas/plugins/HtmlGeneratorOptions.check.js +1 -1
- package/schemas/plugins/HtmlParserOptions.check.d.ts +7 -0
- package/schemas/plugins/HtmlParserOptions.check.js +6 -0
- package/schemas/plugins/HtmlParserOptions.json +3 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/types.d.ts +1456 -290
- package/lib/css/walkCssTokens.js +0 -2020
- package/lib/util/AppendOnlyStackedSet.js +0 -93
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Haijie Xie @hai-x
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Dependency = require("./Dependency");
|
|
9
|
+
|
|
10
|
+
/** @typedef {import("./Compilation")} Compilation */
|
|
11
|
+
/** @typedef {import("./Compilation").DependencyConstructor} DependencyConstructor */
|
|
12
|
+
/** @typedef {import("./Module")} Module */
|
|
13
|
+
/** @typedef {import("./ModuleFactory")} ModuleFactory */
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Defines the deferred request group type used by this module.
|
|
17
|
+
* @typedef {object} DependencyGroup
|
|
18
|
+
* @property {ModuleFactory} factory factory for the request
|
|
19
|
+
* @property {Dependency[]} dependencies deferred dependencies of the request
|
|
20
|
+
* @property {string | undefined} context request context
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Defines the lazy barrel state type used by this module.
|
|
25
|
+
* @typedef {object} LazyBarrelState
|
|
26
|
+
* @property {Set<string> | true} forwardedIds export names requested so far, true for all
|
|
27
|
+
* @property {LazyBarrelInfo | undefined} lazyBarrelInfo deferred dependencies, undefined until classified
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Defines the lazy barrel unlazy item type used by this module.
|
|
32
|
+
* @typedef {object} UnlazyDependencyInfo
|
|
33
|
+
* @property {ModuleFactory} factory factory for the request
|
|
34
|
+
* @property {Dependency[]} dependencies deferred dependencies of the request
|
|
35
|
+
* @property {string | undefined} context request context
|
|
36
|
+
* @property {Module} originModule the lazy barrel module
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Collects the export names a dependency group requests from its target.
|
|
41
|
+
* @param {Dependency[]} dependencies dependency group resolving to one module
|
|
42
|
+
* @returns {Set<string> | true} requested export names, true for all
|
|
43
|
+
*/
|
|
44
|
+
function getForwardedIds(dependencies) {
|
|
45
|
+
/** @type {Set<string>} */
|
|
46
|
+
const ids = new Set();
|
|
47
|
+
for (const dependency of dependencies) {
|
|
48
|
+
// TODO remove in webpack 6
|
|
49
|
+
// It may be missing on custom dependency types not extending the base Dependency
|
|
50
|
+
if (!("getForwardId" in dependency)) continue;
|
|
51
|
+
|
|
52
|
+
const id = dependency.getForwardId();
|
|
53
|
+
if (id === true) return true;
|
|
54
|
+
if (id !== null) ids.add(id);
|
|
55
|
+
}
|
|
56
|
+
return ids;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Tracks the deferred (not yet factorized/built) dependencies of a
|
|
61
|
+
* side-effect-free barrel module and which export names resolve to them.
|
|
62
|
+
*/
|
|
63
|
+
class LazyBarrelInfo {
|
|
64
|
+
constructor() {
|
|
65
|
+
/** @type {Map<string, string>} forward id -> request key */
|
|
66
|
+
this._forwardIdToRequest = new Map();
|
|
67
|
+
/** @type {Map<string, DependencyGroup>} request key -> still-deferred group */
|
|
68
|
+
this._requestToDepGroup = new Map();
|
|
69
|
+
/** @type {Set<string> | undefined} locally provided export names */
|
|
70
|
+
this._terminalIds = undefined;
|
|
71
|
+
/** @type {Set<string> | undefined} request keys of star re-exports */
|
|
72
|
+
this._fallbackRequests = undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Defers a dependency under its request key.
|
|
77
|
+
* @param {string} requestKey request key
|
|
78
|
+
* @param {Dependency} dependency dependency to defer
|
|
79
|
+
* @param {ModuleFactory} factory factory for the request
|
|
80
|
+
* @param {string | undefined} context request context
|
|
81
|
+
*/
|
|
82
|
+
addLazy(requestKey, dependency, factory, context) {
|
|
83
|
+
let group = this._requestToDepGroup.get(requestKey);
|
|
84
|
+
if (group === undefined) {
|
|
85
|
+
group = { factory, dependencies: [], context };
|
|
86
|
+
this._requestToDepGroup.set(requestKey, group);
|
|
87
|
+
}
|
|
88
|
+
group.dependencies.push(dependency);
|
|
89
|
+
dependency.setLazy(true);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Maps an export name to the request providing it.
|
|
94
|
+
* @param {string} id export name
|
|
95
|
+
* @param {string} requestKey request key
|
|
96
|
+
*/
|
|
97
|
+
addForwardId(id, requestKey) {
|
|
98
|
+
this._forwardIdToRequest.set(id, requestKey);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Registers a locally provided export name.
|
|
103
|
+
* @param {string} id export name
|
|
104
|
+
*/
|
|
105
|
+
addTerminal(id) {
|
|
106
|
+
if (this._terminalIds === undefined) this._terminalIds = new Set();
|
|
107
|
+
this._terminalIds.add(id);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Registers a star re-export request key.
|
|
112
|
+
* @param {string} requestKey request key
|
|
113
|
+
*/
|
|
114
|
+
addFallback(requestKey) {
|
|
115
|
+
if (this._fallbackRequests === undefined) {
|
|
116
|
+
this._fallbackRequests = new Set();
|
|
117
|
+
}
|
|
118
|
+
this._fallbackRequests.add(requestKey);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Returns whether nothing is deferred.
|
|
123
|
+
* @returns {boolean} true, when no dependency is deferred
|
|
124
|
+
*/
|
|
125
|
+
isEmpty() {
|
|
126
|
+
return this._requestToDepGroup.size === 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Drops the export-name lookups once no group stays deferred; they only serve
|
|
131
|
+
* to find still-deferred groups, so keeping them per module wastes memory.
|
|
132
|
+
*/
|
|
133
|
+
_release() {
|
|
134
|
+
this._forwardIdToRequest.clear();
|
|
135
|
+
this._terminalIds = undefined;
|
|
136
|
+
this._fallbackRequests = undefined;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Removes and returns the groups needed to provide the requested export names.
|
|
141
|
+
* @param {Set<string> | true} forwardedIds requested export names, true for all
|
|
142
|
+
* @returns {DependencyGroup[]} groups that must be processed now
|
|
143
|
+
*/
|
|
144
|
+
request(forwardedIds) {
|
|
145
|
+
/** @type {DependencyGroup[]} */
|
|
146
|
+
const result = [];
|
|
147
|
+
/**
|
|
148
|
+
* @param {DependencyGroup} group taken group
|
|
149
|
+
*/
|
|
150
|
+
const unlazy = (group) => {
|
|
151
|
+
for (const dependency of group.dependencies) {
|
|
152
|
+
dependency.setLazy(false);
|
|
153
|
+
}
|
|
154
|
+
result.push(group);
|
|
155
|
+
};
|
|
156
|
+
if (forwardedIds === true) {
|
|
157
|
+
for (const group of this._requestToDepGroup.values()) unlazy(group);
|
|
158
|
+
this._requestToDepGroup.clear();
|
|
159
|
+
this._release();
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* @param {string} requestKey request key to take
|
|
164
|
+
*/
|
|
165
|
+
const take = (requestKey) => {
|
|
166
|
+
const group = this._requestToDepGroup.get(requestKey);
|
|
167
|
+
if (group === undefined) return;
|
|
168
|
+
this._requestToDepGroup.delete(requestKey);
|
|
169
|
+
unlazy(group);
|
|
170
|
+
};
|
|
171
|
+
for (const id of forwardedIds) {
|
|
172
|
+
if (this._terminalIds !== undefined && this._terminalIds.has(id)) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
const requestKey = this._forwardIdToRequest.get(id);
|
|
176
|
+
if (requestKey !== undefined) {
|
|
177
|
+
take(requestKey);
|
|
178
|
+
} else if (this._fallbackRequests !== undefined) {
|
|
179
|
+
// unknown name: any star re-export may provide it
|
|
180
|
+
for (const fallbackKey of this._fallbackRequests) take(fallbackKey);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (this._requestToDepGroup.size === 0) this._release();
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const esmDependencyCategory = "esm";
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Owns the per side-effect-free module lazy barrel state for a `Compilation`,
|
|
192
|
+
* keeping the deferral bookkeeping out of `Compilation` itself.
|
|
193
|
+
*/
|
|
194
|
+
class LazyBarrelController {
|
|
195
|
+
/**
|
|
196
|
+
* @param {Compilation} compilation the owning compilation
|
|
197
|
+
*/
|
|
198
|
+
constructor(compilation) {
|
|
199
|
+
/** @type {Compilation} */
|
|
200
|
+
this._compilation = compilation;
|
|
201
|
+
/** @type {WeakMap<Module, LazyBarrelState>} */
|
|
202
|
+
this._modules = new WeakMap();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Releases all per-module deferral state. Lazy barrel only acts while the
|
|
207
|
+
* module graph is built, so the bookkeeping is dead weight once make is done.
|
|
208
|
+
*/
|
|
209
|
+
clear() {
|
|
210
|
+
this._modules = new WeakMap();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Classifies the re-export dependencies of a side-effect-free module (lazy barrel)
|
|
215
|
+
* into deferrable groups and marks the deferred ones.
|
|
216
|
+
* @param {Module} module the module whose dependencies are processed
|
|
217
|
+
* @returns {boolean} true, when some dependencies were deferred
|
|
218
|
+
*/
|
|
219
|
+
classify(module) {
|
|
220
|
+
const modules = this._modules;
|
|
221
|
+
const factoryMeta = module.factoryMeta;
|
|
222
|
+
if (factoryMeta === undefined || !factoryMeta.sideEffectFree) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
const dependencies = module.dependencies;
|
|
226
|
+
const dependencyFactories = this._compilation.dependencyFactories;
|
|
227
|
+
/** @type {LazyBarrelInfo | undefined} */
|
|
228
|
+
let info;
|
|
229
|
+
let hasFallback = false;
|
|
230
|
+
for (const dep of dependencies) {
|
|
231
|
+
// TODO remove in webpack 6
|
|
232
|
+
// It may be missing on custom dependency types not extending the base Dependency
|
|
233
|
+
if (!("getLazyUntil" in dep)) continue;
|
|
234
|
+
|
|
235
|
+
const until = dep.getLazyUntil();
|
|
236
|
+
// null (eager) and LAZY_UNTIL_LOCAL (terminal) defer nothing; terminals are
|
|
237
|
+
// only consulted alongside a star re-export, so they are recorded below
|
|
238
|
+
if (until === null || until === Dependency.LAZY_UNTIL_LOCAL) continue;
|
|
239
|
+
// deferrable: setLazy is needed to toggle its deferred state
|
|
240
|
+
if (!("setLazy" in dep)) continue;
|
|
241
|
+
const resourceIdent = dep.getResourceIdentifier();
|
|
242
|
+
if (resourceIdent === null) continue;
|
|
243
|
+
const factory = dependencyFactories.get(
|
|
244
|
+
/** @type {DependencyConstructor} */ (dep.constructor)
|
|
245
|
+
);
|
|
246
|
+
if (factory === undefined) continue;
|
|
247
|
+
const category = dep.category;
|
|
248
|
+
// Match the request grouping key of `processDependencyForResolving`
|
|
249
|
+
const requestKey =
|
|
250
|
+
category === esmDependencyCategory
|
|
251
|
+
? resourceIdent
|
|
252
|
+
: `${category}${resourceIdent}`;
|
|
253
|
+
if (info === undefined) info = new LazyBarrelInfo();
|
|
254
|
+
info.addLazy(requestKey, dep, factory, dep.getContext());
|
|
255
|
+
if (until === Dependency.LAZY_UNTIL_ID) {
|
|
256
|
+
info.addForwardId(
|
|
257
|
+
/** @type {string} */ (dep.getLazyName()),
|
|
258
|
+
requestKey
|
|
259
|
+
);
|
|
260
|
+
} else if (until === Dependency.LAZY_UNTIL_FALLBACK) {
|
|
261
|
+
info.addFallback(requestKey);
|
|
262
|
+
hasFallback = true;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const state = modules.get(module);
|
|
266
|
+
// info is only created once a deferrable target exists, so it is never empty here
|
|
267
|
+
if (info === undefined) {
|
|
268
|
+
if (state !== undefined) modules.delete(module);
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
// terminals only matter together with a star re-export (to avoid building it
|
|
272
|
+
// for a locally-provided name); skip the extra pass otherwise
|
|
273
|
+
if (hasFallback) {
|
|
274
|
+
for (const dep of dependencies) {
|
|
275
|
+
if (
|
|
276
|
+
"getLazyUntil" in dep &&
|
|
277
|
+
dep.getLazyUntil() === Dependency.LAZY_UNTIL_LOCAL
|
|
278
|
+
) {
|
|
279
|
+
info.addTerminal(/** @type {string} */ (dep.getLazyName()));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (state !== undefined) {
|
|
284
|
+
// barrel classified after its targets were already requested: replay the
|
|
285
|
+
// recorded ids so processDependency un-lazies and builds those targets now
|
|
286
|
+
info.request(state.forwardedIds);
|
|
287
|
+
// stay lazy only while some targets remain deferred
|
|
288
|
+
if (info.isEmpty()) return false;
|
|
289
|
+
state.lazyBarrelInfo = info;
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
modules.set(module, {
|
|
294
|
+
forwardedIds: new Set(),
|
|
295
|
+
lazyBarrelInfo: info
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Requests the export names that `dependencies` need from a lazy barrel and
|
|
303
|
+
* returns the deferred re-export targets that must be built now. Records the
|
|
304
|
+
* request when the barrel's dependencies were not classified yet.
|
|
305
|
+
* @param {Module} module the resolved module
|
|
306
|
+
* @param {Dependency[]} dependencies the dependencies that resolved to the module
|
|
307
|
+
* @returns {UnlazyDependencyInfo[] | undefined} items to process, if any
|
|
308
|
+
*/
|
|
309
|
+
request(module, dependencies) {
|
|
310
|
+
// state only exists for side-effect-free modules, so a non-side-effect-free
|
|
311
|
+
// module never has state — skip the WeakMap lookup entirely for it
|
|
312
|
+
const factoryMeta = module.factoryMeta;
|
|
313
|
+
if (factoryMeta === undefined || !factoryMeta.sideEffectFree) return;
|
|
314
|
+
const modules = this._modules;
|
|
315
|
+
const state = modules.get(module);
|
|
316
|
+
|
|
317
|
+
if (state === undefined) {
|
|
318
|
+
const forwardedIds = getForwardedIds(dependencies);
|
|
319
|
+
if (forwardedIds !== true && forwardedIds.size === 0) return;
|
|
320
|
+
modules.set(module, {
|
|
321
|
+
forwardedIds,
|
|
322
|
+
lazyBarrelInfo: undefined
|
|
323
|
+
});
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const forwardedIds = getForwardedIds(dependencies);
|
|
328
|
+
if (forwardedIds !== true && forwardedIds.size === 0) return;
|
|
329
|
+
if (state.forwardedIds !== true) {
|
|
330
|
+
if (forwardedIds === true) state.forwardedIds = true;
|
|
331
|
+
else for (const id of forwardedIds) state.forwardedIds.add(id);
|
|
332
|
+
}
|
|
333
|
+
const info = state.lazyBarrelInfo;
|
|
334
|
+
// Pending requests will be replayed during `classify` later
|
|
335
|
+
if (info === undefined) return;
|
|
336
|
+
const groups = info.request(forwardedIds);
|
|
337
|
+
// drop the per-module state once every deferred target has been built
|
|
338
|
+
if (info.isEmpty()) state.lazyBarrelInfo = undefined;
|
|
339
|
+
if (groups.length === 0) return;
|
|
340
|
+
return groups.map((group) => ({
|
|
341
|
+
factory: group.factory,
|
|
342
|
+
dependencies: group.dependencies,
|
|
343
|
+
context: group.context,
|
|
344
|
+
originModule: module
|
|
345
|
+
}));
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Queues the deferred dependency groups of a lazy barrel requested by a single dependency.
|
|
350
|
+
* @param {Module} module the resolved module of the dependency
|
|
351
|
+
* @param {Dependency} dependency the requesting dependency
|
|
352
|
+
* @param {{ factory: ModuleFactory, dependencies: Dependency[], context: string | undefined, originModule: Module | null }[]} sortedDependencies item list to append to
|
|
353
|
+
*/
|
|
354
|
+
unlazyForDependency(module, dependency, sortedDependencies) {
|
|
355
|
+
const unlazyItems = this.request(module, [dependency]);
|
|
356
|
+
if (unlazyItems === undefined) return;
|
|
357
|
+
for (const item of unlazyItems) sortedDependencies.push(item);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
module.exports = LazyBarrelController;
|
package/lib/Module.js
CHANGED
|
@@ -33,11 +33,9 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
33
33
|
/** @typedef {import("./ConcatenationScope")} ConcatenationScope */
|
|
34
34
|
/** @typedef {import("./Dependency")} Dependency */
|
|
35
35
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
|
36
|
-
/** @typedef {import("./DependencyTemplate").CssData} CssData */
|
|
37
36
|
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
|
38
37
|
/** @typedef {import("./ModuleSourceTypeConstants").AllTypes} AllTypes */
|
|
39
38
|
/** @typedef {import("./FileSystemInfo")} FileSystemInfo */
|
|
40
|
-
/** @typedef {import("./FileSystemInfo").Snapshot} Snapshot */
|
|
41
39
|
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
42
40
|
/** @typedef {import("./ModuleTypeConstants").ModuleTypes} ModuleTypes */
|
|
43
41
|
/** @typedef {import("./ModuleGraph").OptimizationBailouts} OptimizationBailouts */
|
|
@@ -52,7 +50,6 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
52
50
|
* @typedef {import("./InitFragment")<T>} InitFragment
|
|
53
51
|
*/
|
|
54
52
|
/** @typedef {import("./errors/WebpackError")} WebpackError */
|
|
55
|
-
/** @typedef {import("./json/JsonData")} JsonData */
|
|
56
53
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
57
54
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
58
55
|
/** @typedef {import("./util/Hash")} Hash */
|
|
@@ -118,6 +115,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
118
115
|
* Defines the all code generation schemas type used by this module.
|
|
119
116
|
* @typedef {object} AllCodeGenerationSchemas
|
|
120
117
|
* @property {Set<string>} topLevelDeclarations top level declarations for javascript modules
|
|
118
|
+
* @property {Set<string>} freeNames free identifier names in the rendered source for javascript modules
|
|
121
119
|
* @property {InitFragment<EXPECTED_ANY>[]} chunkInitFragments chunk init fragments for javascript modules
|
|
122
120
|
* @property {{ javascript?: string, ["asset-url"]?: string }} url url for asset modules
|
|
123
121
|
* @property {string} filename a filename for asset modules
|
|
@@ -165,51 +163,29 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
165
163
|
*/
|
|
166
164
|
|
|
167
165
|
/**
|
|
168
|
-
* Defines the
|
|
166
|
+
* Defines the build meta properties common to all module types.
|
|
167
|
+
* Module type specific properties live in the `Known*BuildMeta` typedef of the dedicated module class.
|
|
169
168
|
* @typedef {object} KnownBuildMeta
|
|
170
169
|
* @property {("default" | "namespace" | "flagged" | "dynamic")=} exportsType
|
|
171
170
|
* @property {(false | "redirect" | "redirect-warn")=} defaultObject
|
|
172
|
-
* @property {boolean=} strictHarmonyModule
|
|
173
|
-
* @property {boolean=} treatAsCommonJs
|
|
174
171
|
* @property {boolean=} async
|
|
175
172
|
* @property {boolean=} sideEffectFree
|
|
176
|
-
* @property {
|
|
177
|
-
* @property {
|
|
178
|
-
* @property {Record<string, string>=} jsIncompatibleExports
|
|
179
|
-
* @property {Map<string, Record<string, string>>=} exportsFinalNameByRuntime
|
|
180
|
-
* @property {Map<string, string>=} exportsSourceByRuntime
|
|
173
|
+
* @property {Map<string, Record<string, string>>=} exportsFinalNameByRuntime using in ModuleLibraryPlugin
|
|
174
|
+
* @property {Map<string, string>=} exportsSourceByRuntime using in ModuleLibraryPlugin
|
|
181
175
|
*/
|
|
182
176
|
|
|
183
177
|
/**
|
|
184
|
-
* Defines the
|
|
178
|
+
* Defines the build info properties common to all module types.
|
|
179
|
+
* Module type specific properties live in the `Known*BuildInfo` typedef of the dedicated module class.
|
|
185
180
|
* @typedef {object} KnownBuildInfo
|
|
186
181
|
* @property {boolean=} cacheable
|
|
187
|
-
* @property {boolean=} parsed
|
|
188
182
|
* @property {boolean=} strict
|
|
189
|
-
* @property {string=} moduleArgument
|
|
190
|
-
* @property {string=} exportsArgument
|
|
191
|
-
* @property {string
|
|
192
|
-
* @property {
|
|
193
|
-
* @property {string=} resourceIntegrity using in HttpUriPlugin
|
|
194
|
-
* @property {FileSystemDependencies=} fileDependencies using in NormalModule
|
|
195
|
-
* @property {FileSystemDependencies=} contextDependencies using in NormalModule
|
|
196
|
-
* @property {FileSystemDependencies=} missingDependencies using in NormalModule
|
|
197
|
-
* @property {FileSystemDependencies=} buildDependencies using in NormalModule
|
|
198
|
-
* @property {ValueCacheVersions=} valueDependencies using in NormalModule
|
|
199
|
-
* @property {Record<string, Source>=} assets using in NormalModule
|
|
200
|
-
* @property {Map<string, AssetInfo | undefined>=} assetsInfo using in NormalModule
|
|
201
|
-
* @property {string=} hash using in NormalModule
|
|
202
|
-
* @property {(Snapshot | null)=} snapshot using in ContextModule
|
|
203
|
-
* @property {string=} fullContentHash for assets modules
|
|
204
|
-
* @property {string=} filename for assets modules
|
|
205
|
-
* @property {boolean=} dataUrl for assets modules
|
|
206
|
-
* @property {AssetInfo=} assetInfo for assets modules
|
|
207
|
-
* @property {boolean=} javascriptModule for external modules
|
|
208
|
-
* @property {boolean=} active for lazy compilation modules
|
|
209
|
-
* @property {CssData=} cssData for css modules
|
|
210
|
-
* @property {string=} charset for css modules (charset at-rule)
|
|
211
|
-
* @property {JsonData=} jsonData for json modules
|
|
183
|
+
* @property {string=} moduleArgument
|
|
184
|
+
* @property {string=} exportsArgument
|
|
185
|
+
* @property {Record<string, Source>=} assets assets added by loaders or plugins
|
|
186
|
+
* @property {Map<string, AssetInfo | undefined>=} assetsInfo
|
|
212
187
|
* @property {Set<string>=} topLevelDeclarations top level declaration names
|
|
188
|
+
* @property {boolean=} isCircular true when the module is part of a circular dependency chain
|
|
213
189
|
*/
|
|
214
190
|
|
|
215
191
|
/** @typedef {string | Set<string>} ValueCacheVersion */
|
|
@@ -299,15 +275,12 @@ class Module extends DependenciesBlock {
|
|
|
299
275
|
/** @type {boolean} */
|
|
300
276
|
this.useSimpleSourceMap = false;
|
|
301
277
|
|
|
302
|
-
// Is in hot context, i.e. HotModuleReplacementPlugin.js enabled
|
|
303
|
-
// TODO do we need hot here?
|
|
304
|
-
/** @type {boolean} */
|
|
305
|
-
this.hot = false;
|
|
306
278
|
// Info from Build
|
|
307
279
|
/** @type {Error[] | undefined} */
|
|
308
280
|
this._warnings = undefined;
|
|
309
281
|
/** @type {Error[] | undefined} */
|
|
310
282
|
this._errors = undefined;
|
|
283
|
+
// Subclasses with type specific build info/meta redeclare these with a narrowed type
|
|
311
284
|
/** @type {BuildMeta | undefined} */
|
|
312
285
|
this.buildMeta = undefined;
|
|
313
286
|
/** @type {BuildInfo | undefined} */
|
|
@@ -1076,6 +1049,14 @@ class Module extends DependenciesBlock {
|
|
|
1076
1049
|
return JAVASCRIPT_TYPES;
|
|
1077
1050
|
}
|
|
1078
1051
|
|
|
1052
|
+
/**
|
|
1053
|
+
* Freshly recomputed source types when they depend on incoming connections, for chunk-graph cache invalidation; undefined otherwise. #20800
|
|
1054
|
+
* @returns {SourceTypes | undefined} source types or undefined
|
|
1055
|
+
*/
|
|
1056
|
+
getReferencedSourceTypes() {
|
|
1057
|
+
return undefined;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1079
1060
|
/**
|
|
1080
1061
|
* Basic source types are high-level categories like javascript, css, webassembly, etc.
|
|
1081
1062
|
* We only have built-in knowledge about the javascript basic type here; other basic types may be
|
|
@@ -1301,7 +1282,6 @@ class Module extends DependenciesBlock {
|
|
|
1301
1282
|
write(this.factoryMeta);
|
|
1302
1283
|
write(this.useSourceMap);
|
|
1303
1284
|
write(this.useSimpleSourceMap);
|
|
1304
|
-
write(this.hot);
|
|
1305
1285
|
write(
|
|
1306
1286
|
this._warnings !== undefined && this._warnings.length === 0
|
|
1307
1287
|
? undefined
|
|
@@ -1332,7 +1312,6 @@ class Module extends DependenciesBlock {
|
|
|
1332
1312
|
this.factoryMeta = read();
|
|
1333
1313
|
this.useSourceMap = read();
|
|
1334
1314
|
this.useSimpleSourceMap = read();
|
|
1335
|
-
this.hot = read();
|
|
1336
1315
|
this._warnings = read();
|
|
1337
1316
|
this._errors = read();
|
|
1338
1317
|
this.buildMeta = read();
|
package/lib/ModuleGraph.js
CHANGED
|
@@ -262,7 +262,8 @@ class ModuleGraph {
|
|
|
262
262
|
dependency,
|
|
263
263
|
module,
|
|
264
264
|
undefined,
|
|
265
|
-
dependency
|
|
265
|
+
// weak is defined on ModuleDependency; undefined for other dependency kinds
|
|
266
|
+
/** @type {{ weak?: boolean }} */ (dependency).weak,
|
|
266
267
|
dependency.getCondition(this)
|
|
267
268
|
);
|
|
268
269
|
const connections = this._getModuleGraphModule(module).incomingConnections;
|
|
@@ -980,7 +981,7 @@ class ModuleGraph {
|
|
|
980
981
|
*/
|
|
981
982
|
cached(fn, ...args) {
|
|
982
983
|
if (this._cache === undefined) return fn(this, ...args);
|
|
983
|
-
return this._cache.
|
|
984
|
+
return this._cache.cachedProvide(fn, this, args);
|
|
984
985
|
}
|
|
985
986
|
|
|
986
987
|
/**
|
package/lib/ModuleProfile.js
CHANGED
|
@@ -7,39 +7,65 @@
|
|
|
7
7
|
|
|
8
8
|
class ModuleProfile {
|
|
9
9
|
constructor() {
|
|
10
|
+
/** @type {number} */
|
|
10
11
|
this.startTime = Date.now();
|
|
11
12
|
|
|
13
|
+
/** @type {number} */
|
|
12
14
|
this.factoryStartTime = 0;
|
|
15
|
+
/** @type {number} */
|
|
13
16
|
this.factoryEndTime = 0;
|
|
17
|
+
/** @type {number} */
|
|
14
18
|
this.factory = 0;
|
|
19
|
+
/** @type {number} */
|
|
15
20
|
this.factoryParallelismFactor = 0;
|
|
16
21
|
|
|
22
|
+
/** @type {number} */
|
|
17
23
|
this.restoringStartTime = 0;
|
|
24
|
+
/** @type {number} */
|
|
18
25
|
this.restoringEndTime = 0;
|
|
26
|
+
/** @type {number} */
|
|
19
27
|
this.restoring = 0;
|
|
28
|
+
/** @type {number} */
|
|
20
29
|
this.restoringParallelismFactor = 0;
|
|
21
30
|
|
|
31
|
+
/** @type {number} */
|
|
22
32
|
this.integrationStartTime = 0;
|
|
33
|
+
/** @type {number} */
|
|
23
34
|
this.integrationEndTime = 0;
|
|
35
|
+
/** @type {number} */
|
|
24
36
|
this.integration = 0;
|
|
37
|
+
/** @type {number} */
|
|
25
38
|
this.integrationParallelismFactor = 0;
|
|
26
39
|
|
|
40
|
+
/** @type {number} */
|
|
27
41
|
this.buildingStartTime = 0;
|
|
42
|
+
/** @type {number} */
|
|
28
43
|
this.buildingEndTime = 0;
|
|
44
|
+
/** @type {number} */
|
|
29
45
|
this.building = 0;
|
|
46
|
+
/** @type {number} */
|
|
30
47
|
this.buildingParallelismFactor = 0;
|
|
31
48
|
|
|
49
|
+
/** @type {number} */
|
|
32
50
|
this.storingStartTime = 0;
|
|
51
|
+
/** @type {number} */
|
|
33
52
|
this.storingEndTime = 0;
|
|
53
|
+
/** @type {number} */
|
|
34
54
|
this.storing = 0;
|
|
55
|
+
/** @type {number} */
|
|
35
56
|
this.storingParallelismFactor = 0;
|
|
36
57
|
|
|
37
58
|
/** @type {{ start: number, end: number }[] | undefined} */
|
|
38
59
|
this.additionalFactoryTimes = undefined;
|
|
60
|
+
/** @type {number} */
|
|
39
61
|
this.additionalFactories = 0;
|
|
62
|
+
/** @type {number} */
|
|
40
63
|
this.additionalFactoriesParallelismFactor = 0;
|
|
41
64
|
|
|
42
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated
|
|
67
|
+
* @type {number}
|
|
68
|
+
*/
|
|
43
69
|
this.additionalIntegration = 0;
|
|
44
70
|
}
|
|
45
71
|
|
package/lib/ModuleTemplate.js
CHANGED
|
@@ -37,7 +37,9 @@ class ModuleTemplate {
|
|
|
37
37
|
* @param {Compilation} compilation the compilation
|
|
38
38
|
*/
|
|
39
39
|
constructor(runtimeTemplate, compilation) {
|
|
40
|
+
/** @type {RuntimeTemplate} */
|
|
40
41
|
this._runtimeTemplate = runtimeTemplate;
|
|
42
|
+
/** @type {string} */
|
|
41
43
|
this.type = "javascript";
|
|
42
44
|
this.hooks = Object.freeze({
|
|
43
45
|
content: {
|
package/lib/MultiCompiler.js
CHANGED
|
@@ -92,6 +92,7 @@ module.exports = class MultiCompiler {
|
|
|
92
92
|
compilers.map((c) => c.hooks.infrastructureLog)
|
|
93
93
|
)
|
|
94
94
|
});
|
|
95
|
+
/** @type {Compiler[]} */
|
|
95
96
|
this.compilers = compilers;
|
|
96
97
|
/** @type {MultiCompilerOptions} */
|
|
97
98
|
this._options = {
|
|
@@ -99,6 +100,7 @@ module.exports = class MultiCompiler {
|
|
|
99
100
|
};
|
|
100
101
|
/** @type {WeakMap<Compiler, string[]>} */
|
|
101
102
|
this.dependencies = new WeakMap();
|
|
103
|
+
/** @type {boolean} */
|
|
102
104
|
this.running = false;
|
|
103
105
|
|
|
104
106
|
/** @type {(Stats | null)[]} */
|
package/lib/MultiStats.js
CHANGED
package/lib/MultiWatching.js
CHANGED