webpack 5.104.1 → 5.105.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bin/webpack.js +6 -3
- package/lib/APIPlugin.js +85 -15
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AsyncDependenciesBlock.js +17 -2
- package/lib/AsyncDependencyToInitialChunkError.js +3 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +5 -1
- package/lib/CacheFacade.js +2 -2
- package/lib/CaseSensitiveModulesWarning.js +1 -0
- package/lib/Chunk.js +9 -5
- package/lib/ChunkGraph.js +30 -9
- package/lib/ChunkGroup.js +6 -3
- package/lib/ChunkRenderError.js +9 -2
- package/lib/CleanPlugin.js +5 -1
- package/lib/CodeGenerationError.js +7 -1
- package/lib/CodeGenerationResults.js +10 -3
- package/lib/CommentCompilationWarning.js +2 -1
- package/lib/Compilation.js +294 -244
- package/lib/Compiler.js +4 -3
- package/lib/ConcatenationScope.js +2 -1
- package/lib/ConcurrentCompilationError.js +3 -3
- package/lib/ContextModule.js +255 -112
- package/lib/ContextModuleFactory.js +14 -2
- package/lib/DefinePlugin.js +15 -8
- package/lib/DelegatedModule.js +6 -0
- package/lib/DelegatedModuleFactoryPlugin.js +2 -0
- package/lib/Dependency.js +7 -2
- package/lib/DependencyTemplates.js +3 -2
- package/lib/DllModule.js +2 -0
- package/lib/DllReferencePlugin.js +1 -0
- package/lib/DotenvPlugin.js +11 -5
- package/lib/DynamicEntryPlugin.js +8 -1
- package/lib/EnvironmentNotSupportAsyncWarning.js +2 -0
- package/lib/EvalDevToolModulePlugin.js +3 -0
- package/lib/EvalSourceMapDevToolPlugin.js +25 -14
- package/lib/ExportsInfo.js +8 -34
- package/lib/ExternalModule.js +18 -2
- package/lib/ExternalModuleFactoryPlugin.js +9 -2
- package/lib/ExternalsPlugin.js +2 -1
- package/lib/FalseIIFEUmdWarning.js +1 -0
- package/lib/FileSystemInfo.js +49 -25
- package/lib/FlagDependencyExportsPlugin.js +8 -1
- package/lib/FlagDependencyUsagePlugin.js +9 -7
- package/lib/HarmonyLinkingError.js +1 -0
- package/lib/HookWebpackError.js +2 -0
- package/lib/HotModuleReplacementPlugin.js +16 -2
- package/lib/IgnoreWarningsPlugin.js +5 -2
- package/lib/InitFragment.js +1 -0
- package/lib/InvalidDependenciesModuleWarning.js +1 -0
- package/lib/LibManifestPlugin.js +1 -0
- package/lib/ManifestPlugin.js +8 -1
- package/lib/Module.js +51 -8
- package/lib/ModuleBuildError.js +3 -1
- package/lib/ModuleDependencyError.js +1 -0
- package/lib/ModuleDependencyWarning.js +1 -0
- package/lib/ModuleError.js +4 -1
- package/lib/ModuleFilenameHelpers.js +4 -2
- package/lib/ModuleGraph.js +3 -0
- package/lib/ModuleGraphConnection.js +10 -10
- package/lib/ModuleHashingError.js +2 -0
- package/lib/ModuleInfoHeaderPlugin.js +6 -1
- package/lib/ModuleNotFoundError.js +1 -0
- package/lib/ModuleParseError.js +5 -1
- package/lib/ModuleProfile.js +1 -1
- package/lib/ModuleRestoreError.js +2 -0
- package/lib/ModuleSourceTypeConstants.js +1 -11
- package/lib/ModuleStoreError.js +2 -0
- package/lib/ModuleWarning.js +3 -1
- package/lib/MultiCompiler.js +11 -7
- package/lib/MultiStats.js +5 -5
- package/lib/MultiWatching.js +2 -2
- package/lib/NoModeWarning.js +1 -0
- package/lib/NodeStuffInWebError.js +1 -0
- package/lib/NormalModule.js +28 -5
- package/lib/NormalModuleFactory.js +20 -4
- package/lib/OptionsApply.js +3 -1
- package/lib/ProgressPlugin.js +4 -0
- package/lib/RawModule.js +2 -0
- package/lib/RuntimeModule.js +28 -1
- package/lib/RuntimePlugin.js +7 -9
- package/lib/RuntimeTemplate.js +14 -7
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +1 -0
- package/lib/SourceMapDevToolPlugin.js +40 -25
- package/lib/Stats.js +3 -2
- package/lib/Template.js +10 -5
- package/lib/TemplatedPathPlugin.js +4 -2
- package/lib/UnhandledSchemeError.js +1 -0
- package/lib/UnsupportedFeatureWarning.js +3 -0
- package/lib/WarnDeprecatedOptionPlugin.js +1 -0
- package/lib/WatchIgnorePlugin.js +1 -1
- package/lib/Watching.js +5 -0
- package/lib/WebpackError.js +4 -0
- package/lib/WebpackOptionsApply.js +74 -44
- package/lib/asset/AssetBytesGenerator.js +1 -0
- package/lib/asset/AssetGenerator.js +18 -3
- package/lib/asset/AssetModulesPlugin.js +48 -2
- package/lib/asset/AssetParser.js +4 -0
- package/lib/asset/AssetSourceGenerator.js +1 -0
- package/lib/asset/RawDataUrlModule.js +9 -1
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
- package/lib/buildChunkGraph.js +31 -2
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +41 -8
- package/lib/cache/getLazyHashedEtag.js +13 -4
- package/lib/cache/mergeEtags.js +3 -1
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +65 -44
- package/lib/config/normalization.js +96 -0
- package/lib/container/ContainerEntryDependency.js +3 -0
- package/lib/container/ContainerEntryModule.js +7 -0
- package/lib/container/ContainerExposedDependency.js +1 -0
- package/lib/container/FallbackDependency.js +1 -0
- package/lib/container/FallbackItemDependency.js +1 -0
- package/lib/container/FallbackModule.js +4 -0
- package/lib/container/HoistContainerReferencesPlugin.js +6 -0
- package/lib/container/ModuleFederationPlugin.js +1 -1
- package/lib/container/RemoteModule.js +42 -1
- package/lib/css/CssGenerator.js +38 -4
- package/lib/css/CssModulesPlugin.js +33 -30
- package/lib/css/CssParser.js +12 -9
- package/lib/debug/ProfilingPlugin.js +1 -0
- package/lib/dependencies/AMDDefineDependency.js +3 -1
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -0
- package/lib/dependencies/AMDPlugin.js +1 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +7 -1
- package/lib/dependencies/CachedConstDependency.js +1 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +2 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +5 -0
- package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
- package/lib/dependencies/CommonJsImportsParserPlugin.js +315 -506
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -0
- package/lib/dependencies/ConstDependency.js +1 -0
- package/lib/dependencies/ContextDependencyHelpers.js +11 -4
- package/lib/dependencies/ContextElementDependency.js +1 -0
- package/lib/dependencies/CreateRequireParserPlugin.js +356 -0
- package/lib/dependencies/CriticalDependencyWarning.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +7 -4
- package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
- package/lib/dependencies/CssUrlDependency.js +2 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
- package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -8
- package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
- package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
- package/lib/dependencies/HarmonyImportDependency.js +31 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +217 -49
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +11 -5
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
- package/lib/dependencies/HarmonyModulesPlugin.js +4 -0
- package/lib/dependencies/ImportDependency.js +1 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +53 -11
- package/lib/dependencies/ImportParserPlugin.js +8 -23
- package/lib/dependencies/ImportPhase.js +4 -0
- package/lib/dependencies/LoaderPlugin.js +3 -0
- package/lib/dependencies/ModuleDecoratorDependency.js +1 -0
- package/lib/dependencies/ModuleDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
- package/lib/dependencies/ProvidedDependency.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +1 -0
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +1 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
- package/lib/dependencies/WorkerDependency.js +9 -3
- package/lib/dependencies/WorkerPlugin.js +1 -0
- package/lib/dependencies/getFunctionExpression.js +3 -1
- package/lib/electron/ElectronTargetPlugin.js +3 -1
- package/lib/errors/BuildCycleError.js +4 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
- package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +5 -0
- package/lib/hmr/lazyCompilationBackend.js +3 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +9 -7
- package/lib/ids/DeterministicChunkIdsPlugin.js +1 -0
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -0
- package/lib/ids/HashedModuleIdsPlugin.js +3 -8
- package/lib/ids/IdHelpers.js +10 -8
- package/lib/ids/NamedChunkIdsPlugin.js +7 -5
- package/lib/ids/NamedModuleIdsPlugin.js +1 -0
- package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +18 -10
- package/lib/ids/SyncModuleIdsPlugin.js +30 -20
- package/lib/javascript/BasicEvaluatedExpression.js +1 -0
- package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
- package/lib/javascript/JavascriptModulesPlugin.js +104 -30
- package/lib/javascript/JavascriptParser.js +48 -15
- package/lib/json/JsonGenerator.js +1 -0
- package/lib/json/JsonParser.js +9 -2
- package/lib/library/AbstractLibraryPlugin.js +4 -1
- package/lib/library/AmdLibraryPlugin.js +2 -1
- package/lib/library/AssignLibraryPlugin.js +6 -2
- package/lib/library/EnableLibraryPlugin.js +1 -0
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
- package/lib/library/JsonpLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +130 -13
- package/lib/library/SystemLibraryPlugin.js +4 -1
- package/lib/library/UmdLibraryPlugin.js +4 -3
- package/lib/logging/Logger.js +9 -5
- package/lib/logging/createConsoleLogger.js +4 -0
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +6 -4
- package/lib/node/NodeEnvironmentPlugin.js +1 -0
- package/lib/node/NodeTargetPlugin.js +10 -1
- package/lib/node/NodeTemplatePlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +6 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -0
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -0
- package/lib/node/nodeConsole.js +18 -1
- package/lib/optimize/AggressiveMergingPlugin.js +2 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +15 -6
- package/lib/optimize/ConcatenatedModule.js +36 -19
- package/lib/optimize/FlagIncludedChunksPlugin.js +11 -1
- package/lib/optimize/InnerGraph.js +5 -3
- package/lib/optimize/InnerGraphPlugin.js +25 -25
- package/lib/optimize/LimitChunkCountPlugin.js +3 -2
- package/lib/optimize/MangleExportsPlugin.js +14 -2
- package/lib/optimize/MergeDuplicateChunksPlugin.js +5 -1
- package/lib/optimize/MinChunkSizePlugin.js +5 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +23 -5
- package/lib/optimize/RealContentHashPlugin.js +37 -27
- package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
- package/lib/optimize/RuntimeChunkPlugin.js +3 -5
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
- package/lib/optimize/SplitChunksPlugin.js +23 -5
- package/lib/performance/AssetsOverSizeLimitWarning.js +7 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +7 -2
- package/lib/performance/NoAsyncChunksWarning.js +1 -0
- package/lib/performance/SizeLimitsPlugin.js +7 -6
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +2 -0
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -0
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -0
- package/lib/rules/BasicEffectRulePlugin.js +2 -0
- package/lib/rules/BasicMatcherRulePlugin.js +3 -0
- package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
- package/lib/rules/RuleSetCompiler.js +6 -0
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
- package/lib/runtime/CompatRuntimeModule.js +1 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -0
- package/lib/runtime/GetFullHashRuntimeModule.js +1 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
- package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +16 -32
- package/lib/runtime/PublicPathRuntimeModule.js +1 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
- package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
- package/lib/runtime/ToBinaryRuntimeModule.js +14 -6
- package/lib/schemes/HttpUriPlugin.js +39 -20
- package/lib/schemes/VirtualUrlPlugin.js +28 -2
- package/lib/serialization/BinaryMiddleware.js +4 -0
- package/lib/serialization/FileMiddleware.js +9 -4
- package/lib/serialization/ObjectMiddleware.js +34 -11
- package/lib/serialization/PlainObjectSerializer.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +78 -1
- package/lib/sharing/ConsumeSharedPlugin.js +5 -4
- package/lib/sharing/ProvideSharedModule.js +4 -0
- package/lib/sharing/ProvideSharedPlugin.js +24 -25
- package/lib/sharing/resolveMatchedConfigs.js +2 -2
- package/lib/sharing/utils.js +8 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +20 -12
- package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
- package/lib/stats/StatsFactory.js +2 -2
- package/lib/url/URLParserPlugin.js +5 -3
- package/lib/util/AppendOnlyStackedSet.js +78 -0
- package/lib/util/Hash.js +1 -0
- package/lib/util/IterableHelpers.js +1 -0
- package/lib/util/LazyBucketSortedSet.js +1 -0
- package/lib/util/LazySet.js +1 -0
- package/lib/util/ParallelismFactorCalculator.js +1 -0
- package/lib/util/SortableSet.js +1 -0
- package/lib/util/StringXor.js +1 -0
- package/lib/util/binarySearchBounds.js +15 -8
- package/lib/util/chainedImports.js +1 -1
- package/lib/util/cleverMerge.js +6 -1
- package/lib/util/comparators.js +21 -1
- package/lib/util/compileBooleanMatcher.js +3 -3
- package/lib/util/concatenate.js +3 -2
- package/lib/util/conventions.js +3 -2
- package/lib/util/deterministicGrouping.js +13 -1
- package/lib/util/extractSourceMap.js +12 -13
- package/lib/util/findGraphRoots.js +79 -109
- package/lib/util/fs.js +15 -19
- package/lib/util/hash/BatchedHash.js +4 -0
- package/lib/util/hash/BulkUpdateHash.js +8 -1
- package/lib/util/hash/hash-digest.js +1 -0
- package/lib/util/hash/wasm-hash.js +18 -2
- package/lib/util/identifier.js +7 -2
- package/lib/util/magicComment.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -0
- package/lib/util/runtime.js +15 -1
- package/lib/util/semver.js +1 -0
- package/lib/util/serialization.js +2 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +2 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyParser.js +3 -1
- package/lib/web/FetchCompileWasmPlugin.js +1 -0
- package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
- package/lib/webpack.js +16 -4
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -0
- package/package.json +40 -40
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +121 -55
- package/schemas/plugins/BannerPlugin.json +2 -2
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/ManifestPlugin.json +3 -3
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
- package/schemas/plugins/schemes/HttpUriPlugin.json +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +677 -230
package/lib/Module.js
CHANGED
|
@@ -80,6 +80,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
80
80
|
/** @typedef {KnownSourceType | string} SourceType */
|
|
81
81
|
/** @typedef {ReadonlySet<SourceType>} SourceTypes */
|
|
82
82
|
|
|
83
|
+
/** @typedef {ReadonlySet<typeof JAVASCRIPT_TYPE | string>} BasicSourceTypes */
|
|
84
|
+
|
|
83
85
|
// TODO webpack 6: compilation will be required in CodeGenerationContext
|
|
84
86
|
/**
|
|
85
87
|
* @typedef {object} CodeGenerationContext
|
|
@@ -104,15 +106,42 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
104
106
|
/** @typedef {Set<string>} RuntimeRequirements */
|
|
105
107
|
/** @typedef {ReadonlySet<string>} ReadOnlyRuntimeRequirements */
|
|
106
108
|
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
/**
|
|
110
|
+
* @typedef {object} AllCodeGenerationSchemas
|
|
111
|
+
* @property {Set<string>} topLevelDeclarations top level declarations for javascript modules
|
|
112
|
+
* @property {InitFragment<EXPECTED_ANY>[]} chunkInitFragments chunk init fragments for javascript modules
|
|
113
|
+
* @property {{ javascript?: string, ["css-url"]?: string }} url url for css and javascript modules
|
|
114
|
+
* @property {string} filename a filename for asset modules
|
|
115
|
+
* @property {AssetInfo} assetInfo an asset info for asset modules
|
|
116
|
+
* @property {string} fullContentHash a full content hash for asset modules
|
|
117
|
+
* @property {[{ shareScope: string, initStage: number, init: string }]} share-init share-init for modules federation
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
/* eslint-disable jsdoc/type-formatting */
|
|
121
|
+
/**
|
|
122
|
+
* @template {string} K
|
|
123
|
+
* @typedef {K extends keyof AllCodeGenerationSchemas ? AllCodeGenerationSchemas[K] : EXPECTED_ANY} CodeGenValue
|
|
124
|
+
*/
|
|
125
|
+
/* eslint-enable jsdoc/type-formatting */
|
|
126
|
+
|
|
127
|
+
/* eslint-disable jsdoc/require-template */
|
|
128
|
+
/**
|
|
129
|
+
* @typedef {object} CodeGenMapOverloads
|
|
130
|
+
* @property {<K extends string>(key: K) => CodeGenValue<K> | undefined} get
|
|
131
|
+
* @property {<K extends string>(key: K, value: CodeGenValue<K>) => CodeGenerationResultData} set
|
|
132
|
+
* @property {<K extends string>(key: K) => boolean} has
|
|
133
|
+
* @property {<K extends string>(key: K) => boolean} delete
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @typedef {Omit<Map<string, EXPECTED_ANY>, "get" | "set" | "has" | "delete"> & CodeGenMapOverloads} CodeGenerationResultData
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
/** @typedef {Map<SourceType, Source>} Sources */
|
|
112
141
|
|
|
113
142
|
/**
|
|
114
143
|
* @typedef {object} CodeGenerationResult
|
|
115
|
-
* @property {
|
|
144
|
+
* @property {Sources} sources the resulting sources for all source types
|
|
116
145
|
* @property {CodeGenerationResultData=} data the resulting data for all source types
|
|
117
146
|
* @property {ReadOnlyRuntimeRequirements | null} runtimeRequirements the runtime requirements
|
|
118
147
|
* @property {string=} hash a hash of the code generation result (will be automatically calculated from sources and runtimeRequirements if not provided)
|
|
@@ -135,8 +164,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
135
164
|
* @property {boolean=} sideEffectFree
|
|
136
165
|
* @property {boolean=} isCSSModule
|
|
137
166
|
* @property {Record<string, string>=} jsIncompatibleExports
|
|
138
|
-
* @property {Map<
|
|
139
|
-
* @property {Map<
|
|
167
|
+
* @property {Map<string, Record<string, string>>=} exportsFinalNameByRuntime
|
|
168
|
+
* @property {Map<string, string>=} exportsSourceByRuntime
|
|
140
169
|
*/
|
|
141
170
|
|
|
142
171
|
/**
|
|
@@ -939,6 +968,19 @@ class Module extends DependenciesBlock {
|
|
|
939
968
|
return JAVASCRIPT_TYPES;
|
|
940
969
|
}
|
|
941
970
|
|
|
971
|
+
/**
|
|
972
|
+
* Basic source types are high-level categories like javascript, css, webassembly, etc.
|
|
973
|
+
* We only have built-in knowledge about the javascript basic type here; other basic types may be
|
|
974
|
+
* added or changed over time by generators and do not need to be handled or detected here.
|
|
975
|
+
*
|
|
976
|
+
* Some modules, e.g. RemoteModule, may return non-basic source types like "remote" and "share-init"
|
|
977
|
+
* from getSourceTypes(), but their generated output is still JavaScript, i.e. their basic type is JS.
|
|
978
|
+
* @returns {BasicSourceTypes} types available (do not mutate)
|
|
979
|
+
*/
|
|
980
|
+
getSourceBasicTypes() {
|
|
981
|
+
return this.getSourceTypes();
|
|
982
|
+
}
|
|
983
|
+
|
|
942
984
|
/**
|
|
943
985
|
* @abstract
|
|
944
986
|
* @deprecated Use codeGeneration() instead
|
|
@@ -1026,6 +1068,7 @@ class Module extends DependenciesBlock {
|
|
|
1026
1068
|
*/
|
|
1027
1069
|
codeGeneration(context) {
|
|
1028
1070
|
// Best override this method
|
|
1071
|
+
/** @type {Sources} */
|
|
1029
1072
|
const sources = new Map();
|
|
1030
1073
|
for (const type of this.getSourceTypes()) {
|
|
1031
1074
|
if (type !== UNKNOWN_TYPE) {
|
package/lib/ModuleBuildError.js
CHANGED
|
@@ -17,10 +17,11 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
17
17
|
class ModuleBuildError extends WebpackError {
|
|
18
18
|
/**
|
|
19
19
|
* @param {string | ErrorWithHideStack} err error thrown
|
|
20
|
-
* @param {{from?: string | null}} info additional info
|
|
20
|
+
* @param {{ from?: string | null }} info additional info
|
|
21
21
|
*/
|
|
22
22
|
constructor(err, { from = null } = {}) {
|
|
23
23
|
let message = "Module build failed";
|
|
24
|
+
/** @type {undefined | string} */
|
|
24
25
|
let details;
|
|
25
26
|
|
|
26
27
|
message += from ? ` (from ${from}):\n` : ": ";
|
|
@@ -48,6 +49,7 @@ class ModuleBuildError extends WebpackError {
|
|
|
48
49
|
|
|
49
50
|
super(message);
|
|
50
51
|
|
|
52
|
+
/** @type {string} */
|
|
51
53
|
this.name = "ModuleBuildError";
|
|
52
54
|
this.details = details;
|
|
53
55
|
this.error = err;
|
package/lib/ModuleError.js
CHANGED
|
@@ -15,7 +15,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
15
15
|
class ModuleError extends WebpackError {
|
|
16
16
|
/**
|
|
17
17
|
* @param {Error} err error thrown
|
|
18
|
-
* @param {{from?: string | null}} info additional info
|
|
18
|
+
* @param {{ from?: string | null }} info additional info
|
|
19
19
|
*/
|
|
20
20
|
constructor(err, { from = null } = {}) {
|
|
21
21
|
let message = "Module Error";
|
|
@@ -30,8 +30,11 @@ class ModuleError extends WebpackError {
|
|
|
30
30
|
|
|
31
31
|
super(message);
|
|
32
32
|
|
|
33
|
+
/** @type {string} */
|
|
33
34
|
this.name = "ModuleError";
|
|
35
|
+
/** @type {Error} */
|
|
34
36
|
this.error = err;
|
|
37
|
+
/** @type {string | undefined} */
|
|
35
38
|
this.details =
|
|
36
39
|
err && typeof err === "object" && err.stack
|
|
37
40
|
? cleanUp(err.stack, this.message)
|
|
@@ -15,7 +15,8 @@ const memoize = require("./util/memoize");
|
|
|
15
15
|
/** @typedef {import("./Module")} Module */
|
|
16
16
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
|
17
17
|
|
|
18
|
-
/** @typedef {
|
|
18
|
+
/** @typedef {(str: string) => boolean} MatcherFn */
|
|
19
|
+
/** @typedef {string | RegExp | MatcherFn | (string | RegExp | MatcherFn)[]} Matcher */
|
|
19
20
|
/** @typedef {{ test?: Matcher, include?: Matcher, exclude?: Matcher }} MatchObject */
|
|
20
21
|
|
|
21
22
|
const ModuleFilenameHelpers = module.exports;
|
|
@@ -115,7 +116,7 @@ const lazyObject = (obj) => {
|
|
|
115
116
|
return newObj;
|
|
116
117
|
};
|
|
117
118
|
|
|
118
|
-
const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/
|
|
119
|
+
const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/g;
|
|
119
120
|
/**
|
|
120
121
|
* @typedef {object} ModuleFilenameTemplateContext
|
|
121
122
|
* @property {string} identifier the identifier of the module
|
|
@@ -157,6 +158,7 @@ ModuleFilenameHelpers.createFilename = (
|
|
|
157
158
|
|
|
158
159
|
/** @type {ReturnStringCallback} */
|
|
159
160
|
let absoluteResourcePath;
|
|
161
|
+
/** @type {ReturnStringCallback} */
|
|
160
162
|
let hash;
|
|
161
163
|
/** @type {ReturnStringCallback} */
|
|
162
164
|
let identifier;
|
package/lib/ModuleGraph.js
CHANGED
|
@@ -33,6 +33,7 @@ const { sortWithSourceOrder } = require("./util/comparators");
|
|
|
33
33
|
* @returns {string}
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
|
+
/** @type {Iterable<ModuleGraphConnection>} */
|
|
36
37
|
const EMPTY_SET = new Set();
|
|
37
38
|
|
|
38
39
|
/**
|
|
@@ -42,6 +43,7 @@ const EMPTY_SET = new Set();
|
|
|
42
43
|
* @returns {ReadonlyMap<T, ReadonlyArray<ModuleGraphConnection>>} mapped by key
|
|
43
44
|
*/
|
|
44
45
|
const getConnectionsByKey = (set, getKey) => {
|
|
46
|
+
/** @type {Map<T, ModuleGraphConnection[]>} */
|
|
45
47
|
const map = new Map();
|
|
46
48
|
/** @type {T | 0} */
|
|
47
49
|
let lastKey = 0;
|
|
@@ -528,6 +530,7 @@ class ModuleGraph {
|
|
|
528
530
|
mgm._unassignedConnections &&
|
|
529
531
|
mgm._unassignedConnections.length !== 0
|
|
530
532
|
) {
|
|
533
|
+
/** @type {undefined | ModuleGraphConnection} */
|
|
531
534
|
let foundConnection;
|
|
532
535
|
for (const connection of mgm._unassignedConnections) {
|
|
533
536
|
this._dependencyMap.set(
|
|
@@ -57,7 +57,7 @@ class ModuleGraphConnection {
|
|
|
57
57
|
* @param {Module} module the referenced module
|
|
58
58
|
* @param {string=} explanation some extra detail
|
|
59
59
|
* @param {boolean=} weak the reference is weak
|
|
60
|
-
* @param {false | null | GetConditionFn
|
|
60
|
+
* @param {false | null | GetConditionFn=} condition condition for the connection
|
|
61
61
|
*/
|
|
62
62
|
constructor(
|
|
63
63
|
originModule,
|
|
@@ -67,14 +67,23 @@ class ModuleGraphConnection {
|
|
|
67
67
|
weak = false,
|
|
68
68
|
condition = undefined
|
|
69
69
|
) {
|
|
70
|
+
/** @type {Module | null} */
|
|
70
71
|
this.originModule = originModule;
|
|
72
|
+
/** @type {Module | null} */
|
|
71
73
|
this.resolvedOriginModule = originModule;
|
|
74
|
+
/** @type {Dependency | null} */
|
|
72
75
|
this.dependency = dependency;
|
|
76
|
+
/** @type {Module} */
|
|
73
77
|
this.resolvedModule = module;
|
|
78
|
+
/** @type {Module} */
|
|
74
79
|
this.module = module;
|
|
80
|
+
/** @type {boolean | undefined} */
|
|
75
81
|
this.weak = weak;
|
|
82
|
+
/** @type {boolean} */
|
|
76
83
|
this.conditional = Boolean(condition);
|
|
84
|
+
/** @type {boolean} */
|
|
77
85
|
this._active = condition !== false;
|
|
86
|
+
/** @type {false | null | GetConditionFn | undefined} */
|
|
78
87
|
this.condition = condition || undefined;
|
|
79
88
|
/** @type {Set<string> | undefined} */
|
|
80
89
|
this.explanations = undefined;
|
|
@@ -175,15 +184,6 @@ class ModuleGraphConnection {
|
|
|
175
184
|
this.conditional = false;
|
|
176
185
|
this._active = value;
|
|
177
186
|
}
|
|
178
|
-
|
|
179
|
-
// TODO webpack 5 remove
|
|
180
|
-
get active() {
|
|
181
|
-
throw new Error("Use getActiveState instead");
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
set active(value) {
|
|
185
|
-
throw new Error("Use setActive instead");
|
|
186
|
-
}
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
/** @typedef {typeof TRANSITIVE_ONLY} TRANSITIVE_ONLY */
|
|
@@ -18,6 +18,7 @@ class ModuleHashingError extends WebpackError {
|
|
|
18
18
|
constructor(module, error) {
|
|
19
19
|
super();
|
|
20
20
|
|
|
21
|
+
/** @type {string} */
|
|
21
22
|
this.name = "ModuleHashingError";
|
|
22
23
|
this.error = error;
|
|
23
24
|
this.message = error.message;
|
|
@@ -26,4 +27,5 @@ class ModuleHashingError extends WebpackError {
|
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
/** @type {typeof ModuleHashingError} */
|
|
29
31
|
module.exports = ModuleHashingError;
|
|
@@ -63,6 +63,7 @@ const printExportsInfoToSource = (
|
|
|
63
63
|
let alreadyPrintedExports = 0;
|
|
64
64
|
|
|
65
65
|
// determine exports to print
|
|
66
|
+
/** @type {ExportInfo[]} */
|
|
66
67
|
const printedExports = [];
|
|
67
68
|
for (const exportInfo of exportsInfo.orderedExports) {
|
|
68
69
|
if (!alreadyPrinted.has(exportInfo)) {
|
|
@@ -145,7 +146,8 @@ const printExportsInfoToSource = (
|
|
|
145
146
|
}
|
|
146
147
|
};
|
|
147
148
|
|
|
148
|
-
/** @
|
|
149
|
+
/** @typedef {{ header: RawSource | undefined, full: WeakMap<Source, CachedSource> }} CacheEntry */
|
|
150
|
+
/** @type {WeakMap<RequestShortener, WeakMap<Module, CacheEntry>>} */
|
|
149
151
|
const caches = new WeakMap();
|
|
150
152
|
|
|
151
153
|
const PLUGIN_NAME = "ModuleInfoHeaderPlugin";
|
|
@@ -155,6 +157,7 @@ class ModuleInfoHeaderPlugin {
|
|
|
155
157
|
* @param {boolean=} verbose add more information like exports, runtime requirements and bailouts
|
|
156
158
|
*/
|
|
157
159
|
constructor(verbose = true) {
|
|
160
|
+
/** @type {boolean} */
|
|
158
161
|
this._verbose = verbose;
|
|
159
162
|
}
|
|
160
163
|
|
|
@@ -175,6 +178,7 @@ class ModuleInfoHeaderPlugin {
|
|
|
175
178
|
{ chunk, chunkGraph, moduleGraph, runtimeTemplate }
|
|
176
179
|
) => {
|
|
177
180
|
const { requestShortener } = runtimeTemplate;
|
|
181
|
+
/** @type {undefined | CacheEntry} */
|
|
178
182
|
let cacheEntry;
|
|
179
183
|
let cache = caches.get(requestShortener);
|
|
180
184
|
if (cache === undefined) {
|
|
@@ -256,6 +260,7 @@ class ModuleInfoHeaderPlugin {
|
|
|
256
260
|
PLUGIN_NAME,
|
|
257
261
|
(moduleSource, module, { runtimeTemplate }) => {
|
|
258
262
|
const { requestShortener } = runtimeTemplate;
|
|
263
|
+
/** @type {undefined | CacheEntry} */
|
|
259
264
|
let cacheEntry;
|
|
260
265
|
let cache = caches.get(requestShortener);
|
|
261
266
|
if (cache === undefined) {
|
package/lib/ModuleParseError.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
const WebpackError = require("./WebpackError");
|
|
9
9
|
const makeSerializable = require("./util/makeSerializable");
|
|
10
10
|
|
|
11
|
+
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
|
11
12
|
/** @typedef {import("./Dependency").SourcePosition} SourcePosition */
|
|
12
13
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
13
14
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
@@ -23,6 +24,7 @@ class ModuleParseError extends WebpackError {
|
|
|
23
24
|
*/
|
|
24
25
|
constructor(source, err, loaders, type) {
|
|
25
26
|
let message = `Module parse failed: ${err && err.message}`;
|
|
27
|
+
/** @type {undefined | DependencyLocation} */
|
|
26
28
|
let loc;
|
|
27
29
|
|
|
28
30
|
if (
|
|
@@ -40,7 +42,8 @@ class ModuleParseError extends WebpackError {
|
|
|
40
42
|
"\nFor files that transpile to WebAssembly, make sure to set the module type in the 'module.rules' section of the config (e. g. 'type: \"webassembly/async\"').";
|
|
41
43
|
} else if (!loaders) {
|
|
42
44
|
message +=
|
|
43
|
-
"\nYou may need an appropriate loader to handle this file type."
|
|
45
|
+
"\nYou may need an appropriate loader to handle this file type. " +
|
|
46
|
+
"See https://webpack.js.org/concepts/loaders";
|
|
44
47
|
} else if (loaders.length >= 1) {
|
|
45
48
|
message += `\nFile was processed with these loaders:${loaders
|
|
46
49
|
.map((loader) => `\n * ${loader}`)
|
|
@@ -88,6 +91,7 @@ class ModuleParseError extends WebpackError {
|
|
|
88
91
|
|
|
89
92
|
super(message);
|
|
90
93
|
|
|
94
|
+
/** @type {string} */
|
|
91
95
|
this.name = "ModuleParseError";
|
|
92
96
|
this.loc = loc;
|
|
93
97
|
this.error = err;
|
package/lib/ModuleProfile.js
CHANGED
|
@@ -34,7 +34,7 @@ class ModuleProfile {
|
|
|
34
34
|
this.storing = 0;
|
|
35
35
|
this.storingParallelismFactor = 0;
|
|
36
36
|
|
|
37
|
-
/** @type {{ start: number, end: number }[] | undefined
|
|
37
|
+
/** @type {{ start: number, end: number }[] | undefined} */
|
|
38
38
|
this.additionalFactoryTimes = undefined;
|
|
39
39
|
this.additionalFactories = 0;
|
|
40
40
|
this.additionalFactoriesParallelismFactor = 0;
|
|
@@ -33,6 +33,7 @@ class ModuleRestoreError extends WebpackError {
|
|
|
33
33
|
|
|
34
34
|
super(message);
|
|
35
35
|
|
|
36
|
+
/** @type {string} */
|
|
36
37
|
this.name = "ModuleRestoreError";
|
|
37
38
|
/** @type {string | undefined} */
|
|
38
39
|
this.details = details;
|
|
@@ -41,4 +42,5 @@ class ModuleRestoreError extends WebpackError {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
/** @type {typeof ModuleRestoreError} */
|
|
44
46
|
module.exports = ModuleRestoreError;
|
|
@@ -61,17 +61,7 @@ const CONSUME_SHARED_GENERATOR_TYPE = "consume-shared";
|
|
|
61
61
|
const UNKNOWN_TYPE = "unknown";
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* @typedef {JAVASCRIPT_TYPE |
|
|
65
|
-
* RUNTIME_TYPE |
|
|
66
|
-
* WEBASSEMBLY_TYPE |
|
|
67
|
-
* ASSET_TYPE |
|
|
68
|
-
* CSS_TYPE |
|
|
69
|
-
* CSS_IMPORT_TYPE |
|
|
70
|
-
* CSS_URL_TYPE |
|
|
71
|
-
* SHARED_INIT_TYPE |
|
|
72
|
-
* REMOTE_GENERATOR_TYPE |
|
|
73
|
-
* CONSUME_SHARED_GENERATOR_TYPE |
|
|
74
|
-
* UNKNOWN_TYPE} AllTypes
|
|
64
|
+
* @typedef {JAVASCRIPT_TYPE | RUNTIME_TYPE | WEBASSEMBLY_TYPE | ASSET_TYPE | CSS_TYPE | CSS_IMPORT_TYPE | CSS_URL_TYPE | SHARED_INIT_TYPE | REMOTE_GENERATOR_TYPE | CONSUME_SHARED_GENERATOR_TYPE | UNKNOWN_TYPE} AllTypes
|
|
75
65
|
*/
|
|
76
66
|
|
|
77
67
|
/**
|
package/lib/ModuleStoreError.js
CHANGED
|
@@ -33,6 +33,7 @@ class ModuleStoreError extends WebpackError {
|
|
|
33
33
|
|
|
34
34
|
super(message);
|
|
35
35
|
|
|
36
|
+
/** @type {string} */
|
|
36
37
|
this.name = "ModuleStoreError";
|
|
37
38
|
this.details = /** @type {string | undefined} */ (details);
|
|
38
39
|
this.module = module;
|
|
@@ -40,4 +41,5 @@ class ModuleStoreError extends WebpackError {
|
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
/** @type {typeof ModuleStoreError} */
|
|
43
45
|
module.exports = ModuleStoreError;
|
package/lib/ModuleWarning.js
CHANGED
|
@@ -15,7 +15,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
15
15
|
class ModuleWarning extends WebpackError {
|
|
16
16
|
/**
|
|
17
17
|
* @param {Error} warning error thrown
|
|
18
|
-
* @param {{from?: string | null}} info additional info
|
|
18
|
+
* @param {{ from?: string | null }} info additional info
|
|
19
19
|
*/
|
|
20
20
|
constructor(warning, { from = null } = {}) {
|
|
21
21
|
let message = "Module Warning";
|
|
@@ -30,6 +30,7 @@ class ModuleWarning extends WebpackError {
|
|
|
30
30
|
|
|
31
31
|
super(message);
|
|
32
32
|
|
|
33
|
+
/** @type {string} */
|
|
33
34
|
this.name = "ModuleWarning";
|
|
34
35
|
this.warning = warning;
|
|
35
36
|
this.details =
|
|
@@ -63,4 +64,5 @@ class ModuleWarning extends WebpackError {
|
|
|
63
64
|
|
|
64
65
|
makeSerializable(ModuleWarning, "webpack/lib/ModuleWarning");
|
|
65
66
|
|
|
67
|
+
/** @type {typeof ModuleWarning} */
|
|
66
68
|
module.exports = ModuleWarning;
|
package/lib/MultiCompiler.js
CHANGED
|
@@ -137,10 +137,11 @@ module.exports = class MultiCompiler {
|
|
|
137
137
|
compilation.warnings.push(warning);
|
|
138
138
|
});
|
|
139
139
|
};
|
|
140
|
+
/** @type {Set<string>} */
|
|
140
141
|
const cacheNames = new Set();
|
|
141
142
|
for (const compiler of this.compilers) {
|
|
142
143
|
if (compiler.options.cache && "name" in compiler.options.cache) {
|
|
143
|
-
const name = compiler.options.cache.name;
|
|
144
|
+
const name = /** @type {string} */ (compiler.options.cache.name);
|
|
144
145
|
if (cacheNames.has(name)) {
|
|
145
146
|
addWarning(
|
|
146
147
|
compiler,
|
|
@@ -255,7 +256,7 @@ module.exports = class MultiCompiler {
|
|
|
255
256
|
* @returns {boolean} true if the dependencies are valid
|
|
256
257
|
*/
|
|
257
258
|
validateDependencies(callback) {
|
|
258
|
-
/** @type {Set<{source: Compiler, target: Compiler}>} */
|
|
259
|
+
/** @type {Set<{ source: Compiler, target: Compiler }>} */
|
|
259
260
|
const edges = new Set();
|
|
260
261
|
/** @type {string[]} */
|
|
261
262
|
const missing = [];
|
|
@@ -272,8 +273,8 @@ module.exports = class MultiCompiler {
|
|
|
272
273
|
return false;
|
|
273
274
|
};
|
|
274
275
|
/**
|
|
275
|
-
* @param {{source: Compiler, target: Compiler}} e1 edge 1
|
|
276
|
-
* @param {{source: Compiler, target: Compiler}} e2 edge 2
|
|
276
|
+
* @param {{ source: Compiler, target: Compiler }} e1 edge 1
|
|
277
|
+
* @param {{ source: Compiler, target: Compiler }} e2 edge 2
|
|
277
278
|
* @returns {number} result
|
|
278
279
|
*/
|
|
279
280
|
const sortEdges = (e1, e2) =>
|
|
@@ -339,6 +340,7 @@ module.exports = class MultiCompiler {
|
|
|
339
340
|
* @returns {void}
|
|
340
341
|
*/
|
|
341
342
|
runWithDependencies(compilers, fn, callback) {
|
|
343
|
+
/** @type {Set<string>} */
|
|
342
344
|
const fulfilledNames = new Set();
|
|
343
345
|
let remainingCompilers = compilers;
|
|
344
346
|
/**
|
|
@@ -350,6 +352,7 @@ module.exports = class MultiCompiler {
|
|
|
350
352
|
* @returns {Compiler[]} compilers
|
|
351
353
|
*/
|
|
352
354
|
const getReadyCompilers = () => {
|
|
355
|
+
/** @type {Compiler[]} */
|
|
353
356
|
const readyCompilers = [];
|
|
354
357
|
const list = remainingCompilers;
|
|
355
358
|
remainingCompilers = [];
|
|
@@ -376,12 +379,12 @@ module.exports = class MultiCompiler {
|
|
|
376
379
|
(compiler, callback) => {
|
|
377
380
|
fn(compiler, (err) => {
|
|
378
381
|
if (err) return callback(err);
|
|
379
|
-
fulfilledNames.add(compiler.name);
|
|
382
|
+
fulfilledNames.add(/** @type {string} */ (compiler.name));
|
|
380
383
|
runCompilers(callback);
|
|
381
384
|
});
|
|
382
385
|
},
|
|
383
386
|
(err, results) => {
|
|
384
|
-
callback(err, results);
|
|
387
|
+
callback(/** @type {Error | null} */ (err), results);
|
|
385
388
|
}
|
|
386
389
|
);
|
|
387
390
|
};
|
|
@@ -567,6 +570,7 @@ module.exports = class MultiCompiler {
|
|
|
567
570
|
running === 0 &&
|
|
568
571
|
nodes.every((node) => node.state === "done")
|
|
569
572
|
) {
|
|
573
|
+
/** @type {Stats[]} */
|
|
570
574
|
const stats = [];
|
|
571
575
|
for (const node of nodes) {
|
|
572
576
|
const result = node.result;
|
|
@@ -667,7 +671,7 @@ module.exports = class MultiCompiler {
|
|
|
667
671
|
compiler.close(callback);
|
|
668
672
|
},
|
|
669
673
|
(error) => {
|
|
670
|
-
callback(error);
|
|
674
|
+
callback(/** @type {Error | null} */ (error));
|
|
671
675
|
}
|
|
672
676
|
);
|
|
673
677
|
}
|
package/lib/MultiStats.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
const identifierUtils = require("./util/identifier");
|
|
9
9
|
|
|
10
10
|
/** @typedef {import("../declarations/WebpackOptions").StatsOptions} StatsOptions */
|
|
11
|
+
/** @typedef {import("../declarations/WebpackOptions").StatsValue} StatsValue */
|
|
11
12
|
/** @typedef {import("./Compilation").CreateStatsOptionsContext} CreateStatsOptionsContext */
|
|
12
13
|
/** @typedef {import("./Compilation").NormalizedStatsOptions} NormalizedStatsOptions */
|
|
13
14
|
/** @typedef {import("./Stats")} Stats */
|
|
@@ -25,8 +26,7 @@ const indent = (str, prefix) => {
|
|
|
25
26
|
return prefix + rem;
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
/** @typedef {
|
|
29
|
-
/** @typedef {Omit<StatsOptions, "children"> & { children?: ChildrenStatsOptions | ChildrenStatsOptions[] }} MultiStatsOptions */
|
|
29
|
+
/** @typedef {StatsOptions} MultiStatsOptions */
|
|
30
30
|
/** @typedef {{ version: boolean, hash: boolean, errorsCount: boolean, warningsCount: boolean, errors: boolean, warnings: boolean, children: NormalizedStatsOptions[] }} ChildOptions */
|
|
31
31
|
|
|
32
32
|
class MultiStats {
|
|
@@ -56,7 +56,7 @@ class MultiStats {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
* @param {undefined |
|
|
59
|
+
* @param {undefined | StatsValue} options stats options
|
|
60
60
|
* @param {CreateStatsOptionsContext} context context
|
|
61
61
|
* @returns {ChildOptions} context context
|
|
62
62
|
*/
|
|
@@ -109,7 +109,7 @@ class MultiStats {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
* @param {
|
|
112
|
+
* @param {StatsValue=} options stats options
|
|
113
113
|
* @returns {StatsCompilation} json output
|
|
114
114
|
*/
|
|
115
115
|
toJson(options) {
|
|
@@ -184,7 +184,7 @@ class MultiStats {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
/**
|
|
187
|
-
* @param {
|
|
187
|
+
* @param {StatsValue=} options stats options
|
|
188
188
|
* @returns {string} string output
|
|
189
189
|
*/
|
|
190
190
|
toString(options) {
|
package/lib/MultiWatching.js
CHANGED
|
@@ -31,7 +31,7 @@ class MultiWatching {
|
|
|
31
31
|
this.watchings,
|
|
32
32
|
(watching, callback) => watching.invalidate(callback),
|
|
33
33
|
(err) => {
|
|
34
|
-
callback(err);
|
|
34
|
+
callback(/** @type {Error | null} */ (err));
|
|
35
35
|
}
|
|
36
36
|
);
|
|
37
37
|
} else {
|
|
@@ -67,7 +67,7 @@ class MultiWatching {
|
|
|
67
67
|
this.compiler.hooks.watchClose.call();
|
|
68
68
|
if (typeof callback === "function") {
|
|
69
69
|
this.compiler.running = false;
|
|
70
|
-
callback(err);
|
|
70
|
+
callback(/** @type {Error | null} */ (err));
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
);
|
package/lib/NoModeWarning.js
CHANGED