webpack 5.104.1 → 5.105.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 +2 -2
- package/bin/webpack.js +6 -3
- package/lib/APIPlugin.js +85 -15
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AsyncDependenciesBlock.js +17 -2
- package/lib/AsyncDependencyToInitialChunkError.js +3 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +5 -1
- package/lib/CacheFacade.js +2 -2
- package/lib/CaseSensitiveModulesWarning.js +1 -0
- package/lib/Chunk.js +9 -5
- package/lib/ChunkGraph.js +30 -9
- package/lib/ChunkGroup.js +6 -3
- package/lib/ChunkRenderError.js +9 -2
- package/lib/CleanPlugin.js +4 -1
- package/lib/CodeGenerationError.js +7 -1
- package/lib/CodeGenerationResults.js +10 -3
- package/lib/CommentCompilationWarning.js +2 -1
- package/lib/Compilation.js +284 -236
- package/lib/Compiler.js +4 -3
- 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 +15 -8
- 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 +8 -1
- 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/ExternalModuleFactoryPlugin.js +9 -2
- package/lib/ExternalsPlugin.js +2 -1
- package/lib/FalseIIFEUmdWarning.js +1 -0
- package/lib/FileSystemInfo.js +49 -25
- package/lib/FlagDependencyExportsPlugin.js +8 -1
- package/lib/FlagDependencyUsagePlugin.js +9 -7
- package/lib/HarmonyLinkingError.js +1 -0
- package/lib/HookWebpackError.js +2 -0
- package/lib/HotModuleReplacementPlugin.js +16 -2
- package/lib/IgnoreWarningsPlugin.js +5 -2
- package/lib/InitFragment.js +1 -0
- package/lib/InvalidDependenciesModuleWarning.js +1 -0
- package/lib/LibManifestPlugin.js +1 -0
- package/lib/ManifestPlugin.js +8 -1
- package/lib/Module.js +7 -4
- package/lib/ModuleBuildError.js +3 -1
- package/lib/ModuleDependencyError.js +1 -0
- package/lib/ModuleDependencyWarning.js +1 -0
- package/lib/ModuleError.js +4 -1
- package/lib/ModuleFilenameHelpers.js +4 -2
- package/lib/ModuleGraph.js +3 -0
- package/lib/ModuleGraphConnection.js +10 -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 +28 -5
- package/lib/NormalModuleFactory.js +20 -4
- package/lib/OptionsApply.js +3 -1
- package/lib/ProgressPlugin.js +4 -0
- package/lib/RawModule.js +2 -0
- package/lib/RuntimeModule.js +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 +3 -0
- package/lib/WarnDeprecatedOptionPlugin.js +1 -0
- package/lib/WatchIgnorePlugin.js +1 -1
- package/lib/Watching.js +5 -0
- package/lib/WebpackError.js +4 -0
- package/lib/WebpackOptionsApply.js +61 -41
- package/lib/asset/AssetBytesGenerator.js +1 -0
- package/lib/asset/AssetGenerator.js +18 -3
- package/lib/asset/AssetModulesPlugin.js +33 -2
- package/lib/asset/AssetParser.js +4 -0
- 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/ContainerEntryDependency.js +3 -0
- package/lib/container/ContainerEntryModule.js +7 -0
- package/lib/container/ContainerExposedDependency.js +1 -0
- package/lib/container/FallbackDependency.js +1 -0
- package/lib/container/FallbackItemDependency.js +1 -0
- package/lib/container/FallbackModule.js +4 -0
- package/lib/container/HoistContainerReferencesPlugin.js +6 -0
- package/lib/container/ModuleFederationPlugin.js +1 -1
- package/lib/container/RemoteModule.js +24 -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 +7 -4
- package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
- package/lib/dependencies/CssUrlDependency.js +2 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
- package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -1
- package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
- package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
- package/lib/dependencies/HarmonyImportDependency.js +1 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +269 -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/RequireEnsureDependenciesBlock.js +1 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
- package/lib/dependencies/WorkerDependency.js +9 -3
- package/lib/dependencies/WorkerPlugin.js +1 -0
- package/lib/dependencies/getFunctionExpression.js +3 -1
- package/lib/electron/ElectronTargetPlugin.js +3 -1
- package/lib/errors/BuildCycleError.js +4 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
- package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +5 -0
- package/lib/hmr/lazyCompilationBackend.js +3 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +9 -7
- package/lib/ids/DeterministicChunkIdsPlugin.js +1 -0
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -0
- package/lib/ids/HashedModuleIdsPlugin.js +3 -8
- package/lib/ids/IdHelpers.js +10 -8
- package/lib/ids/NamedChunkIdsPlugin.js +7 -5
- package/lib/ids/NamedModuleIdsPlugin.js +1 -0
- package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +18 -10
- package/lib/ids/SyncModuleIdsPlugin.js +30 -20
- package/lib/index.js +2 -2
- 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/JsonGenerator.js +1 -0
- package/lib/json/JsonParser.js +9 -2
- package/lib/library/AbstractLibraryPlugin.js +4 -1
- package/lib/library/AmdLibraryPlugin.js +2 -1
- package/lib/library/AssignLibraryPlugin.js +6 -2
- package/lib/library/EnableLibraryPlugin.js +1 -0
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
- package/lib/library/JsonpLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +130 -13
- package/lib/library/SystemLibraryPlugin.js +4 -1
- package/lib/library/UmdLibraryPlugin.js +4 -3
- package/lib/logging/Logger.js +9 -5
- package/lib/logging/createConsoleLogger.js +4 -0
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +6 -4
- package/lib/node/NodeEnvironmentPlugin.js +1 -0
- package/lib/node/NodeTargetPlugin.js +10 -1
- package/lib/node/NodeTemplatePlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +6 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -0
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -0
- package/lib/node/nodeConsole.js +18 -1
- package/lib/optimize/AggressiveMergingPlugin.js +2 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +15 -6
- package/lib/optimize/ConcatenatedModule.js +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/LimitChunkCountPlugin.js +3 -2
- package/lib/optimize/MangleExportsPlugin.js +14 -2
- package/lib/optimize/MergeDuplicateChunksPlugin.js +5 -1
- package/lib/optimize/MinChunkSizePlugin.js +5 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +19 -4
- package/lib/optimize/RealContentHashPlugin.js +37 -27
- package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
- package/lib/optimize/RuntimeChunkPlugin.js +3 -5
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
- package/lib/optimize/SplitChunksPlugin.js +23 -5
- package/lib/performance/AssetsOverSizeLimitWarning.js +6 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -2
- package/lib/performance/NoAsyncChunksWarning.js +1 -0
- package/lib/performance/SizeLimitsPlugin.js +6 -6
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +2 -0
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -0
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -0
- package/lib/rules/BasicEffectRulePlugin.js +2 -0
- package/lib/rules/BasicMatcherRulePlugin.js +3 -0
- package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
- package/lib/rules/RuleSetCompiler.js +6 -0
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
- package/lib/runtime/CompatRuntimeModule.js +1 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -0
- package/lib/runtime/GetFullHashRuntimeModule.js +1 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
- package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +16 -32
- package/lib/runtime/PublicPathRuntimeModule.js +1 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
- package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
- package/lib/schemes/HttpUriPlugin.js +39 -20
- package/lib/schemes/VirtualUrlPlugin.js +28 -2
- package/lib/serialization/BinaryMiddleware.js +4 -0
- package/lib/serialization/FileMiddleware.js +9 -4
- package/lib/serialization/ObjectMiddleware.js +34 -11
- package/lib/serialization/PlainObjectSerializer.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +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 +20 -12
- package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
- package/lib/stats/StatsFactory.js +2 -2
- package/lib/url/URLParserPlugin.js +5 -3
- package/lib/util/AppendOnlyStackedSet.js +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 +4 -0
- package/lib/util/hash/BulkUpdateHash.js +8 -1
- package/lib/util/hash/hash-digest.js +1 -0
- package/lib/util/hash/wasm-hash.js +18 -2
- package/lib/util/identifier.js +7 -2
- package/lib/util/magicComment.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -0
- package/lib/util/runtime.js +15 -1
- package/lib/util/semver.js +1 -0
- package/lib/util/serialization.js +2 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +2 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyParser.js +3 -1
- package/lib/web/FetchCompileWasmPlugin.js +1 -0
- package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
- package/lib/webpack.js +16 -4
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -0
- package/package.json +33 -36
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +121 -55
- package/schemas/plugins/BannerPlugin.json +2 -2
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/ManifestPlugin.json +3 -3
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
- package/schemas/plugins/schemes/HttpUriPlugin.json +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +440 -137
|
@@ -53,7 +53,6 @@ class HashedModuleIdsPlugin {
|
|
|
53
53
|
* @returns {void}
|
|
54
54
|
*/
|
|
55
55
|
apply(compiler) {
|
|
56
|
-
const options = this.options;
|
|
57
56
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
58
57
|
compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => {
|
|
59
58
|
const chunkGraph = compilation.chunkGraph;
|
|
@@ -67,14 +66,10 @@ class HashedModuleIdsPlugin {
|
|
|
67
66
|
);
|
|
68
67
|
for (const module of modulesInNaturalOrder) {
|
|
69
68
|
const ident = getFullModuleName(module, context, compiler.root);
|
|
70
|
-
const hash = createHash(
|
|
71
|
-
/** @type {NonNullable<HashedModuleIdsPluginOptions["hashFunction"]>} */ (
|
|
72
|
-
options.hashFunction
|
|
73
|
-
)
|
|
74
|
-
);
|
|
69
|
+
const hash = createHash(this.options.hashFunction);
|
|
75
70
|
hash.update(ident || "");
|
|
76
|
-
const hashId = hash.digest(options.hashDigest);
|
|
77
|
-
let len = options.hashDigestLength;
|
|
71
|
+
const hashId = hash.digest(this.options.hashDigest);
|
|
72
|
+
let len = this.options.hashDigestLength;
|
|
78
73
|
while (usedIds.has(hashId.slice(0, len))) {
|
|
79
74
|
/** @type {number} */ (len)++;
|
|
80
75
|
}
|
package/lib/ids/IdHelpers.js
CHANGED
|
@@ -13,14 +13,14 @@ const numberHash = require("../util/numberHash");
|
|
|
13
13
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
14
14
|
/** @typedef {import("../Compilation")} Compilation */
|
|
15
15
|
/** @typedef {import("../Module")} Module */
|
|
16
|
-
/** @typedef {
|
|
16
|
+
/** @typedef {import("../util/Hash").HashFunction} HashFunction */
|
|
17
17
|
/** @typedef {import("../util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
|
18
18
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @param {string} str string to hash
|
|
22
22
|
* @param {number} len max length of the hash
|
|
23
|
-
* @param {
|
|
23
|
+
* @param {HashFunction} hashFunction hash function to use
|
|
24
24
|
* @returns {string} hash
|
|
25
25
|
*/
|
|
26
26
|
const getHash = (str, len, hashFunction) => {
|
|
@@ -56,12 +56,12 @@ const avoidNumber = (str) => {
|
|
|
56
56
|
* @returns {string} id representation
|
|
57
57
|
*/
|
|
58
58
|
const requestToId = (request) =>
|
|
59
|
-
request.replace(/^(\.\.?\/)+/, "").replace(/(^[.-]|[^a-
|
|
59
|
+
request.replace(/^(\.\.?\/)+/, "").replace(/(^[.-]|[^a-z0-9_-])+/gi, "_");
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* @param {string} string the string
|
|
63
63
|
* @param {string} delimiter separator for string and hash
|
|
64
|
-
* @param {
|
|
64
|
+
* @param {HashFunction} hashFunction hash function to use
|
|
65
65
|
* @returns {string} string with limited max length to 100 chars
|
|
66
66
|
*/
|
|
67
67
|
const shortenLongString = (string, delimiter, hashFunction) => {
|
|
@@ -95,7 +95,7 @@ const getShortModuleName = (module, context, associatedObjectForCache) => {
|
|
|
95
95
|
* @param {string} shortName the short name
|
|
96
96
|
* @param {Module} module the module
|
|
97
97
|
* @param {string} context context directory
|
|
98
|
-
* @param {
|
|
98
|
+
* @param {HashFunction} hashFunction hash function to use
|
|
99
99
|
* @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached
|
|
100
100
|
* @returns {string} long module name
|
|
101
101
|
*/
|
|
@@ -124,7 +124,7 @@ const getFullModuleName = (module, context, associatedObjectForCache) =>
|
|
|
124
124
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
125
125
|
* @param {string} context context directory
|
|
126
126
|
* @param {string} delimiter delimiter for names
|
|
127
|
-
* @param {
|
|
127
|
+
* @param {HashFunction} hashFunction hash function to use
|
|
128
128
|
* @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached
|
|
129
129
|
* @returns {string} short chunk name
|
|
130
130
|
*/
|
|
@@ -152,7 +152,7 @@ const getShortChunkName = (
|
|
|
152
152
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
153
153
|
* @param {string} context context directory
|
|
154
154
|
* @param {string} delimiter delimiter for names
|
|
155
|
-
* @param {
|
|
155
|
+
* @param {HashFunction} hashFunction hash function to use
|
|
156
156
|
* @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached
|
|
157
157
|
* @returns {string} short chunk name
|
|
158
158
|
*/
|
|
@@ -231,7 +231,7 @@ const addToMapOfItems = (map, key, value) => {
|
|
|
231
231
|
*/
|
|
232
232
|
const getUsedModuleIdsAndModules = (compilation, filter) => {
|
|
233
233
|
const chunkGraph = compilation.chunkGraph;
|
|
234
|
-
|
|
234
|
+
/** @type {Module[]} */
|
|
235
235
|
const modules = [];
|
|
236
236
|
|
|
237
237
|
/** @type {UsedModuleIds} */
|
|
@@ -402,6 +402,7 @@ const assignDeterministicIds = (
|
|
|
402
402
|
|
|
403
403
|
for (const item of items) {
|
|
404
404
|
const ident = getName(item);
|
|
405
|
+
/** @type {number} */
|
|
405
406
|
let id;
|
|
406
407
|
let i = salt;
|
|
407
408
|
do {
|
|
@@ -420,6 +421,7 @@ const assignAscendingModuleIds = (usedIds, modules, compilation) => {
|
|
|
420
421
|
const chunkGraph = compilation.chunkGraph;
|
|
421
422
|
|
|
422
423
|
let nextId = 0;
|
|
424
|
+
/** @type {(mod: Module) => void} */
|
|
423
425
|
let assignId;
|
|
424
426
|
if (usedIds.size > 0) {
|
|
425
427
|
/**
|
|
@@ -28,9 +28,9 @@ class NamedChunkIdsPlugin {
|
|
|
28
28
|
/**
|
|
29
29
|
* @param {NamedChunkIdsPluginOptions=} options options
|
|
30
30
|
*/
|
|
31
|
-
constructor(options) {
|
|
32
|
-
|
|
33
|
-
this.
|
|
31
|
+
constructor(options = {}) {
|
|
32
|
+
/** @type {NamedChunkIdsPluginOptions} */
|
|
33
|
+
this.options = options;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -43,8 +43,10 @@ class NamedChunkIdsPlugin {
|
|
|
43
43
|
const hashFunction = compilation.outputOptions.hashFunction;
|
|
44
44
|
compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => {
|
|
45
45
|
const chunkGraph = compilation.chunkGraph;
|
|
46
|
-
const context = this.
|
|
47
|
-
|
|
46
|
+
const context = this.options.context
|
|
47
|
+
? this.options.context
|
|
48
|
+
: compiler.context;
|
|
49
|
+
const delimiter = this.options.delimiter || "-";
|
|
48
50
|
|
|
49
51
|
const unnamedChunks = assignNames(
|
|
50
52
|
[...chunks].filter((chunk) => {
|
|
@@ -30,6 +30,7 @@ class OccurrenceChunkIdsPlugin {
|
|
|
30
30
|
*/
|
|
31
31
|
constructor(options = {}) {
|
|
32
32
|
validate(options);
|
|
33
|
+
/** @type {OccurrenceChunkIdsPluginOptions} */
|
|
33
34
|
this.options = options;
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -39,7 +40,6 @@ class OccurrenceChunkIdsPlugin {
|
|
|
39
40
|
* @returns {void}
|
|
40
41
|
*/
|
|
41
42
|
apply(compiler) {
|
|
42
|
-
const prioritiseInitial = this.options.prioritiseInitial;
|
|
43
43
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
44
44
|
compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => {
|
|
45
45
|
const chunkGraph = compilation.chunkGraph;
|
|
@@ -61,7 +61,7 @@ class OccurrenceChunkIdsPlugin {
|
|
|
61
61
|
|
|
62
62
|
/** @type {Chunk[]} */
|
|
63
63
|
const chunksInOccurrenceOrder = [...chunks].sort((a, b) => {
|
|
64
|
-
if (prioritiseInitial) {
|
|
64
|
+
if (this.options.prioritiseInitial) {
|
|
65
65
|
const aEntryOccurs =
|
|
66
66
|
/** @type {number} */
|
|
67
67
|
(occursInInitialChunksMap.get(a));
|
|
@@ -35,6 +35,7 @@ class OccurrenceModuleIdsPlugin {
|
|
|
35
35
|
*/
|
|
36
36
|
constructor(options = {}) {
|
|
37
37
|
validate(options);
|
|
38
|
+
/** @type {OccurrenceModuleIdsPluginOptions} */
|
|
38
39
|
this.options = options;
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -44,7 +45,6 @@ class OccurrenceModuleIdsPlugin {
|
|
|
44
45
|
* @returns {void}
|
|
45
46
|
*/
|
|
46
47
|
apply(compiler) {
|
|
47
|
-
const prioritiseInitial = this.options.prioritiseInitial;
|
|
48
48
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
49
49
|
const moduleGraph = compilation.moduleGraph;
|
|
50
50
|
|
|
@@ -54,10 +54,14 @@ class OccurrenceModuleIdsPlugin {
|
|
|
54
54
|
const [usedIds, modulesInOccurrenceOrder] =
|
|
55
55
|
getUsedModuleIdsAndModules(compilation);
|
|
56
56
|
|
|
57
|
+
/** @type {Map<Module, number>} */
|
|
57
58
|
const occursInInitialChunksMap = new Map();
|
|
59
|
+
/** @type {Map<Module, number>} */
|
|
58
60
|
const occursInAllChunksMap = new Map();
|
|
59
61
|
|
|
62
|
+
/** @type {Map<Module, number>} */
|
|
60
63
|
const initialChunkChunkMap = new Map();
|
|
64
|
+
/** @type {Map<Module, number>} */
|
|
61
65
|
const entryCountMap = new Map();
|
|
62
66
|
for (const m of modulesInOccurrenceOrder) {
|
|
63
67
|
let initial = 0;
|
|
@@ -111,12 +115,12 @@ class OccurrenceModuleIdsPlugin {
|
|
|
111
115
|
return sum;
|
|
112
116
|
};
|
|
113
117
|
|
|
114
|
-
if (prioritiseInitial) {
|
|
118
|
+
if (this.options.prioritiseInitial) {
|
|
115
119
|
for (const m of modulesInOccurrenceOrder) {
|
|
116
120
|
const result =
|
|
117
121
|
countOccursInEntry(m) +
|
|
118
|
-
initialChunkChunkMap.get(m) +
|
|
119
|
-
entryCountMap.get(m);
|
|
122
|
+
/** @type {number} */ (initialChunkChunkMap.get(m)) +
|
|
123
|
+
/** @type {number} */ (entryCountMap.get(m));
|
|
120
124
|
occursInInitialChunksMap.set(m, result);
|
|
121
125
|
}
|
|
122
126
|
}
|
|
@@ -125,7 +129,7 @@ class OccurrenceModuleIdsPlugin {
|
|
|
125
129
|
const result =
|
|
126
130
|
countOccurs(m) +
|
|
127
131
|
chunkGraph.getNumberOfModuleChunks(m) +
|
|
128
|
-
entryCountMap.get(m);
|
|
132
|
+
/** @type {number} */ (entryCountMap.get(m));
|
|
129
133
|
occursInAllChunksMap.set(m, result);
|
|
130
134
|
}
|
|
131
135
|
|
|
@@ -134,14 +138,18 @@ class OccurrenceModuleIdsPlugin {
|
|
|
134
138
|
);
|
|
135
139
|
|
|
136
140
|
modulesInOccurrenceOrder.sort((a, b) => {
|
|
137
|
-
if (prioritiseInitial) {
|
|
138
|
-
const aEntryOccurs =
|
|
139
|
-
|
|
141
|
+
if (this.options.prioritiseInitial) {
|
|
142
|
+
const aEntryOccurs =
|
|
143
|
+
/** @type {number} */
|
|
144
|
+
(occursInInitialChunksMap.get(a));
|
|
145
|
+
const bEntryOccurs =
|
|
146
|
+
/** @type {number} */
|
|
147
|
+
(occursInInitialChunksMap.get(b));
|
|
140
148
|
if (aEntryOccurs > bEntryOccurs) return -1;
|
|
141
149
|
if (aEntryOccurs < bEntryOccurs) return 1;
|
|
142
150
|
}
|
|
143
|
-
const aOccurs = occursInAllChunksMap.get(a);
|
|
144
|
-
const bOccurs = occursInAllChunksMap.get(b);
|
|
151
|
+
const aOccurs = /** @type {number} */ (occursInAllChunksMap.get(a));
|
|
152
|
+
const bOccurs = /** @type {number} */ (occursInAllChunksMap.get(b));
|
|
145
153
|
if (aOccurs > bOccurs) return -1;
|
|
146
154
|
if (aOccurs < bOccurs) return 1;
|
|
147
155
|
return naturalCompare(a, b);
|
|
@@ -13,6 +13,8 @@ const { getUsedModuleIdsAndModules } = require("./IdHelpers");
|
|
|
13
13
|
/** @typedef {import("../Module").ModuleId} ModuleId */
|
|
14
14
|
/** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
|
|
15
15
|
|
|
16
|
+
/** @typedef {{ [key: string]: ModuleId }} JSONContent */
|
|
17
|
+
|
|
16
18
|
const plugin = "SyncModuleIdsPlugin";
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -27,14 +29,9 @@ class SyncModuleIdsPlugin {
|
|
|
27
29
|
/**
|
|
28
30
|
* @param {SyncModuleIdsPluginOptions} options options
|
|
29
31
|
*/
|
|
30
|
-
constructor(
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
this._test = test || (() => true);
|
|
34
|
-
const readAndWrite = !mode || mode === "merge" || mode === "update";
|
|
35
|
-
this._read = readAndWrite || mode === "read";
|
|
36
|
-
this._write = readAndWrite || mode === "create";
|
|
37
|
-
this._prune = mode === "update";
|
|
32
|
+
constructor(options) {
|
|
33
|
+
/** @type {SyncModuleIdsPluginOptions} */
|
|
34
|
+
this.options = options;
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
/**
|
|
@@ -46,19 +43,31 @@ class SyncModuleIdsPlugin {
|
|
|
46
43
|
/** @type {Map<string, ModuleId>} */
|
|
47
44
|
let data;
|
|
48
45
|
let dataChanged = false;
|
|
49
|
-
|
|
46
|
+
|
|
47
|
+
const readAndWrite =
|
|
48
|
+
!this.options.mode ||
|
|
49
|
+
this.options.mode === "merge" ||
|
|
50
|
+
this.options.mode === "update";
|
|
51
|
+
|
|
52
|
+
const needRead = readAndWrite || this.options.mode === "read";
|
|
53
|
+
const needWrite = readAndWrite || this.options.mode === "create";
|
|
54
|
+
const needPrune = this.options.mode === "update";
|
|
55
|
+
|
|
56
|
+
if (needRead) {
|
|
50
57
|
compiler.hooks.readRecords.tapAsync(plugin, (callback) => {
|
|
51
58
|
const fs =
|
|
52
59
|
/** @type {IntermediateFileSystem} */
|
|
53
60
|
(compiler.intermediateFileSystem);
|
|
54
|
-
fs.readFile(this.
|
|
61
|
+
fs.readFile(this.options.path, (err, buffer) => {
|
|
55
62
|
if (err) {
|
|
56
63
|
if (err.code !== "ENOENT") {
|
|
57
64
|
return callback(err);
|
|
58
65
|
}
|
|
59
66
|
return callback();
|
|
60
67
|
}
|
|
68
|
+
/** @type {JSONContent} */
|
|
61
69
|
const json = JSON.parse(/** @type {Buffer} */ (buffer).toString());
|
|
70
|
+
/** @type {Map<string, string | number | null>} */
|
|
62
71
|
data = new Map();
|
|
63
72
|
for (const key of Object.keys(json)) {
|
|
64
73
|
data.set(key, json[key]);
|
|
@@ -68,10 +77,10 @@ class SyncModuleIdsPlugin {
|
|
|
68
77
|
});
|
|
69
78
|
});
|
|
70
79
|
}
|
|
71
|
-
if (
|
|
80
|
+
if (needWrite) {
|
|
72
81
|
compiler.hooks.emitRecords.tapAsync(plugin, (callback) => {
|
|
73
82
|
if (!data || !dataChanged) return callback();
|
|
74
|
-
/** @type {
|
|
83
|
+
/** @type {JSONContent} */
|
|
75
84
|
const json = {};
|
|
76
85
|
const sorted = [...data].sort(([a], [b]) => (a < b ? -1 : 1));
|
|
77
86
|
for (const [key, value] of sorted) {
|
|
@@ -80,19 +89,20 @@ class SyncModuleIdsPlugin {
|
|
|
80
89
|
const fs =
|
|
81
90
|
/** @type {IntermediateFileSystem} */
|
|
82
91
|
(compiler.intermediateFileSystem);
|
|
83
|
-
fs.writeFile(this.
|
|
92
|
+
fs.writeFile(this.options.path, JSON.stringify(json), callback);
|
|
84
93
|
});
|
|
85
94
|
}
|
|
86
95
|
compiler.hooks.thisCompilation.tap(plugin, (compilation) => {
|
|
87
96
|
const associatedObjectForCache = compiler.root;
|
|
88
|
-
const context = this.
|
|
89
|
-
|
|
97
|
+
const context = this.options.context || compiler.context;
|
|
98
|
+
const test = this.options.test || (() => true);
|
|
99
|
+
if (needRead) {
|
|
90
100
|
compilation.hooks.reviveModules.tap(plugin, (_1, _2) => {
|
|
91
101
|
if (!data) return;
|
|
92
102
|
const { chunkGraph } = compilation;
|
|
93
103
|
const [usedIds, modules] = getUsedModuleIdsAndModules(
|
|
94
104
|
compilation,
|
|
95
|
-
|
|
105
|
+
test
|
|
96
106
|
);
|
|
97
107
|
for (const module of modules) {
|
|
98
108
|
const name = module.libIdent({
|
|
@@ -104,7 +114,7 @@ class SyncModuleIdsPlugin {
|
|
|
104
114
|
const idAsString = `${id}`;
|
|
105
115
|
if (usedIds.has(idAsString)) {
|
|
106
116
|
const err = new WebpackError(
|
|
107
|
-
`SyncModuleIdsPlugin: Unable to restore id '${id}' from '${this.
|
|
117
|
+
`SyncModuleIdsPlugin: Unable to restore id '${id}' from '${this.options.path}' as it's already used.`
|
|
108
118
|
);
|
|
109
119
|
err.module = module;
|
|
110
120
|
compilation.errors.push(err);
|
|
@@ -114,17 +124,17 @@ class SyncModuleIdsPlugin {
|
|
|
114
124
|
}
|
|
115
125
|
});
|
|
116
126
|
}
|
|
117
|
-
if (
|
|
127
|
+
if (needWrite) {
|
|
118
128
|
compilation.hooks.recordModules.tap(plugin, (modules) => {
|
|
119
129
|
const { chunkGraph } = compilation;
|
|
120
130
|
let oldData = data;
|
|
121
131
|
if (!oldData) {
|
|
122
132
|
oldData = data = new Map();
|
|
123
|
-
} else if (
|
|
133
|
+
} else if (needPrune) {
|
|
124
134
|
data = new Map();
|
|
125
135
|
}
|
|
126
136
|
for (const module of modules) {
|
|
127
|
-
if (
|
|
137
|
+
if (test(module)) {
|
|
128
138
|
const name = module.libIdent({
|
|
129
139
|
context,
|
|
130
140
|
associatedObjectForCache
|
package/lib/index.js
CHANGED
|
@@ -33,8 +33,8 @@ const memoize = require("./util/memoize");
|
|
|
33
33
|
/** @typedef {import("../declarations/WebpackOptions").StatsOptions} StatsOptions */
|
|
34
34
|
/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} Configuration */
|
|
35
35
|
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptionsNormalized */
|
|
36
|
-
/** @typedef {import("
|
|
37
|
-
/** @typedef {import("
|
|
36
|
+
/** @typedef {import("./webpack").WebpackPluginFunction} WebpackPluginFunction */
|
|
37
|
+
/** @typedef {import("./webpack").WebpackPluginInstance} WebpackPluginInstance */
|
|
38
38
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
39
39
|
/** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
|
|
40
40
|
/** @typedef {import("./Compilation").Asset} Asset */
|
|
@@ -296,6 +296,7 @@ class BasicEvaluatedExpression {
|
|
|
296
296
|
if (this.isBigInt()) return `${this.bigint}`;
|
|
297
297
|
if (this.isRegExp()) return `${this.regExp}`;
|
|
298
298
|
if (this.isArray()) {
|
|
299
|
+
/** @type {string[]} */
|
|
299
300
|
const array = [];
|
|
300
301
|
for (const item of /** @type {BasicEvaluatedExpression[]} */ (
|
|
301
302
|
this.items
|
|
@@ -8,16 +8,19 @@
|
|
|
8
8
|
/** @typedef {import("../../declarations/WebpackOptions").ChunkLoadingType} ChunkLoadingType */
|
|
9
9
|
/** @typedef {import("../Compiler")} Compiler */
|
|
10
10
|
|
|
11
|
-
/** @
|
|
11
|
+
/** @typedef {Set<ChunkLoadingType>} ChunkLoadingTypes */
|
|
12
|
+
|
|
13
|
+
/** @type {WeakMap<Compiler, ChunkLoadingTypes>} */
|
|
12
14
|
const enabledTypes = new WeakMap();
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* @param {Compiler} compiler compiler
|
|
16
|
-
* @returns {
|
|
18
|
+
* @returns {ChunkLoadingTypes} enabled types
|
|
17
19
|
*/
|
|
18
20
|
const getEnabledTypes = (compiler) => {
|
|
19
21
|
let set = enabledTypes.get(compiler);
|
|
20
22
|
if (set === undefined) {
|
|
23
|
+
/** @type {ChunkLoadingTypes} */
|
|
21
24
|
set = new Set();
|
|
22
25
|
enabledTypes.set(compiler, set);
|
|
23
26
|
}
|
|
@@ -32,7 +32,7 @@ const RuntimeGlobals = require("../RuntimeGlobals");
|
|
|
32
32
|
const Template = require("../Template");
|
|
33
33
|
const { last, someInIterable } = require("../util/IterableHelpers");
|
|
34
34
|
const StringXor = require("../util/StringXor");
|
|
35
|
-
const {
|
|
35
|
+
const { compareModulesByFullName } = require("../util/comparators");
|
|
36
36
|
const {
|
|
37
37
|
RESERVED_NAMES,
|
|
38
38
|
addScopeSymbols,
|
|
@@ -59,17 +59,21 @@ const JavascriptParser = require("./JavascriptParser");
|
|
|
59
59
|
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
|
60
60
|
/** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
|
|
61
61
|
/** @typedef {import("../Compilation").ExecuteModuleObject} ExecuteModuleObject */
|
|
62
|
+
/** @typedef {import("../Compilation").WebpackRequire} WebpackRequire */
|
|
62
63
|
/** @typedef {import("../Compiler")} Compiler */
|
|
63
64
|
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
|
64
65
|
/** @typedef {import("../Entrypoint")} Entrypoint */
|
|
65
66
|
/** @typedef {import("../Module")} Module */
|
|
66
67
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
68
|
+
/** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
|
|
67
69
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
68
70
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
69
71
|
/** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
|
|
70
72
|
/** @typedef {import("../WebpackError")} WebpackError */
|
|
71
73
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
72
74
|
/** @typedef {import("../util/Hash")} Hash */
|
|
75
|
+
/** @typedef {import("../util/concatenate").ScopeSet} ScopeSet */
|
|
76
|
+
/** @typedef {import("../util/concatenate").UsedNamesInScopeInfo} UsedNamesInScopeInfo */
|
|
73
77
|
|
|
74
78
|
/**
|
|
75
79
|
* @param {Chunk} chunk a chunk
|
|
@@ -278,7 +282,7 @@ class JavascriptModulesPlugin {
|
|
|
278
282
|
|
|
279
283
|
constructor(options = {}) {
|
|
280
284
|
this.options = options;
|
|
281
|
-
/** @type {WeakMap<Source, { source: Source, needModule:boolean, needExports: boolean, needRequire: boolean, needThisAsExports: boolean, needStrict: boolean | undefined, renderShorthand: boolean }>} */
|
|
285
|
+
/** @type {WeakMap<Source, { source: Source, needModule: boolean, needExports: boolean, needRequire: boolean, needThisAsExports: boolean, needStrict: boolean | undefined, renderShorthand: boolean }>} */
|
|
282
286
|
this._moduleFactoryCache = new WeakMap();
|
|
283
287
|
}
|
|
284
288
|
|
|
@@ -354,6 +358,7 @@ class JavascriptModulesPlugin {
|
|
|
354
358
|
outputOptions
|
|
355
359
|
);
|
|
356
360
|
|
|
361
|
+
/** @type {() => Source} */
|
|
357
362
|
let render;
|
|
358
363
|
|
|
359
364
|
if (hotUpdateChunk) {
|
|
@@ -535,6 +540,7 @@ class JavascriptModulesPlugin {
|
|
|
535
540
|
const { module } = options;
|
|
536
541
|
const code = source.source();
|
|
537
542
|
|
|
543
|
+
/** @type {(this: ExecuteModuleObject["exports"], exports: ExecuteModuleObject["exports"], moduleObject: ExecuteModuleObject, webpackRequire: WebpackRequire) => void} */
|
|
538
544
|
const fn = vm.runInThisContext(
|
|
539
545
|
`(function(${module.moduleArgument}, ${module.exportsArgument}, ${RuntimeGlobals.require}) {\n${code}\n/**/})`,
|
|
540
546
|
{
|
|
@@ -552,7 +558,8 @@ class JavascriptModulesPlugin {
|
|
|
552
558
|
moduleObject.exports,
|
|
553
559
|
moduleObject,
|
|
554
560
|
moduleObject.exports,
|
|
555
|
-
|
|
561
|
+
/** @type {WebpackRequire} */
|
|
562
|
+
(context.__webpack_require__)
|
|
556
563
|
);
|
|
557
564
|
} catch (err) {
|
|
558
565
|
/** @type {Error} */
|
|
@@ -569,6 +576,7 @@ class JavascriptModulesPlugin {
|
|
|
569
576
|
let code = source.source();
|
|
570
577
|
if (typeof code !== "string") code = code.toString();
|
|
571
578
|
|
|
579
|
+
/** @type {(this: null, webpackRequire: WebpackRequire) => void} */
|
|
572
580
|
const fn = vm.runInThisContext(
|
|
573
581
|
`(function(${RuntimeGlobals.require}) {\n${code}\n/**/})`,
|
|
574
582
|
{
|
|
@@ -578,7 +586,11 @@ class JavascriptModulesPlugin {
|
|
|
578
586
|
);
|
|
579
587
|
try {
|
|
580
588
|
// eslint-disable-next-line no-useless-call
|
|
581
|
-
fn.call(
|
|
589
|
+
fn.call(
|
|
590
|
+
null,
|
|
591
|
+
/** @type {WebpackRequire} */
|
|
592
|
+
(context.__webpack_require__)
|
|
593
|
+
);
|
|
582
594
|
} catch (err) {
|
|
583
595
|
/** @type {Error} */
|
|
584
596
|
(err).stack += printGeneratedCodeForStack(options.module, code);
|
|
@@ -638,6 +650,7 @@ class JavascriptModulesPlugin {
|
|
|
638
650
|
hooks.renderModuleContent.call(moduleSource, module, renderContext),
|
|
639
651
|
"JavascriptModulesPlugin.getCompilationHooks().renderModuleContent"
|
|
640
652
|
);
|
|
653
|
+
/** @type {Source} */
|
|
641
654
|
let moduleSourcePostContainer;
|
|
642
655
|
if (factory) {
|
|
643
656
|
const runtimeRequirements = chunkGraph.getModuleRuntimeRequirements(
|
|
@@ -660,6 +673,7 @@ class JavascriptModulesPlugin {
|
|
|
660
673
|
);
|
|
661
674
|
const renderShorthand =
|
|
662
675
|
renderInObject === true && runtimeTemplate.supportsMethodShorthand();
|
|
676
|
+
/** @type {Source} */
|
|
663
677
|
let source;
|
|
664
678
|
if (
|
|
665
679
|
cacheEntry &&
|
|
@@ -673,6 +687,7 @@ class JavascriptModulesPlugin {
|
|
|
673
687
|
source = cacheEntry.source;
|
|
674
688
|
} else {
|
|
675
689
|
const factorySource = new ConcatSource();
|
|
690
|
+
/** @type {string[]} */
|
|
676
691
|
const args = [];
|
|
677
692
|
if (needExports || needRequire || needModule) {
|
|
678
693
|
args.push(
|
|
@@ -747,13 +762,14 @@ class JavascriptModulesPlugin {
|
|
|
747
762
|
* @returns {Source} the rendered source
|
|
748
763
|
*/
|
|
749
764
|
renderChunk(renderContext, hooks) {
|
|
750
|
-
const { chunk, chunkGraph } = renderContext;
|
|
765
|
+
const { chunk, chunkGraph, runtimeTemplate } = renderContext;
|
|
751
766
|
const modules = chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
|
752
767
|
chunk,
|
|
753
768
|
JAVASCRIPT_TYPE,
|
|
754
|
-
|
|
769
|
+
compareModulesByFullName(runtimeTemplate.compilation.compiler)
|
|
755
770
|
);
|
|
756
771
|
const allModules = modules ? [...modules] : [];
|
|
772
|
+
/** @type {undefined | string} */
|
|
757
773
|
let strictHeader;
|
|
758
774
|
let allStrict = renderContext.strictMode;
|
|
759
775
|
if (
|
|
@@ -838,7 +854,7 @@ class JavascriptModulesPlugin {
|
|
|
838
854
|
...(chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
|
839
855
|
chunk,
|
|
840
856
|
JAVASCRIPT_TYPE,
|
|
841
|
-
|
|
857
|
+
compareModulesByFullName(runtimeTemplate.compilation.compiler)
|
|
842
858
|
) || [])
|
|
843
859
|
];
|
|
844
860
|
|
|
@@ -850,6 +866,7 @@ class JavascriptModulesPlugin {
|
|
|
850
866
|
}
|
|
851
867
|
|
|
852
868
|
const source = new ConcatSource();
|
|
869
|
+
/** @type {string} */
|
|
853
870
|
let prefix;
|
|
854
871
|
if (iife) {
|
|
855
872
|
if (runtimeTemplate.supportsArrowFunction()) {
|
|
@@ -1026,6 +1043,7 @@ class JavascriptModulesPlugin {
|
|
|
1026
1043
|
);
|
|
1027
1044
|
|
|
1028
1045
|
if (renderedModule) {
|
|
1046
|
+
/** @type {string} */
|
|
1029
1047
|
let footer;
|
|
1030
1048
|
if (iife !== undefined) {
|
|
1031
1049
|
startupSource.add(
|
|
@@ -1209,7 +1227,7 @@ class JavascriptModulesPlugin {
|
|
|
1209
1227
|
requireFunction || interceptModuleExecution || moduleUsed;
|
|
1210
1228
|
|
|
1211
1229
|
/**
|
|
1212
|
-
* @type {{startup: string[], beforeStartup: string[], header: string[], afterStartup: string[], allowInlineStartup: boolean}}
|
|
1230
|
+
* @type {{ startup: string[], beforeStartup: string[], header: string[], afterStartup: string[], allowInlineStartup: boolean }}
|
|
1213
1231
|
*/
|
|
1214
1232
|
const result = {
|
|
1215
1233
|
header: [],
|
|
@@ -1334,6 +1352,7 @@ class JavascriptModulesPlugin {
|
|
|
1334
1352
|
result.allowInlineStartup = false;
|
|
1335
1353
|
}
|
|
1336
1354
|
|
|
1355
|
+
/** @type {undefined | CodeGenerationResultData} */
|
|
1337
1356
|
let data;
|
|
1338
1357
|
if (codeGenerationResults.has(entryModule, chunk.runtime)) {
|
|
1339
1358
|
const result = codeGenerationResults.get(
|
|
@@ -1766,7 +1785,9 @@ class JavascriptModulesPlugin {
|
|
|
1766
1785
|
}
|
|
1767
1786
|
|
|
1768
1787
|
for (const variable of info.variables) {
|
|
1788
|
+
/** @type {UsedNamesInScopeInfo} */
|
|
1769
1789
|
const usedNamesInScopeInfo = new Map();
|
|
1790
|
+
/** @type {ScopeSet} */
|
|
1770
1791
|
const ignoredScopes = new Set();
|
|
1771
1792
|
|
|
1772
1793
|
const name = variable.name;
|