webpack 5.104.1 → 5.105.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/bin/webpack.js +6 -3
- package/lib/APIPlugin.js +85 -15
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AsyncDependenciesBlock.js +13 -1
- package/lib/AsyncDependencyToInitialChunkError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +2 -0
- package/lib/CacheFacade.js +2 -2
- package/lib/CaseSensitiveModulesWarning.js +1 -0
- package/lib/Chunk.js +8 -4
- package/lib/ChunkGraph.js +30 -9
- package/lib/ChunkGroup.js +6 -3
- package/lib/ChunkRenderError.js +2 -0
- package/lib/CleanPlugin.js +4 -1
- package/lib/CodeGenerationError.js +7 -1
- package/lib/CodeGenerationResults.js +10 -3
- package/lib/CommentCompilationWarning.js +2 -1
- package/lib/Compilation.js +280 -236
- package/lib/Compiler.js +3 -2
- package/lib/ConcatenationScope.js +2 -1
- package/lib/ConcurrentCompilationError.js +3 -3
- package/lib/ContextModule.js +248 -111
- package/lib/ContextModuleFactory.js +14 -2
- package/lib/DefinePlugin.js +3 -1
- package/lib/DelegatedModule.js +6 -0
- package/lib/DelegatedModuleFactoryPlugin.js +2 -0
- package/lib/Dependency.js +6 -1
- 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 +1 -0
- package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
- package/lib/EvalSourceMapDevToolPlugin.js +17 -13
- package/lib/ExportsInfo.js +8 -4
- package/lib/ExternalModule.js +16 -0
- 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/InitFragment.js +1 -0
- package/lib/InvalidDependenciesModuleWarning.js +1 -0
- package/lib/LibManifestPlugin.js +1 -0
- package/lib/ManifestPlugin.js +4 -1
- package/lib/Module.js +7 -4
- package/lib/ModuleBuildError.js +3 -1
- package/lib/ModuleDependencyError.js +1 -0
- package/lib/ModuleDependencyWarning.js +1 -0
- package/lib/ModuleError.js +2 -1
- package/lib/ModuleFilenameHelpers.js +2 -1
- package/lib/ModuleGraph.js +3 -0
- package/lib/ModuleGraphConnection.js +10 -1
- 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/MultiWatching.js +2 -2
- package/lib/NoModeWarning.js +1 -0
- package/lib/NodeStuffInWebError.js +1 -0
- package/lib/NormalModule.js +26 -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 +10 -0
- package/lib/RuntimePlugin.js +7 -9
- package/lib/RuntimeTemplate.js +14 -7
- package/lib/SourceMapDevToolPlugin.js +30 -23
- package/lib/Template.js +10 -5
- package/lib/TemplatedPathPlugin.js +4 -2
- package/lib/UnhandledSchemeError.js +1 -0
- package/lib/UnsupportedFeatureWarning.js +1 -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 +60 -40
- package/lib/asset/AssetBytesGenerator.js +1 -0
- package/lib/asset/AssetGenerator.js +9 -3
- package/lib/asset/AssetModulesPlugin.js +33 -2
- package/lib/asset/AssetSourceGenerator.js +1 -0
- package/lib/asset/RawDataUrlModule.js +4 -0
- 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/ContainerEntryModule.js +4 -0
- package/lib/container/FallbackModule.js +2 -0
- package/lib/container/HoistContainerReferencesPlugin.js +6 -0
- package/lib/container/RemoteModule.js +19 -0
- package/lib/css/CssGenerator.js +31 -4
- package/lib/css/CssModulesPlugin.js +26 -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 +1 -0
- package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
- package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -0
- 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/CriticalDependencyWarning.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +5 -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 +1 -0
- 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/HarmonyImportDependencyParserPlugin.js +266 -5
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
- 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 +7 -12
- 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/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/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 +2 -0
- package/lib/ids/IdHelpers.js +10 -8
- package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -7
- package/lib/ids/SyncModuleIdsPlugin.js +5 -1
- package/lib/javascript/BasicEvaluatedExpression.js +1 -0
- package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
- package/lib/javascript/JavascriptModulesPlugin.js +29 -8
- package/lib/javascript/JavascriptParser.js +47 -14
- package/lib/json/JsonParser.js +6 -0
- 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/createConsoleLogger.js +3 -0
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +1 -0
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +3 -0
- package/lib/node/nodeConsole.js +18 -1
- package/lib/optimize/AggressiveMergingPlugin.js +2 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +10 -6
- package/lib/optimize/ConcatenatedModule.js +33 -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/MangleExportsPlugin.js +14 -2
- package/lib/optimize/MergeDuplicateChunksPlugin.js +3 -0
- package/lib/optimize/MinChunkSizePlugin.js +5 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +19 -4
- package/lib/optimize/RealContentHashPlugin.js +35 -27
- package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
- package/lib/optimize/SplitChunksPlugin.js +14 -3
- package/lib/performance/AssetsOverSizeLimitWarning.js +6 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -2
- package/lib/performance/NoAsyncChunksWarning.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 +2 -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 +4 -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 +15 -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/schemes/HttpUriPlugin.js +27 -7
- package/lib/schemes/VirtualUrlPlugin.js +7 -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 +60 -0
- 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 +14 -12
- package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
- package/lib/stats/StatsFactory.js +2 -2
- package/lib/url/URLParserPlugin.js +4 -3
- package/lib/util/AppendOnlyStackedSet.js +57 -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/fs.js +15 -19
- package/lib/util/hash/BatchedHash.js +3 -0
- package/lib/util/hash/BulkUpdateHash.js +7 -1
- package/lib/util/hash/hash-digest.js +1 -0
- package/lib/util/hash/wasm-hash.js +16 -1
- 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 +1 -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 +13 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/package.json +20 -28
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +71 -5
- package/types.d.ts +339 -93
|
@@ -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/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
package/lib/NormalModule.js
CHANGED
|
@@ -79,6 +79,7 @@ const memoize = require("./util/memoize");
|
|
|
79
79
|
/** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
|
|
80
80
|
/** @typedef {import("./Module").BuildCallback} BuildCallback */
|
|
81
81
|
/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
|
|
82
|
+
/** @typedef {import("./Module").Sources} Sources */
|
|
82
83
|
/** @typedef {import("./Module").SourceType} SourceType */
|
|
83
84
|
/** @typedef {import("./Module").SourceTypes} SourceTypes */
|
|
84
85
|
/** @typedef {import("./Module").UnsafeCacheData} UnsafeCacheData */
|
|
@@ -123,7 +124,7 @@ const getExtractSourceMap = memoize(() => require("./util/extractSourceMap"));
|
|
|
123
124
|
|
|
124
125
|
const getValidate = memoize(() => require("schema-utils").validate);
|
|
125
126
|
|
|
126
|
-
const ABSOLUTE_PATH_REGEX = /^([a-
|
|
127
|
+
const ABSOLUTE_PATH_REGEX = /^(?:[a-z]:\\|\\\\|\/)/i;
|
|
127
128
|
|
|
128
129
|
/**
|
|
129
130
|
* @typedef {object} LoaderItem
|
|
@@ -360,7 +361,7 @@ class NormalModule extends Module {
|
|
|
360
361
|
/** @type {NormalModuleCreateData['rawRequest']} */
|
|
361
362
|
this.rawRequest = rawRequest;
|
|
362
363
|
/** @type {boolean} */
|
|
363
|
-
this.binary = /^(asset|webassembly)\b/.test(type);
|
|
364
|
+
this.binary = /^(?:asset|webassembly)\b/.test(type);
|
|
364
365
|
/** @type {NormalModuleCreateData['parser'] | undefined} */
|
|
365
366
|
this.parser = parser;
|
|
366
367
|
/** @type {NormalModuleCreateData['parserOptions']} */
|
|
@@ -403,14 +404,31 @@ class NormalModule extends Module {
|
|
|
403
404
|
* @type {undefined | SourceTypes}
|
|
404
405
|
*/
|
|
405
406
|
this._sourceTypes = undefined;
|
|
406
|
-
|
|
407
407
|
// Cache
|
|
408
|
+
/**
|
|
409
|
+
* @private
|
|
410
|
+
* @type {BuildMeta}
|
|
411
|
+
*/
|
|
408
412
|
this._lastSuccessfulBuildMeta = {};
|
|
413
|
+
/**
|
|
414
|
+
* @private
|
|
415
|
+
* @type {boolean}
|
|
416
|
+
*/
|
|
409
417
|
this._forceBuild = true;
|
|
418
|
+
/**
|
|
419
|
+
* @private
|
|
420
|
+
* @type {boolean}
|
|
421
|
+
*/
|
|
410
422
|
this._isEvaluatingSideEffects = false;
|
|
411
|
-
/**
|
|
423
|
+
/**
|
|
424
|
+
* @private
|
|
425
|
+
* @type {WeakSet<ModuleGraph> | undefined}
|
|
426
|
+
*/
|
|
412
427
|
this._addedSideEffectsBailout = undefined;
|
|
413
|
-
/**
|
|
428
|
+
/**
|
|
429
|
+
* @private
|
|
430
|
+
* @type {CodeGenerationResultData}
|
|
431
|
+
*/
|
|
414
432
|
this._codeGeneratorData = new Map();
|
|
415
433
|
}
|
|
416
434
|
|
|
@@ -718,6 +736,7 @@ class NormalModule extends Module {
|
|
|
718
736
|
if (schema) {
|
|
719
737
|
let name = "Loader";
|
|
720
738
|
let baseDataPath = "options";
|
|
739
|
+
/** @type {RegExpExecArray | null} */
|
|
721
740
|
let match;
|
|
722
741
|
if (schema.title && (match = /^(.+) (.+)$/.exec(schema.title))) {
|
|
723
742
|
[, name, baseDataPath] = match;
|
|
@@ -982,6 +1001,7 @@ class NormalModule extends Module {
|
|
|
982
1001
|
compilation.compiler.root
|
|
983
1002
|
);
|
|
984
1003
|
if (this._sourceSizes !== undefined) this._sourceSizes.clear();
|
|
1004
|
+
/** @type {PreparsedAst | null} */
|
|
985
1005
|
this._ast =
|
|
986
1006
|
typeof extraInfo === "object" &&
|
|
987
1007
|
extraInfo !== null &&
|
|
@@ -1518,6 +1538,7 @@ class NormalModule extends Module {
|
|
|
1518
1538
|
|
|
1519
1539
|
const getData = () => this._codeGeneratorData;
|
|
1520
1540
|
|
|
1541
|
+
/** @type {Sources} */
|
|
1521
1542
|
const sources = new Map();
|
|
1522
1543
|
for (const type of sourceTypes || chunkGraph.getModuleSourceTypes(this)) {
|
|
1523
1544
|
// TODO webpack@6 make generateError required
|
|
@@ -54,6 +54,7 @@ const {
|
|
|
54
54
|
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
|
|
55
55
|
/** @typedef {import("./javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
|
56
56
|
/** @typedef {import("./rules/RuleSetCompiler").RuleSetRules} RuleSetRules */
|
|
57
|
+
/** @typedef {import("./rules/RuleSetCompiler").RuleSet} RuleSet */
|
|
57
58
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
58
59
|
/** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
|
59
60
|
|
|
@@ -104,7 +105,7 @@ const {
|
|
|
104
105
|
/**
|
|
105
106
|
* @typedef {object} ParsedLoaderRequest
|
|
106
107
|
* @property {string} loader loader
|
|
107
|
-
* @property {string|undefined} options options
|
|
108
|
+
* @property {string | undefined} options options
|
|
108
109
|
*/
|
|
109
110
|
|
|
110
111
|
/** @typedef {import("./ModuleTypeConstants").JAVASCRIPT_MODULE_TYPE_AUTO} JAVASCRIPT_MODULE_TYPE_AUTO */
|
|
@@ -195,6 +196,7 @@ const needCalls = (times, callback) => (err) => {
|
|
|
195
196
|
*/
|
|
196
197
|
const mergeGlobalOptions = (globalOptions, type, localOptions) => {
|
|
197
198
|
const parts = type.split("/");
|
|
199
|
+
/** @type {undefined | T} */
|
|
198
200
|
let result;
|
|
199
201
|
let current = "";
|
|
200
202
|
for (const part of parts) {
|
|
@@ -302,6 +304,7 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
|
302
304
|
/** @typedef {import("../declarations/WebpackOptions").CssGeneratorOptions} CssGeneratorOptions */
|
|
303
305
|
/** @typedef {import("../declarations/WebpackOptions").CssModuleGeneratorOptions} CssModuleGeneratorOptions */
|
|
304
306
|
|
|
307
|
+
/* eslint-disable jsdoc/type-formatting */
|
|
305
308
|
/**
|
|
306
309
|
* @typedef {[
|
|
307
310
|
* [JAVASCRIPT_MODULE_TYPE_AUTO, JavascriptParser, JavascriptParserOptions, JavascriptGenerator, EmptyGeneratorOptions],
|
|
@@ -322,6 +325,7 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
|
322
325
|
* [string, Parser, ParserOptions, Generator, GeneratorOptions],
|
|
323
326
|
* ]} ParsersAndGeneratorsByTypes
|
|
324
327
|
*/
|
|
328
|
+
/* eslint-enable jsdoc/type-formatting */
|
|
325
329
|
|
|
326
330
|
/**
|
|
327
331
|
* @template {unknown[]} T
|
|
@@ -391,7 +395,9 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
391
395
|
() => new SyncBailHook(["createData", "resolveData"])
|
|
392
396
|
)
|
|
393
397
|
});
|
|
398
|
+
/** @type {ResolverFactory} */
|
|
394
399
|
this.resolverFactory = resolverFactory;
|
|
400
|
+
/** @type {RuleSet} */
|
|
395
401
|
this.ruleSet = ruleSetCompiler.compile([
|
|
396
402
|
{
|
|
397
403
|
rules: /** @type {RuleSetRules} */ (options.defaultRules)
|
|
@@ -400,7 +406,9 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
400
406
|
rules: /** @type {RuleSetRules} */ (options.rules)
|
|
401
407
|
}
|
|
402
408
|
]);
|
|
409
|
+
/** @type {string} */
|
|
403
410
|
this.context = context || "";
|
|
411
|
+
/** @type {InputFileSystem} */
|
|
404
412
|
this.fs = fs;
|
|
405
413
|
this._globalParserOptions = options.parser;
|
|
406
414
|
this._globalGeneratorOptions = options.generator;
|
|
@@ -662,7 +670,9 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
662
670
|
const useLoadersPre = [];
|
|
663
671
|
|
|
664
672
|
// handle .webpack[] suffix
|
|
673
|
+
/** @type {string} */
|
|
665
674
|
let resource;
|
|
675
|
+
/** @type {RegExpExecArray | null} */
|
|
666
676
|
let match;
|
|
667
677
|
if (
|
|
668
678
|
matchResourceData &&
|
|
@@ -853,7 +863,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
853
863
|
* @param {string} context context
|
|
854
864
|
*/
|
|
855
865
|
const defaultResolve = (context) => {
|
|
856
|
-
if (/^(
|
|
866
|
+
if (/^(?:$|\?)/.test(unresolvedResource)) {
|
|
857
867
|
resourceData = {
|
|
858
868
|
...cacheParseResource(unresolvedResource),
|
|
859
869
|
resource: unresolvedResource,
|
|
@@ -969,8 +979,11 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
969
979
|
(dependency).attributes;
|
|
970
980
|
const dependencyType = dependency.category || "";
|
|
971
981
|
const contextInfo = data.contextInfo;
|
|
982
|
+
/** @type {FileSystemDependencies} */
|
|
972
983
|
const fileDependencies = new LazySet();
|
|
984
|
+
/** @type {FileSystemDependencies} */
|
|
973
985
|
const missingDependencies = new LazySet();
|
|
986
|
+
/** @type {FileSystemDependencies} */
|
|
974
987
|
const contextDependencies = new LazySet();
|
|
975
988
|
/** @type {ResolveData} */
|
|
976
989
|
const resolveData = {
|
|
@@ -1185,7 +1198,7 @@ Add the extension to the request.`
|
|
|
1185
1198
|
(err, resolvedResource) => {
|
|
1186
1199
|
if (!err && resolvedResource) {
|
|
1187
1200
|
let hint = "";
|
|
1188
|
-
const match =
|
|
1201
|
+
const match = /\.[^.]+(?:\?|$)/.exec(unresolvedResource);
|
|
1189
1202
|
if (match) {
|
|
1190
1203
|
const fixedRequest = unresolvedResource.replace(
|
|
1191
1204
|
/(\.[^.]+)(\?|$)/,
|
|
@@ -1335,7 +1348,10 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1335
1348
|
);
|
|
1336
1349
|
},
|
|
1337
1350
|
(err, value) => {
|
|
1338
|
-
callback(
|
|
1351
|
+
callback(
|
|
1352
|
+
/** @type {Error | null} */ (err),
|
|
1353
|
+
/** @type {(LoaderItem)[]} */ (value)
|
|
1354
|
+
);
|
|
1339
1355
|
}
|
|
1340
1356
|
);
|
|
1341
1357
|
}
|
package/lib/OptionsApply.js
CHANGED
|
@@ -6,15 +6,17 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
/** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
9
|
+
/** @typedef {import("./config/normalization").WebpackOptionsInterception} WebpackOptionsInterception */
|
|
9
10
|
/** @typedef {import("./Compiler")} Compiler */
|
|
10
11
|
|
|
11
12
|
class OptionsApply {
|
|
12
13
|
/**
|
|
13
14
|
* @param {WebpackOptions} options options object
|
|
14
15
|
* @param {Compiler} compiler compiler object
|
|
16
|
+
* @param {WebpackOptionsInterception=} interception intercepted options
|
|
15
17
|
* @returns {WebpackOptions} options object
|
|
16
18
|
*/
|
|
17
|
-
process(options, compiler) {
|
|
19
|
+
process(options, compiler, interception) {
|
|
18
20
|
return options;
|
|
19
21
|
}
|
|
20
22
|
}
|
package/lib/ProgressPlugin.js
CHANGED
|
@@ -235,6 +235,7 @@ class ProgressPlugin {
|
|
|
235
235
|
let doneModules = 0;
|
|
236
236
|
let doneDependencies = 0;
|
|
237
237
|
let doneEntries = 0;
|
|
238
|
+
/** @type {Set<string>} */
|
|
238
239
|
const activeModules = new Set();
|
|
239
240
|
let lastUpdate = 0;
|
|
240
241
|
|
|
@@ -254,6 +255,7 @@ class ProgressPlugin {
|
|
|
254
255
|
const percentByDependencies =
|
|
255
256
|
doneDependencies /
|
|
256
257
|
Math.max(lastDependenciesCount || 1, dependenciesCount);
|
|
258
|
+
/** @type {number} */
|
|
257
259
|
let percentageFactor;
|
|
258
260
|
|
|
259
261
|
switch (this.percentBy) {
|
|
@@ -285,6 +287,7 @@ class ProgressPlugin {
|
|
|
285
287
|
)}`
|
|
286
288
|
);
|
|
287
289
|
} else {
|
|
290
|
+
/** @type {string[]} */
|
|
288
291
|
const statItems = [];
|
|
289
292
|
if (showEntries) {
|
|
290
293
|
statItems.push(`${doneEntries}/${entriesCount} entries`);
|
|
@@ -480,6 +483,7 @@ class ProgressPlugin {
|
|
|
480
483
|
|
|
481
484
|
// @ts-expect-error avoid dynamic require if bundled with webpack
|
|
482
485
|
if (typeof __webpack_require__ !== "function") {
|
|
486
|
+
/** @type {Set<string>} */
|
|
483
487
|
const requiredLoaders = new Set();
|
|
484
488
|
NormalModule.getCompilationHooks(compilation).beforeLoaders.tap(
|
|
485
489
|
PLUGIN_NAME,
|
package/lib/RawModule.js
CHANGED
|
@@ -24,6 +24,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
24
24
|
/** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
|
|
25
25
|
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
|
|
26
26
|
/** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
|
27
|
+
/** @typedef {import("./Module").Sources} Sources */
|
|
27
28
|
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
|
28
29
|
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
29
30
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
|
@@ -122,6 +123,7 @@ class RawModule extends Module {
|
|
|
122
123
|
* @returns {CodeGenerationResult} result
|
|
123
124
|
*/
|
|
124
125
|
codeGeneration(context) {
|
|
126
|
+
/** @type {Sources} */
|
|
125
127
|
const sources = new Map();
|
|
126
128
|
if (this.useSourceMap || this.useSimpleSourceMap) {
|
|
127
129
|
sources.set(
|
package/lib/RuntimeModule.js
CHANGED
|
@@ -17,11 +17,14 @@ const { WEBPACK_MODULE_TYPE_RUNTIME } = require("./ModuleTypeConstants");
|
|
|
17
17
|
/** @typedef {import("./Compilation")} Compilation */
|
|
18
18
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
|
19
19
|
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
|
|
20
|
+
/** @typedef {import("./Module").BuildMeta} BuildMeta */
|
|
21
|
+
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
|
20
22
|
/** @typedef {import("./Module").BuildCallback} BuildCallback */
|
|
21
23
|
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
|
22
24
|
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
|
23
25
|
/** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
|
|
24
26
|
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
|
|
27
|
+
/** @typedef {import("./Module").Sources} Sources */
|
|
25
28
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
|
26
29
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
27
30
|
/** @typedef {import("./util/Hash")} Hash */
|
|
@@ -34,9 +37,13 @@ class RuntimeModule extends Module {
|
|
|
34
37
|
*/
|
|
35
38
|
constructor(name, stage = 0) {
|
|
36
39
|
super(WEBPACK_MODULE_TYPE_RUNTIME);
|
|
40
|
+
/** @type {string} */
|
|
37
41
|
this.name = name;
|
|
42
|
+
/** @type {number} */
|
|
38
43
|
this.stage = stage;
|
|
44
|
+
/** @type {BuildMeta} */
|
|
39
45
|
this.buildMeta = {};
|
|
46
|
+
/** @type {BuildInfo} */
|
|
40
47
|
this.buildInfo = {};
|
|
41
48
|
/** @type {Compilation | undefined} */
|
|
42
49
|
this.compilation = undefined;
|
|
@@ -44,7 +51,9 @@ class RuntimeModule extends Module {
|
|
|
44
51
|
this.chunk = undefined;
|
|
45
52
|
/** @type {ChunkGraph | undefined} */
|
|
46
53
|
this.chunkGraph = undefined;
|
|
54
|
+
/** @type {boolean} */
|
|
47
55
|
this.fullHash = false;
|
|
56
|
+
/** @type {boolean} */
|
|
48
57
|
this.dependentHash = false;
|
|
49
58
|
/** @type {string | undefined | null} */
|
|
50
59
|
this._cachedGeneratedCode = undefined;
|
|
@@ -134,6 +143,7 @@ class RuntimeModule extends Module {
|
|
|
134
143
|
* @returns {CodeGenerationResult} result
|
|
135
144
|
*/
|
|
136
145
|
codeGeneration(context) {
|
|
146
|
+
/** @type {Sources} */
|
|
137
147
|
const sources = new Map();
|
|
138
148
|
const generatedCode = this.getGeneratedCode();
|
|
139
149
|
if (generatedCode) {
|
package/lib/RuntimePlugin.js
CHANGED
|
@@ -111,6 +111,8 @@ const TREE_DEPENDENCIES = {
|
|
|
111
111
|
[RuntimeGlobals.shareScopeMap]: [RuntimeGlobals.hasOwnProperty]
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
+
const FULLHASH_REGEXP = /\[(?:full)?hash(?::\d+)?\]/;
|
|
115
|
+
|
|
114
116
|
const PLUGIN_NAME = "RuntimePlugin";
|
|
115
117
|
|
|
116
118
|
class RuntimePlugin {
|
|
@@ -266,7 +268,7 @@ class RuntimePlugin {
|
|
|
266
268
|
|
|
267
269
|
if (
|
|
268
270
|
typeof publicPath !== "string" ||
|
|
269
|
-
/\[(full)?hash\]/.test(publicPath)
|
|
271
|
+
/\[(?:full)?hash\]/.test(publicPath)
|
|
270
272
|
) {
|
|
271
273
|
module.fullHash = true;
|
|
272
274
|
}
|
|
@@ -314,9 +316,7 @@ class RuntimePlugin {
|
|
|
314
316
|
.tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
|
|
315
317
|
if (
|
|
316
318
|
typeof compilation.outputOptions.chunkFilename === "string" &&
|
|
317
|
-
|
|
318
|
-
compilation.outputOptions.chunkFilename
|
|
319
|
-
)
|
|
319
|
+
FULLHASH_REGEXP.test(compilation.outputOptions.chunkFilename)
|
|
320
320
|
) {
|
|
321
321
|
set.add(RuntimeGlobals.getFullHash);
|
|
322
322
|
}
|
|
@@ -342,9 +342,7 @@ class RuntimePlugin {
|
|
|
342
342
|
.tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
|
|
343
343
|
if (
|
|
344
344
|
typeof compilation.outputOptions.cssChunkFilename === "string" &&
|
|
345
|
-
|
|
346
|
-
compilation.outputOptions.cssChunkFilename
|
|
347
|
-
)
|
|
345
|
+
FULLHASH_REGEXP.test(compilation.outputOptions.cssChunkFilename)
|
|
348
346
|
) {
|
|
349
347
|
set.add(RuntimeGlobals.getFullHash);
|
|
350
348
|
}
|
|
@@ -374,7 +372,7 @@ class RuntimePlugin {
|
|
|
374
372
|
.for(RuntimeGlobals.getChunkUpdateScriptFilename)
|
|
375
373
|
.tap(PLUGIN_NAME, (chunk, set) => {
|
|
376
374
|
if (
|
|
377
|
-
|
|
375
|
+
FULLHASH_REGEXP.test(
|
|
378
376
|
compilation.outputOptions.hotUpdateChunkFilename
|
|
379
377
|
)
|
|
380
378
|
) {
|
|
@@ -396,7 +394,7 @@ class RuntimePlugin {
|
|
|
396
394
|
.for(RuntimeGlobals.getUpdateManifestFilename)
|
|
397
395
|
.tap(PLUGIN_NAME, (chunk, set) => {
|
|
398
396
|
if (
|
|
399
|
-
|
|
397
|
+
FULLHASH_REGEXP.test(
|
|
400
398
|
compilation.outputOptions.hotUpdateMainFilename
|
|
401
399
|
)
|
|
402
400
|
) {
|