webpack 5.112.0 → 5.112.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/bin/webpack.js +13 -7
- package/lib/Compilation.js +152 -60
- package/lib/Compiler.js +12 -25
- package/lib/asset/AssetBytesGenerator.js +14 -6
- package/lib/asset/AssetBytesParser.js +10 -8
- package/lib/asset/AssetGenerator.js +36 -48
- package/lib/asset/AssetModule.js +11 -0
- package/lib/asset/AssetModulesPlugin.js +5 -4
- package/lib/asset/AssetParser.js +8 -8
- package/lib/asset/AssetSourceGenerator.js +16 -8
- package/lib/asset/AssetSourceParser.js +10 -8
- package/lib/asset/WebManifestGenerator.js +11 -6
- package/lib/asset/WebManifestParser.js +3 -3
- package/lib/async-modules/AsyncModuleHelpers.js +8 -2
- package/lib/async-modules/InferAsyncModulesPlugin.js +7 -2
- package/lib/cache/CacheFacade.js +1 -1
- package/lib/cache/PackFileCacheStrategy.js +6 -10
- package/lib/cache/ResolverCachePlugin.js +58 -8
- package/lib/config/WebpackOptionsApply.js +8 -28
- package/lib/config/cli.js +9 -6
- package/lib/config/defaults.js +24 -13
- package/lib/config/getClaimedAssetTypes.js +2 -2
- package/lib/config/target.js +1 -1
- package/lib/context/ContextModule.js +1 -1
- package/lib/context/ContextModuleFactory.js +1 -1
- package/lib/context/ContextReplacementPlugin.js +3 -9
- package/lib/css/CssGenerator.js +40 -37
- package/lib/css/CssModule.js +10 -0
- package/lib/css/CssModulesPlugin.js +2 -2
- package/lib/css/CssParser.js +33 -32
- package/lib/css/conventions.js +1 -1
- package/lib/css/data.js +224 -219
- package/lib/css/syntax-parser.js +1159 -298
- package/lib/css/syntax-printer.js +90 -35
- package/lib/debug/ProfilingPlugin.js +65 -43
- package/lib/define/DefinePlugin.js +10 -15
- package/lib/define/DotenvPlugin.js +10 -6
- package/lib/define/EnvironmentPlugin.js +4 -2
- package/lib/dependencies/amd/AMDDefineDependencyParserPlugin.js +1 -2
- package/lib/dependencies/amd/AMDRequireDependenciesBlockParserPlugin.js +4 -1
- package/lib/dependencies/commonjs/CommonJsExportRequireDependency.js +1 -4
- package/lib/dependencies/commonjs/CommonJsExportsParserPlugin.js +18 -33
- package/lib/dependencies/commonjs/CommonJsImportsParserPlugin.js +1 -3
- package/lib/dependencies/commonjs/CommonJsObjectExportDependency.js +4 -4
- package/lib/dependencies/commonjs/CommonJsPlugin.js +2 -5
- package/lib/dependencies/commonjs/RequireEnsureDependenciesBlockParserPlugin.js +4 -1
- package/lib/dependencies/context/ImportMetaContextDependencyParserPlugin.js +1 -2
- package/lib/dependencies/context/ImportMetaGlobDependencyParserPlugin.js +4 -7
- package/lib/dependencies/context/ImportMetaGlobHelpers.js +8 -10
- package/lib/dependencies/core/CachedConstDependency.js +9 -6
- package/lib/dependencies/css/CssIcssExportDependency.js +6 -7
- package/lib/dependencies/css/CssIcssImportDependency.js +1 -3
- package/lib/dependencies/css/CssUrlDependency.js +2 -6
- package/lib/dependencies/esm/ESMDetectionParserPlugin.js +2 -4
- package/lib/dependencies/esm/ESMExportExpressionDependency.js +2 -2
- package/lib/dependencies/esm/ESMExportImportedSpecifierDependency.js +16 -18
- package/lib/dependencies/esm/ESMExportSpecifierDependency.js +20 -3
- package/lib/dependencies/esm/ESMExports.js +2 -10
- package/lib/dependencies/esm/ESMImportDependency.js +17 -2
- package/lib/dependencies/esm/ESMImportDependencyParserPlugin.js +6 -17
- package/lib/dependencies/esm/ESMImportGuard.js +11 -23
- package/lib/dependencies/esm/ESMImportSideEffectDependency.js +1 -1
- package/lib/dependencies/esm/ESMImportSpecifierDependency.js +4 -1
- package/lib/dependencies/esm/ESMLiveExportDependency.js +311 -0
- package/lib/dependencies/esm/ESMLiveExportParserPlugin.js +862 -0
- package/lib/dependencies/esm/ESMModulesPlugin.js +1 -3
- package/lib/dependencies/esm/TopLevelAwaitDependency.js +1 -8
- package/lib/dependencies/helpers/DynamicExports.js +4 -6
- package/lib/dependencies/html/HtmlEntryDependency.js +5 -14
- package/lib/dependencies/html/HtmlInlineHtmlDependency.js +1 -4
- package/lib/dependencies/html/HtmlInlineScriptDependency.js +2 -6
- package/lib/dependencies/html/HtmlInlineStyleDependency.js +1 -4
- package/lib/dependencies/import/ImportParserPlugin.js +3 -6
- package/lib/dependencies/import-meta/ImportMetaPlugin.js +4 -6
- package/lib/dependencies/url/URLParserPlugin.js +1 -1
- package/lib/dependencies/worker/WorkerAndWorkletPlugin.js +51 -20
- package/lib/devtool/ModuleFilenameHelpers.js +1 -1
- package/lib/devtool/SourceMapDevToolPlugin.js +1 -1
- package/lib/dll/DelegatedModule.js +3 -3
- package/lib/dll/DllModule.js +3 -1
- package/lib/dll/DllReferencePlugin.js +1 -4
- package/lib/errors/AbstractMethodError.js +1 -1
- package/lib/errors/ErrorHelpers.js +2 -1
- package/lib/errors/HookWebpackError.js +2 -1
- package/lib/errors/JSONParseError.js +4 -4
- package/lib/errors/WebpackError.js +3 -2
- package/lib/esm/ModuleChunkFormatPlugin.js +36 -1
- package/lib/externals/ExternalModule.js +12 -9
- package/lib/externals/ExternalModuleFactoryPlugin.js +1 -2
- package/lib/externals/ExternalsPlugin.js +1 -1
- package/lib/fs/FileSystemInfo.js +4 -4
- package/lib/graph/AsyncDependenciesBlock.js +1 -1
- package/lib/graph/ChunkGraph.js +5 -0
- package/lib/graph/Dependency.js +8 -2
- package/lib/graph/ExportsInfo.js +1 -1
- package/lib/graph/ModuleGraph.js +14 -3
- package/lib/graph/buildChunkGraph.js +17 -19
- package/lib/graph/findGraphRoots.js +1 -1
- package/lib/hmr/HotModuleReplacement.runtime.js +10 -9
- package/lib/hmr/HotModuleReplacementPlugin.js +5 -11
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +16 -19
- package/lib/hmr/LazyCompilationPlugin.js +1 -7
- package/lib/html/HtmlGenerator.js +25 -17
- package/lib/html/HtmlModule.js +11 -1
- package/lib/html/HtmlModulesPlugin.js +12 -11
- package/lib/html/HtmlParser.js +10 -9
- package/lib/html/builtinEmbeddedRenderer.js +31 -33
- package/lib/html/data.js +42 -21
- package/lib/html/htmlMinify.js +4 -1
- package/lib/html/syntax-parser.js +34 -35
- package/lib/html/syntax-printer.js +2 -3
- package/lib/html/xmlMinify.js +4 -1
- package/lib/ids/HashedModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -12
- package/lib/javascript/APIPlugin.js +7 -13
- package/lib/javascript/BasicEvaluatedExpression.js +5 -5
- package/lib/javascript/CommonJsChunkFormatPlugin.js +2 -7
- package/lib/javascript/ConstPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +16 -11
- package/lib/javascript/JavascriptMetaInfoPlugin.js +3 -15
- package/lib/javascript/JavascriptModule.js +10 -0
- package/lib/javascript/JavascriptModulesPlugin.js +2 -4
- package/lib/javascript/JavascriptParser.js +99 -11
- package/lib/javascript/ScopeAnalyzer.js +183 -107
- package/lib/javascript/UseStrictPlugin.js +2 -5
- package/lib/javascript/jsMinify.js +1 -1
- package/lib/javascript/regexp.js +2 -2
- package/lib/javascript/syntax-parser.js +2114 -1506
- package/lib/javascript/syntax-printer-data.js +167 -1
- package/lib/javascript/syntax-printer.js +9554 -2782
- package/lib/json/JsonGenerator.js +15 -7
- package/lib/json/JsonModule.js +11 -0
- package/lib/json/JsonParser.js +7 -6
- package/lib/library/AssignLibraryPlugin.js +1 -1
- package/lib/library/JsonpLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +399 -23
- package/lib/loaders/LoaderRunner.js +76 -38
- package/lib/loaders/loadLoader.js +16 -10
- package/lib/module/Generator.js +17 -9
- package/lib/module/Module.js +2 -2
- package/lib/module/NormalModule.js +7 -5
- package/lib/module/NormalModuleFactory.js +11 -17
- package/lib/module/Parser.js +9 -2
- package/lib/module/extractSourceMap.js +69 -18
- package/lib/module/findCaseMismatch.js +2 -2
- package/lib/node/ExternalModuleInitFragment.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +4 -12
- package/lib/node/ReadFileCompileWasmPlugin.js +2 -6
- package/lib/node/nodeConsole.js +4 -3
- package/lib/optimize/CircularModulesPlugin.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +2 -6
- package/lib/optimize/FlagDependencyExportsPlugin.js +6 -11
- package/lib/optimize/FlagDependencyUsagePlugin.js +28 -3
- package/lib/optimize/InlineExports.js +4 -7
- package/lib/optimize/LazyBarrels.js +41 -5
- package/lib/optimize/ModuleConcatenationPlugin.js +8 -10
- package/lib/optimize/RealContentHashPlugin.js +2 -6
- package/lib/optimize/SideEffectsFlagPlugin.js +7 -21
- package/lib/optimize/SplitChunksPlugin.js +11 -24
- package/lib/optimize/TupleQueue.js +1 -1
- package/lib/output/CleanPlugin.js +3 -1
- package/lib/output/CopyPlugin.js +3 -4
- package/lib/performance/EvalUsagePlugin.js +1 -3
- package/lib/performance/HotspotsPlugin.js +33 -9
- package/lib/performance/PureAnnotationsPlugin.js +16 -10
- package/lib/performance/TopLevelThisPlugin.js +17 -9
- package/lib/prefetch/ResourceHintPlugin.js +1 -1
- package/lib/provide/ProvidedDependency.js +36 -4
- package/lib/rules/BasicEffectRulePlugin.js +1 -1
- package/lib/rules/RuleSetCompiler.js +15 -5
- package/lib/rules/UseEffectRulePlugin.js +1 -3
- package/lib/runtime/AsyncModuleRuntimeModule.js +7 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +1 -5
- package/lib/runtime/RuntimeGlobals.js +6 -0
- package/lib/runtime/RuntimePlugin.js +2 -0
- package/lib/schemes/HttpUriPlugin.js +1 -2
- package/lib/schemes/VirtualUrlPlugin.js +3 -1
- package/lib/serialization/AggregateErrorSerializer.js +3 -3
- package/lib/serialization/BinaryMiddleware.js +4 -1
- package/lib/serialization/ErrorObjectSerializer.js +2 -5
- package/lib/serialization/ObjectMiddleware.js +17 -15
- package/lib/serialization/PlainObjectSerializer.js +3 -7
- package/lib/serialization/Serializer.js +21 -11
- package/lib/serialization/SerializerMiddleware.js +8 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +35 -35
- package/lib/stats/DefaultStatsPresetPlugin.js +2 -6
- package/lib/stats/DefaultStatsPrinterPlugin.js +12 -11
- package/lib/stats/StatsFactory.js +194 -24
- package/lib/stats/StatsPrinter.js +126 -13
- package/lib/template/DependencyTemplate.js +1 -1
- package/lib/template/RuntimeTemplate.js +13 -32
- package/lib/template/Template.js +1 -1
- package/lib/util/SourceProcessor.js +98 -15
- package/lib/util/WeakTupleMap.js +10 -4
- package/lib/util/cleverMerge.js +61 -33
- package/lib/util/comparators.js +9 -5
- package/lib/util/dataURL.js +2 -0
- package/lib/util/deprecation.js +4 -3
- package/lib/util/globUtils.js +1 -4
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/makeSerializable.js +6 -4
- package/lib/util/memoize.js +1 -1
- package/lib/util/parseJson.js +2 -2
- package/lib/util/serialization.js +31 -27
- package/lib/wasm/AsyncWasmModule.js +12 -2
- package/lib/wasm/AsyncWebAssemblyGenerator.js +12 -4
- package/lib/wasm/AsyncWebAssemblyJavascriptGenerator.js +13 -5
- package/lib/wasm/AsyncWebAssemblyParser.js +7 -5
- package/lib/wasm/UniversalCompileAsyncWasmPlugin.js +2 -6
- package/lib/wasm-sync/SyncWasmModule.js +16 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +15 -10
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +13 -5
- package/lib/wasm-sync/WebAssemblyParser.js +10 -12
- package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -12
- package/lib/web/FetchCompileWasmPlugin.js +2 -6
- package/package.json +16 -18
- package/schemas/WebpackOptions.check.js +3 -3
- package/schemas/WebpackOptions.json +2 -2
- package/schemas/plugins/BannerPlugin.check.js +3 -3
- package/schemas/plugins/HtmlGeneratorOptions.check.js +3 -3
- package/schemas/plugins/HtmlParserOptions.check.js +3 -3
- package/schemas/plugins/IgnorePlugin.check.js +3 -3
- package/schemas/plugins/LoaderOptionsPlugin.check.js +3 -3
- package/schemas/plugins/ManifestPlugin.check.js +3 -3
- package/schemas/plugins/ProgressPlugin.check.js +3 -3
- package/schemas/plugins/SSRManifestPlugin.check.js +3 -3
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +3 -3
- package/schemas/plugins/WatchIgnorePlugin.check.js +3 -3
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetParserOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +3 -3
- package/schemas/plugins/container/ContainerPlugin.check.js +3 -3
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +3 -3
- package/schemas/plugins/container/ExternalsType.check.js +3 -3
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +3 -3
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +3 -3
- package/schemas/plugins/css/CssGeneratorOptions.check.js +3 -3
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +3 -3
- package/schemas/plugins/css/CssModuleParserOptions.check.js +3 -3
- package/schemas/plugins/css/CssParserOptions.check.js +3 -3
- package/schemas/plugins/debug/ProfilingPlugin.check.js +3 -3
- package/schemas/plugins/define/DotenvPluginOptions.check.js +7 -0
- package/schemas/plugins/define/DotenvPluginOptions.json +3 -0
- package/schemas/plugins/dll/DllPlugin.check.js +3 -3
- package/schemas/plugins/dll/DllReferencePlugin.check.js +3 -3
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +3 -3
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +3 -3
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +3 -3
- package/schemas/plugins/json/JsonModulesPluginGenerator.check.js +3 -3
- package/schemas/plugins/json/JsonModulesPluginParser.check.js +3 -3
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +3 -3
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +3 -3
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +3 -3
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +3 -3
- package/schemas/plugins/output/CleanOptions.check.js +7 -0
- package/schemas/plugins/output/CleanOptions.json +3 -0
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +3 -3
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +3 -3
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +3 -3
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +3 -3
- package/schemas/plugins/sharing/SharePlugin.check.js +3 -3
- package/types.d.ts +1482 -358
|
@@ -33,7 +33,7 @@ const {
|
|
|
33
33
|
CLEAR_TABLE_ROW,
|
|
34
34
|
COMMA_LIST_ATTRIBUTES,
|
|
35
35
|
DOM_TOKEN_LIST_ATTRIBUTES,
|
|
36
|
-
|
|
36
|
+
EMPTY_ELEMENT_DROPPED,
|
|
37
37
|
EMPTY_METADATA_ELEMENTS,
|
|
38
38
|
EMPTY_REMOVABLE_ATTRIBUTES,
|
|
39
39
|
ENUMERATED_ATTRIBUTE_NAMES,
|
|
@@ -6042,8 +6042,7 @@ const EMPTY_SKIP = Object.freeze({});
|
|
|
6042
6042
|
* @param {string} name raw SVG tag name
|
|
6043
6043
|
* @returns {string} case-adjusted SVG tag name
|
|
6044
6044
|
*/
|
|
6045
|
-
const adjustSvgTag = (name) =>
|
|
6046
|
-
/** @type {Record<string, string>} */ (SVG_TAG_ADJUST)[name] || name;
|
|
6045
|
+
const adjustSvgTag = (name) => SVG_TAG_ADJUST[name] || name;
|
|
6047
6046
|
|
|
6048
6047
|
/**
|
|
6049
6048
|
* @param {string} name doctype name
|
|
@@ -6297,15 +6296,10 @@ const htmlIntegrationPoint = (el) => {
|
|
|
6297
6296
|
const adjustForeignAttrs = (run, ns) => {
|
|
6298
6297
|
for (let i = run.start; i < run.start + run.count; i++) {
|
|
6299
6298
|
const name = _attrNames[i];
|
|
6300
|
-
if (
|
|
6301
|
-
|
|
6302
|
-
/** @type {Record<string, string>} */ (SVG_ATTR_ADJUST)[name]
|
|
6303
|
-
) {
|
|
6304
|
-
_attrNames[i] = /** @type {Record<string, string>} */ (SVG_ATTR_ADJUST)[
|
|
6305
|
-
name
|
|
6306
|
-
];
|
|
6299
|
+
if (ns === NS_SVG && SVG_ATTR_ADJUST[name]) {
|
|
6300
|
+
_attrNames[i] = SVG_ATTR_ADJUST[name];
|
|
6307
6301
|
}
|
|
6308
|
-
if (
|
|
6302
|
+
if (FOREIGN_ATTR_NS[name]) {
|
|
6309
6303
|
_attrFlags[i] |= 1;
|
|
6310
6304
|
}
|
|
6311
6305
|
}
|
|
@@ -7676,8 +7670,7 @@ const adoptionAgency = (subject, pos) => {
|
|
|
7676
7670
|
}
|
|
7677
7671
|
if (furthestIdx === -1) {
|
|
7678
7672
|
while (open.length > openIdx) {
|
|
7679
|
-
_nodeEnds[
|
|
7680
|
-
tokenEnd;
|
|
7673
|
+
_nodeEnds[open[open.length - 1]] = tokenEnd;
|
|
7681
7674
|
popOpen();
|
|
7682
7675
|
}
|
|
7683
7676
|
afeRemoveAt(fmtIdx);
|
|
@@ -8124,7 +8117,7 @@ modes.afterHead = (t) => {
|
|
|
8124
8117
|
return;
|
|
8125
8118
|
}
|
|
8126
8119
|
if (HEAD_ELEMENTS.has(t.name)) {
|
|
8127
|
-
const headEl =
|
|
8120
|
+
const headEl = _S.head;
|
|
8128
8121
|
open.push(headEl);
|
|
8129
8122
|
modes.inHead(t);
|
|
8130
8123
|
const idx = open.indexOf(headEl);
|
|
@@ -8676,7 +8669,7 @@ modes.text = (t) => {
|
|
|
8676
8669
|
return;
|
|
8677
8670
|
}
|
|
8678
8671
|
// span the close tag, like every other explicit-close pop
|
|
8679
|
-
_nodeEnds[
|
|
8672
|
+
_nodeEnds[popOpen()] = tokenEnd;
|
|
8680
8673
|
mode = originalMode;
|
|
8681
8674
|
}
|
|
8682
8675
|
};
|
|
@@ -9154,7 +9147,7 @@ modes.afterAfterFrameset = (t) => {
|
|
|
9154
9147
|
};
|
|
9155
9148
|
|
|
9156
9149
|
const dispatch = () => {
|
|
9157
|
-
process(/** @type {Token} */ (/** @type {
|
|
9150
|
+
process(/** @type {Token} */ (/** @type {Token | MutableToken} */ (tok)));
|
|
9158
9151
|
// One boolean per token: only a stack change can complete a subtree.
|
|
9159
9152
|
if (_streamEligible && (_openStackChanged || _openSpliced)) {
|
|
9160
9153
|
_openStackChanged = false;
|
|
@@ -9338,7 +9331,9 @@ const handleCommentToken = (input, start, end, dataStart, dataEnd) => {
|
|
|
9338
9331
|
const data = input.slice(dataStart, dataEnd).replace(/\r\n?/g, "\n");
|
|
9339
9332
|
if (data !== "") {
|
|
9340
9333
|
tok.type = TOKEN_CHAR;
|
|
9341
|
-
|
|
9334
|
+
// A NUL stays a NUL: foreign content replaces it without clearing
|
|
9335
|
+
// frameset-ok, and an HTML integration point drops it (§13.2.5.69).
|
|
9336
|
+
tok.data = data;
|
|
9342
9337
|
tok.start = start;
|
|
9343
9338
|
tok.end = end;
|
|
9344
9339
|
dispatch();
|
|
@@ -9567,7 +9562,7 @@ const PARSE_CALLBACKS = {
|
|
|
9567
9562
|
};
|
|
9568
9563
|
|
|
9569
9564
|
const dispatchXml = () => {
|
|
9570
|
-
processXml(/** @type {Token} */ (/** @type {
|
|
9565
|
+
processXml(/** @type {Token} */ (/** @type {Token | MutableToken} */ (tok)));
|
|
9571
9566
|
};
|
|
9572
9567
|
|
|
9573
9568
|
// A reference in the same shape as `XML_REFERENCE_REGEXP`, matched in place.
|
|
@@ -10327,10 +10322,10 @@ const _endsOutsideLineBox = (path, node, parent) => {
|
|
|
10327
10322
|
|
|
10328
10323
|
/**
|
|
10329
10324
|
* Whether a node prints nothing at all, so what follows it in the output is its
|
|
10330
|
-
* next sibling. The
|
|
10331
|
-
* whitespace-only text node the
|
|
10332
|
-
*
|
|
10333
|
-
* §13.1.2.4 tests
|
|
10325
|
+
* next sibling. The three that can: a comment the inert-comment rule drops, an
|
|
10326
|
+
* element `removeEmptyElements` drops, and a whitespace-only text node the
|
|
10327
|
+
* active `collapseWhitespace` tier deletes — the same questions the printer asks
|
|
10328
|
+
* when it reaches them, asked here so the §13.1.2.4 tests read the output.
|
|
10334
10329
|
* @param {HtmlPath} path the accessor
|
|
10335
10330
|
* @param {HtmlNodeRef} node the node
|
|
10336
10331
|
* @returns {boolean} true when it contributes no output
|
|
@@ -10343,6 +10338,9 @@ const _printsNothing = (path, node) => {
|
|
|
10343
10338
|
!_keepComment(_dataOf(node), path.source(node), _startOf(node))
|
|
10344
10339
|
);
|
|
10345
10340
|
}
|
|
10341
|
+
if (type === NodeType.Element) {
|
|
10342
|
+
return _isRemovableEmptyElement(path, node);
|
|
10343
|
+
}
|
|
10346
10344
|
if (type !== NodeType.Text) return false;
|
|
10347
10345
|
const data = _dataOf(node);
|
|
10348
10346
|
if (!isAllAsciiWhitespace(data)) return false;
|
|
@@ -10421,9 +10419,7 @@ const _headLeftBefore = (path, node, parent, parentName) => {
|
|
|
10421
10419
|
// Under `<html>` the whitespace stands after the whole head, so all of it counts.
|
|
10422
10420
|
const inHead = parentName === "head";
|
|
10423
10421
|
for (
|
|
10424
|
-
let child = _firstChild(
|
|
10425
|
-
inHead ? parent : /** @type {HtmlElement} */ (_S.head)
|
|
10426
|
-
);
|
|
10422
|
+
let child = _firstChild(inHead ? parent : _S.head);
|
|
10427
10423
|
child !== 0 && child !== (inHead ? node : 0);
|
|
10428
10424
|
child = _nextSibling(child)
|
|
10429
10425
|
) {
|
|
@@ -11815,12 +11811,10 @@ const _isRemovableEmptyElement = (path, element) => {
|
|
|
11815
11811
|
const answer =
|
|
11816
11812
|
_templateContentOf(element) === 0 &&
|
|
11817
11813
|
_namespaceOf(element) === NS_HTML &&
|
|
11818
|
-
//
|
|
11819
|
-
//
|
|
11820
|
-
|
|
11821
|
-
(!VOID.has(_tagNameOf(element)) ||
|
|
11814
|
+
// Only a name known to render nothing empty: a void element that belongs
|
|
11815
|
+
// in the head, with no attributes, states nothing either.
|
|
11816
|
+
(EMPTY_ELEMENT_DROPPED.has(_tagNameOf(element)) ||
|
|
11822
11817
|
EMPTY_METADATA_ELEMENTS.has(_tagNameOf(element))) &&
|
|
11823
|
-
!EMPTY_ELEMENT_KEPT.has(_tagNameOf(element)) &&
|
|
11824
11818
|
(_childrenPrintNothing(path, element) ||
|
|
11825
11819
|
(_tagNameOf(element) === "style" && _sheetPrintsNothing(path, element)));
|
|
11826
11820
|
_emptyElements.set(element, answer);
|
|
@@ -11844,7 +11838,7 @@ const _childrenPrintNothing = (path, element) => {
|
|
|
11844
11838
|
) {
|
|
11845
11839
|
if (
|
|
11846
11840
|
path.type(child) === NodeType.Element
|
|
11847
|
-
? !_isRemovableEmptyElement(path,
|
|
11841
|
+
? !_isRemovableEmptyElement(path, child)
|
|
11848
11842
|
: !_printsNothing(path, child)
|
|
11849
11843
|
) {
|
|
11850
11844
|
return false;
|
|
@@ -13571,7 +13565,8 @@ const _streamTags = (path, minify) => {
|
|
|
13571
13565
|
_streamImplied = shell && !opensOutside ? name : "";
|
|
13572
13566
|
} else {
|
|
13573
13567
|
_streamOpen = _synthesizeOpenTag(path);
|
|
13574
|
-
_streamClose =
|
|
13568
|
+
_streamClose =
|
|
13569
|
+
minify && _canOmitEndTag(path, name, path.node) ? "" : `</${name}>`;
|
|
13575
13570
|
}
|
|
13576
13571
|
return true;
|
|
13577
13572
|
}
|
|
@@ -14920,7 +14915,7 @@ const parseSrcset = (input) => {
|
|
|
14920
14915
|
lastChar === SMALL_LETTER_W
|
|
14921
14916
|
) {
|
|
14922
14917
|
// If width and density are not both absent, then let error be yes.
|
|
14923
|
-
if (width || density) {
|
|
14918
|
+
if (width !== undefined || density !== undefined) {
|
|
14924
14919
|
pError = true;
|
|
14925
14920
|
}
|
|
14926
14921
|
|
|
@@ -14943,7 +14938,11 @@ const parseSrcset = (input) => {
|
|
|
14943
14938
|
) {
|
|
14944
14939
|
// If width, density and future-compat-h are not all absent, then let error
|
|
14945
14940
|
// be yes.
|
|
14946
|
-
if (
|
|
14941
|
+
if (
|
|
14942
|
+
width !== undefined ||
|
|
14943
|
+
density !== undefined ||
|
|
14944
|
+
height !== undefined
|
|
14945
|
+
) {
|
|
14947
14946
|
pError = true;
|
|
14948
14947
|
}
|
|
14949
14948
|
|
|
@@ -14965,7 +14964,7 @@ const parseSrcset = (input) => {
|
|
|
14965
14964
|
lastChar === SMALL_LETTER_H
|
|
14966
14965
|
) {
|
|
14967
14966
|
// If height and density are not both absent, then let error be yes.
|
|
14968
|
-
if (height || density) {
|
|
14967
|
+
if (height !== undefined || density !== undefined) {
|
|
14969
14968
|
pError = true;
|
|
14970
14969
|
}
|
|
14971
14970
|
|
|
@@ -133,7 +133,7 @@ const CLASSIC_SCRIPT = "script";
|
|
|
133
133
|
* @property {HtmlTransformOptions=} transforms which of the meaning-preserving rewrites the minifying print makes; each is on unless it is `false`
|
|
134
134
|
* @property {(boolean | "conservative" | "smart" | "all")=} collapseWhitespace collapse each run of whitespace in text to a single space, except where an ancestor renders it verbatim; `"smart"` also drops what sits against a block edge and `"all"` drops every edge (default false)
|
|
135
135
|
* @property {boolean=} removeEmptyAttributes drop an attribute whose empty value leaves it in the state its absence gives (default false)
|
|
136
|
-
* @property {boolean=} removeEmptyElements drop an element with no children and no attributes
|
|
136
|
+
* @property {boolean=} removeEmptyElements drop an element with no children and no attributes where its bare form renders nothing and nothing reads it (default false)
|
|
137
137
|
* @property {boolean=} mergeStyles print a run of adjacent `<style>` elements as one sheet, which removes elements (default false)
|
|
138
138
|
* @property {boolean=} mergeScripts print a run of adjacent bare `<script>` elements whose bodies this print writes itself as one, which removes elements, hoists a later body's declarations into the ones before it, and lets a failing body end the whole run (default false)
|
|
139
139
|
* @property {boolean=} sortAttributes print an HTML or XML element's attributes commonest name first, ties by name (default false)
|
|
@@ -628,8 +628,7 @@ const _mergedScriptRun = (path, element, js) => {
|
|
|
628
628
|
if (!_scriptEndsClean(js) || _opensAScript(js)) return js;
|
|
629
629
|
let out = js;
|
|
630
630
|
for (let next = first; next !== 0; next = _mergeableScriptAfter(path, next)) {
|
|
631
|
-
const body =
|
|
632
|
-
_nodeStrings[/** @type {HtmlNodeRef} */ (_onlyTextChild(next))];
|
|
631
|
+
const body = _nodeStrings[_onlyTextChild(next)];
|
|
633
632
|
if (
|
|
634
633
|
!_scriptEndsClean(body) ||
|
|
635
634
|
_opensAScript(body) ||
|
package/lib/html/xmlMinify.js
CHANGED
|
@@ -37,7 +37,10 @@ const xmlMinify = async (input, sourceMap, minimizerOptions = {}) => {
|
|
|
37
37
|
rewriteCustomProperties: css.rewriteCustomProperties,
|
|
38
38
|
unusedSymbols: css.unusedSymbols,
|
|
39
39
|
pseudoClasses: css.pseudoClasses,
|
|
40
|
-
|
|
40
|
+
// Picked on first CSS render, which loads the CSS parser anyway.
|
|
41
|
+
get transforms() {
|
|
42
|
+
return webpack.css.syntax.parser.pickTransforms(css);
|
|
43
|
+
}
|
|
41
44
|
});
|
|
42
45
|
return {
|
|
43
46
|
code: new webpack.html.syntax.SourceProcessor().process(code, {
|
|
@@ -102,7 +102,7 @@ class HashedModuleIdsPlugin {
|
|
|
102
102
|
const hashId = hash.digest(this.options.hashDigest || "base64");
|
|
103
103
|
let len = this.options.hashDigestLength || 4;
|
|
104
104
|
while (usedIds.has(hashId.slice(0, len))) {
|
|
105
|
-
|
|
105
|
+
len++;
|
|
106
106
|
}
|
|
107
107
|
const moduleId = hashId.slice(0, len);
|
|
108
108
|
chunkGraph.setModuleId(module, moduleId);
|
package/lib/index.js
CHANGED
|
@@ -92,7 +92,10 @@ const getCli = memoize(() => ({
|
|
|
92
92
|
/** @typedef {import("./stats/MultiStats")} MultiStats */
|
|
93
93
|
/** @typedef {import("./stats/MultiStats").MultiStatsOptions} MultiStatsOptions */
|
|
94
94
|
/** @typedef {import("./module/NormalModuleFactory").ResolveData} ResolveData */
|
|
95
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* @template {import("./module/NormalModule")} [TModule=import("./module/NormalModule")]
|
|
97
|
+
* @typedef {import("./module/Parser").ParserState<TModule>} ParserState
|
|
98
|
+
*/
|
|
96
99
|
/** @typedef {import("./resolve/ResolverFactory").ResolvePluginInstance} ResolvePluginInstance */
|
|
97
100
|
/** @typedef {import("./resolve/ResolverFactory").Resolver} Resolver */
|
|
98
101
|
/** @typedef {import("./template/Template").RenderManifestEntry} RenderManifestEntry */
|
|
@@ -126,21 +129,19 @@ const getCli = memoize(() => ({
|
|
|
126
129
|
|
|
127
130
|
/**
|
|
128
131
|
* Returns function.
|
|
129
|
-
* @template {(...args:
|
|
132
|
+
* @template {(...args: never[]) => void} T
|
|
130
133
|
* @param {() => T} factory factory function
|
|
131
134
|
* @returns {T} function
|
|
132
135
|
*/
|
|
133
136
|
const lazyFunction = (factory) => {
|
|
134
137
|
const fac = memoize(factory);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
);
|
|
143
|
-
return /** @type {T} */ (f);
|
|
138
|
+
/**
|
|
139
|
+
* Handles the callback logic for this hook.
|
|
140
|
+
* @param {Parameters<T>} args args
|
|
141
|
+
* @returns {ReturnType<T>} result
|
|
142
|
+
*/
|
|
143
|
+
const f = (...args) => /** @type {ReturnType<T>} */ (fac()(...args));
|
|
144
|
+
return /** @type {T} */ (/** @type {T | typeof f} */ (f));
|
|
144
145
|
};
|
|
145
146
|
|
|
146
147
|
/**
|
|
@@ -229,7 +230,7 @@ module.exports = mergeExports(fn, {
|
|
|
229
230
|
return validateSchema;
|
|
230
231
|
},
|
|
231
232
|
get version() {
|
|
232
|
-
return
|
|
233
|
+
return require("../package.json").version;
|
|
233
234
|
},
|
|
234
235
|
|
|
235
236
|
get cli() {
|
|
@@ -34,7 +34,7 @@ const getConcatenatedModule = memoize(() =>
|
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
/** @import Compiler from "../Compiler" */
|
|
37
|
-
/** @import Module
|
|
37
|
+
/** @import Module from "../module/Module" */
|
|
38
38
|
/**
|
|
39
39
|
* @import {
|
|
40
40
|
* JavascriptModuleBuildInfo
|
|
@@ -342,8 +342,7 @@ class APIPlugin {
|
|
|
342
342
|
declarator.id.type === "Identifier" &&
|
|
343
343
|
declarator.id.name === "module"
|
|
344
344
|
) {
|
|
345
|
-
|
|
346
|
-
(parser.state.module.buildInfo).moduleArgument =
|
|
345
|
+
parser.state.module.buildInfo.moduleArgument =
|
|
347
346
|
"__webpack_module__";
|
|
348
347
|
}
|
|
349
348
|
});
|
|
@@ -359,8 +358,7 @@ class APIPlugin {
|
|
|
359
358
|
statement.id &&
|
|
360
359
|
statement.id.name === "module"
|
|
361
360
|
) {
|
|
362
|
-
|
|
363
|
-
(parser.state.module.buildInfo).moduleArgument =
|
|
361
|
+
parser.state.module.buildInfo.moduleArgument =
|
|
364
362
|
"__webpack_module__";
|
|
365
363
|
}
|
|
366
364
|
};
|
|
@@ -378,8 +376,7 @@ class APIPlugin {
|
|
|
378
376
|
|
|
379
377
|
if (key === "__non_webpack_require__" && moduleOutput) {
|
|
380
378
|
if (nodeTarget) {
|
|
381
|
-
|
|
382
|
-
(parser.state.module.buildInfo).needCreateRequire = true;
|
|
379
|
+
parser.state.module.buildInfo.needCreateRequire = true;
|
|
383
380
|
} else {
|
|
384
381
|
const warning = new WebpackError(
|
|
385
382
|
`${PLUGIN_NAME}\n__non_webpack_require__ is only allowed in target node`
|
|
@@ -405,8 +402,7 @@ class APIPlugin {
|
|
|
405
402
|
RuntimeGlobals.requireScope
|
|
406
403
|
]);
|
|
407
404
|
parser.hooks.assign.for(key).tap(PLUGIN_NAME, (expr) => {
|
|
408
|
-
|
|
409
|
-
(parser.state.module.buildInfo).usingPublicPathOverride = true;
|
|
405
|
+
parser.state.module.buildInfo.usingPublicPathOverride = true;
|
|
410
406
|
addRuntimePublicPathOverride(compilation, parser.state.module);
|
|
411
407
|
// A destructuring target is no expression to replace; the read
|
|
412
408
|
// handler still spells the global, with a read's requirement.
|
|
@@ -455,8 +451,7 @@ class APIPlugin {
|
|
|
455
451
|
parser.hooks.expression
|
|
456
452
|
.for("__webpack_module__.id")
|
|
457
453
|
.tap(PLUGIN_NAME, (expr) => {
|
|
458
|
-
|
|
459
|
-
(parser.state.module.buildInfo).moduleConcatenationBailout =
|
|
454
|
+
parser.state.module.buildInfo.moduleConcatenationBailout =
|
|
460
455
|
"__webpack_module__.id";
|
|
461
456
|
const moduleArgument = parser.state.module.moduleArgument;
|
|
462
457
|
if (moduleArgument === "__webpack_module__") {
|
|
@@ -486,8 +481,7 @@ class APIPlugin {
|
|
|
486
481
|
parser.hooks.expression
|
|
487
482
|
.for("__webpack_module__")
|
|
488
483
|
.tap(PLUGIN_NAME, (expr) => {
|
|
489
|
-
|
|
490
|
-
(parser.state.module.buildInfo).moduleConcatenationBailout =
|
|
484
|
+
parser.state.module.buildInfo.moduleConcatenationBailout =
|
|
491
485
|
"__webpack_module__";
|
|
492
486
|
const moduleArgument = parser.state.module.moduleArgument;
|
|
493
487
|
if (moduleArgument === "__webpack_module__") {
|
|
@@ -58,15 +58,15 @@ class BasicEvaluatedExpression {
|
|
|
58
58
|
this.expression = undefined;
|
|
59
59
|
// _v1..._v5 hold the scalar type-specific fields, the accessors narrow
|
|
60
60
|
// them by type; expression-valued fields get typed slots below
|
|
61
|
-
/** @type {
|
|
61
|
+
/** @type {boolean | number | bigint | RegExp | string | string[] | InstanceType<VariableInfo> | undefined} */
|
|
62
62
|
this._v1 = undefined;
|
|
63
|
-
/** @type {
|
|
63
|
+
/** @type {string | InstanceType<VariableInfo> | undefined} */
|
|
64
64
|
this._v2 = undefined;
|
|
65
|
-
/** @type {
|
|
65
|
+
/** @type {"cooked" | "raw" | GetMembers | undefined} */
|
|
66
66
|
this._v3 = undefined;
|
|
67
|
-
/** @type {
|
|
67
|
+
/** @type {GetMembersOptionals | undefined} */
|
|
68
68
|
this._v4 = undefined;
|
|
69
|
-
/** @type {
|
|
69
|
+
/** @type {GetMemberRanges | undefined} */
|
|
70
70
|
this._v5 = undefined;
|
|
71
71
|
// expression-valued fields stay plain data properties: a type that
|
|
72
72
|
// references the class inside one of its own accessors makes tsc fork
|
|
@@ -19,7 +19,6 @@ const {
|
|
|
19
19
|
generateEntryStartup
|
|
20
20
|
} = require("./StartupHelpers");
|
|
21
21
|
|
|
22
|
-
/** @import Chunk from "../graph/Chunk" */
|
|
23
22
|
/** @import Compiler from "../Compiler" */
|
|
24
23
|
|
|
25
24
|
const PLUGIN_NAME = "CommonJsChunkFormatPlugin";
|
|
@@ -76,13 +75,9 @@ class CommonJsChunkFormatPlugin {
|
|
|
76
75
|
.split("/");
|
|
77
76
|
const runtimeOutputName = compilation
|
|
78
77
|
.getPath(
|
|
79
|
-
getChunkFilenameTemplate(
|
|
80
|
-
/** @type {Chunk} */
|
|
81
|
-
(runtimeChunk),
|
|
82
|
-
compilation.outputOptions
|
|
83
|
-
),
|
|
78
|
+
getChunkFilenameTemplate(runtimeChunk, compilation.outputOptions),
|
|
84
79
|
{
|
|
85
|
-
chunk:
|
|
80
|
+
chunk: runtimeChunk,
|
|
86
81
|
contentHashType: "javascript"
|
|
87
82
|
}
|
|
88
83
|
)
|
|
@@ -124,7 +124,7 @@ const getHoistedDeclarations = (branch, includeFunctionDeclarations) => {
|
|
|
124
124
|
break;
|
|
125
125
|
case "FunctionDeclaration":
|
|
126
126
|
if (includeFunctionDeclarations) {
|
|
127
|
-
collectDeclaration(declarations,
|
|
127
|
+
collectDeclaration(declarations, node.id);
|
|
128
128
|
}
|
|
129
129
|
break;
|
|
130
130
|
case "VariableDeclaration":
|
|
@@ -14,6 +14,7 @@ const { JAVASCRIPT_TYPES } = require("../module/ModuleSourceTypeConstants");
|
|
|
14
14
|
const RuntimeGlobals = require("../runtime/RuntimeGlobals");
|
|
15
15
|
const InitFragment = require("../template/InitFragment");
|
|
16
16
|
|
|
17
|
+
/** @import { JavascriptNormalModule } from "./JavascriptModule" */
|
|
17
18
|
/** @import { Source } from "webpack-sources" */
|
|
18
19
|
/** @import { DependencyConstructor } from "../Compilation" */
|
|
19
20
|
/** @import DependenciesBlock from "../graph/DependenciesBlock" */
|
|
@@ -31,8 +32,6 @@ const InitFragment = require("../template/InitFragment");
|
|
|
31
32
|
* SourceTypes
|
|
32
33
|
* } from "../module/Module"
|
|
33
34
|
*/
|
|
34
|
-
/** @import { JavascriptModuleBuildInfo } from "./JavascriptModule" */
|
|
35
|
-
/** @import NormalModule from "../module/NormalModule" */
|
|
36
35
|
|
|
37
36
|
const DEFAULT_SOURCE = {
|
|
38
37
|
source() {
|
|
@@ -77,10 +76,18 @@ const deprecatedGetInitFragments = util.deprecate(
|
|
|
77
76
|
"DEP_WEBPACK_JAVASCRIPT_GENERATOR_GET_INIT_FRAGMENTS"
|
|
78
77
|
);
|
|
79
78
|
|
|
79
|
+
/**
|
|
80
|
+
* The module type the JSDoc inherited from `Generator` names.
|
|
81
|
+
* @typedef {JavascriptNormalModule} TModule
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @extends {Generator<TModule>}
|
|
86
|
+
*/
|
|
80
87
|
class JavascriptGenerator extends Generator {
|
|
81
88
|
/**
|
|
82
89
|
* Returns the source types available for this module.
|
|
83
|
-
* @param {
|
|
90
|
+
* @param {TModule} module fresh module
|
|
84
91
|
* @returns {SourceTypes} available types (do not mutate)
|
|
85
92
|
*/
|
|
86
93
|
getTypes(module) {
|
|
@@ -89,7 +96,7 @@ class JavascriptGenerator extends Generator {
|
|
|
89
96
|
|
|
90
97
|
/**
|
|
91
98
|
* Returns the estimated size for the requested source type.
|
|
92
|
-
* @param {
|
|
99
|
+
* @param {TModule} module the module
|
|
93
100
|
* @param {SourceType=} type source type
|
|
94
101
|
* @returns {number} estimate size of the module
|
|
95
102
|
*/
|
|
@@ -103,15 +110,13 @@ class JavascriptGenerator extends Generator {
|
|
|
103
110
|
|
|
104
111
|
/**
|
|
105
112
|
* Returns the reason this module cannot be concatenated, when one exists.
|
|
106
|
-
* @param {
|
|
113
|
+
* @param {TModule} module module for which the bailout reason should be determined
|
|
107
114
|
* @param {ConcatenationBailoutReasonContext} context context
|
|
108
115
|
* @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated
|
|
109
116
|
*/
|
|
110
117
|
getConcatenationBailoutReason(module, context) {
|
|
111
118
|
const buildMeta = module.buildMeta;
|
|
112
|
-
const buildInfo =
|
|
113
|
-
module.buildInfo
|
|
114
|
-
);
|
|
119
|
+
const buildInfo = module.buildInfo;
|
|
115
120
|
const presentationalDependencies = module.presentationalDependencies;
|
|
116
121
|
// An ESM is a "namespace" module carrying the interop flag the harmony
|
|
117
122
|
// parser emits; anything else is treated as CommonJS below
|
|
@@ -238,7 +243,7 @@ class JavascriptGenerator extends Generator {
|
|
|
238
243
|
* @returns {void}
|
|
239
244
|
*/
|
|
240
245
|
sourceModule(module, initFragments, source, generateContext) {
|
|
241
|
-
/** @type {InitFragment<
|
|
246
|
+
/** @type {InitFragment<import("./JavascriptModulesPlugin").ChunkRenderContext>[] | undefined} */
|
|
242
247
|
let chunkInitFragments;
|
|
243
248
|
|
|
244
249
|
// one template context for all dependencies of the module (hot path)
|
|
@@ -306,7 +311,7 @@ class JavascriptGenerator extends Generator {
|
|
|
306
311
|
|
|
307
312
|
/**
|
|
308
313
|
* Generates generated code for this runtime module.
|
|
309
|
-
* @param {
|
|
314
|
+
* @param {TModule} module module for which the code should be generated
|
|
310
315
|
* @param {GenerateContext} generateContext context for generate
|
|
311
316
|
* @returns {Source | null} generated code
|
|
312
317
|
*/
|
|
@@ -328,7 +333,7 @@ class JavascriptGenerator extends Generator {
|
|
|
328
333
|
/**
|
|
329
334
|
* Generates fallback output for the provided error condition.
|
|
330
335
|
* @param {Error} error the error
|
|
331
|
-
* @param {
|
|
336
|
+
* @param {TModule} module module for which the code should be generated
|
|
332
337
|
* @param {GenerateContext} generateContext context for generate
|
|
333
338
|
* @returns {Source | null} generated code
|
|
334
339
|
*/
|
|
@@ -14,12 +14,6 @@ const { getInnerGraphUtils } = require("../optimize/InnerGraph");
|
|
|
14
14
|
const { recordOptimizationBailout } = require("../util/buildDiagnostics");
|
|
15
15
|
|
|
16
16
|
/** @import Compiler from "../Compiler" */
|
|
17
|
-
/** @import { BuildInfo } from "../module/Module" */
|
|
18
|
-
/**
|
|
19
|
-
* @import {
|
|
20
|
-
* JavascriptModuleBuildInfo
|
|
21
|
-
* } from "../javascript/JavascriptModule"
|
|
22
|
-
*/
|
|
23
17
|
/** @import JavascriptParser from "../javascript/JavascriptParser" */
|
|
24
18
|
|
|
25
19
|
const PLUGIN_NAME = "JavascriptMetaInfoPlugin";
|
|
@@ -52,9 +46,7 @@ class JavascriptMetaInfoPlugin {
|
|
|
52
46
|
statement.kind === "await using")
|
|
53
47
|
)
|
|
54
48
|
) {
|
|
55
|
-
const buildInfo =
|
|
56
|
-
/** @type {JavascriptModuleBuildInfo} */
|
|
57
|
-
(parser.state.module.buildInfo);
|
|
49
|
+
const buildInfo = parser.state.module.buildInfo;
|
|
58
50
|
buildInfo.usesTopLevelUsingDeclaration = true;
|
|
59
51
|
// Concatenation would defer disposal to the enclosing scope.
|
|
60
52
|
buildInfo.moduleConcatenationBailout =
|
|
@@ -62,9 +54,7 @@ class JavascriptMetaInfoPlugin {
|
|
|
62
54
|
}
|
|
63
55
|
});
|
|
64
56
|
parser.hooks.call.for("eval").tap(PLUGIN_NAME, () => {
|
|
65
|
-
const buildInfo =
|
|
66
|
-
/** @type {JavascriptModuleBuildInfo} */
|
|
67
|
-
(parser.state.module.buildInfo);
|
|
57
|
+
const buildInfo = parser.state.module.buildInfo;
|
|
68
58
|
buildInfo.moduleConcatenationBailout = "eval()";
|
|
69
59
|
const currentSymbol = innerGraph.getTopLevelSymbol(parser.state);
|
|
70
60
|
if (currentSymbol) {
|
|
@@ -82,9 +72,7 @@ class JavascriptMetaInfoPlugin {
|
|
|
82
72
|
}
|
|
83
73
|
});
|
|
84
74
|
parser.hooks.finish.tap(PLUGIN_NAME, () => {
|
|
85
|
-
const buildInfo =
|
|
86
|
-
/** @type {BuildInfo} */
|
|
87
|
-
(parser.state.module.buildInfo);
|
|
75
|
+
const buildInfo = parser.state.module.buildInfo;
|
|
88
76
|
let topLevelDeclarations = buildInfo.topLevelDeclarations;
|
|
89
77
|
if (topLevelDeclarations === undefined) {
|
|
90
78
|
topLevelDeclarations = buildInfo.topLevelDeclarations = new Set();
|
|
@@ -39,6 +39,16 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
39
39
|
|
|
40
40
|
/** @typedef {BuildMeta & KnownJavascriptModuleBuildMeta} JavascriptModuleBuildMeta */
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* A javascript module before or after its build, typed with its build info and build meta.
|
|
44
|
+
* @typedef {NormalModule & { buildInfo?: JavascriptModuleBuildInfo, buildMeta?: JavascriptModuleBuildMeta }} JavascriptNormalModule
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A built javascript module, typed with its build info and build meta.
|
|
49
|
+
* @typedef {NormalModule & { buildInfo: JavascriptModuleBuildInfo, buildMeta: JavascriptModuleBuildMeta }} BuiltJavascriptModule
|
|
50
|
+
*/
|
|
51
|
+
|
|
42
52
|
/**
|
|
43
53
|
* Module class for all `javascript/*` modules. JavaScript-specific properties should live here instead of `NormalModule`.
|
|
44
54
|
*/
|
|
@@ -1329,9 +1329,7 @@ class JavascriptModulesPlugin {
|
|
|
1329
1329
|
const chunkModules = Template.renderChunkModules(
|
|
1330
1330
|
chunkRenderContext,
|
|
1331
1331
|
inlinedModules
|
|
1332
|
-
? allModules.filter(
|
|
1333
|
-
(m) => !(/** @type {Set<Module>} */ (inlinedModules).has(m))
|
|
1334
|
-
)
|
|
1332
|
+
? allModules.filter((m) => !inlinedModules.has(m))
|
|
1335
1333
|
: allModules,
|
|
1336
1334
|
(module, renderInObject) =>
|
|
1337
1335
|
this.renderModule(
|
|
@@ -2027,7 +2025,7 @@ class JavascriptModulesPlugin {
|
|
|
2027
2025
|
// whichever one provides each name.
|
|
2028
2026
|
if (merge) {
|
|
2029
2027
|
const { exports, namespace } = getMergedExports(
|
|
2030
|
-
|
|
2028
|
+
mergedModules,
|
|
2031
2029
|
moduleGraph,
|
|
2032
2030
|
chunk.runtime
|
|
2033
2031
|
);
|