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
package/lib/logging/Logger.js
CHANGED
|
@@ -37,14 +37,18 @@ const TIMERS_SYMBOL = Symbol("webpack logger times");
|
|
|
37
37
|
const TIMERS_AGGREGATES_SYMBOL = Symbol("webpack logger aggregated times");
|
|
38
38
|
|
|
39
39
|
/** @typedef {EXPECTED_ANY[]} Args */
|
|
40
|
+
/** @typedef {(type: LogTypeEnum, args?: Args) => void} LogFn */
|
|
41
|
+
/** @typedef {(name: string | (() => string)) => WebpackLogger} GetChildLogger */
|
|
40
42
|
|
|
41
43
|
class WebpackLogger {
|
|
42
44
|
/**
|
|
43
|
-
* @param {
|
|
44
|
-
* @param {
|
|
45
|
+
* @param {LogFn} log log function
|
|
46
|
+
* @param {GetChildLogger} getChildLogger function to create child logger
|
|
45
47
|
*/
|
|
46
48
|
constructor(log, getChildLogger) {
|
|
49
|
+
/** @type {LogFn} */
|
|
47
50
|
this[LOG_SYMBOL] = log;
|
|
51
|
+
/** @type {GetChildLogger} */
|
|
48
52
|
this.getChildLogger = getChildLogger;
|
|
49
53
|
}
|
|
50
54
|
|
|
@@ -84,11 +88,11 @@ class WebpackLogger {
|
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
/**
|
|
87
|
-
* @param {
|
|
91
|
+
* @param {boolean=} condition condition
|
|
88
92
|
* @param {Args} args args
|
|
89
93
|
*/
|
|
90
|
-
assert(
|
|
91
|
-
if (!
|
|
94
|
+
assert(condition, ...args) {
|
|
95
|
+
if (!condition) {
|
|
92
96
|
this[LOG_SYMBOL](LogType.error, args);
|
|
93
97
|
}
|
|
94
98
|
}
|
|
@@ -99,6 +99,10 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
99
99
|
* @returns {void}
|
|
100
100
|
*/
|
|
101
101
|
const logger = (name, type, args) => {
|
|
102
|
+
/**
|
|
103
|
+
* @template T
|
|
104
|
+
* @returns {[string?, ...T[]]} labeled args
|
|
105
|
+
*/
|
|
102
106
|
const labeledArgs = () => {
|
|
103
107
|
if (Array.isArray(args)) {
|
|
104
108
|
if (args.length > 0 && typeof args[0] === "string") {
|
|
@@ -16,7 +16,7 @@ const arraySum = (array) => {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @param {
|
|
19
|
+
* @param {string[]} args items to be truncated
|
|
20
20
|
* @param {number} maxLength maximum length of args including spaces between
|
|
21
21
|
* @returns {string[]} truncated args
|
|
22
22
|
*/
|
|
@@ -24,7 +24,8 @@ class CommonJsChunkLoadingPlugin {
|
|
|
24
24
|
* @param {CommonJsChunkLoadingPluginOptions=} options options
|
|
25
25
|
*/
|
|
26
26
|
constructor(options = {}) {
|
|
27
|
-
|
|
27
|
+
/** @type {CommonJsChunkLoadingPluginOptions} */
|
|
28
|
+
this.options = options;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
/**
|
|
@@ -33,15 +34,15 @@ class CommonJsChunkLoadingPlugin {
|
|
|
33
34
|
* @returns {void}
|
|
34
35
|
*/
|
|
35
36
|
apply(compiler) {
|
|
36
|
-
const ChunkLoadingRuntimeModule = this.
|
|
37
|
+
const ChunkLoadingRuntimeModule = this.options.asyncChunkLoading
|
|
37
38
|
? require("./ReadFileChunkLoadingRuntimeModule")
|
|
38
39
|
: require("./RequireChunkLoadingRuntimeModule");
|
|
39
|
-
const chunkLoadingValue = this.
|
|
40
|
+
const chunkLoadingValue = this.options.asyncChunkLoading
|
|
40
41
|
? "async-node"
|
|
41
42
|
: "require";
|
|
42
43
|
new StartupChunkDependenciesPlugin({
|
|
43
44
|
chunkLoading: chunkLoadingValue,
|
|
44
|
-
asyncChunkLoading: this.
|
|
45
|
+
asyncChunkLoading: this.options.asyncChunkLoading
|
|
45
46
|
}).apply(compiler);
|
|
46
47
|
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
47
48
|
const globalChunkLoading = compilation.outputOptions.chunkLoading;
|
|
@@ -57,6 +58,7 @@ class CommonJsChunkLoadingPlugin {
|
|
|
57
58
|
: globalChunkLoading;
|
|
58
59
|
return chunkLoading === chunkLoadingValue;
|
|
59
60
|
};
|
|
61
|
+
/** @type {WeakSet<Chunk>} */
|
|
60
62
|
const onceForChunkSet = new WeakSet();
|
|
61
63
|
/**
|
|
62
64
|
* @param {Chunk} chunk chunk
|
|
@@ -77,6 +77,7 @@ class NodeTargetPlugin {
|
|
|
77
77
|
* @param {ExternalsType} type default external type
|
|
78
78
|
*/
|
|
79
79
|
constructor(type = "node-commonjs") {
|
|
80
|
+
/** @type {ExternalsType} */
|
|
80
81
|
this.type = type;
|
|
81
82
|
}
|
|
82
83
|
|
|
@@ -86,7 +87,15 @@ class NodeTargetPlugin {
|
|
|
86
87
|
* @returns {void}
|
|
87
88
|
*/
|
|
88
89
|
apply(compiler) {
|
|
89
|
-
new ExternalsPlugin(
|
|
90
|
+
new ExternalsPlugin((dependency) => {
|
|
91
|
+
// When `require` node.js built-in modules with module output
|
|
92
|
+
// we should still emit `createRequire` for compatibility
|
|
93
|
+
if (dependency.category === "commonjs") {
|
|
94
|
+
return "node-commonjs";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return this.type;
|
|
98
|
+
}, builtins).apply(compiler);
|
|
90
99
|
}
|
|
91
100
|
}
|
|
92
101
|
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
const util = require("util");
|
|
9
9
|
const Watchpack = require("watchpack");
|
|
10
10
|
|
|
11
|
+
/** @typedef {import("watchpack").TimeInfoEntries} TimeInfoEntries */
|
|
12
|
+
/** @typedef {import("watchpack").WatchOptions} WatchOptions */
|
|
11
13
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
12
14
|
/** @typedef {import("../util/fs").WatchMethod} WatchMethod */
|
|
13
15
|
/** @typedef {import("../util/fs").Changes} Changes */
|
|
@@ -18,7 +20,9 @@ class NodeWatchFileSystem {
|
|
|
18
20
|
* @param {InputFileSystem} inputFileSystem input filesystem
|
|
19
21
|
*/
|
|
20
22
|
constructor(inputFileSystem) {
|
|
23
|
+
/** @type {InputFileSystem} */
|
|
21
24
|
this.inputFileSystem = inputFileSystem;
|
|
25
|
+
/** @type {WatchOptions} */
|
|
22
26
|
this.watcherOptions = {
|
|
23
27
|
aggregateTimeout: 0
|
|
24
28
|
};
|
|
@@ -65,7 +69,9 @@ class NodeWatchFileSystem {
|
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
const fetchTimeInfo = () => {
|
|
72
|
+
/** @type {TimeInfoEntries} */
|
|
68
73
|
const fileTimeInfoEntries = new Map();
|
|
74
|
+
/** @type {TimeInfoEntries} */
|
|
69
75
|
const contextTimeInfoEntries = new Map();
|
|
70
76
|
if (this.watcher) {
|
|
71
77
|
this.watcher.collectTimeInfoEntries(
|
|
@@ -30,6 +30,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
30
30
|
*/
|
|
31
31
|
constructor(runtimeRequirements) {
|
|
32
32
|
super("readFile chunk loading", RuntimeModule.STAGE_ATTACH);
|
|
33
|
+
/** @type {ReadOnlyRuntimeRequirements} */
|
|
33
34
|
this.runtimeRequirements = runtimeRequirements;
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -30,6 +30,7 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
30
30
|
*/
|
|
31
31
|
constructor(runtimeRequirements) {
|
|
32
32
|
super("require chunk loading", RuntimeModule.STAGE_ATTACH);
|
|
33
|
+
/** @type {ReadOnlyRuntimeRequirements} */
|
|
33
34
|
this.runtimeRequirements = runtimeRequirements;
|
|
34
35
|
}
|
|
35
36
|
|
package/lib/node/nodeConsole.js
CHANGED
|
@@ -67,10 +67,11 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
+
* @template T
|
|
70
71
|
* @param {string} prefix prefix
|
|
71
72
|
* @param {string} colorPrefix color prefix
|
|
72
73
|
* @param {string} colorSuffix color suffix
|
|
73
|
-
* @returns {(...args:
|
|
74
|
+
* @returns {(...args: T[]) => void} function to write with colors
|
|
74
75
|
*/
|
|
75
76
|
const writeColored =
|
|
76
77
|
(prefix, colorPrefix, colorSuffix) =>
|
|
@@ -87,12 +88,14 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
87
88
|
writeStatusMessage();
|
|
88
89
|
};
|
|
89
90
|
|
|
91
|
+
/** @type {<T extends unknown[]>(...args: T) => void} */
|
|
90
92
|
const writeGroupMessage = writeColored(
|
|
91
93
|
"<-> ",
|
|
92
94
|
"\u001B[1m\u001B[36m",
|
|
93
95
|
"\u001B[39m\u001B[22m"
|
|
94
96
|
);
|
|
95
97
|
|
|
98
|
+
/** @type {<T extends unknown[]>(...args: T) => void} */
|
|
96
99
|
const writeGroupCollapsedMessage = writeColored(
|
|
97
100
|
"<+> ",
|
|
98
101
|
"\u001B[1m\u001B[36m",
|
|
@@ -100,17 +103,25 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
100
103
|
);
|
|
101
104
|
|
|
102
105
|
return {
|
|
106
|
+
/** @type {LoggerConsole["log"]} */
|
|
103
107
|
log: writeColored(" ", "\u001B[1m", "\u001B[22m"),
|
|
108
|
+
/** @type {LoggerConsole["debug"]} */
|
|
104
109
|
debug: writeColored(" ", "", ""),
|
|
110
|
+
/** @type {LoggerConsole["trace"]} */
|
|
105
111
|
trace: writeColored(" ", "", ""),
|
|
112
|
+
/** @type {LoggerConsole["info"]} */
|
|
106
113
|
info: writeColored("<i> ", "\u001B[1m\u001B[32m", "\u001B[39m\u001B[22m"),
|
|
114
|
+
/** @type {LoggerConsole["warn"]} */
|
|
107
115
|
warn: writeColored("<w> ", "\u001B[1m\u001B[33m", "\u001B[39m\u001B[22m"),
|
|
116
|
+
/** @type {LoggerConsole["error"]} */
|
|
108
117
|
error: writeColored("<e> ", "\u001B[1m\u001B[31m", "\u001B[39m\u001B[22m"),
|
|
118
|
+
/** @type {LoggerConsole["logTime"]} */
|
|
109
119
|
logTime: writeColored(
|
|
110
120
|
"<t> ",
|
|
111
121
|
"\u001B[1m\u001B[35m",
|
|
112
122
|
"\u001B[39m\u001B[22m"
|
|
113
123
|
),
|
|
124
|
+
/** @type {LoggerConsole["group"]} */
|
|
114
125
|
group: (...args) => {
|
|
115
126
|
writeGroupMessage(...args);
|
|
116
127
|
if (currentCollapsed > 0) {
|
|
@@ -119,10 +130,12 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
119
130
|
currentIndent += " ";
|
|
120
131
|
}
|
|
121
132
|
},
|
|
133
|
+
/** @type {LoggerConsole["groupCollapsed"]} */
|
|
122
134
|
groupCollapsed: (...args) => {
|
|
123
135
|
writeGroupCollapsedMessage(...args);
|
|
124
136
|
currentCollapsed++;
|
|
125
137
|
},
|
|
138
|
+
/** @type {LoggerConsole["groupEnd"]} */
|
|
126
139
|
groupEnd: () => {
|
|
127
140
|
if (currentCollapsed > 0) {
|
|
128
141
|
currentCollapsed--;
|
|
@@ -130,8 +143,11 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
130
143
|
currentIndent = currentIndent.slice(0, -2);
|
|
131
144
|
}
|
|
132
145
|
},
|
|
146
|
+
/** @type {LoggerConsole["profile"]} */
|
|
133
147
|
profile: console.profile && ((name) => console.profile(name)),
|
|
148
|
+
/** @type {LoggerConsole["profileEnd"]} */
|
|
134
149
|
profileEnd: console.profileEnd && ((name) => console.profileEnd(name)),
|
|
150
|
+
/** @type {LoggerConsole["clear"]} */
|
|
135
151
|
clear:
|
|
136
152
|
/** @type {() => void} */
|
|
137
153
|
(
|
|
@@ -143,6 +159,7 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
143
159
|
writeStatusMessage();
|
|
144
160
|
})
|
|
145
161
|
),
|
|
162
|
+
/** @type {LoggerConsole["status"]} */
|
|
146
163
|
status: appendOnly
|
|
147
164
|
? writeColored("<s> ", "", "")
|
|
148
165
|
: (name, ...args) => {
|
|
@@ -30,6 +30,7 @@ class AggressiveMergingPlugin {
|
|
|
30
30
|
"Argument should be an options object. To use defaults, pass in nothing.\nFor more info on options, see https://webpack.js.org/plugins/"
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
|
+
/** @type {AggressiveMergingPluginOptions} */
|
|
33
34
|
this.options = options || {};
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -50,7 +51,7 @@ class AggressiveMergingPlugin {
|
|
|
50
51
|
},
|
|
51
52
|
(chunks) => {
|
|
52
53
|
const chunkGraph = compilation.chunkGraph;
|
|
53
|
-
/** @type {{a: Chunk, b: Chunk, improvement: number}[]} */
|
|
54
|
+
/** @type {{ a: Chunk, b: Chunk, improvement: number }[]} */
|
|
54
55
|
const combinations = [];
|
|
55
56
|
for (const a of chunks) {
|
|
56
57
|
if (a.canBeInitial()) continue;
|
|
@@ -50,7 +50,7 @@ const moveModuleBetween = (chunkGraph, oldChunk, newChunk) => (module) => {
|
|
|
50
50
|
const isNotAEntryModule = (chunkGraph, chunk) => (module) =>
|
|
51
51
|
!chunkGraph.isEntryModuleInChunk(module, chunk);
|
|
52
52
|
|
|
53
|
-
/** @typedef {{ id?: NonNullable<Chunk["id"]>, hash?: NonNullable<Chunk["hash"]>, modules:
|
|
53
|
+
/** @typedef {{ id?: NonNullable<Chunk["id"]>, hash?: NonNullable<Chunk["hash"]>, modules: string[], size: number }} SplitData */
|
|
54
54
|
|
|
55
55
|
/** @type {WeakSet<Chunk>} */
|
|
56
56
|
const recordedChunks = new WeakSet();
|
|
@@ -64,16 +64,21 @@ class AggressiveSplittingPlugin {
|
|
|
64
64
|
constructor(options = {}) {
|
|
65
65
|
validate(options);
|
|
66
66
|
|
|
67
|
+
/** @type {AggressiveSplittingPluginOptions} */
|
|
67
68
|
this.options = options;
|
|
69
|
+
|
|
68
70
|
if (typeof this.options.minSize !== "number") {
|
|
69
71
|
this.options.minSize = 30 * 1024;
|
|
70
72
|
}
|
|
73
|
+
|
|
71
74
|
if (typeof this.options.maxSize !== "number") {
|
|
72
75
|
this.options.maxSize = 50 * 1024;
|
|
73
76
|
}
|
|
77
|
+
|
|
74
78
|
if (typeof this.options.chunkOverhead !== "number") {
|
|
75
79
|
this.options.chunkOverhead = 0;
|
|
76
80
|
}
|
|
81
|
+
|
|
77
82
|
if (typeof this.options.entryChunkMultiplicator !== "number") {
|
|
78
83
|
this.options.entryChunkMultiplicator = 1;
|
|
79
84
|
}
|
|
@@ -114,7 +119,9 @@ class AggressiveSplittingPlugin {
|
|
|
114
119
|
(chunks) => {
|
|
115
120
|
const chunkGraph = compilation.chunkGraph;
|
|
116
121
|
// Precompute stuff
|
|
122
|
+
/** @type {Map<string, Module>} */
|
|
117
123
|
const nameToModuleMap = new Map();
|
|
124
|
+
/** @type {Map<Module, string>} */
|
|
118
125
|
const moduleToNameMap = new Map();
|
|
119
126
|
const makePathsRelative =
|
|
120
127
|
identifierUtils.makePathsRelative.bindContextCache(
|
|
@@ -128,10 +135,10 @@ class AggressiveSplittingPlugin {
|
|
|
128
135
|
}
|
|
129
136
|
|
|
130
137
|
// Check used chunk ids
|
|
131
|
-
/** @
|
|
138
|
+
/** @type {Set<ChunkId>} */
|
|
132
139
|
const usedIds = new Set();
|
|
133
140
|
for (const chunk of chunks) {
|
|
134
|
-
usedIds.add(chunk.id);
|
|
141
|
+
usedIds.add(/** @type {ChunkId} */ (chunk.id));
|
|
135
142
|
}
|
|
136
143
|
|
|
137
144
|
const recordedSplits =
|
|
@@ -154,8 +161,8 @@ class AggressiveSplittingPlugin {
|
|
|
154
161
|
}
|
|
155
162
|
|
|
156
163
|
// Get module objects from names
|
|
157
|
-
const selectedModules = splitData.modules.map(
|
|
158
|
-
nameToModuleMap.get(name)
|
|
164
|
+
const selectedModules = splitData.modules.map(
|
|
165
|
+
(name) => /** @type {Module} */ (nameToModuleMap.get(name))
|
|
159
166
|
);
|
|
160
167
|
|
|
161
168
|
// Does the modules exist at all?
|
|
@@ -240,6 +247,7 @@ class AggressiveSplittingPlugin {
|
|
|
240
247
|
const modules = chunkGraph
|
|
241
248
|
.getOrderedChunkModules(chunk, compareModulesByIdentifier)
|
|
242
249
|
.filter(isNotAEntryModule(chunkGraph, chunk));
|
|
250
|
+
/** @type {Module[]} */
|
|
243
251
|
const selectedModules = [];
|
|
244
252
|
let selectedModulesSize = 0;
|
|
245
253
|
for (let k = 0; k < modules.length; k++) {
|
|
@@ -255,7 +263,7 @@ class AggressiveSplittingPlugin {
|
|
|
255
263
|
/** @type {SplitData} */
|
|
256
264
|
const splitData = {
|
|
257
265
|
modules: selectedModules
|
|
258
|
-
.map((m) => moduleToNameMap.get(m))
|
|
266
|
+
.map((m) => /** @type {string} */ (moduleToNameMap.get(m)))
|
|
259
267
|
.sort(),
|
|
260
268
|
size: selectedModulesSize
|
|
261
269
|
};
|
|
@@ -271,6 +279,7 @@ class AggressiveSplittingPlugin {
|
|
|
271
279
|
);
|
|
272
280
|
compilation.hooks.recordHash.tap(PLUGIN_NAME, (records) => {
|
|
273
281
|
// 4. save made splittings to records
|
|
282
|
+
/** @type {Set<SplitData>} */
|
|
274
283
|
const allSplits = new Set();
|
|
275
284
|
/** @type {Set<SplitData>} */
|
|
276
285
|
const invalidSplits = new Set();
|
|
@@ -72,6 +72,7 @@ const {
|
|
|
72
72
|
/** @typedef {import("../Module").FileSystemDependencies} FileSystemDependencies */
|
|
73
73
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
74
74
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
|
75
|
+
/** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
|
|
75
76
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
|
76
77
|
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
|
77
78
|
/** @typedef {import("../Module").LibIdent} LibIdent */
|
|
@@ -90,7 +91,8 @@ const {
|
|
|
90
91
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
91
92
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
92
93
|
/** @typedef {import("../util/Hash")} Hash */
|
|
93
|
-
/** @typedef {
|
|
94
|
+
/** @typedef {import("../util/Hash").HashFunction} HashFunction */
|
|
95
|
+
/** @typedef {import("../util/concatenate").UsedNames} UsedNames */
|
|
94
96
|
/** @typedef {import("../util/concatenate").ScopeInfo} ScopeInfo */
|
|
95
97
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
96
98
|
/** @typedef {import("../util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
|
@@ -227,6 +229,7 @@ const compareNumbers = (a, b) => {
|
|
|
227
229
|
}
|
|
228
230
|
return 0;
|
|
229
231
|
};
|
|
232
|
+
|
|
230
233
|
const bySourceOrder = createComparator("sourceOrder", compareNumbers);
|
|
231
234
|
const byRangeStart = createComparator("rangeStart", compareNumbers);
|
|
232
235
|
|
|
@@ -653,7 +656,9 @@ const getFinalName = (
|
|
|
653
656
|
);
|
|
654
657
|
{
|
|
655
658
|
const { ids, comment } = binding;
|
|
659
|
+
/** @type {string} */
|
|
656
660
|
let reference;
|
|
661
|
+
/** @type {boolean} */
|
|
657
662
|
let isPropertyAccess;
|
|
658
663
|
if ("rawName" in binding) {
|
|
659
664
|
reference = `${binding.rawName}${comment || ""}${propertyAccess(ids)}`;
|
|
@@ -705,7 +710,7 @@ class ConcatenatedModule extends Module {
|
|
|
705
710
|
* @param {RuntimeSpec} runtime the runtime
|
|
706
711
|
* @param {Compilation} compilation the compilation
|
|
707
712
|
* @param {AssociatedObjectForCache=} associatedObjectForCache object for caching
|
|
708
|
-
* @param {
|
|
713
|
+
* @param {HashFunction=} hashFunction hash function to use
|
|
709
714
|
* @returns {ConcatenatedModule} the module
|
|
710
715
|
*/
|
|
711
716
|
static create(
|
|
@@ -854,6 +859,7 @@ class ConcatenatedModule extends Module {
|
|
|
854
859
|
const { moduleArgument, exportsArgument } =
|
|
855
860
|
/** @type {BuildInfo} */
|
|
856
861
|
(rootModule.buildInfo);
|
|
862
|
+
/** @type {BuildInfo} */
|
|
857
863
|
this.buildInfo = {
|
|
858
864
|
strict: true,
|
|
859
865
|
cacheable: true,
|
|
@@ -872,8 +878,7 @@ class ConcatenatedModule extends Module {
|
|
|
872
878
|
for (const m of this._modules) {
|
|
873
879
|
// populate cacheable
|
|
874
880
|
if (!(/** @type {BuildInfo} */ (m.buildInfo).cacheable)) {
|
|
875
|
-
|
|
876
|
-
(this.buildInfo).cacheable = false;
|
|
881
|
+
this.buildInfo.cacheable = false;
|
|
877
882
|
}
|
|
878
883
|
|
|
879
884
|
// populate dependencies
|
|
@@ -911,7 +916,7 @@ class ConcatenatedModule extends Module {
|
|
|
911
916
|
const { assets, assetsInfo, topLevelDeclarations, needCreateRequire } =
|
|
912
917
|
/** @type {BuildInfo} */ (m.buildInfo);
|
|
913
918
|
|
|
914
|
-
const buildInfo =
|
|
919
|
+
const buildInfo = this.buildInfo;
|
|
915
920
|
|
|
916
921
|
// populate topLevelDeclarations
|
|
917
922
|
if (topLevelDeclarations) {
|
|
@@ -1209,7 +1214,7 @@ class ConcatenatedModule extends Module {
|
|
|
1209
1214
|
* @param {Module} rootModule the root module of the concatenation
|
|
1210
1215
|
* @param {Set<Module>} modules all modules in the concatenation (including the root module)
|
|
1211
1216
|
* @param {AssociatedObjectForCache=} associatedObjectForCache object for caching
|
|
1212
|
-
* @param {
|
|
1217
|
+
* @param {HashFunction=} hashFunction hash function to use
|
|
1213
1218
|
* @returns {string} the identifier
|
|
1214
1219
|
*/
|
|
1215
1220
|
static _createIdentifier(
|
|
@@ -1222,6 +1227,7 @@ class ConcatenatedModule extends Module {
|
|
|
1222
1227
|
/** @type {string} */ (rootModule.context),
|
|
1223
1228
|
associatedObjectForCache
|
|
1224
1229
|
);
|
|
1230
|
+
/** @type {string[]} */
|
|
1225
1231
|
const identifiers = [];
|
|
1226
1232
|
for (const module of modules) {
|
|
1227
1233
|
identifiers.push(cachedMakePathsRelative(module.identifier()));
|
|
@@ -1316,6 +1322,7 @@ class ConcatenatedModule extends Module {
|
|
|
1316
1322
|
const usedNamesInScopeInfo = new Map();
|
|
1317
1323
|
|
|
1318
1324
|
// Set of already checked scopes
|
|
1325
|
+
/** @type {Set<Scope>} */
|
|
1319
1326
|
const ignoredScopes = new Set();
|
|
1320
1327
|
|
|
1321
1328
|
// get all global names
|
|
@@ -1329,14 +1336,17 @@ class ConcatenatedModule extends Module {
|
|
|
1329
1336
|
// The super class expression in class scopes behaves weird
|
|
1330
1337
|
// We get ranges of all super class expressions to make
|
|
1331
1338
|
// renaming to work correctly
|
|
1339
|
+
/** @typedef {{ range: Range, variables: Variable[] }} ClassInfo */
|
|
1340
|
+
/** @type {WeakMap<Scope, ClassInfo[]>} */
|
|
1332
1341
|
const superClassCache = new WeakMap();
|
|
1333
1342
|
/**
|
|
1334
1343
|
* @param {Scope} scope scope
|
|
1335
|
-
* @returns {
|
|
1344
|
+
* @returns {ClassInfo[]} result
|
|
1336
1345
|
*/
|
|
1337
1346
|
const getSuperClassExpressions = (scope) => {
|
|
1338
1347
|
const cacheEntry = superClassCache.get(scope);
|
|
1339
1348
|
if (cacheEntry !== undefined) return cacheEntry;
|
|
1349
|
+
/** @type {ClassInfo[]} */
|
|
1340
1350
|
const superClassExpressions = [];
|
|
1341
1351
|
for (const childScope of scope.childScopes) {
|
|
1342
1352
|
if (childScope.type !== "class") continue;
|
|
@@ -1462,6 +1472,7 @@ class ConcatenatedModule extends Module {
|
|
|
1462
1472
|
info.module.identifier(),
|
|
1463
1473
|
name
|
|
1464
1474
|
);
|
|
1475
|
+
/** @type {UsedNames} */
|
|
1465
1476
|
const referencesUsedNames = new Set();
|
|
1466
1477
|
for (const ref of references) {
|
|
1467
1478
|
addScopeSymbols(
|
|
@@ -1533,11 +1544,12 @@ class ConcatenatedModule extends Module {
|
|
|
1533
1544
|
topLevelDeclarations.add(name);
|
|
1534
1545
|
}
|
|
1535
1546
|
}
|
|
1547
|
+
/** @type {string} */
|
|
1536
1548
|
let namespaceObjectName;
|
|
1537
1549
|
if (info.namespaceExportSymbol) {
|
|
1538
|
-
namespaceObjectName =
|
|
1539
|
-
|
|
1540
|
-
|
|
1550
|
+
namespaceObjectName =
|
|
1551
|
+
/** @type {string} */
|
|
1552
|
+
(info.internalNames.get(info.namespaceExportSymbol));
|
|
1541
1553
|
} else {
|
|
1542
1554
|
namespaceObjectName = findNewName(
|
|
1543
1555
|
"namespaceObject",
|
|
@@ -1547,13 +1559,8 @@ class ConcatenatedModule extends Module {
|
|
|
1547
1559
|
);
|
|
1548
1560
|
allUsedNames.add(namespaceObjectName);
|
|
1549
1561
|
}
|
|
1550
|
-
info.namespaceObjectName =
|
|
1551
|
-
|
|
1552
|
-
(namespaceObjectName);
|
|
1553
|
-
topLevelDeclarations.add(
|
|
1554
|
-
/** @type {string} */
|
|
1555
|
-
(namespaceObjectName)
|
|
1556
|
-
);
|
|
1562
|
+
info.namespaceObjectName = namespaceObjectName;
|
|
1563
|
+
topLevelDeclarations.add(namespaceObjectName);
|
|
1557
1564
|
break;
|
|
1558
1565
|
}
|
|
1559
1566
|
case "external": {
|
|
@@ -1636,13 +1643,15 @@ class ConcatenatedModule extends Module {
|
|
|
1636
1643
|
if (info.type === "concatenated") {
|
|
1637
1644
|
const globalScope = /** @type {Scope} */ (info.globalScope);
|
|
1638
1645
|
// group references by name
|
|
1646
|
+
/** @type {Map<string, Reference[]>} */
|
|
1639
1647
|
const referencesByName = new Map();
|
|
1640
1648
|
for (const reference of globalScope.through) {
|
|
1641
1649
|
const name = reference.identifier.name;
|
|
1642
1650
|
if (!referencesByName.has(name)) {
|
|
1643
1651
|
referencesByName.set(name, []);
|
|
1644
1652
|
}
|
|
1645
|
-
|
|
1653
|
+
/** @type {Reference[]} */
|
|
1654
|
+
(referencesByName.get(name)).push(reference);
|
|
1646
1655
|
}
|
|
1647
1656
|
for (const [name, references] of referencesByName) {
|
|
1648
1657
|
const match = ConcatenationScope.matchModuleReference(name);
|
|
@@ -1775,6 +1784,7 @@ class ConcatenatedModule extends Module {
|
|
|
1775
1784
|
|
|
1776
1785
|
// define exports
|
|
1777
1786
|
if (exportsMap.size > 0) {
|
|
1787
|
+
/** @type {string[]} */
|
|
1778
1788
|
const definitions = [];
|
|
1779
1789
|
for (const [key, value] of exportsMap) {
|
|
1780
1790
|
definitions.push(
|
|
@@ -1826,9 +1836,11 @@ class ConcatenatedModule extends Module {
|
|
|
1826
1836
|
}
|
|
1827
1837
|
|
|
1828
1838
|
// generate namespace objects
|
|
1839
|
+
/** @type {Map<ConcatenatedModuleInfo, string>} */
|
|
1829
1840
|
const namespaceObjectSources = new Map();
|
|
1830
1841
|
for (const info of neededNamespaceObjects) {
|
|
1831
1842
|
if (info.namespaceExportSymbol) continue;
|
|
1843
|
+
/** @type {string[]} */
|
|
1832
1844
|
const nsObj = [];
|
|
1833
1845
|
const exportsInfo = moduleGraph.getExportsInfo(info.module);
|
|
1834
1846
|
for (const exportInfo of exportsInfo.orderedExports) {
|
|
@@ -1924,6 +1936,7 @@ ${defineGetters}`
|
|
|
1924
1936
|
|
|
1925
1937
|
// evaluate modules in order
|
|
1926
1938
|
for (const rawInfo of modulesWithInfo) {
|
|
1939
|
+
/** @type {undefined | string} */
|
|
1927
1940
|
let name;
|
|
1928
1941
|
let isConditional = false;
|
|
1929
1942
|
const info = rawInfo.type === "reference" ? rawInfo.target : rawInfo;
|
|
@@ -2012,6 +2025,7 @@ ${defineGetters}`
|
|
|
2012
2025
|
}
|
|
2013
2026
|
}
|
|
2014
2027
|
|
|
2028
|
+
/** @type {CodeGenerationResultData} */
|
|
2015
2029
|
const data = new Map();
|
|
2016
2030
|
if (chunkInitFragments.length > 0) {
|
|
2017
2031
|
data.set("chunkInitFragments", chunkInitFragments);
|
|
@@ -2038,7 +2052,7 @@ ${defineGetters}`
|
|
|
2038
2052
|
* @param {RuntimeSpec} runtime runtime
|
|
2039
2053
|
* @param {RuntimeSpec[]} runtimes runtimes
|
|
2040
2054
|
* @param {CodeGenerationResults} codeGenerationResults codeGenerationResults
|
|
2041
|
-
* @param {
|
|
2055
|
+
* @param {UsedNames} usedNames used names
|
|
2042
2056
|
*/
|
|
2043
2057
|
_analyseModule(
|
|
2044
2058
|
modulesMap,
|
|
@@ -42,7 +42,16 @@ class FlagIncludedChunksPlugin {
|
|
|
42
42
|
|
|
43
43
|
// precalculate the modulo values for each bit
|
|
44
44
|
const modulo = 1 / (1 / modulesCount) ** (1 / 31);
|
|
45
|
-
|
|
45
|
+
/** @type {number[]} */
|
|
46
|
+
const modulos = Array.from(
|
|
47
|
+
{ length: 31 },
|
|
48
|
+
/**
|
|
49
|
+
* @param {number} x x
|
|
50
|
+
* @param {number} i i
|
|
51
|
+
* @returns {number} result
|
|
52
|
+
*/
|
|
53
|
+
(x, i) => (modulo ** i) | 0
|
|
54
|
+
);
|
|
46
55
|
|
|
47
56
|
// iterate all modules to generate bit values
|
|
48
57
|
let i = 0;
|
|
@@ -72,6 +81,7 @@ class FlagIncludedChunksPlugin {
|
|
|
72
81
|
(chunkModulesHash.get(chunkA));
|
|
73
82
|
const chunkAModulesCount = chunkGraph.getNumberOfChunkModules(chunkA);
|
|
74
83
|
if (chunkAModulesCount === 0) continue;
|
|
84
|
+
/** @type {undefined | Module} */
|
|
75
85
|
let bestModule;
|
|
76
86
|
for (const module of chunkGraph.getChunkModulesIterable(chunkA)) {
|
|
77
87
|
if (
|
|
@@ -35,6 +35,7 @@ class TopLevelSymbol {
|
|
|
35
35
|
* @param {string} name name of the variable
|
|
36
36
|
*/
|
|
37
37
|
constructor(name) {
|
|
38
|
+
/** @type {string} */
|
|
38
39
|
this.name = name;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -310,6 +311,7 @@ module.exports.onUsage = (state, onUsageCallback) => {
|
|
|
310
311
|
let callbacks = usageCallbackMap.get(currentTopLevelSymbol);
|
|
311
312
|
|
|
312
313
|
if (callbacks === undefined) {
|
|
314
|
+
/** @type {Set<UsageCallback>} */
|
|
313
315
|
callbacks = new Set();
|
|
314
316
|
usageCallbackMap.set(currentTopLevelSymbol, callbacks);
|
|
315
317
|
}
|
|
@@ -353,14 +355,14 @@ module.exports.tagTopLevelSymbol = (parser, name) => {
|
|
|
353
355
|
return existingTag;
|
|
354
356
|
}
|
|
355
357
|
|
|
356
|
-
const
|
|
358
|
+
const symbol = new TopLevelSymbol(name);
|
|
357
359
|
parser.tagVariable(
|
|
358
360
|
name,
|
|
359
361
|
topLevelSymbolTag,
|
|
360
|
-
|
|
362
|
+
symbol,
|
|
361
363
|
JavascriptParser.VariableInfoFlags.Normal
|
|
362
364
|
);
|
|
363
|
-
return
|
|
365
|
+
return symbol;
|
|
364
366
|
};
|
|
365
367
|
|
|
366
368
|
module.exports.topLevelSymbolTag = topLevelSymbolTag;
|