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
package/lib/FileSystemInfo.js
CHANGED
|
@@ -25,6 +25,7 @@ const processAsyncTree = require("./util/processAsyncTree");
|
|
|
25
25
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
26
26
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
27
27
|
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
|
28
|
+
/** @typedef {import("./util/fs").JsonObject} JsonObject */
|
|
28
29
|
/** @typedef {import("./util/fs").IStats} IStats */
|
|
29
30
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
30
31
|
/**
|
|
@@ -43,6 +44,7 @@ const builtinModules = new Set(nodeModule.builtinModules);
|
|
|
43
44
|
|
|
44
45
|
let FS_ACCURACY = 2000;
|
|
45
46
|
|
|
47
|
+
/** @type {Set<string>} */
|
|
46
48
|
const EMPTY_SET = new Set();
|
|
47
49
|
|
|
48
50
|
const RBDT_RESOLVE_INITIAL = 0;
|
|
@@ -60,6 +62,9 @@ const RBDT_FILE_DEPENDENCIES = 9;
|
|
|
60
62
|
|
|
61
63
|
const INVALID = Symbol("invalid");
|
|
62
64
|
|
|
65
|
+
// eslint-disable-next-line jsdoc/ts-no-empty-object-type
|
|
66
|
+
/** @typedef {{ }} ExistenceOnlyTimeEntry */
|
|
67
|
+
|
|
63
68
|
/**
|
|
64
69
|
* @typedef {object} FileSystemInfoEntry
|
|
65
70
|
* @property {number} safeTime
|
|
@@ -767,6 +772,7 @@ class SnapshotOptimization {
|
|
|
767
772
|
continue;
|
|
768
773
|
}
|
|
769
774
|
// Extract common timestamps from both snapshots
|
|
775
|
+
/** @type {Set<string> | Map<string, T>} */
|
|
770
776
|
let commonMap;
|
|
771
777
|
if (this._isSet) {
|
|
772
778
|
commonMap = new Set();
|
|
@@ -818,6 +824,7 @@ class SnapshotOptimization {
|
|
|
818
824
|
// Incomplete snapshot, that can't be used
|
|
819
825
|
continue;
|
|
820
826
|
}
|
|
827
|
+
/** @type {Set<string> | Map<string, T>} */
|
|
821
828
|
let commonMap;
|
|
822
829
|
if (this._isSet) {
|
|
823
830
|
commonMap = new Set();
|
|
@@ -1401,22 +1408,30 @@ class FileSystemInfo {
|
|
|
1401
1408
|
}
|
|
1402
1409
|
|
|
1403
1410
|
/**
|
|
1404
|
-
* @param {ReadonlyMap<string,
|
|
1411
|
+
* @param {ReadonlyMap<string, FileSystemInfoEntry | ExistenceOnlyTimeEntry | "ignore" | null>} map timestamps
|
|
1405
1412
|
* @param {boolean=} immutable if 'map' is immutable and FileSystemInfo can keep referencing it
|
|
1406
1413
|
* @returns {void}
|
|
1407
1414
|
*/
|
|
1408
1415
|
addFileTimestamps(map, immutable) {
|
|
1409
|
-
this._fileTimestamps.addAll(
|
|
1416
|
+
this._fileTimestamps.addAll(
|
|
1417
|
+
/** @type {ReadonlyMap<string, FileTimestamp>} */
|
|
1418
|
+
(map),
|
|
1419
|
+
immutable
|
|
1420
|
+
);
|
|
1410
1421
|
this._cachedDeprecatedFileTimestamps = undefined;
|
|
1411
1422
|
}
|
|
1412
1423
|
|
|
1413
1424
|
/**
|
|
1414
|
-
* @param {ReadonlyMap<string,
|
|
1425
|
+
* @param {ReadonlyMap<string, ContextFileSystemInfoEntry | ExistenceOnlyTimeEntry | "ignore" | null>} map timestamps
|
|
1415
1426
|
* @param {boolean=} immutable if 'map' is immutable and FileSystemInfo can keep referencing it
|
|
1416
1427
|
* @returns {void}
|
|
1417
1428
|
*/
|
|
1418
1429
|
addContextTimestamps(map, immutable) {
|
|
1419
|
-
this._contextTimestamps.addAll(
|
|
1430
|
+
this._contextTimestamps.addAll(
|
|
1431
|
+
/** @type {ReadonlyMap<string, ContextTimestamp>} */
|
|
1432
|
+
(map),
|
|
1433
|
+
immutable
|
|
1434
|
+
);
|
|
1420
1435
|
this._cachedDeprecatedContextTimestamps = undefined;
|
|
1421
1436
|
}
|
|
1422
1437
|
|
|
@@ -1889,7 +1904,7 @@ class FileSystemInfo {
|
|
|
1889
1904
|
for (const modulePath of module.paths) {
|
|
1890
1905
|
if (childPath.startsWith(modulePath)) {
|
|
1891
1906
|
const subPath = childPath.slice(modulePath.length + 1);
|
|
1892
|
-
const packageMatch =
|
|
1907
|
+
const packageMatch = /^@[^\\/]+[\\/][^\\/]+/.exec(
|
|
1893
1908
|
subPath
|
|
1894
1909
|
);
|
|
1895
1910
|
if (packageMatch) {
|
|
@@ -1954,9 +1969,11 @@ class FileSystemInfo {
|
|
|
1954
1969
|
const context = dirname(this.fs, path);
|
|
1955
1970
|
const source = /** @type {Buffer} */ (content).toString();
|
|
1956
1971
|
const [imports] = lexer.parse(source);
|
|
1972
|
+
/** @type {Set<string>} */
|
|
1957
1973
|
const added = new Set();
|
|
1958
1974
|
for (const imp of imports) {
|
|
1959
1975
|
try {
|
|
1976
|
+
/** @type {string} */
|
|
1960
1977
|
let dependency;
|
|
1961
1978
|
if (imp.d === -1) {
|
|
1962
1979
|
// import ... from "..."
|
|
@@ -2043,6 +2060,7 @@ class FileSystemInfo {
|
|
|
2043
2060
|
return callback(err);
|
|
2044
2061
|
}
|
|
2045
2062
|
resolveFiles.add(packageJson);
|
|
2063
|
+
/** @type {JsonObject} */
|
|
2046
2064
|
let packageData;
|
|
2047
2065
|
try {
|
|
2048
2066
|
packageData = JSON.parse(
|
|
@@ -2054,7 +2072,9 @@ class FileSystemInfo {
|
|
|
2054
2072
|
}
|
|
2055
2073
|
const depsObject = packageData.dependencies;
|
|
2056
2074
|
const optionalDepsObject = packageData.optionalDependencies;
|
|
2075
|
+
/** @type {Set<string>} */
|
|
2057
2076
|
const allDeps = new Set();
|
|
2077
|
+
/** @type {Set<string>} */
|
|
2058
2078
|
const optionalDeps = new Set();
|
|
2059
2079
|
if (typeof depsObject === "object" && depsObject) {
|
|
2060
2080
|
for (const dep of Object.keys(depsObject)) {
|
|
@@ -2172,15 +2192,17 @@ class FileSystemInfo {
|
|
|
2172
2192
|
* @param {Error | typeof INVALID=} err error or invalid flag
|
|
2173
2193
|
* @returns {void}
|
|
2174
2194
|
*/
|
|
2175
|
-
(
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2195
|
+
/** @type {import("neo-async").ErrorCallback<Error | typeof INVALID>} */ (
|
|
2196
|
+
(err) => {
|
|
2197
|
+
if (err === INVALID) {
|
|
2198
|
+
return callback(null, false);
|
|
2199
|
+
}
|
|
2200
|
+
if (err) {
|
|
2201
|
+
return callback(err);
|
|
2202
|
+
}
|
|
2203
|
+
return callback(null, true);
|
|
2181
2204
|
}
|
|
2182
|
-
|
|
2183
|
-
}
|
|
2205
|
+
)
|
|
2184
2206
|
);
|
|
2185
2207
|
}
|
|
2186
2208
|
|
|
@@ -2492,6 +2514,7 @@ class FileSystemInfo {
|
|
|
2492
2514
|
);
|
|
2493
2515
|
for (const path of capturedDirectories) {
|
|
2494
2516
|
const cache = this._contextHashes.get(path);
|
|
2517
|
+
/** @type {undefined | null | string} */
|
|
2495
2518
|
let resolved;
|
|
2496
2519
|
if (
|
|
2497
2520
|
cache !== undefined &&
|
|
@@ -2533,6 +2556,7 @@ class FileSystemInfo {
|
|
|
2533
2556
|
for (const path of capturedDirectories) {
|
|
2534
2557
|
const cache = this._contextTimestamps.get(path);
|
|
2535
2558
|
if (cache === "ignore") continue;
|
|
2559
|
+
/** @type {undefined | null | ResolvedContextFileSystemInfoEntry} */
|
|
2536
2560
|
let resolved;
|
|
2537
2561
|
if (
|
|
2538
2562
|
cache !== undefined &&
|
|
@@ -2653,6 +2677,7 @@ class FileSystemInfo {
|
|
|
2653
2677
|
*/
|
|
2654
2678
|
const process = (set, fn) => {
|
|
2655
2679
|
if (set.size === 0) return;
|
|
2680
|
+
/** @type {Set<string>} */
|
|
2656
2681
|
const captured = new Set();
|
|
2657
2682
|
for (const file of set) {
|
|
2658
2683
|
if (file.startsWith(path)) captured.add(file);
|
|
@@ -3068,6 +3093,7 @@ class FileSystemInfo {
|
|
|
3068
3093
|
for (const [path, ts] of contextTimestamps) {
|
|
3069
3094
|
const cache = this._contextTimestamps.get(path);
|
|
3070
3095
|
if (cache === "ignore") continue;
|
|
3096
|
+
/** @type {undefined | null | ResolvedContextFileSystemInfoEntry} */
|
|
3071
3097
|
let resolved;
|
|
3072
3098
|
if (
|
|
3073
3099
|
cache !== undefined &&
|
|
@@ -3117,6 +3143,7 @@ class FileSystemInfo {
|
|
|
3117
3143
|
*/
|
|
3118
3144
|
const processContextHashSnapshot = (path, hash) => {
|
|
3119
3145
|
const cache = this._contextHashes.get(path);
|
|
3146
|
+
/** @type {undefined | null | string} */
|
|
3120
3147
|
let resolved;
|
|
3121
3148
|
if (
|
|
3122
3149
|
cache !== undefined &&
|
|
@@ -3165,20 +3192,13 @@ class FileSystemInfo {
|
|
|
3165
3192
|
} else {
|
|
3166
3193
|
const cache = this._contextTimestamps.get(path);
|
|
3167
3194
|
if (cache === "ignore") continue;
|
|
3195
|
+
/** @type {undefined | null | ResolvedContextFileSystemInfoEntry} */
|
|
3168
3196
|
let resolved;
|
|
3169
3197
|
if (
|
|
3170
3198
|
cache !== undefined &&
|
|
3171
3199
|
(resolved = getResolvedTimestamp(cache)) !== undefined
|
|
3172
3200
|
) {
|
|
3173
|
-
if (
|
|
3174
|
-
!checkContext(
|
|
3175
|
-
path,
|
|
3176
|
-
/** @type {ResolvedContextFileSystemInfoEntry | null} */
|
|
3177
|
-
(resolved),
|
|
3178
|
-
tsh,
|
|
3179
|
-
false
|
|
3180
|
-
)
|
|
3181
|
-
) {
|
|
3201
|
+
if (!checkContext(path, resolved, tsh, false)) {
|
|
3182
3202
|
processContextHashSnapshot(path, tsh && tsh.hash);
|
|
3183
3203
|
}
|
|
3184
3204
|
} else {
|
|
@@ -3298,6 +3318,7 @@ class FileSystemInfo {
|
|
|
3298
3318
|
return callback(/** @type {WebpackError} */ (err));
|
|
3299
3319
|
}
|
|
3300
3320
|
const stat = /** @type {IStats} */ (_stat);
|
|
3321
|
+
/** @type {FileSystemInfoEntry} */
|
|
3301
3322
|
let ts;
|
|
3302
3323
|
if (stat.isDirectory()) {
|
|
3303
3324
|
ts = {
|
|
@@ -3576,6 +3597,7 @@ class FileSystemInfo {
|
|
|
3576
3597
|
});
|
|
3577
3598
|
},
|
|
3578
3599
|
reduce: (files, tsEntries) => {
|
|
3600
|
+
/** @type {undefined | Symlinks} */
|
|
3579
3601
|
let symlinks;
|
|
3580
3602
|
|
|
3581
3603
|
const hash = createHash(this._hashFunction);
|
|
@@ -3725,6 +3747,7 @@ class FileSystemInfo {
|
|
|
3725
3747
|
* @returns {ContextHash} reduced hash
|
|
3726
3748
|
*/
|
|
3727
3749
|
reduce: (files, fileHashes) => {
|
|
3750
|
+
/** @type {undefined | Symlinks} */
|
|
3728
3751
|
let symlinks;
|
|
3729
3752
|
const hash = createHash(this._hashFunction);
|
|
3730
3753
|
|
|
@@ -3867,6 +3890,7 @@ class FileSystemInfo {
|
|
|
3867
3890
|
* @returns {ContextTimestampAndHash} tsh
|
|
3868
3891
|
*/
|
|
3869
3892
|
reduce: (files, results) => {
|
|
3893
|
+
/** @type {undefined | Symlinks} */
|
|
3870
3894
|
let symlinks;
|
|
3871
3895
|
|
|
3872
3896
|
const tsHash = createHash(this._hashFunction);
|
|
@@ -3997,9 +4021,8 @@ class FileSystemInfo {
|
|
|
3997
4021
|
return callback(/** @type {WebpackError} */ (err));
|
|
3998
4022
|
}
|
|
3999
4023
|
const set = new Set(
|
|
4000
|
-
/** @type {string[]} */
|
|
4001
|
-
|
|
4002
|
-
)
|
|
4024
|
+
/** @type {string[]} */
|
|
4025
|
+
(elements).map((element) => join(this.fs, path, element))
|
|
4003
4026
|
);
|
|
4004
4027
|
callback(null, set);
|
|
4005
4028
|
});
|
|
@@ -4058,6 +4081,7 @@ class FileSystemInfo {
|
|
|
4058
4081
|
}
|
|
4059
4082
|
return callback(/** @type {WebpackError} */ (err));
|
|
4060
4083
|
}
|
|
4084
|
+
/** @type {JsonObject} */
|
|
4061
4085
|
let data;
|
|
4062
4086
|
try {
|
|
4063
4087
|
data = JSON.parse(/** @type {Buffer} */ (content).toString("utf8"));
|
|
@@ -14,6 +14,7 @@ const Queue = require("./util/Queue");
|
|
|
14
14
|
/** @typedef {import("./Dependency").ExportSpec} ExportSpec */
|
|
15
15
|
/** @typedef {import("./Dependency").ExportsSpec} ExportsSpec */
|
|
16
16
|
/** @typedef {import("./ExportsInfo")} ExportsInfo */
|
|
17
|
+
/** @typedef {import("./ExportsInfo").ExportInfoName} ExportInfoName */
|
|
17
18
|
/** @typedef {import("./ExportsInfo").RestoreProvidedData} RestoreProvidedData */
|
|
18
19
|
/** @typedef {import("./Module")} Module */
|
|
19
20
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
|
@@ -50,7 +51,9 @@ class FlagDependencyExportsPlugin {
|
|
|
50
51
|
// Step 1: Try to restore cached provided export info from cache
|
|
51
52
|
logger.time("restore cached provided exports");
|
|
52
53
|
asyncLib.each(
|
|
53
|
-
|
|
54
|
+
/** @type {import("neo-async").IterableCollection<Module>} */ (
|
|
55
|
+
/** @type {unknown} */ (modules)
|
|
56
|
+
),
|
|
54
57
|
(module, callback) => {
|
|
55
58
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
|
56
59
|
// If the module doesn't have an exportsType, it's a module
|
|
@@ -188,11 +191,14 @@ class FlagDependencyExportsPlugin {
|
|
|
188
191
|
*/
|
|
189
192
|
const mergeExports = (exportsInfo, exports) => {
|
|
190
193
|
for (const exportNameOrSpec of exports) {
|
|
194
|
+
/** @type {ExportInfoName} */
|
|
191
195
|
let name;
|
|
192
196
|
let canMangle = globalCanMangle;
|
|
193
197
|
let terminalBinding = globalTerminalBinding;
|
|
198
|
+
/** @type {ExportSpec["exports"]} */
|
|
194
199
|
let exports;
|
|
195
200
|
let from = globalFrom;
|
|
201
|
+
/** @type {ExportSpec["export"]} */
|
|
196
202
|
let fromExport;
|
|
197
203
|
let priority = globalPriority;
|
|
198
204
|
let hidden = false;
|
|
@@ -270,6 +276,7 @@ class FlagDependencyExportsPlugin {
|
|
|
270
276
|
|
|
271
277
|
// Recalculate target exportsInfo
|
|
272
278
|
const target = exportInfo.getTarget(moduleGraph);
|
|
279
|
+
/** @type {undefined | ExportsInfo} */
|
|
273
280
|
let targetExportsInfo;
|
|
274
281
|
if (target) {
|
|
275
282
|
const targetModuleExportsInfo =
|
|
@@ -31,6 +31,7 @@ class FlagDependencyUsagePlugin {
|
|
|
31
31
|
* @param {boolean} global do a global analysis instead of per runtime
|
|
32
32
|
*/
|
|
33
33
|
constructor(global) {
|
|
34
|
+
/** @type {boolean} */
|
|
34
35
|
this.global = global;
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -80,6 +81,7 @@ class FlagDependencyUsagePlugin {
|
|
|
80
81
|
return;
|
|
81
82
|
}
|
|
82
83
|
for (const usedExportInfo of usedExports) {
|
|
84
|
+
/** @type {string[]} */
|
|
83
85
|
let usedExport;
|
|
84
86
|
let canMangle = true;
|
|
85
87
|
if (Array.isArray(usedExportInfo)) {
|
|
@@ -167,7 +169,8 @@ class FlagDependencyUsagePlugin {
|
|
|
167
169
|
* @returns {void}
|
|
168
170
|
*/
|
|
169
171
|
const processModule = (module, runtime, forceSideEffects) => {
|
|
170
|
-
/** @
|
|
172
|
+
/** @typedef {Map<string, string[] | ReferencedExport>} ExportMaps */
|
|
173
|
+
/** @type {Map<Module, ReferencedExports | ExportMaps>} */
|
|
171
174
|
const map = new Map();
|
|
172
175
|
|
|
173
176
|
/** @type {ArrayQueue<DependenciesBlock>} */
|
|
@@ -177,14 +180,12 @@ class FlagDependencyUsagePlugin {
|
|
|
177
180
|
const block = queue.dequeue();
|
|
178
181
|
if (block === undefined) break;
|
|
179
182
|
for (const b of block.blocks) {
|
|
180
|
-
if (
|
|
181
|
-
!this.global &&
|
|
182
|
-
b.groupOptions &&
|
|
183
|
-
b.groupOptions.entryOptions
|
|
184
|
-
) {
|
|
183
|
+
if (b.groupOptions && b.groupOptions.entryOptions) {
|
|
185
184
|
processModule(
|
|
186
185
|
b,
|
|
187
|
-
|
|
186
|
+
this.global
|
|
187
|
+
? undefined
|
|
188
|
+
: b.groupOptions.entryOptions.runtime || undefined,
|
|
188
189
|
true
|
|
189
190
|
);
|
|
190
191
|
} else {
|
|
@@ -221,6 +222,7 @@ class FlagDependencyUsagePlugin {
|
|
|
221
222
|
) {
|
|
222
223
|
continue;
|
|
223
224
|
} else {
|
|
225
|
+
/** @type {undefined | ExportMaps} */
|
|
224
226
|
let exportsMap;
|
|
225
227
|
if (Array.isArray(oldReferencedExports)) {
|
|
226
228
|
exportsMap = new Map();
|
package/lib/HookWebpackError.js
CHANGED
|
@@ -30,6 +30,7 @@ class HookWebpackError extends WebpackError {
|
|
|
30
30
|
|
|
31
31
|
this.hook = hook;
|
|
32
32
|
this.error = error;
|
|
33
|
+
/** @type {string} */
|
|
33
34
|
this.name = "HookWebpackError";
|
|
34
35
|
this.hideStack = true;
|
|
35
36
|
this.stack += `\n-- inner error --\n${error ? error.stack : ""}`;
|
|
@@ -104,6 +105,7 @@ module.exports.makeWebpackErrorCallback = makeWebpackErrorCallback;
|
|
|
104
105
|
* @returns {T} the result
|
|
105
106
|
*/
|
|
106
107
|
const tryRunOrWebpackError = (fn, hook) => {
|
|
108
|
+
/** @type {T} */
|
|
107
109
|
let r;
|
|
108
110
|
try {
|
|
109
111
|
r = fn();
|
|
@@ -75,7 +75,10 @@ const {
|
|
|
75
75
|
/** @typedef {Record<ChunkId, string>} ChunkRuntime */
|
|
76
76
|
/** @typedef {Record<ChunkId, ModuleId[]>} ChunkModuleIds */
|
|
77
77
|
|
|
78
|
-
/** @typedef {
|
|
78
|
+
/** @typedef {Set<ChunkId>} ChunkIds */
|
|
79
|
+
/** @typedef {Set<Module>} ModuleSet */
|
|
80
|
+
|
|
81
|
+
/** @typedef {{ updatedChunkIds: ChunkIds, removedChunkIds: ChunkIds, removedModules: ModuleSet, filename: string, assetInfo: AssetInfo }} HotUpdateMainContentByRuntimeItem */
|
|
79
82
|
/** @typedef {Map<string, HotUpdateMainContentByRuntimeItem>} HotUpdateMainContentByRuntime */
|
|
80
83
|
|
|
81
84
|
/** @type {WeakMap<JavascriptParser, HMRJavascriptParserHooks>} */
|
|
@@ -517,6 +520,7 @@ class HotModuleReplacementPlugin {
|
|
|
517
520
|
|
|
518
521
|
/** @type {HotUpdateMainContentByRuntime} */
|
|
519
522
|
const hotUpdateMainContentByRuntime = new Map();
|
|
523
|
+
/** @type {RuntimeSpec} */
|
|
520
524
|
let allOldRuntime;
|
|
521
525
|
const chunkRuntime =
|
|
522
526
|
/** @type {ChunkRuntime} */
|
|
@@ -537,8 +541,11 @@ class HotModuleReplacementPlugin {
|
|
|
537
541
|
hotUpdateMainContentByRuntime.set(
|
|
538
542
|
/** @type {string} */ (runtime),
|
|
539
543
|
{
|
|
544
|
+
/** @type {ChunkIds} */
|
|
540
545
|
updatedChunkIds: new Set(),
|
|
546
|
+
/** @type {ChunkIds} */
|
|
541
547
|
removedChunkIds: new Set(),
|
|
548
|
+
/** @type {ModuleSet} */
|
|
542
549
|
removedModules: new Set(),
|
|
543
550
|
filename,
|
|
544
551
|
assetInfo
|
|
@@ -580,11 +587,17 @@ class HotModuleReplacementPlugin {
|
|
|
580
587
|
|
|
581
588
|
/** @type {ChunkId | null} */
|
|
582
589
|
let chunkId;
|
|
590
|
+
/** @type {undefined | Module[]} */
|
|
583
591
|
let newModules;
|
|
592
|
+
/** @type {undefined | RuntimeModule[]} */
|
|
584
593
|
let newRuntimeModules;
|
|
594
|
+
/** @type {undefined | RuntimeModule[]} */
|
|
585
595
|
let newFullHashModules;
|
|
596
|
+
/** @type {undefined | RuntimeModule[]} */
|
|
586
597
|
let newDependentHashModules;
|
|
598
|
+
/** @type {RuntimeSpec} */
|
|
587
599
|
let newRuntime;
|
|
600
|
+
/** @type {RuntimeSpec} */
|
|
588
601
|
let removedFromRuntime;
|
|
589
602
|
const currentChunk = find(
|
|
590
603
|
compilation.chunks,
|
|
@@ -775,6 +788,7 @@ class HotModuleReplacementPlugin {
|
|
|
775
788
|
}
|
|
776
789
|
}
|
|
777
790
|
const completelyRemovedModulesArray = [...completelyRemovedModules];
|
|
791
|
+
/** @type {Map<string, Omit<HotUpdateMainContentByRuntimeItem, "filename">>} */
|
|
778
792
|
const hotUpdateMainContentByFilename = new Map();
|
|
779
793
|
for (const {
|
|
780
794
|
removedChunkIds,
|
|
@@ -818,7 +832,7 @@ To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename
|
|
|
818
832
|
filename,
|
|
819
833
|
{ removedChunkIds, removedModules, updatedChunkIds, assetInfo }
|
|
820
834
|
] of hotUpdateMainContentByFilename) {
|
|
821
|
-
/** @type {{c: ChunkId[], r: ChunkId[], m: ModuleId[], css?: {r: ChunkId[]}}} */
|
|
835
|
+
/** @type {{ c: ChunkId[], r: ChunkId[], m: ModuleId[], css?: { r: ChunkId[] } }} */
|
|
822
836
|
const hotUpdateMainJson = {
|
|
823
837
|
c: [...updatedChunkIds],
|
|
824
838
|
r: [...removedChunkIds],
|
package/lib/InitFragment.js
CHANGED
package/lib/LibManifestPlugin.js
CHANGED
|
@@ -55,6 +55,7 @@ class LibManifestPlugin {
|
|
|
55
55
|
(compilation, callback) => {
|
|
56
56
|
const moduleGraph = compilation.moduleGraph;
|
|
57
57
|
// store used paths to detect issue and output an error. #18200
|
|
58
|
+
/** @type {Set<string>} */
|
|
58
59
|
const usedPaths = new Set();
|
|
59
60
|
asyncLib.each(
|
|
60
61
|
[...compilation.chunks],
|
package/lib/ManifestPlugin.js
CHANGED
|
@@ -42,7 +42,9 @@ const extname = (filename) => {
|
|
|
42
42
|
const split = replaced.split(".");
|
|
43
43
|
const last = split.pop();
|
|
44
44
|
if (!last) return "";
|
|
45
|
-
return last && /^(gz|br|map)$/i.test(last)
|
|
45
|
+
return last && /^(?:gz|br|map)$/i.test(last)
|
|
46
|
+
? `${split.pop()}.${last}`
|
|
47
|
+
: last;
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
class ManifestPlugin {
|
|
@@ -121,6 +123,7 @@ class ManifestPlugin {
|
|
|
121
123
|
const entrypoints = {};
|
|
122
124
|
|
|
123
125
|
for (const [name, entrypoint] of compilation.entrypoints) {
|
|
126
|
+
/** @type {string[]} */
|
|
124
127
|
const imports = [];
|
|
125
128
|
|
|
126
129
|
for (const chunk of entrypoint.chunks) {
|
package/lib/Module.js
CHANGED
|
@@ -106,13 +106,15 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
106
106
|
|
|
107
107
|
/** @typedef {Map<"topLevelDeclarations", Set<string>> & Map<"chunkInitFragments", InitFragment<EXPECTED_ANY>[]>} KnownCodeGenerationResultDataForJavascriptModules */
|
|
108
108
|
/** @typedef {Map<"url", { ["css-url"]: string }>} KnownCodeGenerationResultDataForCssModules */
|
|
109
|
-
/** @typedef {Map<"filename", string> & Map<"assetInfo", AssetInfo> & Map<"fullContentHash", string>} KnownCodeGenerationResultDataForAssetModules */
|
|
109
|
+
/** @typedef {Map<"filename", string> & Map<"assetInfo", AssetInfo> & Map<"fullContentHash", string> & Map<"url", { javascript: string }>} KnownCodeGenerationResultDataForAssetModules */
|
|
110
110
|
/** @typedef {Map<"share-init", [{ shareScope: string, initStage: number, init: string }]>} KnownCodeGenerationResultForSharing */
|
|
111
111
|
/** @typedef {KnownCodeGenerationResultDataForJavascriptModules & KnownCodeGenerationResultDataForCssModules & KnownCodeGenerationResultDataForAssetModules & KnownCodeGenerationResultForSharing & Map<string, EXPECTED_ANY>} CodeGenerationResultData */
|
|
112
112
|
|
|
113
|
+
/** @typedef {Map<SourceType, Source>} Sources */
|
|
114
|
+
|
|
113
115
|
/**
|
|
114
116
|
* @typedef {object} CodeGenerationResult
|
|
115
|
-
* @property {
|
|
117
|
+
* @property {Sources} sources the resulting sources for all source types
|
|
116
118
|
* @property {CodeGenerationResultData=} data the resulting data for all source types
|
|
117
119
|
* @property {ReadOnlyRuntimeRequirements | null} runtimeRequirements the runtime requirements
|
|
118
120
|
* @property {string=} hash a hash of the code generation result (will be automatically calculated from sources and runtimeRequirements if not provided)
|
|
@@ -135,8 +137,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
135
137
|
* @property {boolean=} sideEffectFree
|
|
136
138
|
* @property {boolean=} isCSSModule
|
|
137
139
|
* @property {Record<string, string>=} jsIncompatibleExports
|
|
138
|
-
* @property {Map<
|
|
139
|
-
* @property {Map<
|
|
140
|
+
* @property {Map<string, Record<string, string>>=} exportsFinalNameByRuntime
|
|
141
|
+
* @property {Map<string, string>=} exportsSourceByRuntime
|
|
140
142
|
*/
|
|
141
143
|
|
|
142
144
|
/**
|
|
@@ -1026,6 +1028,7 @@ class Module extends DependenciesBlock {
|
|
|
1026
1028
|
*/
|
|
1027
1029
|
codeGeneration(context) {
|
|
1028
1030
|
// Best override this method
|
|
1031
|
+
/** @type {Sources} */
|
|
1029
1032
|
const sources = new Map();
|
|
1030
1033
|
for (const type of this.getSourceTypes()) {
|
|
1031
1034
|
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,6 +30,7 @@ class ModuleError extends WebpackError {
|
|
|
30
30
|
|
|
31
31
|
super(message);
|
|
32
32
|
|
|
33
|
+
/** @type {string} */
|
|
33
34
|
this.name = "ModuleError";
|
|
34
35
|
this.error = err;
|
|
35
36
|
this.details =
|
|
@@ -115,7 +115,7 @@ const lazyObject = (obj) => {
|
|
|
115
115
|
return newObj;
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
-
const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/
|
|
118
|
+
const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/g;
|
|
119
119
|
/**
|
|
120
120
|
* @typedef {object} ModuleFilenameTemplateContext
|
|
121
121
|
* @property {string} identifier the identifier of the module
|
|
@@ -157,6 +157,7 @@ ModuleFilenameHelpers.createFilename = (
|
|
|
157
157
|
|
|
158
158
|
/** @type {ReturnStringCallback} */
|
|
159
159
|
let absoluteResourcePath;
|
|
160
|
+
/** @type {ReturnStringCallback} */
|
|
160
161
|
let hash;
|
|
161
162
|
/** @type {ReturnStringCallback} */
|
|
162
163
|
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;
|
|
@@ -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;
|