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
package/lib/Compilation.js
CHANGED
|
@@ -28,6 +28,7 @@ const DependencyTemplates = require("./DependencyTemplates");
|
|
|
28
28
|
const Entrypoint = require("./Entrypoint");
|
|
29
29
|
const ErrorHelpers = require("./ErrorHelpers");
|
|
30
30
|
const FileSystemInfo = require("./FileSystemInfo");
|
|
31
|
+
const LazyBarrelController = require("./LazyBarrel");
|
|
31
32
|
const MainTemplate = require("./MainTemplate");
|
|
32
33
|
const Module = require("./Module");
|
|
33
34
|
const ModuleGraph = require("./ModuleGraph");
|
|
@@ -108,6 +109,7 @@ const { isSourceEqual } = require("./util/source");
|
|
|
108
109
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
|
109
110
|
/** @typedef {import("./Module").ValueCacheVersions} ValueCacheVersions */
|
|
110
111
|
/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
|
|
112
|
+
/** @typedef {import("./Module").SourceTypes} SourceTypes */
|
|
111
113
|
/** @typedef {import("./NormalModule").NormalModuleCompilationHooks} NormalModuleCompilationHooks */
|
|
112
114
|
/** @typedef {import("./Module").FactoryMeta} FactoryMeta */
|
|
113
115
|
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
|
@@ -212,8 +214,10 @@ const { isSourceEqual } = require("./util/source");
|
|
|
212
214
|
* @property {string=} name
|
|
213
215
|
* @property {string} hash
|
|
214
216
|
* @property {HashWithLengthFunction=} hashWithLength
|
|
217
|
+
* @property {HashWithDigestFunction=} hashWithDigest builds `[chunkhash:<digest>]` per chunk in the runtime chunk-filename map
|
|
215
218
|
* @property {(Record<string, string>)=} contentHash
|
|
216
219
|
* @property {(Record<string, HashWithLengthFunction>)=} contentHashWithLength
|
|
220
|
+
* @property {(Record<string, HashWithDigestFunction>)=} contentHashWithDigest builds `[contenthash:<digest>]` per chunk in the runtime chunk-filename map
|
|
217
221
|
*/
|
|
218
222
|
|
|
219
223
|
/**
|
|
@@ -318,6 +322,7 @@ const { isSourceEqual } = require("./util/source");
|
|
|
318
322
|
* @property {string | string[]=} chunkhash the value(s) of the chunk hash used for this asset
|
|
319
323
|
* @property {string | string[]=} modulehash the value(s) of the module hash used for this asset
|
|
320
324
|
* @property {string | string[]=} contenthash the value(s) of the content hash used for this asset
|
|
325
|
+
* @property {Record<string, string>=} contenthashDigest maps a `[contenthash:<digest>]` value to its digest, so `RealContentHashPlugin` re-encodes the recomputed hash in it
|
|
321
326
|
* @property {string=} sourceFilename when asset was created from a source file (potentially transformed), the original filename relative to compilation context
|
|
322
327
|
* @property {number=} size size in bytes, only set after asset has been emitted
|
|
323
328
|
* @property {boolean=} development true, when asset is only used for development and doesn't count towards user-facing assets
|
|
@@ -341,6 +346,8 @@ const { isSourceEqual } = require("./util/source");
|
|
|
341
346
|
|
|
342
347
|
/** @typedef {(length: number) => string} HashWithLengthFunction */
|
|
343
348
|
|
|
349
|
+
/** @typedef {(digest: string, length?: number) => string} HashWithDigestFunction */
|
|
350
|
+
|
|
344
351
|
/**
|
|
345
352
|
* Defines the module path data type used by this module.
|
|
346
353
|
* @typedef {object} ModulePathData
|
|
@@ -356,7 +363,10 @@ const { isSourceEqual } = require("./util/source");
|
|
|
356
363
|
* @typedef {object} PathData
|
|
357
364
|
* @property {ChunkGraph=} chunkGraph
|
|
358
365
|
* @property {string=} hash
|
|
366
|
+
* @property {string=} fullHash untruncated compilation hash, for re-encoding `[fullhash:<digest>]`
|
|
367
|
+
* @property {string=} fullHashDigest digest `fullHash` is encoded in (defaults to `hashDigest`)
|
|
359
368
|
* @property {HashWithLengthFunction=} hashWithLength
|
|
369
|
+
* @property {HashWithDigestFunction=} hashWithDigest builds `[fullhash:<digest>]`/`[hash:<digest>]` in the runtime chunk-filename context, where it throws because a runtime `getFullHash()` expression cannot be re-encoded
|
|
360
370
|
* @property {(Chunk | ChunkPathData)=} chunk
|
|
361
371
|
* @property {(Module | ModulePathData)=} module
|
|
362
372
|
* @property {RuntimeSpec=} runtime
|
|
@@ -365,10 +375,15 @@ const { isSourceEqual } = require("./util/source");
|
|
|
365
375
|
* @property {string=} query
|
|
366
376
|
* @property {string=} contentHashType
|
|
367
377
|
* @property {string=} contentHash
|
|
378
|
+
* @property {string=} contentHashFull untruncated module/asset content hash, for re-encoding `[contenthash:<digest>]` from full entropy
|
|
368
379
|
* @property {HashWithLengthFunction=} contentHashWithLength
|
|
380
|
+
* @property {string=} hashDigest digest the stored hashes are encoded in (for `[hash:<digest>]`)
|
|
381
|
+
* @property {boolean=} realContentHash whether `optimization.realContentHash` recomputes content hashes (records an inline `[contenthash:<digest>]` so it re-encodes in that digest)
|
|
382
|
+
* @property {boolean=} hashAsFullHash treat `[hash]` as `[fullhash]` rather than the module hash (CSS local idents)
|
|
369
383
|
* @property {boolean=} noChunkHash
|
|
370
384
|
* @property {string=} url
|
|
371
385
|
* @property {string=} local
|
|
386
|
+
* @property {string=} uniqueName
|
|
372
387
|
* @property {PrepareIdFunction=} prepareId
|
|
373
388
|
*/
|
|
374
389
|
|
|
@@ -545,7 +560,38 @@ const unsafeCacheDependencies = new WeakMap();
|
|
|
545
560
|
/** @type {WeakMap<ModuleWithRestoreFromUnsafeCache, UnsafeCacheData>} */
|
|
546
561
|
const unsafeCacheData = new WeakMap();
|
|
547
562
|
|
|
548
|
-
/** @typedef {
|
|
563
|
+
/** @typedef {EXPECTED_OBJECT} DependencyReportCacheToken */
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Renewed when the module or a transitively referenced module is rebuilt.
|
|
567
|
+
* @type {WeakMap<Module, DependencyReportCacheToken>}
|
|
568
|
+
*/
|
|
569
|
+
const dependencyReportCacheTokens = new WeakMap();
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Modules known to have no dependency errors/warnings, per cache token.
|
|
573
|
+
* @type {WeakMap<DependencyReportCacheToken, WeakSet<Module>>}
|
|
574
|
+
*/
|
|
575
|
+
const modulesWithoutProblems = new WeakMap();
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Reduce affect type.
|
|
579
|
+
* @param {Readonly<ModuleGraphConnection[]>} connections connections
|
|
580
|
+
* @returns {symbol | boolean} result
|
|
581
|
+
*/
|
|
582
|
+
const reduceAffectType = (connections) => {
|
|
583
|
+
let affected = false;
|
|
584
|
+
for (const { dependency } of connections) {
|
|
585
|
+
if (!dependency) continue;
|
|
586
|
+
const type = dependency.couldAffectReferencingModule();
|
|
587
|
+
if (type === Dependency.TRANSITIVE) return Dependency.TRANSITIVE;
|
|
588
|
+
if (type === false) continue;
|
|
589
|
+
affected = true;
|
|
590
|
+
}
|
|
591
|
+
return affected;
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
/** @typedef {{ id: ModuleId, modules?: Map<Module, ModuleId>, blocks?: (ChunkId | null)[], sourceTypes?: SourceTypes }} References */
|
|
549
595
|
/** @typedef {Map<Module, WeakTupleMap<EXPECTED_ANY[], EXPECTED_ANY>>} ModuleMemCaches */
|
|
550
596
|
|
|
551
597
|
class Compilation {
|
|
@@ -555,6 +601,7 @@ class Compilation {
|
|
|
555
601
|
* @param {CompilationParams} params the compilation parameters
|
|
556
602
|
*/
|
|
557
603
|
constructor(compiler, params) {
|
|
604
|
+
/** @type {boolean} */
|
|
558
605
|
this._backCompat = compiler._backCompat;
|
|
559
606
|
|
|
560
607
|
const getNormalModuleLoader = () => deprecatedNormalModuleLoaderHook(this);
|
|
@@ -1115,6 +1162,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1115
1162
|
this.inputFileSystem =
|
|
1116
1163
|
/** @type {InputFileSystem} */
|
|
1117
1164
|
(compiler.inputFileSystem);
|
|
1165
|
+
/** @type {FileSystemInfo} */
|
|
1118
1166
|
this.fileSystemInfo = new FileSystemInfo(this.inputFileSystem, {
|
|
1119
1167
|
unmanagedPaths: compiler.unmanagedPaths,
|
|
1120
1168
|
managedPaths: compiler.managedPaths,
|
|
@@ -1133,7 +1181,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1133
1181
|
}
|
|
1134
1182
|
/** @type {ValueCacheVersions} */
|
|
1135
1183
|
this.valueCacheVersions = new Map();
|
|
1184
|
+
/** @type {RequestShortener} */
|
|
1136
1185
|
this.requestShortener = compiler.requestShortener;
|
|
1186
|
+
/** @type {string} */
|
|
1137
1187
|
this.compilerPath = compiler.compilerPath;
|
|
1138
1188
|
|
|
1139
1189
|
this.logger = this.getLogger("webpack.Compilation");
|
|
@@ -1148,9 +1198,13 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1148
1198
|
/** @type {boolean} */
|
|
1149
1199
|
this.profile = (options && options.profile) || false;
|
|
1150
1200
|
|
|
1201
|
+
/** @type {CompilationParams} */
|
|
1151
1202
|
this.params = params;
|
|
1203
|
+
/** @type {MainTemplate} */
|
|
1152
1204
|
this.mainTemplate = new MainTemplate(this.outputOptions, this);
|
|
1205
|
+
/** @type {ChunkTemplate} */
|
|
1153
1206
|
this.chunkTemplate = new ChunkTemplate(this.outputOptions, this);
|
|
1207
|
+
/** @type {RuntimeTemplate} */
|
|
1154
1208
|
this.runtimeTemplate = new RuntimeTemplate(
|
|
1155
1209
|
this,
|
|
1156
1210
|
this.outputOptions,
|
|
@@ -1260,6 +1314,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1260
1314
|
this.assetsInfo = new Map();
|
|
1261
1315
|
/** @type {Map<string, Map<string, Set<string>>>} */
|
|
1262
1316
|
this._assetsRelatedIn = new Map();
|
|
1317
|
+
/** @type {Map<string, Set<Chunk>> | undefined} */
|
|
1318
|
+
this._assetToChunkIndex = undefined;
|
|
1319
|
+
/** @type {Map<string, Set<Chunk>> | undefined} */
|
|
1320
|
+
this._assetToChunkAuxiliaryIndex = undefined;
|
|
1263
1321
|
/** @type {Error[]} */
|
|
1264
1322
|
this.errors = [];
|
|
1265
1323
|
/** @type {Error[]} */
|
|
@@ -1322,8 +1380,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1322
1380
|
)
|
|
1323
1381
|
};
|
|
1324
1382
|
|
|
1383
|
+
/** @type {CacheFacade} */
|
|
1325
1384
|
this._modulesCache = this.getCache("Compilation/modules");
|
|
1385
|
+
/** @type {CacheFacade} */
|
|
1326
1386
|
this._assetsCache = this.getCache("Compilation/assets");
|
|
1387
|
+
/** @type {CacheFacade} */
|
|
1327
1388
|
this._codeGenerationCache = this.getCache("Compilation/codeGeneration");
|
|
1328
1389
|
|
|
1329
1390
|
const unsafeCache = options.module.unsafeCache;
|
|
@@ -1332,6 +1393,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1332
1393
|
/** @type {UnsafeCachePredicate} */
|
|
1333
1394
|
this._unsafeCachePredicate =
|
|
1334
1395
|
typeof unsafeCache === "function" ? unsafeCache : () => true;
|
|
1396
|
+
|
|
1397
|
+
/**
|
|
1398
|
+
* @private
|
|
1399
|
+
* @type {LazyBarrelController}
|
|
1400
|
+
*/
|
|
1401
|
+
this._lazyBarrelController = new LazyBarrelController(this);
|
|
1335
1402
|
}
|
|
1336
1403
|
|
|
1337
1404
|
getStats() {
|
|
@@ -1451,7 +1518,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1451
1518
|
typeof console.profileEnd === "function"
|
|
1452
1519
|
) {
|
|
1453
1520
|
console.profileEnd(
|
|
1454
|
-
`[${name}] ${
|
|
1521
|
+
`[${name}] ${
|
|
1522
|
+
/** @type {NonNullable<LogEntry["args"]>} */ (logEntry.args)[0]
|
|
1523
|
+
}`
|
|
1455
1524
|
);
|
|
1456
1525
|
}
|
|
1457
1526
|
if (logEntries === undefined) {
|
|
@@ -1739,6 +1808,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1739
1808
|
Dependency.isLowPriorityDependency
|
|
1740
1809
|
);
|
|
1741
1810
|
|
|
1811
|
+
// lazy barrel: defer re-export targets of side-effect-free modules
|
|
1812
|
+
const hasLazyBarrel = this._lazyBarrelController.classify(module);
|
|
1813
|
+
|
|
1742
1814
|
/** @type {DependenciesBlock} */
|
|
1743
1815
|
let currentBlock;
|
|
1744
1816
|
|
|
@@ -1818,6 +1890,16 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1818
1890
|
*/
|
|
1819
1891
|
const processDependency = (dep, index) => {
|
|
1820
1892
|
this.moduleGraph.setParents(dep, currentBlock, module, index);
|
|
1893
|
+
if (
|
|
1894
|
+
hasLazyBarrel &&
|
|
1895
|
+
// TODO remove in webpack 6
|
|
1896
|
+
// It may be missing on custom dependency types not extending the base Dependency
|
|
1897
|
+
"isLazy" in dep &&
|
|
1898
|
+
dep.isLazy()
|
|
1899
|
+
) {
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1821
1903
|
if (this._unsafeCache) {
|
|
1822
1904
|
try {
|
|
1823
1905
|
const unsafeCachedModule = unsafeCacheDependencies.get(dep);
|
|
@@ -1831,6 +1913,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1831
1913
|
dep,
|
|
1832
1914
|
unsafeCachedModule
|
|
1833
1915
|
);
|
|
1916
|
+
this._lazyBarrelController.unlazyForDependency(
|
|
1917
|
+
unsafeCachedModule,
|
|
1918
|
+
dep,
|
|
1919
|
+
sortedDependencies
|
|
1920
|
+
);
|
|
1834
1921
|
return;
|
|
1835
1922
|
}
|
|
1836
1923
|
const identifier = unsafeCachedModule.identifier();
|
|
@@ -1844,6 +1931,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1844
1931
|
dep,
|
|
1845
1932
|
cachedModule
|
|
1846
1933
|
);
|
|
1934
|
+
this._lazyBarrelController.unlazyForDependency(
|
|
1935
|
+
cachedModule,
|
|
1936
|
+
dep,
|
|
1937
|
+
sortedDependencies
|
|
1938
|
+
);
|
|
1847
1939
|
return;
|
|
1848
1940
|
}
|
|
1849
1941
|
inProgressSorting++;
|
|
@@ -1904,6 +1996,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1904
1996
|
dep,
|
|
1905
1997
|
cachedModule
|
|
1906
1998
|
); // a3
|
|
1999
|
+
this._lazyBarrelController.unlazyForDependency(
|
|
2000
|
+
cachedModule,
|
|
2001
|
+
dep,
|
|
2002
|
+
sortedDependencies
|
|
2003
|
+
);
|
|
1907
2004
|
} catch (err) {
|
|
1908
2005
|
if (inProgressSorting <= 0) return;
|
|
1909
2006
|
inProgressSorting = -1;
|
|
@@ -2070,6 +2167,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
2070
2167
|
module,
|
|
2071
2168
|
true,
|
|
2072
2169
|
false,
|
|
2170
|
+
[dependency],
|
|
2073
2171
|
callback
|
|
2074
2172
|
);
|
|
2075
2173
|
}
|
|
@@ -2352,6 +2450,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
2352
2450
|
module,
|
|
2353
2451
|
recursive,
|
|
2354
2452
|
checkCycle,
|
|
2453
|
+
dependencies,
|
|
2355
2454
|
callback
|
|
2356
2455
|
);
|
|
2357
2456
|
});
|
|
@@ -2366,6 +2465,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
2366
2465
|
* @param {Module} module module
|
|
2367
2466
|
* @param {boolean} recursive true if make it recursive, otherwise false
|
|
2368
2467
|
* @param {boolean} checkCycle true if need to check cycle, otherwise false
|
|
2468
|
+
* @param {Dependency[]} dependencies the dependencies that resolved to the module (lazy barrel)
|
|
2369
2469
|
* @param {ModuleCallback} callback callback
|
|
2370
2470
|
* @returns {void}
|
|
2371
2471
|
*/
|
|
@@ -2374,6 +2474,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
2374
2474
|
module,
|
|
2375
2475
|
recursive,
|
|
2376
2476
|
checkCycle,
|
|
2477
|
+
dependencies,
|
|
2377
2478
|
callback
|
|
2378
2479
|
) {
|
|
2379
2480
|
// Check for cycles when build is trigger inside another build
|
|
@@ -2438,17 +2539,55 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
2438
2539
|
return;
|
|
2439
2540
|
}
|
|
2440
2541
|
|
|
2441
|
-
//
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2542
|
+
// lazy barrel:
|
|
2543
|
+
// 1. first call: barrel module is not classified yet, so this records the requested
|
|
2544
|
+
// ids and returns undefined; the targets get built below when
|
|
2545
|
+
// `processModuleDependencies` runs `_lazyBarrelController.classify` and replays them.
|
|
2546
|
+
// 2. later call: barrel module is already built, so `processModuleDependencies` won't
|
|
2547
|
+
// re-walk it; the newly requested targets must be built here.
|
|
2548
|
+
const unlazyItems = this._lazyBarrelController.request(
|
|
2549
|
+
module,
|
|
2550
|
+
dependencies
|
|
2551
|
+
);
|
|
2445
2552
|
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2553
|
+
if (unlazyItems !== undefined) {
|
|
2554
|
+
let inProgress = unlazyItems.length + 1; // +1 = the module's own dep processing
|
|
2555
|
+
let errored = false;
|
|
2556
|
+
/**
|
|
2557
|
+
* @param {(WebpackError | null)=} err error
|
|
2558
|
+
* @returns {void}
|
|
2559
|
+
*/
|
|
2560
|
+
const onJobDone = (err) => {
|
|
2561
|
+
if (errored) return;
|
|
2562
|
+
if (err) {
|
|
2563
|
+
errored = true;
|
|
2564
|
+
return callback(err);
|
|
2565
|
+
}
|
|
2566
|
+
if (--inProgress === 0) callback(null, module);
|
|
2567
|
+
};
|
|
2568
|
+
for (const item of unlazyItems) {
|
|
2569
|
+
this.handleModuleCreation(item, (err) => {
|
|
2570
|
+
onJobDone(err && this.bail ? err : null);
|
|
2571
|
+
});
|
|
2449
2572
|
}
|
|
2450
|
-
|
|
2451
|
-
|
|
2573
|
+
if (this.processDependenciesQueue.isProcessing(module)) {
|
|
2574
|
+
onJobDone();
|
|
2575
|
+
} else {
|
|
2576
|
+
this.processModuleDependencies(module, onJobDone);
|
|
2577
|
+
}
|
|
2578
|
+
} else {
|
|
2579
|
+
// This avoids deadlocks for circular dependencies
|
|
2580
|
+
if (this.processDependenciesQueue.isProcessing(module)) {
|
|
2581
|
+
return callback(null, module);
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
this.processModuleDependencies(module, (err) => {
|
|
2585
|
+
if (err) {
|
|
2586
|
+
return callback(err);
|
|
2587
|
+
}
|
|
2588
|
+
callback(null, module);
|
|
2589
|
+
});
|
|
2590
|
+
}
|
|
2452
2591
|
});
|
|
2453
2592
|
}
|
|
2454
2593
|
|
|
@@ -2809,22 +2948,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
2809
2948
|
}
|
|
2810
2949
|
}
|
|
2811
2950
|
|
|
2812
|
-
/**
|
|
2813
|
-
* Reduce affect type.
|
|
2814
|
-
* @param {Readonly<ModuleGraphConnection[]>} connections connections
|
|
2815
|
-
* @returns {symbol | boolean} result
|
|
2816
|
-
*/
|
|
2817
|
-
const reduceAffectType = (connections) => {
|
|
2818
|
-
let affected = false;
|
|
2819
|
-
for (const { dependency } of connections) {
|
|
2820
|
-
if (!dependency) continue;
|
|
2821
|
-
const type = dependency.couldAffectReferencingModule();
|
|
2822
|
-
if (type === Dependency.TRANSITIVE) return Dependency.TRANSITIVE;
|
|
2823
|
-
if (type === false) continue;
|
|
2824
|
-
affected = true;
|
|
2825
|
-
}
|
|
2826
|
-
return affected;
|
|
2827
|
-
};
|
|
2828
2951
|
/** @type {Set<Module>} */
|
|
2829
2952
|
const directOnlyInfectedModules = new Set();
|
|
2830
2953
|
for (const module of infectedModules) {
|
|
@@ -2927,7 +3050,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
2927
3050
|
queue.push.apply(queue, block.blocks);
|
|
2928
3051
|
}
|
|
2929
3052
|
}
|
|
2930
|
-
return {
|
|
3053
|
+
return {
|
|
3054
|
+
id,
|
|
3055
|
+
modules,
|
|
3056
|
+
blocks,
|
|
3057
|
+
sourceTypes: module.getReferencedSourceTypes()
|
|
3058
|
+
};
|
|
2931
3059
|
};
|
|
2932
3060
|
/**
|
|
2933
3061
|
* Compares references.
|
|
@@ -2936,9 +3064,13 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
2936
3064
|
* @param {string | number} references.id id
|
|
2937
3065
|
* @param {Map<Module, string | number | undefined>=} references.modules modules
|
|
2938
3066
|
* @param {(string | number | null)[]=} references.blocks blocks
|
|
3067
|
+
* @param {SourceTypes=} references.sourceTypes connection-dependent source types
|
|
2939
3068
|
* @returns {boolean} ok?
|
|
2940
3069
|
*/
|
|
2941
|
-
const compareReferences = (
|
|
3070
|
+
const compareReferences = (
|
|
3071
|
+
module,
|
|
3072
|
+
{ id, modules, blocks, sourceTypes }
|
|
3073
|
+
) => {
|
|
2942
3074
|
if (id !== chunkGraph.getModuleId(module)) return false;
|
|
2943
3075
|
if (modules !== undefined) {
|
|
2944
3076
|
for (const [module, id] of modules) {
|
|
@@ -2962,6 +3094,13 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
2962
3094
|
}
|
|
2963
3095
|
if (i !== blocks.length) return false;
|
|
2964
3096
|
}
|
|
3097
|
+
// getReferencedSourceTypes() returns interned type sets, compare by reference. #20800
|
|
3098
|
+
if (
|
|
3099
|
+
sourceTypes !== undefined &&
|
|
3100
|
+
module.getReferencedSourceTypes() !== sourceTypes
|
|
3101
|
+
) {
|
|
3102
|
+
return false;
|
|
3103
|
+
}
|
|
2965
3104
|
return true;
|
|
2966
3105
|
};
|
|
2967
3106
|
|
|
@@ -2997,6 +3136,57 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
2997
3136
|
);
|
|
2998
3137
|
}
|
|
2999
3138
|
|
|
3139
|
+
/**
|
|
3140
|
+
* Assigns a fresh dependency report cache token to every module whose
|
|
3141
|
+
* dependency errors/warnings could have changed since the previous
|
|
3142
|
+
* compilation: built modules and their (transitive) parents.
|
|
3143
|
+
* @private
|
|
3144
|
+
* @param {Set<Module>} modules modules
|
|
3145
|
+
* @returns {void}
|
|
3146
|
+
*/
|
|
3147
|
+
_flagModulesForDependencyReporting(modules) {
|
|
3148
|
+
/** @type {DependencyReportCacheToken} */
|
|
3149
|
+
const token = {};
|
|
3150
|
+
const { moduleGraph, builtModules } = this;
|
|
3151
|
+
/** @type {Set<Module>} */
|
|
3152
|
+
const updatedModules = new Set();
|
|
3153
|
+
for (const module of modules) {
|
|
3154
|
+
if (
|
|
3155
|
+
builtModules.has(module) ||
|
|
3156
|
+
!dependencyReportCacheTokens.has(module)
|
|
3157
|
+
) {
|
|
3158
|
+
updatedModules.add(module);
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
// skip the parent walk when everything is updated anyway (initial build)
|
|
3162
|
+
if (updatedModules.size !== modules.size) {
|
|
3163
|
+
/** @type {Set<Module>} */
|
|
3164
|
+
const directOnlyUpdatedModules = new Set();
|
|
3165
|
+
for (const module of updatedModules) {
|
|
3166
|
+
for (const [
|
|
3167
|
+
referencingModule,
|
|
3168
|
+
connections
|
|
3169
|
+
] of moduleGraph.getIncomingConnectionsByOriginModule(module)) {
|
|
3170
|
+
if (!referencingModule) continue;
|
|
3171
|
+
if (updatedModules.has(referencingModule)) continue;
|
|
3172
|
+
const type = reduceAffectType(connections);
|
|
3173
|
+
if (!type) continue;
|
|
3174
|
+
if (type === true) {
|
|
3175
|
+
directOnlyUpdatedModules.add(referencingModule);
|
|
3176
|
+
} else {
|
|
3177
|
+
updatedModules.add(referencingModule);
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
for (const module of directOnlyUpdatedModules) {
|
|
3182
|
+
updatedModules.add(module);
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
for (const module of updatedModules) {
|
|
3186
|
+
dependencyReportCacheTokens.set(module, token);
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
|
|
3000
3190
|
/**
|
|
3001
3191
|
* Processes the provided callback.
|
|
3002
3192
|
* @param {Callback} callback callback
|
|
@@ -3135,16 +3325,18 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3135
3325
|
if (d === 0 || p === 0) continue;
|
|
3136
3326
|
const t = d / p;
|
|
3137
3327
|
innerSum += t;
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3328
|
+
/* istanbul ignore next -- @preserve: only slow (>10ms) modules are logged, timing-dependent */
|
|
3329
|
+
if (t > 10) {
|
|
3330
|
+
logByValue(
|
|
3331
|
+
t,
|
|
3332
|
+
` | | ${Math.round(t)} ms${
|
|
3333
|
+
p >= 1.1 ? ` (parallelism ${Math.round(p * 10) / 10})` : ""
|
|
3334
|
+
} ${category} > ${module.readableIdentifier(
|
|
3335
|
+
this.requestShortener
|
|
3336
|
+
)}`
|
|
3337
|
+
);
|
|
3338
|
+
innerMax = Math.max(innerMax, t);
|
|
3339
|
+
}
|
|
3148
3340
|
}
|
|
3149
3341
|
sum += innerSum;
|
|
3150
3342
|
if (innerSum <= 10) continue;
|
|
@@ -3215,15 +3407,24 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3215
3407
|
|
|
3216
3408
|
// extract warnings and errors from modules
|
|
3217
3409
|
this.moduleGraph.freeze("dependency errors");
|
|
3218
|
-
// TODO keep a cacheToken (= {}) for each module in the graph
|
|
3219
|
-
// create a new one per compilation and flag all updated files
|
|
3220
|
-
// and parents with it
|
|
3221
3410
|
this.logger.time("report dependency errors and warnings");
|
|
3411
|
+
// moduleMemCaches has its own invalidation (incl. reference changes),
|
|
3412
|
+
// so cache tokens are only used without it
|
|
3413
|
+
const useReportCacheTokens = moduleMemCaches === undefined;
|
|
3414
|
+
if (useReportCacheTokens) {
|
|
3415
|
+
this._flagModulesForDependencyReporting(modules);
|
|
3416
|
+
}
|
|
3222
3417
|
for (const module of modules) {
|
|
3223
|
-
// TODO only run for modules with changed cacheToken
|
|
3224
|
-
// global WeakMap<CacheToken, WeakSet<Module>> to keep modules without errors/warnings
|
|
3225
3418
|
const memCache = moduleMemCaches && moduleMemCaches.get(module);
|
|
3226
3419
|
if (memCache && memCache.get("noWarningsOrErrors")) continue;
|
|
3420
|
+
let token;
|
|
3421
|
+
if (useReportCacheTokens) {
|
|
3422
|
+
token = dependencyReportCacheTokens.get(module);
|
|
3423
|
+
const cleanModules = modulesWithoutProblems.get(
|
|
3424
|
+
/** @type {DependencyReportCacheToken} */ (token)
|
|
3425
|
+
);
|
|
3426
|
+
if (cleanModules !== undefined && cleanModules.has(module)) continue;
|
|
3427
|
+
}
|
|
3227
3428
|
let hasProblems = this.reportDependencyErrorsAndWarnings(module, [
|
|
3228
3429
|
module
|
|
3229
3430
|
]);
|
|
@@ -3247,7 +3448,21 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3247
3448
|
hasProblems = true;
|
|
3248
3449
|
}
|
|
3249
3450
|
}
|
|
3250
|
-
if (!hasProblems
|
|
3451
|
+
if (!hasProblems) {
|
|
3452
|
+
if (memCache) memCache.set("noWarningsOrErrors", true);
|
|
3453
|
+
if (useReportCacheTokens) {
|
|
3454
|
+
let cleanModules = modulesWithoutProblems.get(
|
|
3455
|
+
/** @type {DependencyReportCacheToken} */ (token)
|
|
3456
|
+
);
|
|
3457
|
+
if (cleanModules === undefined) {
|
|
3458
|
+
modulesWithoutProblems.set(
|
|
3459
|
+
/** @type {DependencyReportCacheToken} */ (token),
|
|
3460
|
+
(cleanModules = new WeakSet())
|
|
3461
|
+
);
|
|
3462
|
+
}
|
|
3463
|
+
cleanModules.add(module);
|
|
3464
|
+
}
|
|
3465
|
+
}
|
|
3251
3466
|
}
|
|
3252
3467
|
this.moduleGraph.unfreeze();
|
|
3253
3468
|
this.logger.timeEnd("report dependency errors and warnings");
|
|
@@ -3266,6 +3481,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3266
3481
|
this.additionalChunkAssets.length = 0;
|
|
3267
3482
|
this.assets = {};
|
|
3268
3483
|
this.assetsInfo.clear();
|
|
3484
|
+
this._assetToChunkIndex = undefined;
|
|
3485
|
+
this._assetToChunkAuxiliaryIndex = undefined;
|
|
3269
3486
|
this.moduleGraph.removeAllModuleAttributes();
|
|
3270
3487
|
this.moduleGraph.unfreeze();
|
|
3271
3488
|
this.moduleMemCaches2 = undefined;
|
|
@@ -3288,6 +3505,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3288
3505
|
this.rebuildQueue.clear();
|
|
3289
3506
|
this.processDependenciesQueue.clear();
|
|
3290
3507
|
this.addModuleQueue.clear();
|
|
3508
|
+
// lazy barrel only acts during make; release its bookkeeping now
|
|
3509
|
+
this._lazyBarrelController.clear();
|
|
3291
3510
|
return callback(err);
|
|
3292
3511
|
};
|
|
3293
3512
|
|
|
@@ -3675,7 +3894,14 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
3675
3894
|
const warnings = d.getWarnings(this.moduleGraph);
|
|
3676
3895
|
if (warnings) {
|
|
3677
3896
|
for (const w of warnings) {
|
|
3678
|
-
|
|
3897
|
+
// A consolidated dependency (e.g. CssIcssExportDependency) carries
|
|
3898
|
+
// per-item locations on the error itself; fall back to the
|
|
3899
|
+
// dependency loc for the usual one-loc-per-dependency case.
|
|
3900
|
+
const warning = new ModuleDependencyWarning(
|
|
3901
|
+
module,
|
|
3902
|
+
w,
|
|
3903
|
+
/** @type {EXPECTED_ANY} */ (w).loc || d.loc
|
|
3904
|
+
);
|
|
3679
3905
|
this.warnings.push(warning);
|
|
3680
3906
|
hasProblems = true;
|
|
3681
3907
|
}
|
|
@@ -3683,7 +3909,11 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
3683
3909
|
const errors = d.getErrors(this.moduleGraph);
|
|
3684
3910
|
if (errors) {
|
|
3685
3911
|
for (const e of errors) {
|
|
3686
|
-
const error = new ModuleDependencyError(
|
|
3912
|
+
const error = new ModuleDependencyError(
|
|
3913
|
+
module,
|
|
3914
|
+
e,
|
|
3915
|
+
/** @type {EXPECTED_ANY} */ (e).loc || d.loc
|
|
3916
|
+
);
|
|
3687
3917
|
this.errors.push(error);
|
|
3688
3918
|
hasProblems = true;
|
|
3689
3919
|
}
|
|
@@ -3905,7 +4135,8 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
3905
4135
|
);
|
|
3906
4136
|
result = cachedResult = {
|
|
3907
4137
|
sources: new Map(),
|
|
3908
|
-
runtimeRequirements: null
|
|
4138
|
+
runtimeRequirements: null,
|
|
4139
|
+
data: undefined
|
|
3909
4140
|
};
|
|
3910
4141
|
}
|
|
3911
4142
|
} else {
|
|
@@ -4896,6 +5127,11 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
4896
5127
|
* @returns {void}
|
|
4897
5128
|
*/
|
|
4898
5129
|
emitAsset(file, source, assetInfo = {}) {
|
|
5130
|
+
// A file may be attached to a chunk right after any emit (including the
|
|
5131
|
+
// re-emit path for assets shared across chunks in createChunkAssets), so
|
|
5132
|
+
// the lazily-built reverse index is stale after every emitAsset.
|
|
5133
|
+
this._assetToChunkIndex = undefined;
|
|
5134
|
+
this._assetToChunkAuxiliaryIndex = undefined;
|
|
4899
5135
|
if (this.assets[file]) {
|
|
4900
5136
|
if (!isSourceEqual(this.assets[file], source)) {
|
|
4901
5137
|
this.errors.push(
|
|
@@ -5077,22 +5313,95 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
5077
5313
|
this._setAssetInfo(newFile, assetInfo);
|
|
5078
5314
|
delete this.assets[file];
|
|
5079
5315
|
this.assets[newFile] = source;
|
|
5316
|
+
this._buildAssetToChunkIndex();
|
|
5317
|
+
const index = /** @type {Map<string, Set<Chunk>>} */ (
|
|
5318
|
+
this._assetToChunkIndex
|
|
5319
|
+
);
|
|
5320
|
+
const auxiliaryIndex = /** @type {Map<string, Set<Chunk>>} */ (
|
|
5321
|
+
this._assetToChunkAuxiliaryIndex
|
|
5322
|
+
);
|
|
5323
|
+
const chunks = index.get(file);
|
|
5324
|
+
const auxiliaryChunks = auxiliaryIndex.get(file);
|
|
5325
|
+
if (chunks === undefined && auxiliaryChunks === undefined) {
|
|
5326
|
+
// Not tracked in either index: chunk sets may have been mutated
|
|
5327
|
+
// directly (bypassing emitAsset), so scan all chunks to stay correct.
|
|
5328
|
+
for (const chunk of this.chunks) {
|
|
5329
|
+
this._renameAssetInChunk(chunk, chunk.files, index, file, newFile);
|
|
5330
|
+
this._renameAssetInChunk(
|
|
5331
|
+
chunk,
|
|
5332
|
+
chunk.auxiliaryFiles,
|
|
5333
|
+
auxiliaryIndex,
|
|
5334
|
+
file,
|
|
5335
|
+
newFile
|
|
5336
|
+
);
|
|
5337
|
+
}
|
|
5338
|
+
return;
|
|
5339
|
+
}
|
|
5340
|
+
if (chunks !== undefined) {
|
|
5341
|
+
index.delete(file);
|
|
5342
|
+
for (const chunk of chunks) {
|
|
5343
|
+
this._renameAssetInChunk(chunk, chunk.files, index, file, newFile);
|
|
5344
|
+
}
|
|
5345
|
+
}
|
|
5346
|
+
if (auxiliaryChunks !== undefined) {
|
|
5347
|
+
auxiliaryIndex.delete(file);
|
|
5348
|
+
for (const chunk of auxiliaryChunks) {
|
|
5349
|
+
this._renameAssetInChunk(
|
|
5350
|
+
chunk,
|
|
5351
|
+
chunk.auxiliaryFiles,
|
|
5352
|
+
auxiliaryIndex,
|
|
5353
|
+
file,
|
|
5354
|
+
newFile
|
|
5355
|
+
);
|
|
5356
|
+
}
|
|
5357
|
+
}
|
|
5358
|
+
}
|
|
5359
|
+
|
|
5360
|
+
// Lazily build the reverse index file -> chunks. emitAsset() invalidates
|
|
5361
|
+
// it, so chunk.files / chunk.auxiliaryFiles entries added alongside a newly
|
|
5362
|
+
// emitted asset are always picked up on the next rebuild.
|
|
5363
|
+
/**
|
|
5364
|
+
* @private
|
|
5365
|
+
* @returns {void}
|
|
5366
|
+
*/
|
|
5367
|
+
_buildAssetToChunkIndex() {
|
|
5368
|
+
if (this._assetToChunkIndex !== undefined) return;
|
|
5369
|
+
/** @type {Map<string, Set<Chunk>>} */
|
|
5370
|
+
const filesIndex = new Map();
|
|
5371
|
+
/** @type {Map<string, Set<Chunk>>} */
|
|
5372
|
+
const auxiliaryIndex = new Map();
|
|
5080
5373
|
for (const chunk of this.chunks) {
|
|
5081
|
-
{
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
chunk.files.add(newFile);
|
|
5086
|
-
}
|
|
5374
|
+
for (const file of chunk.files) {
|
|
5375
|
+
let set = filesIndex.get(file);
|
|
5376
|
+
if (set === undefined) filesIndex.set(file, (set = new Set()));
|
|
5377
|
+
set.add(chunk);
|
|
5087
5378
|
}
|
|
5088
|
-
{
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
chunk.auxiliaryFiles.add(newFile);
|
|
5093
|
-
}
|
|
5379
|
+
for (const file of chunk.auxiliaryFiles) {
|
|
5380
|
+
let set = auxiliaryIndex.get(file);
|
|
5381
|
+
if (set === undefined) auxiliaryIndex.set(file, (set = new Set()));
|
|
5382
|
+
set.add(chunk);
|
|
5094
5383
|
}
|
|
5095
5384
|
}
|
|
5385
|
+
this._assetToChunkIndex = filesIndex;
|
|
5386
|
+
this._assetToChunkAuxiliaryIndex = auxiliaryIndex;
|
|
5387
|
+
}
|
|
5388
|
+
|
|
5389
|
+
/**
|
|
5390
|
+
* @private
|
|
5391
|
+
* @param {Chunk} chunk the chunk owning the set
|
|
5392
|
+
* @param {Set<string>} set chunk.files or chunk.auxiliaryFiles
|
|
5393
|
+
* @param {Map<string, Set<Chunk>>} index matching reverse index
|
|
5394
|
+
* @param {string} file old file name
|
|
5395
|
+
* @param {string} newFile new file name
|
|
5396
|
+
* @returns {void}
|
|
5397
|
+
*/
|
|
5398
|
+
_renameAssetInChunk(chunk, set, index, file, newFile) {
|
|
5399
|
+
// Only carry the rename to chunks that actually held the old name.
|
|
5400
|
+
if (!set.delete(file)) return;
|
|
5401
|
+
set.add(newFile);
|
|
5402
|
+
let target = index.get(newFile);
|
|
5403
|
+
if (target === undefined) index.set(newFile, (target = new Set()));
|
|
5404
|
+
target.add(chunk);
|
|
5096
5405
|
}
|
|
5097
5406
|
|
|
5098
5407
|
/**
|
|
@@ -5128,11 +5437,31 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
5128
5437
|
}
|
|
5129
5438
|
}
|
|
5130
5439
|
}
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5440
|
+
this._buildAssetToChunkIndex();
|
|
5441
|
+
const index = /** @type {Map<string, Set<Chunk>>} */ (
|
|
5442
|
+
this._assetToChunkIndex
|
|
5443
|
+
);
|
|
5444
|
+
const auxiliaryIndex = /** @type {Map<string, Set<Chunk>>} */ (
|
|
5445
|
+
this._assetToChunkAuxiliaryIndex
|
|
5446
|
+
);
|
|
5447
|
+
const chunks = index.get(file);
|
|
5448
|
+
const auxiliaryChunks = auxiliaryIndex.get(file);
|
|
5449
|
+
if (chunks === undefined && auxiliaryChunks === undefined) {
|
|
5450
|
+
// Not tracked in either index: chunk sets may have been mutated
|
|
5451
|
+
// directly (bypassing emitAsset), so scan all chunks to stay correct.
|
|
5452
|
+
for (const chunk of this.chunks) {
|
|
5453
|
+
chunk.files.delete(file);
|
|
5454
|
+
chunk.auxiliaryFiles.delete(file);
|
|
5455
|
+
}
|
|
5456
|
+
return;
|
|
5457
|
+
}
|
|
5458
|
+
if (chunks !== undefined) {
|
|
5459
|
+
for (const chunk of chunks) chunk.files.delete(file);
|
|
5460
|
+
index.delete(file);
|
|
5461
|
+
}
|
|
5462
|
+
if (auxiliaryChunks !== undefined) {
|
|
5463
|
+
for (const chunk of auxiliaryChunks) chunk.auxiliaryFiles.delete(file);
|
|
5464
|
+
auxiliaryIndex.delete(file);
|
|
5136
5465
|
}
|
|
5137
5466
|
}
|
|
5138
5467
|
|
|
@@ -5170,6 +5499,8 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
5170
5499
|
chunk.files.clear();
|
|
5171
5500
|
chunk.auxiliaryFiles.clear();
|
|
5172
5501
|
}
|
|
5502
|
+
this._assetToChunkIndex = undefined;
|
|
5503
|
+
this._assetToChunkAuxiliaryIndex = undefined;
|
|
5173
5504
|
}
|
|
5174
5505
|
|
|
5175
5506
|
createModuleAssets() {
|