webpack 5.106.2 → 5.107.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/APIPlugin.js +1 -1
- package/lib/Cache.js +3 -6
- package/lib/CompatibilityPlugin.js +8 -7
- package/lib/Compilation.js +34 -26
- package/lib/Compiler.js +4 -13
- package/lib/ContextModule.js +2 -2
- package/lib/DefinePlugin.js +2 -2
- package/lib/Dependency.js +22 -1
- package/lib/DependencyTemplate.js +2 -1
- package/lib/EnvironmentPlugin.js +1 -1
- package/lib/EvalSourceMapDevToolPlugin.js +8 -9
- package/lib/ExternalModule.js +76 -15
- package/lib/ExternalModuleFactoryPlugin.js +5 -0
- package/lib/FileSystemInfo.js +187 -72
- package/lib/Generator.js +3 -3
- package/lib/HotModuleReplacementPlugin.js +26 -8
- package/lib/IgnorePlugin.js +2 -1
- package/lib/Module.js +19 -18
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleSourceTypeConstants.js +31 -1
- package/lib/ModuleTypeConstants.js +12 -3
- package/lib/MultiCompiler.js +2 -2
- package/lib/NodeStuffPlugin.js +1 -1
- package/lib/NormalModule.js +13 -31
- package/lib/NormalModuleFactory.js +10 -2
- package/lib/Parser.js +1 -1
- package/lib/ProgressPlugin.js +129 -56
- package/lib/RuntimeGlobals.js +5 -5
- package/lib/RuntimeModule.js +9 -7
- package/lib/RuntimePlugin.js +11 -0
- package/lib/WarnCaseSensitiveModulesPlugin.js +70 -2
- package/lib/WarnDeprecatedOptionPlugin.js +1 -1
- package/lib/WarnNoModeSetPlugin.js +16 -1
- package/lib/Watching.js +2 -3
- package/lib/WebpackError.js +3 -77
- package/lib/WebpackIsIncludedPlugin.js +1 -1
- package/lib/WebpackOptionsApply.js +13 -1
- package/lib/asset/AssetBytesGenerator.js +6 -2
- package/lib/asset/AssetGenerator.js +22 -8
- package/lib/asset/AssetModulesPlugin.js +3 -1
- package/lib/asset/AssetSourceGenerator.js +6 -2
- package/lib/buildChunkGraph.js +4 -6
- package/lib/cache/PackFileCacheStrategy.js +4 -4
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +197 -10
- package/lib/config/normalization.js +3 -1
- package/lib/css/CssGenerator.js +320 -105
- package/lib/css/CssInjectStyleRuntimeModule.js +44 -42
- package/lib/css/CssLoadingRuntimeModule.js +22 -4
- package/lib/{CssModule.js → css/CssModule.js} +15 -15
- package/lib/css/CssModulesPlugin.js +166 -86
- package/lib/css/CssParser.js +566 -269
- package/lib/css/walkCssTokens.js +148 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +63 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +54 -10
- package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsFullRequireDependency.js +32 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +4 -3
- package/lib/dependencies/CommonJsRequireDependency.js +67 -4
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +1 -1
- package/lib/dependencies/CreateRequireParserPlugin.js +1 -1
- package/lib/dependencies/CriticalDependencyWarning.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +332 -67
- package/lib/dependencies/CssIcssImportDependency.js +49 -7
- package/lib/dependencies/CssIcssSymbolDependency.js +11 -3
- package/lib/dependencies/CssImportDependency.js +8 -0
- package/lib/dependencies/CssUrlDependency.js +25 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +1 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +8 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +22 -14
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +110 -3
- package/lib/dependencies/HarmonyImportDependency.js +10 -2
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +22 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +1 -1
- package/lib/{HarmonyLinkingError.js → dependencies/HarmonyLinkingError.js} +5 -3
- package/lib/dependencies/HtmlInlineScriptDependency.js +133 -0
- package/lib/dependencies/HtmlInlineStyleDependency.js +101 -0
- package/lib/dependencies/HtmlScriptSrcDependency.js +318 -0
- package/lib/dependencies/HtmlSourceDependency.js +127 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportParserPlugin.js +2 -2
- package/lib/dependencies/ImportPhase.js +1 -1
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +1 -1
- package/lib/{RequireJsStuffPlugin.js → dependencies/RequireJsStuffPlugin.js} +7 -7
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/WebAssemblyImportDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/{DelegatedModule.js → dll/DelegatedModule.js} +31 -31
- package/lib/{DelegatedModuleFactoryPlugin.js → dll/DelegatedModuleFactoryPlugin.js} +4 -4
- package/lib/{DelegatedPlugin.js → dll/DelegatedPlugin.js} +2 -2
- package/lib/{DllEntryPlugin.js → dll/DllEntryPlugin.js} +4 -4
- package/lib/{DllModule.js → dll/DllModule.js} +24 -24
- package/lib/{DllModuleFactory.js → dll/DllModuleFactory.js} +4 -4
- package/lib/{DllPlugin.js → dll/DllPlugin.js} +6 -5
- package/lib/{DllReferencePlugin.js → dll/DllReferencePlugin.js} +14 -14
- package/lib/{LibManifestPlugin.js → dll/LibManifestPlugin.js} +9 -9
- package/lib/{AsyncDependencyToInitialChunkError.js → errors/AsyncDependencyToInitialChunkError.js} +2 -2
- package/lib/errors/BuildCycleError.js +1 -1
- package/lib/{ChunkRenderError.js → errors/ChunkRenderError.js} +1 -1
- package/lib/{CodeGenerationError.js → errors/CodeGenerationError.js} +1 -1
- package/lib/{CommentCompilationWarning.js → errors/CommentCompilationWarning.js} +3 -3
- package/lib/{ConcurrentCompilationError.js → errors/ConcurrentCompilationError.js} +4 -2
- package/lib/{EnvironmentNotSupportAsyncWarning.js → errors/EnvironmentNotSupportAsyncWarning.js} +4 -4
- package/lib/{HookWebpackError.js → errors/HookWebpackError.js} +5 -5
- package/lib/{IgnoreErrorModuleFactory.js → errors/IgnoreErrorModuleFactory.js} +4 -4
- package/lib/{InvalidDependenciesModuleWarning.js → errors/InvalidDependenciesModuleWarning.js} +3 -3
- package/lib/errors/JSONParseError.js +114 -0
- package/lib/{ModuleBuildError.js → errors/ModuleBuildError.js} +5 -5
- package/lib/{ModuleDependencyError.js → errors/ModuleDependencyError.js} +2 -2
- package/lib/{ModuleDependencyWarning.js → errors/ModuleDependencyWarning.js} +4 -4
- package/lib/{ModuleError.js → errors/ModuleError.js} +5 -5
- package/lib/{ModuleHashingError.js → errors/ModuleHashingError.js} +1 -1
- package/lib/{ModuleNotFoundError.js → errors/ModuleNotFoundError.js} +2 -2
- package/lib/{ModuleParseError.js → errors/ModuleParseError.js} +8 -6
- package/lib/{ModuleRestoreError.js → errors/ModuleRestoreError.js} +1 -1
- package/lib/{ModuleStoreError.js → errors/ModuleStoreError.js} +1 -1
- package/lib/{ModuleWarning.js → errors/ModuleWarning.js} +5 -5
- package/lib/{NodeStuffInWebError.js → errors/NodeStuffInWebError.js} +4 -4
- package/lib/errors/NonErrorEmittedError.js +28 -0
- package/lib/{UnhandledSchemeError.js → errors/UnhandledSchemeError.js} +2 -2
- package/lib/{UnsupportedFeatureWarning.js → errors/UnsupportedFeatureWarning.js} +3 -3
- package/lib/errors/WebpackError.js +84 -0
- package/lib/html/HtmlGenerator.js +379 -0
- package/lib/html/HtmlModulesPlugin.js +433 -0
- package/lib/html/HtmlParser.js +1489 -0
- package/lib/html/walkHtmlTokens.js +2733 -0
- package/lib/ids/IdHelpers.js +2 -1
- package/lib/index.js +34 -15
- package/lib/javascript/JavascriptModulesPlugin.js +89 -8
- package/lib/javascript/JavascriptParser.js +197 -16
- package/lib/javascript/JavascriptParserHelpers.js +1 -1
- package/lib/json/JsonParser.js +7 -16
- package/lib/library/AbstractLibraryPlugin.js +1 -1
- package/lib/library/EnableLibraryPlugin.js +1 -1
- package/lib/{FalseIIFEUmdWarning.js → library/FalseIIFEUmdWarning.js} +1 -1
- package/lib/library/ModuleLibraryPlugin.js +74 -0
- package/lib/node/NodeEnvironmentPlugin.js +4 -2
- package/lib/node/nodeConsole.js +113 -64
- package/lib/optimize/ConcatenatedModule.js +51 -6
- package/lib/optimize/InnerGraph.js +1 -1
- package/lib/optimize/InnerGraphPlugin.js +11 -1
- package/lib/optimize/MinMaxSizeWarning.js +4 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +15 -7
- package/lib/optimize/RealContentHashPlugin.js +89 -26
- package/lib/optimize/SideEffectsFlagPlugin.js +111 -3
- package/lib/optimize/SplitChunksPlugin.js +1 -1
- package/lib/performance/AssetsOverSizeLimitWarning.js +2 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
- package/lib/performance/NoAsyncChunksWarning.js +5 -3
- package/lib/performance/SizeLimitsPlugin.js +1 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -1
- package/lib/rules/UseEffectRulePlugin.js +4 -3
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +119 -13
- package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +35 -0
- package/lib/schemes/DataUriPlugin.js +13 -1
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/sharing/ConsumeSharedPlugin.js +2 -2
- package/lib/sharing/ConsumeSharedRuntimeModule.js +8 -4
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +1 -1
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +2 -2
- package/lib/stats/DefaultStatsPresetPlugin.js +1 -1
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/stats/StatsFactory.js +1 -1
- package/lib/typescript/TypeScriptPlugin.js +210 -0
- package/lib/url/URLParserPlugin.js +2 -2
- package/lib/util/AsyncQueue.js +2 -2
- package/lib/util/Hash.js +2 -2
- package/lib/util/LocConverter.js +53 -0
- package/lib/util/SortableSet.js +1 -1
- package/lib/util/cleverMerge.js +2 -2
- package/lib/util/comparators.js +3 -3
- package/lib/util/concatenate.js +3 -3
- package/lib/util/conventions.js +42 -1
- package/lib/util/createMappings.js +118 -0
- package/lib/{formatLocation.js → util/formatLocation.js} +2 -2
- package/lib/{SizeFormatHelpers.js → util/formatSize.js} +3 -1
- package/lib/util/fs.js +8 -8
- package/lib/util/hash/md4.js +1 -1
- package/lib/util/hash/xxhash64.js +1 -1
- package/lib/util/identifier.js +48 -0
- package/lib/util/internalSerializables.js +35 -19
- package/lib/util/magicComment.js +10 -7
- package/lib/util/parseJson.js +2 -73
- package/lib/util/source.js +21 -0
- package/lib/util/topologicalSort.js +69 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -2
- package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +1 -1
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +5 -3
- package/lib/webpack.js +3 -1
- package/package.json +22 -20
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +118 -3
- package/schemas/plugins/{DllPlugin.check.d.ts → HtmlGeneratorOptions.check.d.ts} +1 -1
- package/schemas/plugins/HtmlGeneratorOptions.check.js +6 -0
- package/schemas/plugins/HtmlGeneratorOptions.json +3 -0
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +22 -0
- package/schemas/plugins/{DllReferencePlugin.check.d.ts → css/CssAutoOrModuleParserOptions.check.d.ts} +1 -1
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.json +3 -0
- package/schemas/plugins/dll/DllPlugin.check.d.ts +7 -0
- package/schemas/plugins/dll/DllReferencePlugin.check.d.ts +7 -0
- package/types.d.ts +810 -101
- package/lib/CaseSensitiveModulesWarning.js +0 -80
- package/lib/GraphHelpers.js +0 -49
- package/lib/NoModeWarning.js +0 -23
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +0 -57
- /package/lib/{AbstractMethodError.js → errors/AbstractMethodError.js} +0 -0
- /package/schemas/plugins/{DllPlugin.check.js → dll/DllPlugin.check.js} +0 -0
- /package/schemas/plugins/{DllPlugin.json → dll/DllPlugin.json} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.check.js → dll/DllReferencePlugin.check.js} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.json → dll/DllReferencePlugin.json} +0 -0
|
@@ -11,6 +11,7 @@ const ExternalModule = require("../ExternalModule");
|
|
|
11
11
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
12
12
|
const Template = require("../Template");
|
|
13
13
|
const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency");
|
|
14
|
+
const JavascriptModulesPlugin = require("../javascript/JavascriptModulesPlugin");
|
|
14
15
|
const ConcatenatedModule = require("../optimize/ConcatenatedModule");
|
|
15
16
|
const { propertyAccess } = require("../util/property");
|
|
16
17
|
const { getEntryRuntime, getRuntimeKey } = require("../util/runtime");
|
|
@@ -80,6 +81,8 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
80
81
|
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
81
82
|
const { onDemandExportsGeneration } =
|
|
82
83
|
ConcatenatedModule.getCompilationHooks(compilation);
|
|
84
|
+
const javascriptHooks =
|
|
85
|
+
JavascriptModulesPlugin.getCompilationHooks(compilation);
|
|
83
86
|
onDemandExportsGeneration.tap(
|
|
84
87
|
PLUGIN_NAME,
|
|
85
88
|
(module, runtimes, source, finalName) => {
|
|
@@ -105,6 +108,77 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
105
108
|
return true;
|
|
106
109
|
}
|
|
107
110
|
);
|
|
111
|
+
|
|
112
|
+
// `ModuleLibraryPlugin` stashes the on-demand exports source via
|
|
113
|
+
// `onDemandExportsGeneration` and only re-emits it when the
|
|
114
|
+
// module is wrapped in an IIFE/factory. When a single concatenated
|
|
115
|
+
// entry is inlined directly, the stashed source — and the
|
|
116
|
+
// `definePropertyGetters` / `requireScope` runtime helpers it
|
|
117
|
+
// pulled in — never make it into the output. Drop those helpers
|
|
118
|
+
// from the chunk's set in that simple shape so the bundle stays
|
|
119
|
+
// clean.
|
|
120
|
+
compilation.hooks.additionalChunkRuntimeRequirements.tap(
|
|
121
|
+
PLUGIN_NAME,
|
|
122
|
+
(chunk, set, { chunkGraph, codeGenerationResults }) => {
|
|
123
|
+
if (!set.has(RuntimeGlobals.definePropertyGetters)) return;
|
|
124
|
+
|
|
125
|
+
// Only handle the simple "single concatenated entry"
|
|
126
|
+
// shape. Anything else (additional modules, multiple
|
|
127
|
+
// entries, sibling runtime chunks, or chunk-level
|
|
128
|
+
// requirements that disable inline startup) forces the
|
|
129
|
+
// module through factory/IIFE rendering, which re-emits
|
|
130
|
+
// the source.
|
|
131
|
+
if (chunkGraph.getNumberOfChunkModules(chunk) !== 1) return;
|
|
132
|
+
if (chunkGraph.getNumberOfEntryModules(chunk) !== 1) return;
|
|
133
|
+
if (chunkGraph.hasChunkEntryDependentChunks(chunk)) return;
|
|
134
|
+
if (
|
|
135
|
+
set.has(RuntimeGlobals.moduleFactories) ||
|
|
136
|
+
set.has(RuntimeGlobals.moduleCache) ||
|
|
137
|
+
set.has(RuntimeGlobals.interceptModuleExecution) ||
|
|
138
|
+
set.has(RuntimeGlobals.module) ||
|
|
139
|
+
set.has(RuntimeGlobals.thisAsExports)
|
|
140
|
+
) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
// Anyone tapping `inlineInRuntimeBailout` may force factory
|
|
144
|
+
// rendering at render time, so conservatively bail out.
|
|
145
|
+
if (javascriptHooks.inlineInRuntimeBailout.isUsed()) return;
|
|
146
|
+
|
|
147
|
+
const [module] = chunkGraph.getChunkEntryModulesIterable(chunk);
|
|
148
|
+
const exportsSourceByRuntime =
|
|
149
|
+
module.buildMeta && module.buildMeta.exportsSourceByRuntime;
|
|
150
|
+
if (
|
|
151
|
+
!exportsSourceByRuntime ||
|
|
152
|
+
!exportsSourceByRuntime.has(getRuntimeKey(chunk.runtime))
|
|
153
|
+
) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
// If the generated source references any
|
|
157
|
+
// `__webpack_require__.<helper>` (the on-demand `.d(...)`
|
|
158
|
+
// is stashed, but `.r(__webpack_exports__)` from the ESM
|
|
159
|
+
// compat flag, namespace objects, deferred externals, ...
|
|
160
|
+
// stay in the result) the helpers and the require scope
|
|
161
|
+
// they live in are still needed. The dot in the substring
|
|
162
|
+
// avoids matching the bare `"__webpack_require__"` string
|
|
163
|
+
// literals that some test fixtures include.
|
|
164
|
+
const codeGenResult = codeGenerationResults.get(
|
|
165
|
+
module,
|
|
166
|
+
chunk.runtime
|
|
167
|
+
);
|
|
168
|
+
const jsSource =
|
|
169
|
+
codeGenResult && codeGenResult.sources.get("javascript");
|
|
170
|
+
if (
|
|
171
|
+
jsSource &&
|
|
172
|
+
String(jsSource.source()).includes(`${RuntimeGlobals.require}.`)
|
|
173
|
+
) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
set.delete(RuntimeGlobals.definePropertyGetters);
|
|
178
|
+
set.delete(RuntimeGlobals.exports);
|
|
179
|
+
set.delete(RuntimeGlobals.requireScope);
|
|
180
|
+
}
|
|
181
|
+
);
|
|
108
182
|
});
|
|
109
183
|
}
|
|
110
184
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const CachedInputFileSystem = require("enhanced-resolve")
|
|
8
|
+
const { CachedInputFileSystem } = require("enhanced-resolve");
|
|
9
9
|
const fs = require("graceful-fs");
|
|
10
10
|
const createConsoleLogger = require("../logging/createConsoleLogger");
|
|
11
11
|
const NodeWatchFileSystem = require("./NodeWatchFileSystem");
|
|
@@ -50,9 +50,11 @@ class NodeEnvironmentPlugin {
|
|
|
50
50
|
appendOnly: infrastructureLogging.appendOnly,
|
|
51
51
|
stream:
|
|
52
52
|
/** @type {NodeJS.WritableStream} */
|
|
53
|
-
(infrastructureLogging.stream)
|
|
53
|
+
(infrastructureLogging.stream),
|
|
54
|
+
compiler
|
|
54
55
|
})
|
|
55
56
|
});
|
|
57
|
+
// @ts-expect-error need to fix on enhanced-resolve side
|
|
56
58
|
compiler.inputFileSystem = new CachedInputFileSystem(fs, 60000);
|
|
57
59
|
const inputFileSystem =
|
|
58
60
|
/** @type {InputFileSystem} */
|
package/lib/node/nodeConsole.js
CHANGED
|
@@ -7,9 +7,45 @@
|
|
|
7
7
|
|
|
8
8
|
const util = require("util");
|
|
9
9
|
const truncateArgs = require("../logging/truncateArgs");
|
|
10
|
+
const memoize = require("../util/memoize");
|
|
10
11
|
|
|
12
|
+
const getCli = memoize(() => require("../cli"));
|
|
13
|
+
|
|
14
|
+
const ESC = "\u001B[";
|
|
15
|
+
const CURSOR_UP = `${ESC}1A`;
|
|
16
|
+
const CLEAR_LINE = `${ESC}2K\r`;
|
|
17
|
+
|
|
18
|
+
/** @typedef {import("../Compiler")} Compiler */
|
|
11
19
|
/** @typedef {import("../config/defaults").InfrastructureLoggingNormalizedWithDefaults} InfrastructureLoggingNormalizedWithDefaults */
|
|
12
20
|
/** @typedef {import("../logging/createConsoleLogger").LoggerConsole} LoggerConsole */
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {object} StatusMessageState
|
|
23
|
+
* @property {string[] | undefined} currentMessage current status message
|
|
24
|
+
* @property {number} currentLines current status message rows
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** @type {WeakMap<Compiler, StatusMessageState>} */
|
|
28
|
+
const logStatusStateByCompiler = new WeakMap();
|
|
29
|
+
/** @type {Set<StatusMessageState>} */
|
|
30
|
+
const logStatusStates = new Set();
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns status state
|
|
34
|
+
* @param {Compiler} compiler compiler
|
|
35
|
+
* @returns {StatusMessageState} status state
|
|
36
|
+
*/
|
|
37
|
+
const getLogStatusState = (compiler) => {
|
|
38
|
+
let state = logStatusStateByCompiler.get(compiler);
|
|
39
|
+
if (state === undefined) {
|
|
40
|
+
state = {
|
|
41
|
+
currentMessage: undefined,
|
|
42
|
+
currentLines: 0
|
|
43
|
+
};
|
|
44
|
+
logStatusStateByCompiler.set(compiler, state);
|
|
45
|
+
logStatusStates.add(state);
|
|
46
|
+
}
|
|
47
|
+
return state;
|
|
48
|
+
};
|
|
13
49
|
|
|
14
50
|
/* eslint-disable no-console */
|
|
15
51
|
|
|
@@ -19,12 +55,13 @@ const truncateArgs = require("../logging/truncateArgs");
|
|
|
19
55
|
* @param {boolean=} options.colors colors
|
|
20
56
|
* @param {boolean=} options.appendOnly append only
|
|
21
57
|
* @param {InfrastructureLoggingNormalizedWithDefaults["stream"]} options.stream stream
|
|
58
|
+
* @param {Compiler} options.compiler compiler
|
|
22
59
|
* @returns {LoggerConsole} logger function
|
|
23
60
|
*/
|
|
24
|
-
module.exports = ({ colors, appendOnly, stream }) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
61
|
+
module.exports = ({ colors, appendOnly, stream, compiler }) => {
|
|
62
|
+
const c = getCli().createColors({ useColor: Boolean(colors) });
|
|
63
|
+
const logStatusState = getLogStatusState(compiler);
|
|
64
|
+
|
|
28
65
|
let currentIndent = "";
|
|
29
66
|
let currentCollapsed = 0;
|
|
30
67
|
|
|
@@ -32,98 +69,113 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
32
69
|
* Returns indented string.
|
|
33
70
|
* @param {string} str string
|
|
34
71
|
* @param {string} prefix prefix
|
|
35
|
-
* @param {string}
|
|
36
|
-
* @param {string} colorSuffix color suffix
|
|
72
|
+
* @param {(line: string) => string} colorFn color function
|
|
37
73
|
* @returns {string} indented string
|
|
38
74
|
*/
|
|
39
|
-
const indent = (str, prefix,
|
|
75
|
+
const indent = (str, prefix, colorFn) => {
|
|
40
76
|
if (str === "") return str;
|
|
41
77
|
prefix = currentIndent + prefix;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return prefix + str.replace(/\n/g, `\n${prefix}`);
|
|
78
|
+
return (
|
|
79
|
+
prefix +
|
|
80
|
+
str
|
|
81
|
+
.split("\n")
|
|
82
|
+
.map((line) => colorFn(line))
|
|
83
|
+
.join(`\n${prefix}`)
|
|
84
|
+
);
|
|
52
85
|
};
|
|
53
86
|
|
|
54
87
|
const clearStatusMessage = () => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
88
|
+
let lines = 0;
|
|
89
|
+
for (const state of logStatusStates) {
|
|
90
|
+
if (state.currentLines) {
|
|
91
|
+
lines += state.currentLines;
|
|
92
|
+
state.currentLines = 0;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
for (let i = 0; i < lines; i++) {
|
|
96
|
+
if (i > 0) stream.write(CURSOR_UP);
|
|
97
|
+
stream.write(CLEAR_LINE);
|
|
58
98
|
}
|
|
59
99
|
};
|
|
60
100
|
|
|
61
101
|
const writeStatusMessage = () => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
102
|
+
const column = stream.columns || 40;
|
|
103
|
+
/** @type {string[]} */
|
|
104
|
+
const all = [];
|
|
105
|
+
|
|
106
|
+
for (const state of logStatusStates) {
|
|
107
|
+
if (!state.currentMessage) continue;
|
|
108
|
+
/** @type {string[][]} */
|
|
109
|
+
const lines = [[]];
|
|
110
|
+
for (const item of state.currentMessage) {
|
|
111
|
+
const parts = item.split("\n");
|
|
112
|
+
lines[lines.length - 1].push(parts[0]);
|
|
113
|
+
for (let i = 1; i < parts.length; i++) {
|
|
114
|
+
lines.push([parts[i]]);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const truncateLines = lines.map((args) =>
|
|
118
|
+
truncateArgs(args, column - 1).join(" ")
|
|
119
|
+
);
|
|
120
|
+
state.currentLines = truncateLines.length;
|
|
121
|
+
for (const line of truncateLines) all.push(line);
|
|
122
|
+
}
|
|
123
|
+
if (all.length === 0) return;
|
|
124
|
+
|
|
125
|
+
const coloredLines = all.map((str) => c.bold(str));
|
|
126
|
+
stream.write(`${CLEAR_LINE}${coloredLines.join(`\n${CLEAR_LINE}`)}`);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @param {EXPECTED_ANY[]} statusMessage status message
|
|
131
|
+
* @returns {void}
|
|
132
|
+
*/
|
|
133
|
+
const setStatusMessage = (statusMessage) => {
|
|
134
|
+
clearStatusMessage();
|
|
135
|
+
logStatusState.currentMessage = statusMessage.map((item) => `${item}`);
|
|
136
|
+
writeStatusMessage();
|
|
69
137
|
};
|
|
70
138
|
|
|
71
139
|
/**
|
|
72
140
|
* Returns function to write with colors.
|
|
73
141
|
* @template T
|
|
74
142
|
* @param {string} prefix prefix
|
|
75
|
-
* @param {string}
|
|
76
|
-
* @param {string} colorSuffix color suffix
|
|
143
|
+
* @param {(line: string) => string} colorFn color function
|
|
77
144
|
* @returns {(...args: T[]) => void} function to write with colors
|
|
78
145
|
*/
|
|
79
146
|
const writeColored =
|
|
80
|
-
(prefix,
|
|
147
|
+
(prefix, colorFn) =>
|
|
81
148
|
(...args) => {
|
|
82
149
|
if (currentCollapsed > 0) return;
|
|
83
150
|
clearStatusMessage();
|
|
84
|
-
const str = indent(
|
|
85
|
-
util.format(...args),
|
|
86
|
-
prefix,
|
|
87
|
-
colorPrefix,
|
|
88
|
-
colorSuffix
|
|
89
|
-
);
|
|
151
|
+
const str = indent(util.format(...args), prefix, colorFn);
|
|
90
152
|
stream.write(`${str}\n`);
|
|
91
153
|
writeStatusMessage();
|
|
92
154
|
};
|
|
93
155
|
|
|
94
156
|
/** @type {<T extends unknown[]>(...args: T) => void} */
|
|
95
|
-
const writeGroupMessage = writeColored(
|
|
96
|
-
"<-> ",
|
|
97
|
-
"\u001B[1m\u001B[36m",
|
|
98
|
-
"\u001B[39m\u001B[22m"
|
|
99
|
-
);
|
|
157
|
+
const writeGroupMessage = writeColored("<-> ", (str) => c.bold(c.cyan(str)));
|
|
100
158
|
|
|
101
159
|
/** @type {<T extends unknown[]>(...args: T) => void} */
|
|
102
|
-
const writeGroupCollapsedMessage = writeColored(
|
|
103
|
-
|
|
104
|
-
"\u001B[1m\u001B[36m",
|
|
105
|
-
"\u001B[39m\u001B[22m"
|
|
160
|
+
const writeGroupCollapsedMessage = writeColored("<+> ", (str) =>
|
|
161
|
+
c.bold(c.cyan(str))
|
|
106
162
|
);
|
|
107
163
|
|
|
108
164
|
return {
|
|
109
165
|
/** @type {LoggerConsole["log"]} */
|
|
110
|
-
log: writeColored(" ",
|
|
166
|
+
log: writeColored(" ", c.bold),
|
|
111
167
|
/** @type {LoggerConsole["debug"]} */
|
|
112
|
-
debug: writeColored(" ",
|
|
168
|
+
debug: writeColored(" ", String),
|
|
113
169
|
/** @type {LoggerConsole["trace"]} */
|
|
114
|
-
trace: writeColored(" ",
|
|
170
|
+
trace: writeColored(" ", String),
|
|
115
171
|
/** @type {LoggerConsole["info"]} */
|
|
116
|
-
info: writeColored("<i> ",
|
|
172
|
+
info: writeColored("<i> ", (str) => c.bold(c.green(str))),
|
|
117
173
|
/** @type {LoggerConsole["warn"]} */
|
|
118
|
-
warn: writeColored("<w> ",
|
|
174
|
+
warn: writeColored("<w> ", (str) => c.bold(c.yellow(str))),
|
|
119
175
|
/** @type {LoggerConsole["error"]} */
|
|
120
|
-
error: writeColored("<e> ",
|
|
176
|
+
error: writeColored("<e> ", (str) => c.bold(c.red(str))),
|
|
121
177
|
/** @type {LoggerConsole["logTime"]} */
|
|
122
|
-
logTime: writeColored(
|
|
123
|
-
"<t> ",
|
|
124
|
-
"\u001B[1m\u001B[35m",
|
|
125
|
-
"\u001B[39m\u001B[22m"
|
|
126
|
-
),
|
|
178
|
+
logTime: writeColored("<t> ", (str) => c.bold(c.magenta(str))),
|
|
127
179
|
/** @type {LoggerConsole["group"]} */
|
|
128
180
|
group: (...args) => {
|
|
129
181
|
writeGroupMessage(...args);
|
|
@@ -164,24 +216,21 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
164
216
|
),
|
|
165
217
|
/** @type {LoggerConsole["status"]} */
|
|
166
218
|
status: appendOnly
|
|
167
|
-
? writeColored("<s> ",
|
|
219
|
+
? writeColored("<s> ", String)
|
|
168
220
|
: (name, ...args) => {
|
|
169
221
|
args = args.filter(Boolean);
|
|
170
222
|
if (name === undefined && args.length === 0) {
|
|
171
223
|
clearStatusMessage();
|
|
172
|
-
|
|
224
|
+
logStatusState.currentMessage = undefined;
|
|
173
225
|
} else if (
|
|
174
226
|
typeof name === "string" &&
|
|
175
227
|
name.startsWith("[webpack.Progress] ")
|
|
176
228
|
) {
|
|
177
|
-
|
|
178
|
-
writeStatusMessage();
|
|
229
|
+
setStatusMessage([name.slice(19), ...args]);
|
|
179
230
|
} else if (name === "[webpack.Progress]") {
|
|
180
|
-
|
|
181
|
-
writeStatusMessage();
|
|
231
|
+
setStatusMessage([...args]);
|
|
182
232
|
} else {
|
|
183
|
-
|
|
184
|
-
writeStatusMessage();
|
|
233
|
+
setStatusMessage([name, ...args]);
|
|
185
234
|
}
|
|
186
235
|
}
|
|
187
236
|
};
|
|
@@ -14,6 +14,7 @@ const {
|
|
|
14
14
|
ReplaceSource
|
|
15
15
|
} = require("webpack-sources");
|
|
16
16
|
const ConcatenationScope = require("../ConcatenationScope");
|
|
17
|
+
const Dependency = require("../Dependency");
|
|
17
18
|
const { UsageState } = require("../ExportsInfo");
|
|
18
19
|
const Module = require("../Module");
|
|
19
20
|
const {
|
|
@@ -24,7 +25,6 @@ const { JAVASCRIPT_MODULE_TYPE_ESM } = require("../ModuleTypeConstants");
|
|
|
24
25
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
25
26
|
const Template = require("../Template");
|
|
26
27
|
const { DEFAULTS } = require("../config/defaults");
|
|
27
|
-
const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
|
|
28
28
|
const { ImportPhaseUtils } = require("../dependencies/ImportPhase");
|
|
29
29
|
const JavascriptParser = require("../javascript/JavascriptParser");
|
|
30
30
|
const {
|
|
@@ -55,15 +55,14 @@ const {
|
|
|
55
55
|
subtractRuntimeCondition
|
|
56
56
|
} = require("../util/runtime");
|
|
57
57
|
|
|
58
|
-
/** @typedef {import("eslint-scope").Reference} Reference */
|
|
59
|
-
/** @typedef {import("eslint-scope").Scope} Scope */
|
|
60
|
-
/** @typedef {import("eslint-scope").Variable} Variable */
|
|
61
58
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
62
59
|
/** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
63
60
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
64
61
|
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
|
65
62
|
/** @typedef {import("../Compilation")} Compilation */
|
|
66
63
|
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
|
64
|
+
/** @typedef {import("../dependencies/ModuleDependency")} ModuleDependency */
|
|
65
|
+
/** @typedef {import("../dependencies/HarmonyImportDependency")} HarmonyImportDependency */
|
|
67
66
|
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
|
68
67
|
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
|
|
69
68
|
/** @typedef {import("../Module").BuildCallback} BuildCallback */
|
|
@@ -86,6 +85,9 @@ const {
|
|
|
86
85
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
87
86
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
88
87
|
/** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
|
|
88
|
+
/** @typedef {import("../javascript/JavascriptModulesPlugin").Scope} Scope */
|
|
89
|
+
/** @typedef {import("../javascript/JavascriptModulesPlugin").Reference} Reference */
|
|
90
|
+
/** @typedef {import("../javascript/JavascriptModulesPlugin").Variable} Variable */
|
|
89
91
|
/** @typedef {import("../javascript/JavascriptParser").Program} Program */
|
|
90
92
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
91
93
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
@@ -362,6 +364,20 @@ const getFinalBinding = (
|
|
|
362
364
|
switch (exportName[0]) {
|
|
363
365
|
case "default":
|
|
364
366
|
exportName = exportName.slice(1);
|
|
367
|
+
if (deferred) {
|
|
368
|
+
// `ns.default` for a deferred default-with-named external
|
|
369
|
+
// module must read through the optimized `.a` getter
|
|
370
|
+
// (which lazily evaluates the module and returns its
|
|
371
|
+
// exports), not the proxy namespace itself — otherwise
|
|
372
|
+
// `typeof ns.default` / `ns.default instanceof X`
|
|
373
|
+
// observe the proxy instead of the actual default.
|
|
374
|
+
return {
|
|
375
|
+
info,
|
|
376
|
+
rawName: `${info.deferredName}.a`,
|
|
377
|
+
ids: exportName,
|
|
378
|
+
exportName
|
|
379
|
+
};
|
|
380
|
+
}
|
|
365
381
|
break;
|
|
366
382
|
case "__esModule":
|
|
367
383
|
return {
|
|
@@ -392,6 +408,18 @@ const getFinalBinding = (
|
|
|
392
408
|
exportName
|
|
393
409
|
};
|
|
394
410
|
}
|
|
411
|
+
if (deferred) {
|
|
412
|
+
// As with default-with-named above, `ns.default` for a
|
|
413
|
+
// deferred default-only external must read through the
|
|
414
|
+
// optimized `.a` getter so that `typeof` / `instanceof`
|
|
415
|
+
// observe the actual default value rather than the proxy.
|
|
416
|
+
return {
|
|
417
|
+
info,
|
|
418
|
+
rawName: `${info.deferredName}.a`,
|
|
419
|
+
ids: exportName,
|
|
420
|
+
exportName
|
|
421
|
+
};
|
|
422
|
+
}
|
|
395
423
|
break;
|
|
396
424
|
}
|
|
397
425
|
case "dynamic":
|
|
@@ -890,7 +918,7 @@ class ConcatenatedModule extends Module {
|
|
|
890
918
|
// populate dependencies
|
|
891
919
|
for (const d of m.dependencies.filter(
|
|
892
920
|
(dep) =>
|
|
893
|
-
!(dep
|
|
921
|
+
!Dependency.canConcatenate(dep) ||
|
|
894
922
|
!this._modules.has(
|
|
895
923
|
/** @type {Module} */
|
|
896
924
|
(compilation.moduleGraph.getModule(dep))
|
|
@@ -898,6 +926,20 @@ class ConcatenatedModule extends Module {
|
|
|
898
926
|
)) {
|
|
899
927
|
this.dependencies.push(d);
|
|
900
928
|
}
|
|
929
|
+
// populate codeGenerationDependencies — the inner modules'
|
|
930
|
+
// templates are applied during ConcatenatedModule.codeGeneration,
|
|
931
|
+
// so the referenced modules must have been code-generated by then.
|
|
932
|
+
// Skip references that point back into the concat set itself.
|
|
933
|
+
if (m.codeGenerationDependencies !== undefined) {
|
|
934
|
+
for (const d of m.codeGenerationDependencies) {
|
|
935
|
+
const referenced =
|
|
936
|
+
/** @type {Module} */
|
|
937
|
+
(compilation.moduleGraph.getModule(d));
|
|
938
|
+
if (!this._modules.has(referenced)) {
|
|
939
|
+
this.addCodeGenerationDependency(d);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
}
|
|
901
943
|
// populate blocks
|
|
902
944
|
for (const d of m.blocks) {
|
|
903
945
|
this.blocks.push(d);
|
|
@@ -1008,7 +1050,10 @@ class ConcatenatedModule extends Module {
|
|
|
1008
1050
|
*/
|
|
1009
1051
|
const references = connections
|
|
1010
1052
|
.filter((connection) => {
|
|
1011
|
-
if (
|
|
1053
|
+
if (
|
|
1054
|
+
!connection.dependency ||
|
|
1055
|
+
!Dependency.canConcatenate(connection.dependency)
|
|
1056
|
+
) {
|
|
1012
1057
|
return false;
|
|
1013
1058
|
}
|
|
1014
1059
|
if (
|
|
@@ -145,7 +145,7 @@ module.exports.getDependencyUsedByExportsCondition = (
|
|
|
145
145
|
/** @type {Module} */
|
|
146
146
|
(moduleGraph.getParentModule(dependency));
|
|
147
147
|
const exportsInfo = moduleGraph.getExportsInfo(selfModule);
|
|
148
|
-
return (
|
|
148
|
+
return (_connections, runtime) => {
|
|
149
149
|
for (const exportName of usedByExports) {
|
|
150
150
|
if (exportsInfo.getUsed(exportName, runtime) !== UsageState.Unused) {
|
|
151
151
|
return true;
|
|
@@ -9,6 +9,7 @@ const {
|
|
|
9
9
|
JAVASCRIPT_MODULE_TYPE_AUTO,
|
|
10
10
|
JAVASCRIPT_MODULE_TYPE_ESM
|
|
11
11
|
} = require("../ModuleTypeConstants");
|
|
12
|
+
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
12
13
|
const PureExpressionDependency = require("../dependencies/PureExpressionDependency");
|
|
13
14
|
const InnerGraph = require("./InnerGraph");
|
|
14
15
|
|
|
@@ -29,6 +30,7 @@ const InnerGraph = require("./InnerGraph");
|
|
|
29
30
|
const { topLevelSymbolTag } = InnerGraph;
|
|
30
31
|
|
|
31
32
|
const PLUGIN_NAME = "InnerGraphPlugin";
|
|
33
|
+
const impureVariableDeclarationKinds = new Set(["using", "await using"]);
|
|
32
34
|
|
|
33
35
|
class InnerGraphPlugin {
|
|
34
36
|
/**
|
|
@@ -200,14 +202,22 @@ class InnerGraphPlugin {
|
|
|
200
202
|
}
|
|
201
203
|
});
|
|
202
204
|
|
|
203
|
-
parser.hooks.preDeclarator.tap(PLUGIN_NAME, (decl,
|
|
205
|
+
parser.hooks.preDeclarator.tap(PLUGIN_NAME, (decl, statement) => {
|
|
204
206
|
if (!InnerGraph.isEnabled(parser.state)) return;
|
|
207
|
+
if (impureVariableDeclarationKinds.has(statement.kind)) return;
|
|
205
208
|
if (
|
|
206
209
|
parser.scope.topLevelScope === true &&
|
|
207
210
|
decl.init &&
|
|
208
211
|
decl.id.type === "Identifier"
|
|
209
212
|
) {
|
|
210
213
|
const name = decl.id.name;
|
|
214
|
+
// Skip webpack runtime variables handled by CompatibilityPlugin
|
|
215
|
+
if (
|
|
216
|
+
name === RuntimeGlobals.require ||
|
|
217
|
+
name === RuntimeGlobals.exports
|
|
218
|
+
) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
211
221
|
if (
|
|
212
222
|
decl.init.type === "ClassExpression" &&
|
|
213
223
|
parser.isPure(
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const WebpackError = require("../errors/WebpackError");
|
|
9
|
+
const formatSize = require("../util/formatSize");
|
|
10
10
|
|
|
11
11
|
class MinMaxSizeWarning extends WebpackError {
|
|
12
12
|
/**
|
|
@@ -26,8 +26,8 @@ class MinMaxSizeWarning extends WebpackError {
|
|
|
26
26
|
super(
|
|
27
27
|
"SplitChunksPlugin\n" +
|
|
28
28
|
`${keysMessage}\n` +
|
|
29
|
-
`Configured minSize (${
|
|
30
|
-
`bigger than maxSize (${
|
|
29
|
+
`Configured minSize (${formatSize(minSize)}) is ` +
|
|
30
|
+
`bigger than maxSize (${formatSize(maxSize)}).\n` +
|
|
31
31
|
"This seem to be a invalid optimization.splitChunks configuration."
|
|
32
32
|
);
|
|
33
33
|
}
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
const asyncLib = require("neo-async");
|
|
9
9
|
const ChunkGraph = require("../ChunkGraph");
|
|
10
|
+
const Dependency = require("../Dependency");
|
|
11
|
+
const Module = require("../Module");
|
|
10
12
|
const ModuleGraph = require("../ModuleGraph");
|
|
11
13
|
const { JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants");
|
|
12
14
|
const { STAGE_DEFAULT } = require("../OptimizationStages");
|
|
13
|
-
const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
|
|
14
15
|
const { compareModulesByIdentifier } = require("../util/comparators");
|
|
15
16
|
const {
|
|
16
17
|
filterRuntime,
|
|
@@ -23,7 +24,6 @@ const ConcatenatedModule = require("./ConcatenatedModule");
|
|
|
23
24
|
|
|
24
25
|
/** @typedef {import("../Compilation")} Compilation */
|
|
25
26
|
/** @typedef {import("../Compiler")} Compiler */
|
|
26
|
-
/** @typedef {import("../Module")} Module */
|
|
27
27
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
28
28
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
29
29
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
@@ -228,6 +228,12 @@ class ModuleConcatenationPlugin {
|
|
|
228
228
|
canBeRoot = false;
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
+
// TODO: ConcatenatedModule.getSourceTypes only javascript now
|
|
232
|
+
const basicTypes = Module.getSourceBasicTypes(module);
|
|
233
|
+
if (basicTypes.size !== 1 || !basicTypes.has(JAVASCRIPT_TYPE)) {
|
|
234
|
+
canBeRoot = false;
|
|
235
|
+
}
|
|
236
|
+
|
|
231
237
|
// Module must not be an entry point
|
|
232
238
|
if (chunkGraph.isEntryModule(module)) {
|
|
233
239
|
setInnerBailoutReason(module, "Module is an entry point");
|
|
@@ -460,7 +466,8 @@ class ModuleConcatenationPlugin {
|
|
|
460
466
|
(c) =>
|
|
461
467
|
c.originModule === m &&
|
|
462
468
|
!(
|
|
463
|
-
c.dependency
|
|
469
|
+
c.dependency &&
|
|
470
|
+
Dependency.canConcatenate(c.dependency) &&
|
|
464
471
|
modules.has(c.module)
|
|
465
472
|
)
|
|
466
473
|
);
|
|
@@ -503,7 +510,8 @@ class ModuleConcatenationPlugin {
|
|
|
503
510
|
const otherModule =
|
|
504
511
|
c.module === rootModule ? c.originModule : c.module;
|
|
505
512
|
const innerConnection =
|
|
506
|
-
c.dependency
|
|
513
|
+
c.dependency &&
|
|
514
|
+
Dependency.canConcatenate(c.dependency) &&
|
|
507
515
|
modules.has(/** @type {Module} */ (otherModule));
|
|
508
516
|
return !innerConnection;
|
|
509
517
|
}
|
|
@@ -538,8 +546,8 @@ class ModuleConcatenationPlugin {
|
|
|
538
546
|
/** @type {Set<Module>} */
|
|
539
547
|
const set = new Set();
|
|
540
548
|
for (const dep of module.dependencies) {
|
|
541
|
-
// Get reference info only for
|
|
542
|
-
if (!(dep
|
|
549
|
+
// Get reference info only for dependencies that support concatenation
|
|
550
|
+
if (!Dependency.canConcatenate(dep)) continue;
|
|
543
551
|
|
|
544
552
|
const connection = moduleGraph.getConnection(dep);
|
|
545
553
|
// Reference is valid and has a module
|
|
@@ -757,7 +765,7 @@ class ModuleConcatenationPlugin {
|
|
|
757
765
|
const selected = connections.filter(
|
|
758
766
|
(connection) =>
|
|
759
767
|
!connection.dependency ||
|
|
760
|
-
!(connection.dependency
|
|
768
|
+
!Dependency.canConcatenate(connection.dependency)
|
|
761
769
|
);
|
|
762
770
|
if (selected.length > 0) {
|
|
763
771
|
nonHarmonyConnections.set(originModule, connections);
|