webpack 5.101.3 → 5.102.1
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 +21 -26
- package/lib/APIPlugin.js +30 -36
- package/lib/AsyncDependenciesBlock.js +1 -4
- package/lib/BannerPlugin.js +0 -1
- package/lib/Cache.js +7 -6
- package/lib/CacheFacade.js +0 -1
- package/lib/Chunk.js +49 -31
- package/lib/ChunkGraph.js +37 -27
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +3 -2
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +209 -196
- package/lib/Compiler.js +36 -35
- package/lib/ConcatenationScope.js +6 -1
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +6 -5
- package/lib/ContextExclusionPlugin.js +0 -1
- package/lib/ContextModule.js +25 -21
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +5 -9
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +2 -4
- package/lib/DllModule.js +1 -7
- package/lib/DllReferencePlugin.js +2 -4
- package/lib/DynamicEntryPlugin.js +0 -2
- package/lib/EntryOptionPlugin.js +0 -5
- package/lib/EnvironmentNotSupportAsyncWarning.js +0 -3
- package/lib/EvalDevToolModulePlugin.js +4 -3
- package/lib/EvalSourceMapDevToolPlugin.js +3 -4
- package/lib/ExportsInfo.js +50 -49
- package/lib/ExternalModule.js +84 -52
- package/lib/ExternalModuleFactoryPlugin.js +27 -7
- package/lib/ExternalsPlugin.js +24 -17
- package/lib/FileSystemInfo.js +105 -90
- package/lib/FlagDependencyUsagePlugin.js +3 -4
- package/lib/Generator.js +2 -13
- package/lib/GraphHelpers.js +0 -3
- package/lib/HookWebpackError.js +0 -2
- package/lib/HotModuleReplacementPlugin.js +22 -24
- package/lib/HotUpdateChunk.js +0 -3
- package/lib/IgnorePlugin.js +5 -2
- package/lib/InitFragment.js +41 -29
- package/lib/InvalidDependenciesModuleWarning.js +0 -1
- package/lib/LibManifestPlugin.js +4 -6
- package/lib/LoaderOptionsPlugin.js +1 -10
- package/lib/MainTemplate.js +8 -19
- package/lib/Module.js +32 -20
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleFilenameHelpers.js +42 -25
- package/lib/ModuleGraph.js +30 -16
- package/lib/ModuleInfoHeaderPlugin.js +0 -1
- package/lib/ModuleTemplate.js +0 -2
- package/lib/ModuleTypeConstants.js +11 -1
- package/lib/MultiCompiler.js +23 -15
- package/lib/MultiWatching.js +6 -10
- package/lib/NodeStuffPlugin.js +2 -10
- package/lib/NormalModule.js +146 -89
- package/lib/NormalModuleFactory.js +132 -42
- package/lib/OptionsApply.js +1 -1
- package/lib/Parser.js +1 -1
- package/lib/ProgressPlugin.js +6 -10
- package/lib/ProvidePlugin.js +5 -7
- package/lib/RawModule.js +1 -6
- package/lib/RecordIdsPlugin.js +10 -6
- package/lib/ResolverFactory.js +0 -2
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimeModule.js +1 -3
- package/lib/RuntimePlugin.js +26 -22
- package/lib/RuntimeTemplate.js +22 -12
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +11 -18
- package/lib/Stats.js +0 -1
- package/lib/Template.js +6 -11
- package/lib/TemplatedPathPlugin.js +2 -1
- package/lib/WatchIgnorePlugin.js +2 -3
- package/lib/Watching.js +15 -15
- package/lib/WebpackIsIncludedPlugin.js +0 -2
- package/lib/WebpackOptionsApply.js +74 -107
- package/lib/asset/AssetBytesGenerator.js +167 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +22 -37
- package/lib/asset/AssetModulesPlugin.js +34 -16
- package/lib/asset/AssetParser.js +7 -3
- package/lib/asset/AssetSourceGenerator.js +1 -1
- package/lib/asset/RawDataUrlModule.js +3 -2
- package/lib/async-modules/AsyncModuleHelpers.js +6 -4
- package/lib/buildChunkGraph.js +0 -1
- package/lib/cache/MemoryCachePlugin.js +0 -2
- package/lib/cache/MemoryWithGcCachePlugin.js +0 -2
- package/lib/cache/PackFileCacheStrategy.js +14 -1
- package/lib/cache/ResolverCachePlugin.js +9 -15
- package/lib/cache/getLazyHashedEtag.js +1 -1
- package/lib/config/browserslistTargetHandler.js +77 -76
- package/lib/config/defaults.js +162 -23
- package/lib/config/normalization.js +18 -3
- package/lib/config/target.js +1 -1
- package/lib/container/ContainerEntryDependency.js +0 -1
- package/lib/container/ContainerEntryModule.js +3 -7
- package/lib/container/ContainerPlugin.js +1 -2
- package/lib/container/ContainerReferencePlugin.js +0 -1
- package/lib/container/FallbackDependency.js +2 -1
- package/lib/container/FallbackModule.js +6 -7
- package/lib/container/ModuleFederationPlugin.js +0 -1
- package/lib/container/RemoteModule.js +8 -8
- package/lib/container/RemoteRuntimeModule.js +2 -2
- package/lib/css/CssGenerator.js +3 -6
- package/lib/css/CssLoadingRuntimeModule.js +6 -9
- package/lib/css/CssModulesPlugin.js +13 -19
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +2 -2
- package/lib/debug/ProfilingPlugin.js +35 -8
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
- package/lib/dependencies/AMDPlugin.js +2 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/CachedConstDependency.js +0 -4
- package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
- package/lib/dependencies/CommonJsExportsDependency.js +2 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
- package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +9 -4
- package/lib/dependencies/ContextDependencyHelpers.js +2 -2
- package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
- package/lib/dependencies/ContextElementDependency.js +22 -11
- package/lib/dependencies/CssIcssImportDependency.js +0 -2
- package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
- package/lib/dependencies/CssImportDependency.js +0 -8
- package/lib/dependencies/CssLocalIdentifierDependency.js +4 -7
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssUrlDependency.js +0 -6
- package/lib/dependencies/ExportsInfoDependency.js +7 -9
- package/lib/dependencies/ExternalModuleDependency.js +0 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
- package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
- package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
- package/lib/dependencies/HarmonyImportDependency.js +33 -14
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
- package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
- package/lib/dependencies/ImportContextDependency.js +13 -0
- package/lib/dependencies/ImportDependency.js +18 -6
- package/lib/dependencies/ImportEagerDependency.js +2 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
- package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
- package/lib/dependencies/ImportMetaPlugin.js +3 -2
- package/lib/dependencies/ImportParserPlugin.js +288 -45
- package/lib/dependencies/ImportWeakDependency.js +2 -3
- package/lib/dependencies/JsonExportsDependency.js +0 -1
- package/lib/dependencies/LoaderDependency.js +0 -3
- package/lib/dependencies/LoaderImportDependency.js +0 -3
- package/lib/dependencies/LoaderPlugin.js +11 -5
- package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
- package/lib/dependencies/ModuleDependency.js +3 -9
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/ProvidedDependency.js +6 -8
- package/lib/dependencies/PureExpressionDependency.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/RequireIncludeDependency.js +2 -2
- package/lib/dependencies/RequireResolveDependency.js +2 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
- package/lib/dependencies/StaticExportsDependency.js +3 -5
- package/lib/dependencies/URLDependency.js +2 -7
- package/lib/dependencies/URLPlugin.js +1 -2
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
- package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
- package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
- package/lib/dependencies/WorkerDependency.js +2 -3
- package/lib/dependencies/WorkerPlugin.js +4 -12
- package/lib/dependencies/processExportInfo.js +2 -3
- package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
- package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
- package/lib/hmr/LazyCompilationPlugin.js +6 -4
- package/lib/hmr/lazyCompilationBackend.js +13 -10
- package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
- package/lib/ids/HashedModuleIdsPlugin.js +5 -7
- package/lib/ids/IdHelpers.js +1 -1
- package/lib/ids/NamedChunkIdsPlugin.js +1 -6
- package/lib/ids/NamedModuleIdsPlugin.js +1 -5
- package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
- package/lib/ids/SyncModuleIdsPlugin.js +4 -3
- package/lib/index.js +8 -7
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
- package/lib/javascript/BasicEvaluatedExpression.js +13 -6
- package/lib/javascript/ChunkFormatHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
- package/lib/javascript/JavascriptGenerator.js +2 -3
- package/lib/javascript/JavascriptModulesPlugin.js +46 -24
- package/lib/javascript/JavascriptParser.js +120 -55
- package/lib/javascript/JavascriptParserHelpers.js +2 -2
- package/lib/javascript/StartupHelpers.js +2 -4
- package/lib/json/JsonData.js +1 -1
- package/lib/json/JsonGenerator.js +4 -5
- package/lib/json/JsonModulesPlugin.js +0 -3
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +0 -1
- package/lib/library/AssignLibraryPlugin.js +23 -12
- package/lib/library/EnableLibraryPlugin.js +7 -11
- package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
- package/lib/library/JsonpLibraryPlugin.js +5 -2
- package/lib/library/ModuleLibraryPlugin.js +88 -43
- package/lib/library/SystemLibraryPlugin.js +15 -6
- package/lib/library/UmdLibraryPlugin.js +12 -18
- package/lib/logging/Logger.js +12 -10
- package/lib/logging/createConsoleLogger.js +15 -14
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeWatchFileSystem.js +4 -4
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
- package/lib/node/nodeConsole.js +2 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
- package/lib/optimize/ConcatenatedModule.js +142 -100
- package/lib/optimize/InnerGraph.js +17 -11
- package/lib/optimize/InnerGraphPlugin.js +0 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
- package/lib/optimize/RealContentHashPlugin.js +5 -3
- package/lib/optimize/RuntimeChunkPlugin.js +0 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
- package/lib/optimize/SplitChunksPlugin.js +46 -40
- package/lib/performance/SizeLimitsPlugin.js +2 -1
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
- package/lib/rules/BasicMatcherRulePlugin.js +0 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
- package/lib/rules/RuleSetCompiler.js +8 -6
- package/lib/runtime/BaseUriRuntimeModule.js +2 -2
- package/lib/runtime/CompatRuntimeModule.js +0 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
- package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
- package/lib/runtime/PublicPathRuntimeModule.js +2 -2
- package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
- package/lib/runtime/SystemContextRuntimeModule.js +0 -2
- package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
- package/lib/schemes/DataUriPlugin.js +2 -28
- package/lib/schemes/FileUriPlugin.js +5 -2
- package/lib/schemes/HttpUriPlugin.js +4 -2
- package/lib/schemes/VirtualUrlPlugin.js +11 -11
- package/lib/serialization/FileMiddleware.js +1 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +31 -20
- package/lib/serialization/SerializerMiddleware.js +1 -3
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +3 -5
- package/lib/sharing/ConsumeSharedPlugin.js +2 -4
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
- package/lib/sharing/ProvideSharedModule.js +3 -7
- package/lib/sharing/SharePlugin.js +0 -2
- package/lib/sharing/ShareRuntimeModule.js +4 -1
- package/lib/sharing/resolveMatchedConfigs.js +14 -6
- package/lib/sharing/utils.js +0 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +179 -95
- package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
- package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
- package/lib/stats/StatsFactory.js +14 -11
- package/lib/url/URLParserPlugin.js +2 -4
- package/lib/util/ArrayHelpers.js +4 -4
- package/lib/util/AsyncQueue.js +1 -0
- package/lib/util/Hash.js +35 -5
- package/lib/util/LazySet.js +2 -2
- package/lib/util/StackedCacheMap.js +0 -2
- package/lib/util/TupleSet.js +9 -4
- package/lib/util/URLAbsoluteSpecifier.js +0 -1
- package/lib/util/WeakTupleMap.js +1 -1
- package/lib/util/chainedImports.js +3 -1
- package/lib/util/cleverMerge.js +15 -18
- package/lib/util/comparators.js +2 -4
- package/lib/util/compileBooleanMatcher.js +11 -9
- package/lib/util/concatenate.js +1 -2
- package/lib/util/create-schema-validation.js +1 -2
- package/lib/util/createHash.js +85 -15
- package/lib/util/dataURL.js +39 -0
- package/lib/util/deprecation.js +29 -31
- package/lib/util/deterministicGrouping.js +34 -30
- package/lib/util/extractSourceMap.js +319 -0
- package/lib/util/findGraphRoots.js +15 -5
- package/lib/util/fs.js +29 -8
- package/lib/util/hash/BatchedHash.js +47 -8
- package/lib/util/hash/wasm-hash.js +53 -13
- package/lib/util/semver.js +9 -8
- package/lib/util/smartGrouping.js +41 -26
- package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
- package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -10
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
- package/lib/wasm-sync/WebAssemblyParser.js +1 -13
- package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/web/JsonpTemplatePlugin.js +0 -1
- package/lib/webpack.js +21 -8
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +21 -21
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +93 -96
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +4 -0
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +5 -1
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
- package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1699 -706
- package/SECURITY.md +0 -9
- package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +0 -7
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
package/lib/FileSystemInfo.js
CHANGED
|
@@ -18,7 +18,6 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
18
18
|
const memoize = require("./util/memoize");
|
|
19
19
|
const processAsyncTree = require("./util/processAsyncTree");
|
|
20
20
|
|
|
21
|
-
/** @typedef {import("enhanced-resolve").Resolver} Resolver */
|
|
22
21
|
/** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
|
|
23
22
|
/** @typedef {import("enhanced-resolve").ResolveFunctionAsync} ResolveFunctionAsync */
|
|
24
23
|
/** @typedef {import("./WebpackError")} WebpackError */
|
|
@@ -28,8 +27,6 @@ const processAsyncTree = require("./util/processAsyncTree");
|
|
|
28
27
|
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
|
29
28
|
/** @typedef {import("./util/fs").IStats} IStats */
|
|
30
29
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
31
|
-
/** @typedef {import("./util/fs").PathLike} PathLike */
|
|
32
|
-
/** @typedef {import("./util/fs").StringCallback} StringCallback */
|
|
33
30
|
/**
|
|
34
31
|
* @template T
|
|
35
32
|
* @typedef {import("./util/AsyncQueue").Callback<T>} ProcessorCallback
|
|
@@ -48,8 +45,8 @@ let FS_ACCURACY = 2000;
|
|
|
48
45
|
|
|
49
46
|
const EMPTY_SET = new Set();
|
|
50
47
|
|
|
51
|
-
const
|
|
52
|
-
const
|
|
48
|
+
const RBDT_RESOLVE_INITIAL = 0;
|
|
49
|
+
const RBDT_RESOLVE_FILE = 1;
|
|
53
50
|
const RBDT_RESOLVE_DIRECTORY = 2;
|
|
54
51
|
const RBDT_RESOLVE_CJS_FILE = 3;
|
|
55
52
|
const RBDT_RESOLVE_CJS_FILE_AS_CHILD = 4;
|
|
@@ -59,7 +56,7 @@ const RBDT_FILE = 7;
|
|
|
59
56
|
const RBDT_DIRECTORY_DEPENDENCIES = 8;
|
|
60
57
|
const RBDT_FILE_DEPENDENCIES = 9;
|
|
61
58
|
|
|
62
|
-
/** @typedef {
|
|
59
|
+
/** @typedef {RBDT_RESOLVE_INITIAL | RBDT_RESOLVE_FILE | RBDT_RESOLVE_DIRECTORY | RBDT_RESOLVE_CJS_FILE | RBDT_RESOLVE_CJS_FILE_AS_CHILD | RBDT_RESOLVE_ESM_FILE | RBDT_DIRECTORY | RBDT_FILE | RBDT_DIRECTORY_DEPENDENCIES | RBDT_FILE_DEPENDENCIES} JobType */
|
|
63
60
|
|
|
64
61
|
const INVALID = Symbol("invalid");
|
|
65
62
|
|
|
@@ -168,13 +165,18 @@ class SnapshotIterator {
|
|
|
168
165
|
}
|
|
169
166
|
}
|
|
170
167
|
|
|
171
|
-
/**
|
|
172
|
-
|
|
168
|
+
/**
|
|
169
|
+
* @template T
|
|
170
|
+
* @typedef {(snapshot: Snapshot) => T[]} GetMapsFunction
|
|
171
|
+
*/
|
|
173
172
|
|
|
173
|
+
/**
|
|
174
|
+
* @template T
|
|
175
|
+
*/
|
|
174
176
|
class SnapshotIterable {
|
|
175
177
|
/**
|
|
176
178
|
* @param {Snapshot} snapshot snapshot
|
|
177
|
-
* @param {GetMapsFunction} getMaps get maps function
|
|
179
|
+
* @param {GetMapsFunction<T>} getMaps get maps function
|
|
178
180
|
*/
|
|
179
181
|
constructor(snapshot, getMaps) {
|
|
180
182
|
this.snapshot = snapshot;
|
|
@@ -185,9 +187,9 @@ class SnapshotIterable {
|
|
|
185
187
|
let state = 0;
|
|
186
188
|
/** @type {IterableIterator<string>} */
|
|
187
189
|
let it;
|
|
188
|
-
/** @type {GetMapsFunction} */
|
|
190
|
+
/** @type {GetMapsFunction<T>} */
|
|
189
191
|
let getMaps;
|
|
190
|
-
/** @type {
|
|
192
|
+
/** @type {T[]} */
|
|
191
193
|
let maps;
|
|
192
194
|
/** @type {Snapshot} */
|
|
193
195
|
let snapshot;
|
|
@@ -206,7 +208,9 @@ class SnapshotIterable {
|
|
|
206
208
|
if (maps.length > 0) {
|
|
207
209
|
const map = maps.pop();
|
|
208
210
|
if (map !== undefined) {
|
|
209
|
-
it =
|
|
211
|
+
it =
|
|
212
|
+
/** @type {Set<EXPECTED_ANY> | Map<string, EXPECTED_ANY>} */
|
|
213
|
+
(map).keys();
|
|
210
214
|
state = 2;
|
|
211
215
|
} else {
|
|
212
216
|
break;
|
|
@@ -539,8 +543,9 @@ class Snapshot {
|
|
|
539
543
|
}
|
|
540
544
|
|
|
541
545
|
/**
|
|
542
|
-
* @
|
|
543
|
-
* @
|
|
546
|
+
* @template T
|
|
547
|
+
* @param {GetMapsFunction<T>} getMaps first
|
|
548
|
+
* @returns {SnapshotIterable<T>} iterable
|
|
544
549
|
*/
|
|
545
550
|
_createIterable(getMaps) {
|
|
546
551
|
return new SnapshotIterable(this, getMaps);
|
|
@@ -658,6 +663,9 @@ class SnapshotOptimization {
|
|
|
658
663
|
* @returns {void}
|
|
659
664
|
*/
|
|
660
665
|
optimize(newSnapshot, capturedFiles) {
|
|
666
|
+
if (capturedFiles.size === 0) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
661
669
|
/**
|
|
662
670
|
* @param {SnapshotOptimizationEntry} entry optimization entry
|
|
663
671
|
* @returns {void}
|
|
@@ -727,6 +735,7 @@ class SnapshotOptimization {
|
|
|
727
735
|
) {
|
|
728
736
|
continue;
|
|
729
737
|
}
|
|
738
|
+
/** @type {Set<string>} */
|
|
730
739
|
const nonSharedFiles = new Set();
|
|
731
740
|
const snapshotContent =
|
|
732
741
|
/** @type {NonNullable<SnapshotOptimizationEntry["snapshotContent"]>} */
|
|
@@ -1203,34 +1212,34 @@ class FileSystemInfo {
|
|
|
1203
1212
|
processor: this._getManagedItemDirectoryInfo.bind(this)
|
|
1204
1213
|
});
|
|
1205
1214
|
const _unmanagedPaths = [...unmanagedPaths];
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
this.unmanagedPathsRegExps =
|
|
1212
|
-
|
|
1213
|
-
|
|
1215
|
+
/** @type {string[]} */
|
|
1216
|
+
this.unmanagedPathsWithSlash = _unmanagedPaths
|
|
1217
|
+
.filter((p) => typeof p === "string")
|
|
1218
|
+
.map((p) => join(fs, p, "_").slice(0, -1));
|
|
1219
|
+
/** @type {RegExp[]} */
|
|
1220
|
+
this.unmanagedPathsRegExps = _unmanagedPaths.filter(
|
|
1221
|
+
(p) => typeof p !== "string"
|
|
1222
|
+
);
|
|
1214
1223
|
|
|
1215
1224
|
this.managedPaths = [...managedPaths];
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1225
|
+
/** @type {string[]} */
|
|
1226
|
+
this.managedPathsWithSlash = this.managedPaths
|
|
1227
|
+
.filter((p) => typeof p === "string")
|
|
1228
|
+
.map((p) => join(fs, p, "_").slice(0, -1));
|
|
1229
|
+
/** @type {RegExp[]} */
|
|
1230
|
+
this.managedPathsRegExps = this.managedPaths.filter(
|
|
1231
|
+
(p) => typeof p !== "string"
|
|
1232
|
+
);
|
|
1221
1233
|
|
|
1222
|
-
this.managedPathsRegExps =
|
|
1223
|
-
/** @type {RegExp[]} */
|
|
1224
|
-
(this.managedPaths.filter((p) => typeof p !== "string"));
|
|
1225
1234
|
this.immutablePaths = [...immutablePaths];
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
this.immutablePathsRegExps =
|
|
1232
|
-
|
|
1233
|
-
|
|
1235
|
+
/** @type {string[]} */
|
|
1236
|
+
this.immutablePathsWithSlash = this.immutablePaths
|
|
1237
|
+
.filter((p) => typeof p === "string")
|
|
1238
|
+
.map((p) => join(fs, p, "_").slice(0, -1));
|
|
1239
|
+
/** @type {RegExp[]} */
|
|
1240
|
+
this.immutablePathsRegExps = this.immutablePaths.filter(
|
|
1241
|
+
(p) => typeof p !== "string"
|
|
1242
|
+
);
|
|
1234
1243
|
|
|
1235
1244
|
this._cachedDeprecatedFileTimestamps = undefined;
|
|
1236
1245
|
this._cachedDeprecatedContextTimestamps = undefined;
|
|
@@ -1614,16 +1623,12 @@ class FileSystemInfo {
|
|
|
1614
1623
|
|
|
1615
1624
|
/**
|
|
1616
1625
|
* @param {Job} job job
|
|
1617
|
-
* @returns {
|
|
1626
|
+
* @returns {string} result
|
|
1618
1627
|
*/
|
|
1619
1628
|
const jobToString = (job) => {
|
|
1620
1629
|
switch (job.type) {
|
|
1621
|
-
case
|
|
1622
|
-
return `resolve
|
|
1623
|
-
job.expected
|
|
1624
|
-
)}`;
|
|
1625
|
-
case RBDT_RESOLVE_ESM:
|
|
1626
|
-
return `resolve esm ${job.path}${expectedToString(job.expected)}`;
|
|
1630
|
+
case RBDT_RESOLVE_FILE:
|
|
1631
|
+
return `resolve file ${job.path}${expectedToString(job.expected)}`;
|
|
1627
1632
|
case RBDT_RESOLVE_DIRECTORY:
|
|
1628
1633
|
return `resolve directory ${job.path}`;
|
|
1629
1634
|
case RBDT_RESOLVE_CJS_FILE:
|
|
@@ -1665,7 +1670,7 @@ class FileSystemInfo {
|
|
|
1665
1670
|
deps,
|
|
1666
1671
|
(dep) =>
|
|
1667
1672
|
/** @type {Job} */ ({
|
|
1668
|
-
type:
|
|
1673
|
+
type: RBDT_RESOLVE_INITIAL,
|
|
1669
1674
|
context,
|
|
1670
1675
|
path: dep,
|
|
1671
1676
|
expected: undefined,
|
|
@@ -1769,27 +1774,23 @@ class FileSystemInfo {
|
|
|
1769
1774
|
}
|
|
1770
1775
|
);
|
|
1771
1776
|
};
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
resolveDirectory(path.slice(0, -1));
|
|
1786
|
-
} else {
|
|
1787
|
-
resolveFile(path);
|
|
1788
|
-
}
|
|
1777
|
+
const resolvedType =
|
|
1778
|
+
type === RBDT_RESOLVE_INITIAL
|
|
1779
|
+
? /[\\/]$/.test(path)
|
|
1780
|
+
? RBDT_RESOLVE_DIRECTORY
|
|
1781
|
+
: RBDT_RESOLVE_FILE
|
|
1782
|
+
: type;
|
|
1783
|
+
switch (resolvedType) {
|
|
1784
|
+
case RBDT_RESOLVE_FILE: {
|
|
1785
|
+
resolveFile(
|
|
1786
|
+
path,
|
|
1787
|
+
"f",
|
|
1788
|
+
/\.mjs$/.test(path) ? resolveEsm : resolveCjs
|
|
1789
|
+
);
|
|
1789
1790
|
break;
|
|
1790
1791
|
}
|
|
1791
1792
|
case RBDT_RESOLVE_DIRECTORY: {
|
|
1792
|
-
resolveDirectory(path);
|
|
1793
|
+
resolveDirectory(RBDT_RESOLVE_INITIAL ? path.slice(0, -1) : path);
|
|
1793
1794
|
break;
|
|
1794
1795
|
}
|
|
1795
1796
|
case RBDT_RESOLVE_CJS_FILE: {
|
|
@@ -1867,7 +1868,13 @@ class FileSystemInfo {
|
|
|
1867
1868
|
// Check commonjs cache for the module
|
|
1868
1869
|
/** @type {NodeModule | undefined} */
|
|
1869
1870
|
const module = require.cache[path];
|
|
1870
|
-
if (
|
|
1871
|
+
if (
|
|
1872
|
+
module &&
|
|
1873
|
+
Array.isArray(module.children) &&
|
|
1874
|
+
// https://github.com/nodejs/node/issues/59868
|
|
1875
|
+
// Force use `es-module-lexer` for mjs
|
|
1876
|
+
!/\.mjs$/.test(path)
|
|
1877
|
+
) {
|
|
1871
1878
|
children: for (const child of module.children) {
|
|
1872
1879
|
const childPath = child.filename;
|
|
1873
1880
|
if (childPath) {
|
|
@@ -1947,6 +1954,7 @@ class FileSystemInfo {
|
|
|
1947
1954
|
const context = dirname(this.fs, path);
|
|
1948
1955
|
const source = /** @type {Buffer} */ (content).toString();
|
|
1949
1956
|
const [imports] = lexer.parse(source);
|
|
1957
|
+
const added = new Set();
|
|
1950
1958
|
for (const imp of imports) {
|
|
1951
1959
|
try {
|
|
1952
1960
|
let dependency;
|
|
@@ -1964,9 +1972,11 @@ class FileSystemInfo {
|
|
|
1964
1972
|
continue;
|
|
1965
1973
|
}
|
|
1966
1974
|
|
|
1967
|
-
//
|
|
1975
|
+
// We should not track Node.js build dependencies
|
|
1968
1976
|
if (dependency.startsWith("node:")) continue;
|
|
1969
1977
|
if (builtinModules.has(dependency)) continue;
|
|
1978
|
+
// Avoid extra jobs for identical imports
|
|
1979
|
+
if (added.has(dependency)) continue;
|
|
1970
1980
|
|
|
1971
1981
|
push({
|
|
1972
1982
|
type: RBDT_RESOLVE_ESM_FILE,
|
|
@@ -1975,6 +1985,7 @@ class FileSystemInfo {
|
|
|
1975
1985
|
expected: imp.d > -1 ? false : undefined,
|
|
1976
1986
|
issuer: job
|
|
1977
1987
|
});
|
|
1988
|
+
added.add(dependency);
|
|
1978
1989
|
} catch (err1) {
|
|
1979
1990
|
logger.warn(
|
|
1980
1991
|
`Parsing of ${path} for build dependencies failed at 'import(${source.slice(
|
|
@@ -2336,6 +2347,9 @@ class FileSystemInfo {
|
|
|
2336
2347
|
* @param {ManagedFiles} capturedFiles captured files
|
|
2337
2348
|
*/
|
|
2338
2349
|
const processCapturedFiles = (capturedFiles) => {
|
|
2350
|
+
if (capturedFiles.size === 0) {
|
|
2351
|
+
return;
|
|
2352
|
+
}
|
|
2339
2353
|
switch (mode) {
|
|
2340
2354
|
case 3:
|
|
2341
2355
|
this._fileTshsOptimization.optimize(snapshot, capturedFiles);
|
|
@@ -2424,6 +2438,9 @@ class FileSystemInfo {
|
|
|
2424
2438
|
* @param {ManagedContexts} capturedDirectories captured directories
|
|
2425
2439
|
*/
|
|
2426
2440
|
const processCapturedDirectories = (capturedDirectories) => {
|
|
2441
|
+
if (capturedDirectories.size === 0) {
|
|
2442
|
+
return;
|
|
2443
|
+
}
|
|
2427
2444
|
switch (mode) {
|
|
2428
2445
|
case 3:
|
|
2429
2446
|
this._contextTshsOptimization.optimize(snapshot, capturedDirectories);
|
|
@@ -2569,6 +2586,9 @@ class FileSystemInfo {
|
|
|
2569
2586
|
* @param {ManagedMissing} capturedMissing captured missing
|
|
2570
2587
|
*/
|
|
2571
2588
|
const processCapturedMissing = (capturedMissing) => {
|
|
2589
|
+
if (capturedMissing.size === 0) {
|
|
2590
|
+
return;
|
|
2591
|
+
}
|
|
2572
2592
|
this._missingExistenceOptimization.optimize(snapshot, capturedMissing);
|
|
2573
2593
|
for (const path of capturedMissing) {
|
|
2574
2594
|
const cache = this._fileTimestamps.get(path);
|
|
@@ -3330,7 +3350,7 @@ class FileSystemInfo {
|
|
|
3330
3350
|
|
|
3331
3351
|
hash.update(/** @type {string | Buffer} */ (content));
|
|
3332
3352
|
|
|
3333
|
-
const digest =
|
|
3353
|
+
const digest = hash.digest("hex");
|
|
3334
3354
|
|
|
3335
3355
|
this._fileHashes.set(path, digest);
|
|
3336
3356
|
|
|
@@ -3341,7 +3361,7 @@ class FileSystemInfo {
|
|
|
3341
3361
|
/**
|
|
3342
3362
|
* @private
|
|
3343
3363
|
* @param {string} path path
|
|
3344
|
-
* @param {(err: WebpackError | null, timestampAndHash?: TimestampAndHash) => void} callback callback
|
|
3364
|
+
* @param {(err: WebpackError | null, timestampAndHash?: TimestampAndHash | string) => void} callback callback
|
|
3345
3365
|
*/
|
|
3346
3366
|
_getFileTimestampAndHash(path, callback) {
|
|
3347
3367
|
/**
|
|
@@ -3361,7 +3381,7 @@ class FileSystemInfo {
|
|
|
3361
3381
|
return callback(null, result);
|
|
3362
3382
|
}
|
|
3363
3383
|
this._fileTshs.set(path, hash);
|
|
3364
|
-
return callback(null,
|
|
3384
|
+
return callback(null, hash);
|
|
3365
3385
|
}
|
|
3366
3386
|
this.fileTimestampQueue.add(path, (err, entry) => {
|
|
3367
3387
|
if (err) {
|
|
@@ -3598,7 +3618,7 @@ class FileSystemInfo {
|
|
|
3598
3618
|
}
|
|
3599
3619
|
}
|
|
3600
3620
|
|
|
3601
|
-
const digest =
|
|
3621
|
+
const digest = hash.digest("hex");
|
|
3602
3622
|
/** @type {ContextFileSystemInfoEntry} */
|
|
3603
3623
|
const result = {
|
|
3604
3624
|
safeTime,
|
|
@@ -3661,7 +3681,7 @@ class FileSystemInfo {
|
|
|
3661
3681
|
null,
|
|
3662
3682
|
(entry.resolved = {
|
|
3663
3683
|
safeTime,
|
|
3664
|
-
timestampHash:
|
|
3684
|
+
timestampHash: hash.digest("hex")
|
|
3665
3685
|
})
|
|
3666
3686
|
);
|
|
3667
3687
|
}
|
|
@@ -3723,7 +3743,7 @@ class FileSystemInfo {
|
|
|
3723
3743
|
|
|
3724
3744
|
/** @type {ContextHash} */
|
|
3725
3745
|
const result = {
|
|
3726
|
-
hash:
|
|
3746
|
+
hash: hash.digest("hex")
|
|
3727
3747
|
};
|
|
3728
3748
|
if (symlinks) result.symlinks = symlinks;
|
|
3729
3749
|
return result;
|
|
@@ -3770,10 +3790,7 @@ class FileSystemInfo {
|
|
|
3770
3790
|
for (const h of hashes) {
|
|
3771
3791
|
hash.update(h);
|
|
3772
3792
|
}
|
|
3773
|
-
callback(
|
|
3774
|
-
null,
|
|
3775
|
-
(entry.resolved = /** @type {string} */ (hash.digest("hex")))
|
|
3776
|
-
);
|
|
3793
|
+
callback(null, (entry.resolved = hash.digest("hex")));
|
|
3777
3794
|
}
|
|
3778
3795
|
);
|
|
3779
3796
|
}
|
|
@@ -3819,22 +3836,20 @@ class FileSystemInfo {
|
|
|
3819
3836
|
{
|
|
3820
3837
|
path,
|
|
3821
3838
|
fromImmutablePath: () =>
|
|
3822
|
-
/** @type {ContextTimestampAndHash | null} */ (
|
|
3839
|
+
/** @type {ContextTimestampAndHash | Omit<ContextTimestampAndHash, "safeTime"> | string | null} */ (
|
|
3840
|
+
null
|
|
3841
|
+
),
|
|
3823
3842
|
fromManagedItem: (info) => ({
|
|
3824
3843
|
safeTime: 0,
|
|
3825
3844
|
timestampHash: info,
|
|
3826
3845
|
hash: info || ""
|
|
3827
3846
|
}),
|
|
3828
3847
|
fromSymlink: (file, target, callback) => {
|
|
3829
|
-
callback(
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
(
|
|
3833
|
-
|
|
3834
|
-
hash: target,
|
|
3835
|
-
symlinks: new Set([target])
|
|
3836
|
-
})
|
|
3837
|
-
);
|
|
3848
|
+
callback(null, {
|
|
3849
|
+
timestampHash: target,
|
|
3850
|
+
hash: target,
|
|
3851
|
+
symlinks: new Set([target])
|
|
3852
|
+
});
|
|
3838
3853
|
},
|
|
3839
3854
|
fromFile: (file, stat, callback) => {
|
|
3840
3855
|
this._getFileTimestampAndHash(file, callback);
|
|
@@ -3892,8 +3907,8 @@ class FileSystemInfo {
|
|
|
3892
3907
|
/** @type {ContextTimestampAndHash} */
|
|
3893
3908
|
const result = {
|
|
3894
3909
|
safeTime,
|
|
3895
|
-
timestampHash:
|
|
3896
|
-
hash:
|
|
3910
|
+
timestampHash: tsHash.digest("hex"),
|
|
3911
|
+
hash: hash.digest("hex")
|
|
3897
3912
|
};
|
|
3898
3913
|
if (symlinks) result.symlinks = symlinks;
|
|
3899
3914
|
return result;
|
|
@@ -3961,8 +3976,8 @@ class FileSystemInfo {
|
|
|
3961
3976
|
null,
|
|
3962
3977
|
(entry.resolved = {
|
|
3963
3978
|
safeTime,
|
|
3964
|
-
timestampHash:
|
|
3965
|
-
hash:
|
|
3979
|
+
timestampHash: tsHash.digest("hex"),
|
|
3980
|
+
hash: hash.digest("hex")
|
|
3966
3981
|
})
|
|
3967
3982
|
);
|
|
3968
3983
|
}
|
|
@@ -13,11 +13,10 @@ const ArrayQueue = require("./util/ArrayQueue");
|
|
|
13
13
|
const TupleQueue = require("./util/TupleQueue");
|
|
14
14
|
const { getEntryRuntime, mergeRuntimeOwned } = require("./util/runtime");
|
|
15
15
|
|
|
16
|
-
/** @typedef {import("./Chunk")} Chunk */
|
|
17
|
-
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
18
16
|
/** @typedef {import("./Compiler")} Compiler */
|
|
19
17
|
/** @typedef {import("./DependenciesBlock")} DependenciesBlock */
|
|
20
18
|
/** @typedef {import("./Dependency").ReferencedExport} ReferencedExport */
|
|
19
|
+
/** @typedef {import("./Dependency").ReferencedExports} ReferencedExports */
|
|
21
20
|
/** @typedef {import("./ExportsInfo")} ExportsInfo */
|
|
22
21
|
/** @typedef {import("./Module")} Module */
|
|
23
22
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
|
@@ -61,7 +60,7 @@ class FlagDependencyUsagePlugin {
|
|
|
61
60
|
|
|
62
61
|
/**
|
|
63
62
|
* @param {Module} module module to process
|
|
64
|
-
* @param {
|
|
63
|
+
* @param {ReferencedExports} usedExports list of used exports
|
|
65
64
|
* @param {RuntimeSpec} runtime part of which runtime
|
|
66
65
|
* @param {boolean} forceSideEffects always apply side effects
|
|
67
66
|
* @returns {void}
|
|
@@ -168,7 +167,7 @@ class FlagDependencyUsagePlugin {
|
|
|
168
167
|
* @returns {void}
|
|
169
168
|
*/
|
|
170
169
|
const processModule = (module, runtime, forceSideEffects) => {
|
|
171
|
-
/** @type {Map<Module,
|
|
170
|
+
/** @type {Map<Module, ReferencedExports | Map<string, string[] | ReferencedExport>>} */
|
|
172
171
|
const map = new Map();
|
|
173
172
|
|
|
174
173
|
/** @type {ArrayQueue<DependenciesBlock>} */
|
package/lib/Generator.js
CHANGED
|
@@ -8,11 +8,9 @@
|
|
|
8
8
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
9
9
|
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
|
10
10
|
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
|
|
11
|
-
/** @typedef {import("./Compilation")} Compilation */
|
|
12
|
-
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
|
13
11
|
/** @typedef {import("./ConcatenationScope")} ConcatenationScope */
|
|
14
|
-
/** @typedef {import("./DependencyTemplate")} DependencyTemplate */
|
|
15
12
|
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
|
13
|
+
/** @typedef {import("./Module").CodeGenerationResultData} CodeGenerationResultData */
|
|
16
14
|
/** @typedef {import("./Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
|
17
15
|
/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
|
|
18
16
|
/** @typedef {import("./Module").SourceTypes} SourceTypes */
|
|
@@ -22,15 +20,6 @@
|
|
|
22
20
|
/** @typedef {import("./util/Hash")} Hash */
|
|
23
21
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
|
24
22
|
|
|
25
|
-
/**
|
|
26
|
-
* @template T
|
|
27
|
-
* @typedef {import("./InitFragment")<T>} InitFragment
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/** @typedef {Map<"url", { [key: string]: string }> & Map<"fullContentHash", string> & Map<"contentHash", string> & Map<"filename", string> & Map<"assetInfo", AssetInfo> & Map<"chunkInitFragments", InitFragment<GenerateContext>[]>} KnownGenerateContextData */
|
|
31
|
-
|
|
32
|
-
/** @typedef {KnownGenerateContextData & Record<string, EXPECTED_ANY>} GenerateContextData */
|
|
33
|
-
|
|
34
23
|
/**
|
|
35
24
|
* @typedef {object} GenerateContext
|
|
36
25
|
* @property {DependencyTemplates} dependencyTemplates mapping from dependencies to templates
|
|
@@ -42,7 +31,7 @@
|
|
|
42
31
|
* @property {ConcatenationScope=} concatenationScope when in concatenated module, information about other concatenated modules
|
|
43
32
|
* @property {CodeGenerationResults=} codeGenerationResults code generation results of other modules (need to have a codeGenerationDependency to use that)
|
|
44
33
|
* @property {string} type which kind of code should be generated
|
|
45
|
-
* @property {() =>
|
|
34
|
+
* @property {() => CodeGenerationResultData=} getData get access to the code generation data
|
|
46
35
|
*/
|
|
47
36
|
|
|
48
37
|
/**
|
package/lib/GraphHelpers.js
CHANGED
|
@@ -5,11 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
|
9
8
|
/** @typedef {import("./Chunk")} Chunk */
|
|
10
9
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
11
|
-
/** @typedef {import("./DependenciesBlock")} DependenciesBlock */
|
|
12
|
-
/** @typedef {import("./Module")} Module */
|
|
13
10
|
/** @typedef {import(".").Entrypoint} Entrypoint */
|
|
14
11
|
|
|
15
12
|
/**
|
package/lib/HookWebpackError.js
CHANGED
|
@@ -44,13 +44,13 @@ const {
|
|
|
44
44
|
/** @typedef {import("estree").CallExpression} CallExpression */
|
|
45
45
|
/** @typedef {import("estree").Expression} Expression */
|
|
46
46
|
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
|
47
|
-
/** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputNormalized */
|
|
48
47
|
/** @typedef {import("./Chunk")} Chunk */
|
|
49
48
|
/** @typedef {import("./Chunk").ChunkId} ChunkId */
|
|
50
49
|
/** @typedef {import("./ChunkGraph").ModuleId} ModuleId */
|
|
51
50
|
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
|
52
51
|
/** @typedef {import("./Compilation").Records} Records */
|
|
53
52
|
/** @typedef {import("./Compiler")} Compiler */
|
|
53
|
+
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
|
|
54
54
|
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
|
55
55
|
/** @typedef {import("./Module")} Module */
|
|
56
56
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
|
@@ -59,10 +59,12 @@ const {
|
|
|
59
59
|
/** @typedef {import("./javascript/JavascriptParserHelpers").Range} Range */
|
|
60
60
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
|
61
61
|
|
|
62
|
+
/** @typedef {string[]} Requests */
|
|
63
|
+
|
|
62
64
|
/**
|
|
63
65
|
* @typedef {object} HMRJavascriptParserHooks
|
|
64
|
-
* @property {SyncBailHook<[Expression | SpreadElement,
|
|
65
|
-
* @property {SyncBailHook<[CallExpression,
|
|
66
|
+
* @property {SyncBailHook<[Expression | SpreadElement, Requests], void>} hotAcceptCallback
|
|
67
|
+
* @property {SyncBailHook<[CallExpression, Requests], void>} hotAcceptWithoutCallback
|
|
66
68
|
*/
|
|
67
69
|
|
|
68
70
|
/** @typedef {number} HotIndex */
|
|
@@ -147,7 +149,7 @@ class HotModuleReplacementPlugin {
|
|
|
147
149
|
/** @type {BasicEvaluatedExpression[]} */
|
|
148
150
|
(arg.items).filter((param) => param.isString());
|
|
149
151
|
}
|
|
150
|
-
/** @type {
|
|
152
|
+
/** @type {Requests} */
|
|
151
153
|
const requests = [];
|
|
152
154
|
if (params.length > 0) {
|
|
153
155
|
for (const [idx, param] of params.entries()) {
|
|
@@ -400,13 +402,11 @@ class HotModuleReplacementPlugin {
|
|
|
400
402
|
* @returns {string} module hash
|
|
401
403
|
*/
|
|
402
404
|
const getModuleHash = (module) => {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
chunk.runtime
|
|
409
|
-
);
|
|
405
|
+
const codeGenerationResults =
|
|
406
|
+
/** @type {CodeGenerationResults} */
|
|
407
|
+
(compilation.codeGenerationResults);
|
|
408
|
+
if (codeGenerationResults.has(module, chunk.runtime)) {
|
|
409
|
+
return codeGenerationResults.getHash(module, chunk.runtime);
|
|
410
410
|
}
|
|
411
411
|
nonCodeGeneratedModules.add(module, chunk.runtime);
|
|
412
412
|
return chunkGraph.getModuleHash(module, chunk.runtime);
|
|
@@ -500,14 +500,14 @@ class HotModuleReplacementPlugin {
|
|
|
500
500
|
) {
|
|
501
501
|
return;
|
|
502
502
|
}
|
|
503
|
+
const codeGenerationResults =
|
|
504
|
+
/** @type {CodeGenerationResults} */
|
|
505
|
+
(compilation.codeGenerationResults);
|
|
503
506
|
for (const [module, chunk] of fullHashModules) {
|
|
504
507
|
const key = `${chunk.id}|${module.identifier()}`;
|
|
505
508
|
const hash = nonCodeGeneratedModules.has(module, chunk.runtime)
|
|
506
509
|
? chunkGraph.getModuleHash(module, chunk.runtime)
|
|
507
|
-
:
|
|
508
|
-
module,
|
|
509
|
-
chunk.runtime
|
|
510
|
-
);
|
|
510
|
+
: codeGenerationResults.getHash(module, chunk.runtime);
|
|
511
511
|
if (records.chunkModuleHashes[key] !== hash) {
|
|
512
512
|
updatedModules.add(module, chunk);
|
|
513
513
|
}
|
|
@@ -527,8 +527,7 @@ class HotModuleReplacementPlugin {
|
|
|
527
527
|
forEachRuntime(allOldRuntime, (runtime) => {
|
|
528
528
|
const { path: filename, info: assetInfo } =
|
|
529
529
|
compilation.getPathWithInfo(
|
|
530
|
-
|
|
531
|
-
(compilation.outputOptions.hotUpdateMainFilename),
|
|
530
|
+
compilation.outputOptions.hotUpdateMainFilename,
|
|
532
531
|
{
|
|
533
532
|
hash: records.hash,
|
|
534
533
|
runtime
|
|
@@ -548,7 +547,7 @@ class HotModuleReplacementPlugin {
|
|
|
548
547
|
if (hotUpdateMainContentByRuntime.size === 0) return;
|
|
549
548
|
|
|
550
549
|
// Create a list of all active modules to verify which modules are removed completely
|
|
551
|
-
/** @type {Map<
|
|
550
|
+
/** @type {Map<ModuleId, Module>} */
|
|
552
551
|
const allModules = new Map();
|
|
553
552
|
for (const module of compilation.modules) {
|
|
554
553
|
const id =
|
|
@@ -558,7 +557,7 @@ class HotModuleReplacementPlugin {
|
|
|
558
557
|
}
|
|
559
558
|
|
|
560
559
|
// List of completely removed modules
|
|
561
|
-
/** @type {Set<
|
|
560
|
+
/** @type {Set<ModuleId>} */
|
|
562
561
|
const completelyRemovedModules = new Set();
|
|
563
562
|
|
|
564
563
|
for (const key of Object.keys(records.chunkHashes)) {
|
|
@@ -646,10 +645,7 @@ class HotModuleReplacementPlugin {
|
|
|
646
645
|
// Module is still in the same runtime combination
|
|
647
646
|
const hash = nonCodeGeneratedModules.has(module, newRuntime)
|
|
648
647
|
? chunkGraph.getModuleHash(module, newRuntime)
|
|
649
|
-
:
|
|
650
|
-
module,
|
|
651
|
-
newRuntime
|
|
652
|
-
);
|
|
648
|
+
: codeGenerationResults.getHash(module, newRuntime);
|
|
653
649
|
if (hash !== oldHash) {
|
|
654
650
|
if (module.type === WEBPACK_MODULE_TYPE_RUNTIME) {
|
|
655
651
|
newRuntimeModules = newRuntimeModules || [];
|
|
@@ -733,7 +729,9 @@ class HotModuleReplacementPlugin {
|
|
|
733
729
|
outputOptions: compilation.outputOptions,
|
|
734
730
|
moduleTemplates: compilation.moduleTemplates,
|
|
735
731
|
dependencyTemplates: compilation.dependencyTemplates,
|
|
736
|
-
codeGenerationResults:
|
|
732
|
+
codeGenerationResults: /** @type {CodeGenerationResults} */ (
|
|
733
|
+
compilation.codeGenerationResults
|
|
734
|
+
),
|
|
737
735
|
runtimeTemplate: compilation.runtimeTemplate,
|
|
738
736
|
moduleGraph: compilation.moduleGraph,
|
|
739
737
|
chunkGraph
|