webpack 5.112.0 → 5.112.2
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 +198 -61
- 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 -47
- package/lib/css/CssModule.js +10 -0
- package/lib/css/CssModulesPlugin.js +13 -6
- 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 +1312 -312
- package/lib/css/syntax-printer.js +1142 -1025
- 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 +4 -8
- 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 +146 -29
- 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 +18 -19
- 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
|
@@ -105,8 +105,7 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|
|
105
105
|
/** @type {RawReferencedExports | undefined} */
|
|
106
106
|
let exports;
|
|
107
107
|
if (optionsNode) {
|
|
108
|
-
for (const prop of
|
|
109
|
-
.properties) {
|
|
108
|
+
for (const prop of optionsNode.properties) {
|
|
110
109
|
if (prop.type !== "Property" || prop.key.type !== "Identifier") {
|
|
111
110
|
errors.push(
|
|
112
111
|
createError(
|
|
@@ -11,7 +11,6 @@ const {
|
|
|
11
11
|
const ImportMetaGlobDependency = require("./ImportMetaGlobDependency");
|
|
12
12
|
const { parseImportMetaGlobCall } = require("./ImportMetaGlobHelpers");
|
|
13
13
|
|
|
14
|
-
/** @import { CallExpression } from "estree" */
|
|
15
14
|
/** @import JavascriptParser from "../../javascript/JavascriptParser" */
|
|
16
15
|
|
|
17
16
|
const PLUGIN_NAME = "ImportMetaGlobDependencyParserPlugin";
|
|
@@ -38,7 +37,7 @@ module.exports = class ImportMetaGlobDependencyParserPlugin {
|
|
|
38
37
|
options: globOptions,
|
|
39
38
|
errors,
|
|
40
39
|
warnings
|
|
41
|
-
} = parseImportMetaGlobCall(
|
|
40
|
+
} = parseImportMetaGlobCall(expr, parser);
|
|
42
41
|
for (const warning of warnings) {
|
|
43
42
|
parser.state.module.addWarning(warning);
|
|
44
43
|
}
|
|
@@ -58,11 +57,9 @@ module.exports = class ImportMetaGlobDependencyParserPlugin {
|
|
|
58
57
|
exhaustive: globOptions.exhaustive,
|
|
59
58
|
caseSensitive: globOptions.caseSensitive,
|
|
60
59
|
referencedExports: globOptions.referencedExports,
|
|
61
|
-
namespaceObject:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
? "strict"
|
|
65
|
-
: true,
|
|
60
|
+
namespaceObject: parser.state.module.buildMeta.strictHarmonyModule
|
|
61
|
+
? "strict"
|
|
62
|
+
: true,
|
|
66
63
|
mode: globOptions.mode,
|
|
67
64
|
category: "esm"
|
|
68
65
|
},
|
|
@@ -87,9 +87,7 @@ const staticStringFromExpr = (expr, parser) => {
|
|
|
87
87
|
return /** @type {string} */ (evaluated.string);
|
|
88
88
|
}
|
|
89
89
|
if (expr.type === "TemplateLiteral" && expr.expressions.length === 0) {
|
|
90
|
-
const cooked =
|
|
91
|
-
expr.quasis[0]
|
|
92
|
-
).value.cooked;
|
|
90
|
+
const cooked = expr.quasis[0].value.cooked;
|
|
93
91
|
if (cooked !== null && cooked !== undefined) return cooked;
|
|
94
92
|
}
|
|
95
93
|
};
|
|
@@ -189,7 +187,10 @@ const staticImportMetaGlobQueryKeyFromPropName = (propName, parser) => {
|
|
|
189
187
|
if (typeof propName.value === "number") return String(propName.value);
|
|
190
188
|
if (typeof propName.value === "boolean") return String(propName.value);
|
|
191
189
|
}
|
|
192
|
-
const keyNode =
|
|
190
|
+
const keyNode =
|
|
191
|
+
/** @type {typeof propName | { type: "Computed", expression: Expression }} */ (
|
|
192
|
+
propName
|
|
193
|
+
);
|
|
193
194
|
if (
|
|
194
195
|
typeof keyNode === "object" &&
|
|
195
196
|
keyNode !== null &&
|
|
@@ -197,10 +198,7 @@ const staticImportMetaGlobQueryKeyFromPropName = (propName, parser) => {
|
|
|
197
198
|
keyNode.type === "Computed" &&
|
|
198
199
|
"expression" in keyNode
|
|
199
200
|
) {
|
|
200
|
-
return staticImportMetaGlobQueryKeyFromExpr(
|
|
201
|
-
/** @type {Expression} */ (keyNode.expression),
|
|
202
|
-
parser
|
|
203
|
-
);
|
|
201
|
+
return staticImportMetaGlobQueryKeyFromExpr(keyNode.expression, parser);
|
|
204
202
|
}
|
|
205
203
|
};
|
|
206
204
|
|
|
@@ -551,7 +549,7 @@ const parseImportMetaGlobCall = (expr, parser) => {
|
|
|
551
549
|
}
|
|
552
550
|
|
|
553
551
|
const rawGlobPatterns = parseStaticGlobPatternsFromExpr(
|
|
554
|
-
|
|
552
|
+
directoryNode,
|
|
555
553
|
parser,
|
|
556
554
|
warnings
|
|
557
555
|
);
|
|
@@ -605,7 +603,7 @@ const parseImportMetaGlobCall = (expr, parser) => {
|
|
|
605
603
|
const compilerContext = parser.state.compilation.compiler.context;
|
|
606
604
|
const globOptions =
|
|
607
605
|
optionsNode && optionsNode.type === "ObjectExpression"
|
|
608
|
-
?
|
|
606
|
+
? optionsNode
|
|
609
607
|
: undefined;
|
|
610
608
|
const { eager, importName, query, base, exhaustive, caseSensitive } =
|
|
611
609
|
parseImportMetaGlobOptionsObject(globOptions, parser, warnings);
|
|
@@ -127,12 +127,15 @@ CachedConstDependency.Template = class CachedConstDependencyTemplate extends (
|
|
|
127
127
|
? initFragments
|
|
128
128
|
: chunkInitFragments
|
|
129
129
|
).push(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
InitFragment
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
// Its content is fixed, so it fits either list's render context.
|
|
131
|
+
/** @type {DependencyTemplateContext["initFragments"][number] & DependencyTemplateContext["chunkInitFragments"][number]} */ (
|
|
132
|
+
new InitFragment(
|
|
133
|
+
`var ${dep.identifier} = ${dep.expression};\n`,
|
|
134
|
+
InitFragment.STAGE_CONSTANTS,
|
|
135
|
+
// For a chunk we inject expression after imports
|
|
136
|
+
dep.place === CachedConstDependency.PLACE_MODULE ? 0 : 10,
|
|
137
|
+
`const ${dep.identifier}`
|
|
138
|
+
)
|
|
136
139
|
)
|
|
137
140
|
);
|
|
138
141
|
|
|
@@ -141,8 +141,7 @@ const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
|
|
|
141
141
|
/** @type {CssGeneratorLocalIdentName} */
|
|
142
142
|
(generator.options.localIdentName);
|
|
143
143
|
const relativeResourcePath = makePathsRelative(
|
|
144
|
-
|
|
145
|
-
(runtimeTemplate.compilation.compiler.context),
|
|
144
|
+
runtimeTemplate.compilation.compiler.context,
|
|
146
145
|
/** @type {string} */
|
|
147
146
|
(module.getResource()),
|
|
148
147
|
runtimeTemplate.compilation.compiler.root
|
|
@@ -197,8 +196,8 @@ const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
|
|
|
197
196
|
|
|
198
197
|
contentHash = digestNonNumericOnly(
|
|
199
198
|
hash,
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
runtimeTemplate.outputOptions.hashDigest,
|
|
200
|
+
runtimeTemplate.outputOptions.hashDigestLength
|
|
202
201
|
);
|
|
203
202
|
}
|
|
204
203
|
|
|
@@ -651,7 +650,7 @@ const EMPTY_INDEX = new Map();
|
|
|
651
650
|
* type (CSS and JS), so this survives both passes — the index is built once per
|
|
652
651
|
* build instead of once per `apply`. Weakly held, so it never keeps a module
|
|
653
652
|
* alive.
|
|
654
|
-
* @type {WeakMap<CssModule, { buildInfo:
|
|
653
|
+
* @type {WeakMap<CssModule, { buildInfo: CssModule["buildInfo"], index: Map<string, CssIcssImportDependency[]> }>}
|
|
655
654
|
*/
|
|
656
655
|
const moduleImportIndexes = new WeakMap();
|
|
657
656
|
|
|
@@ -1022,7 +1021,7 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
1022
1021
|
} else {
|
|
1023
1022
|
references.push(
|
|
1024
1023
|
CssIcssExportDependencyTemplate.getIdentifier(
|
|
1025
|
-
|
|
1024
|
+
entry.value,
|
|
1026
1025
|
entry,
|
|
1027
1026
|
templateContext
|
|
1028
1027
|
)
|
|
@@ -1031,7 +1030,7 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
1031
1030
|
const matches = getExportIndex(
|
|
1032
1031
|
cache,
|
|
1033
1032
|
/** @type {CssModule} */ (templateContext.module)
|
|
1034
|
-
).get(
|
|
1033
|
+
).get(entry.value);
|
|
1035
1034
|
if (matches) {
|
|
1036
1035
|
for (const d of matches) {
|
|
1037
1036
|
if (d.exportMode === EXPORT_MODE.NONE) continue;
|
|
@@ -107,9 +107,7 @@ class CssIcssImportDependency extends CssImportDependency {
|
|
|
107
107
|
/** @type {CssGenerator | undefined} */
|
|
108
108
|
(module.generator);
|
|
109
109
|
const convention =
|
|
110
|
-
generator &&
|
|
111
|
-
/** @type {CssGeneratorExportsConvention | undefined} */
|
|
112
|
-
(generator.options && generator.options.exportsConvention);
|
|
110
|
+
generator && generator.options && generator.options.exportsConvention;
|
|
113
111
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
|
114
112
|
const names = convention
|
|
115
113
|
? this.getImportNameConventionNames(convention)
|
|
@@ -94,7 +94,7 @@ class CssUrlDependency extends ModuleDependency {
|
|
|
94
94
|
module.buildInfo
|
|
95
95
|
);
|
|
96
96
|
if (buildInfo && buildInfo.hash) {
|
|
97
|
-
hash.update(
|
|
97
|
+
hash.update(buildInfo.hash);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -231,11 +231,7 @@ CssUrlDependency.Template = class CssUrlDependencyTemplate extends (
|
|
|
231
231
|
break;
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
source.replace(
|
|
235
|
-
dep.range[0],
|
|
236
|
-
dep.range[1] - 1,
|
|
237
|
-
/** @type {string} */ (newValue)
|
|
238
|
-
);
|
|
234
|
+
source.replace(dep.range[0], dep.range[1] - 1, newValue);
|
|
239
235
|
}
|
|
240
236
|
|
|
241
237
|
/**
|
|
@@ -23,7 +23,6 @@ const getEnvironmentNotSupportAsyncWarning = memoize(() =>
|
|
|
23
23
|
require("../../errors/EnvironmentNotSupportAsyncWarning")
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
/** @import { BuildInfo, BuildMeta } from "../../module/Module" */
|
|
27
26
|
/** @import JavascriptParser, { Range } from "../../javascript/JavascriptParser" */
|
|
28
27
|
|
|
29
28
|
const PLUGIN_NAME = "ESMDetectionParserPlugin";
|
|
@@ -82,9 +81,8 @@ module.exports = class ESMDetectionParserPlugin {
|
|
|
82
81
|
parser.hooks.topLevelAwait.tap(PLUGIN_NAME, (node) => {
|
|
83
82
|
const module = parser.state.module;
|
|
84
83
|
enableHarmony(false);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const buildInfo = /** @type {BuildInfo} */ (module.buildInfo);
|
|
84
|
+
module.buildMeta.async = true;
|
|
85
|
+
const buildInfo = module.buildInfo;
|
|
88
86
|
if (node.type === "AwaitExpression") {
|
|
89
87
|
// Record for a possible `await` -> `(yield …)` rewrite when the module
|
|
90
88
|
// is lowered to a generator (target without `async`/`await`).
|
|
@@ -30,8 +30,8 @@ const DEFAULT_EXPORT_NAME = "default";
|
|
|
30
30
|
/** @import { InlinedValue } from "../../optimize/InlineExports" */
|
|
31
31
|
/** @import { Range } from "../../javascript/JavascriptParser" */
|
|
32
32
|
/** @typedef {string | { id?: string | undefined, range: Range, prefix: string, suffix: string }} DeclarationId */
|
|
33
|
-
/** @typedef {import("../../serialization/ObjectMiddleware").ObjectDeserializerContext<[Range, Range, string, DeclarationId | undefined, boolean, boolean]>} ObjectDeserializerContext */
|
|
34
|
-
/** @typedef {import("../../serialization/ObjectMiddleware").ObjectSerializerContext<[Range, Range, string, DeclarationId | undefined, boolean, boolean]>} ObjectSerializerContext */
|
|
33
|
+
/** @typedef {import("../../serialization/ObjectMiddleware").ObjectDeserializerContext<[Range, Range, string, DeclarationId | undefined, boolean, boolean, InlinedValue | undefined]>} ObjectDeserializerContext */
|
|
34
|
+
/** @typedef {import("../../serialization/ObjectMiddleware").ObjectSerializerContext<[Range, Range, string, DeclarationId | undefined, boolean, boolean, InlinedValue | undefined]>} ObjectSerializerContext */
|
|
35
35
|
/** @import { ExportMap } from "./ESMExportInitFragment" */
|
|
36
36
|
/**
|
|
37
37
|
* @import {
|
|
@@ -14,6 +14,7 @@ const {
|
|
|
14
14
|
isInlineExportsEnabled,
|
|
15
15
|
isInlinedUsedName
|
|
16
16
|
} = require("../../optimize/InlineExports");
|
|
17
|
+
const LazyBarrels = require("../../optimize/LazyBarrels");
|
|
17
18
|
const {
|
|
18
19
|
getKnownExportNames,
|
|
19
20
|
getMakeDeferredNamespaceModeFromExportsType
|
|
@@ -899,9 +900,7 @@ class ESMExportImportedSpecifierDependency extends ESMImportDependency {
|
|
|
899
900
|
runtime,
|
|
900
901
|
referencedExports,
|
|
901
902
|
[],
|
|
902
|
-
|
|
903
|
-
mode.partialNamespaceExportInfo
|
|
904
|
-
)
|
|
903
|
+
mode.partialNamespaceExportInfo
|
|
905
904
|
);
|
|
906
905
|
return referencedExports;
|
|
907
906
|
}
|
|
@@ -917,9 +916,7 @@ class ESMExportImportedSpecifierDependency extends ESMImportDependency {
|
|
|
917
916
|
runtime,
|
|
918
917
|
referencedExports,
|
|
919
918
|
[],
|
|
920
|
-
|
|
921
|
-
mode.partialNamespaceExportInfo
|
|
922
|
-
),
|
|
919
|
+
mode.partialNamespaceExportInfo,
|
|
923
920
|
mode.type === "reexport-fake-namespace-object"
|
|
924
921
|
);
|
|
925
922
|
return referencedExports;
|
|
@@ -1387,6 +1384,11 @@ ESMExportImportedSpecifierDependency.Template = class ESMExportImportedSpecifier
|
|
|
1387
1384
|
|
|
1388
1385
|
const mode = dep.getMode(moduleGraph, runtime);
|
|
1389
1386
|
|
|
1387
|
+
// deferred by lazy barrel: never resolved, renders nothing
|
|
1388
|
+
if (mode.type === "missing" && LazyBarrels.isLazy(moduleGraph, dep)) {
|
|
1389
|
+
return;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1390
1392
|
// a wrapped module has no shared-scope symbols to redirect reexports to
|
|
1391
1393
|
if (concatenationScope && !concatenationScope.isWrapped()) {
|
|
1392
1394
|
switch (mode.type) {
|
|
@@ -1457,15 +1459,13 @@ ESMExportImportedSpecifierDependency.Template = class ESMExportImportedSpecifier
|
|
|
1457
1459
|
concatenationScope !== undefined &&
|
|
1458
1460
|
concatenationScope.isModuleInScope(importedModule);
|
|
1459
1461
|
const importVar = inScope
|
|
1460
|
-
?
|
|
1461
|
-
|
|
1462
|
-
|
|
1462
|
+
? concatenationScope.createModuleReference(importedModule, {
|
|
1463
|
+
asiSafe: true
|
|
1464
|
+
})
|
|
1463
1465
|
: dep.getImportVar(moduleGraph);
|
|
1464
1466
|
|
|
1465
1467
|
const defaultImportVar = inScope
|
|
1466
|
-
?
|
|
1467
|
-
concatenationScope
|
|
1468
|
-
).createModuleReference(importedModule, {
|
|
1468
|
+
? concatenationScope.createModuleReference(importedModule, {
|
|
1469
1469
|
ids: ["default"],
|
|
1470
1470
|
asiSafe: true
|
|
1471
1471
|
})
|
|
@@ -1473,9 +1473,7 @@ ESMExportImportedSpecifierDependency.Template = class ESMExportImportedSpecifier
|
|
|
1473
1473
|
|
|
1474
1474
|
// whole-namespace modes need the original export names, not mangled ones
|
|
1475
1475
|
const namespaceImportVar = inScope
|
|
1476
|
-
?
|
|
1477
|
-
concatenationScope
|
|
1478
|
-
).createModuleReference(importedModule, {
|
|
1476
|
+
? concatenationScope.createModuleReference(importedModule, {
|
|
1479
1477
|
asiSafe: true,
|
|
1480
1478
|
mangleableNamespace: true
|
|
1481
1479
|
})
|
|
@@ -1560,9 +1558,9 @@ ESMExportImportedSpecifierDependency.Template = class ESMExportImportedSpecifier
|
|
|
1560
1558
|
moduleGraph
|
|
1561
1559
|
.getExportsInfo(module)
|
|
1562
1560
|
.getUsedName(/** @type {string} */ (mode.name), runtime),
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1561
|
+
concatenationScope.createModuleReference(importedModule, {
|
|
1562
|
+
asiSafe: true
|
|
1563
|
+
}),
|
|
1566
1564
|
"",
|
|
1567
1565
|
runtimeRequirements
|
|
1568
1566
|
)
|
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
const Dependency = require("../../graph/Dependency");
|
|
9
9
|
const { isInlinedUsedName } = require("../../optimize/InlineExports");
|
|
10
10
|
const makeSerializable = require("../../util/makeSerializable");
|
|
11
|
+
const { getRuntimeKey } = require("../../util/runtime");
|
|
11
12
|
const NullDependency = require("../core/NullDependency");
|
|
12
13
|
const ESMExportInitFragment = require("./ESMExportInitFragment");
|
|
13
14
|
|
|
14
15
|
const { ExportBindingType } = ESMExportInitFragment;
|
|
15
16
|
|
|
16
17
|
/** @import { ReplaceSource } from "webpack-sources" */
|
|
17
|
-
/** @import { ExportsSpec, LazyRole, UpdateHashContext } from "../../graph/Dependency" */
|
|
18
|
+
/** @import { DependencyKinds, ExportsSpec, LazyRole, UpdateHashContext } from "../../graph/Dependency" */
|
|
18
19
|
/** @import Module, { BuildInfo } from "../../module/Module" */
|
|
19
20
|
/** @import Hash from "../../util/Hash" */
|
|
20
21
|
/** @import { DependencyTemplateContext } from "../../template/DependencyTemplate" */
|
|
@@ -204,12 +205,22 @@ ESMExportSpecifierDependency.Template = class ESMExportSpecifierDependencyTempla
|
|
|
204
205
|
meta !== undefined &&
|
|
205
206
|
meta.onDemandExports === true;
|
|
206
207
|
|
|
208
|
+
// a module library may have moved the binding to the chunk's scope
|
|
209
|
+
const live =
|
|
210
|
+
meta !== undefined && meta.liveBindings !== undefined
|
|
211
|
+
? meta.liveBindings.get(dep.id)
|
|
212
|
+
: undefined;
|
|
213
|
+
const local =
|
|
214
|
+
live !== undefined && live.runtimes.has(getRuntimeKey(runtime))
|
|
215
|
+
? live.name
|
|
216
|
+
: dep.id;
|
|
217
|
+
|
|
207
218
|
/** @type {ExportMap} */
|
|
208
219
|
const map = new Map();
|
|
209
220
|
map.set(used, {
|
|
210
|
-
value: `/* binding */ ${
|
|
221
|
+
value: `/* binding */ ${local}`,
|
|
211
222
|
type: valueFormat ? ExportBindingType.Value : ExportBindingType.Getter,
|
|
212
|
-
finalName:
|
|
223
|
+
finalName: local
|
|
213
224
|
});
|
|
214
225
|
initFragments.push(
|
|
215
226
|
new ESMExportInitFragment(
|
|
@@ -222,4 +233,10 @@ ESMExportSpecifierDependency.Template = class ESMExportSpecifierDependencyTempla
|
|
|
222
233
|
}
|
|
223
234
|
};
|
|
224
235
|
|
|
236
|
+
/** @type {Set<keyof DependencyKinds>} */
|
|
237
|
+
ESMExportSpecifierDependency.KINDS = new Set([
|
|
238
|
+
...NullDependency.KINDS,
|
|
239
|
+
"esm-export-specifier"
|
|
240
|
+
]);
|
|
241
|
+
|
|
225
242
|
module.exports = ESMExportSpecifierDependency;
|
|
@@ -7,12 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
const RuntimeGlobals = require("../../runtime/RuntimeGlobals");
|
|
9
9
|
|
|
10
|
-
/** @import { BuildInfo } from "../../module/Module" */
|
|
11
|
-
/**
|
|
12
|
-
* @import {
|
|
13
|
-
* JavascriptModuleBuildMeta
|
|
14
|
-
* } from "../../javascript/JavascriptModule"
|
|
15
|
-
*/
|
|
16
10
|
/** @import { JavascriptParserState } from "../../javascript/JavascriptParser" */
|
|
17
11
|
|
|
18
12
|
/** @type {WeakMap<JavascriptParserState, boolean>} */
|
|
@@ -29,11 +23,9 @@ module.exports.enable = (parserState, isStrictHarmony) => {
|
|
|
29
23
|
if (value === false) return;
|
|
30
24
|
parserStateExportsState.set(parserState, true);
|
|
31
25
|
if (value !== true) {
|
|
32
|
-
const buildMeta =
|
|
33
|
-
/** @type {JavascriptModuleBuildMeta} */
|
|
34
|
-
(parserState.module.buildMeta);
|
|
26
|
+
const buildMeta = parserState.module.buildMeta;
|
|
35
27
|
buildMeta.exportsType = "namespace";
|
|
36
|
-
const buildInfo =
|
|
28
|
+
const buildInfo = parserState.module.buildInfo;
|
|
37
29
|
buildInfo.strict = true;
|
|
38
30
|
buildInfo.exportsArgument = RuntimeGlobals.exports;
|
|
39
31
|
if (isStrictHarmony) {
|
|
@@ -23,7 +23,7 @@ const ModuleDependency = require("../core/ModuleDependency");
|
|
|
23
23
|
* JavascriptParserOptions
|
|
24
24
|
* } from "../../../declarations/WebpackOptions"
|
|
25
25
|
*/
|
|
26
|
-
/** @import { ReferencedExports, DependencyKinds, LazyRole } from "../../graph/Dependency" */
|
|
26
|
+
/** @import { ReferencedExports, DependencyKinds, LazyRole, UpdateHashContext } from "../../graph/Dependency" */
|
|
27
27
|
/** @import { DependencyTemplateContext } from "../../template/DependencyTemplate" */
|
|
28
28
|
/** @import ExportsInfo from "../../graph/ExportsInfo" */
|
|
29
29
|
/** @import Module, { BuildMeta } from "../../module/Module" */
|
|
@@ -37,6 +37,7 @@ const ModuleDependency = require("../core/ModuleDependency");
|
|
|
37
37
|
* ObjectSerializerContext
|
|
38
38
|
* } from "../../serialization/ObjectMiddleware"
|
|
39
39
|
*/
|
|
40
|
+
/** @import Hash from "../../util/Hash" */
|
|
40
41
|
/** @import { RuntimeSpec } from "../../util/runtime" */
|
|
41
42
|
|
|
42
43
|
/** @typedef {0 | 1 | 2 | 3} ExportPresenceMode */
|
|
@@ -146,6 +147,20 @@ class ESMImportDependency extends ModuleDependency {
|
|
|
146
147
|
return "esm";
|
|
147
148
|
}
|
|
148
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Updates the hash with the data contributed by this instance.
|
|
152
|
+
* @param {Hash} hash hash to be updated
|
|
153
|
+
* @param {UpdateHashContext} context context
|
|
154
|
+
* @returns {void}
|
|
155
|
+
*/
|
|
156
|
+
updateHash(hash, context) {
|
|
157
|
+
// neither a deferred nor a missing target has a connection, yet only a
|
|
158
|
+
// missing one renders a throw
|
|
159
|
+
if (LazyBarrels.isLazy(context.chunkGraph.moduleGraph, this)) {
|
|
160
|
+
hash.update("lazy");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
149
164
|
/**
|
|
150
165
|
* Returns how this dependency may be deferred when its parent module is side-effect-free (lazy barrel optimization).
|
|
151
166
|
* @returns {LazyRole | null} lazy classification, null when it must be processed eagerly
|
|
@@ -522,7 +537,7 @@ ESMImportDependency.Template = class ESMImportDependencyTemplate extends (
|
|
|
522
537
|
// When the consuming module is emitted as a generator (target without
|
|
523
538
|
// `async`/`await`), the dependency `await` must become `yield`.
|
|
524
539
|
const generatorLowered = isGeneratorLowered(
|
|
525
|
-
|
|
540
|
+
module,
|
|
526
541
|
moduleGraph,
|
|
527
542
|
templateContext.runtimeTemplate
|
|
528
543
|
);
|
|
@@ -50,7 +50,6 @@ const ESMImportSpecifierDependency = require("./ESMImportSpecifierDependency");
|
|
|
50
50
|
* } from "../../../declarations/WebpackOptions"
|
|
51
51
|
*/
|
|
52
52
|
/** @import Module from "../../module/Module" */
|
|
53
|
-
/** @import { JavascriptModuleBuildInfo } from "../../javascript/JavascriptModule" */
|
|
54
53
|
/**
|
|
55
54
|
* @import JavascriptParser, {
|
|
56
55
|
* ImportAttributes,
|
|
@@ -155,14 +154,11 @@ const findImportSpecifier = (parser, node) => {
|
|
|
155
154
|
(parser.getTagData(node.name, harmonySpecifierTag))
|
|
156
155
|
);
|
|
157
156
|
case "UnaryExpression":
|
|
158
|
-
return findImportSpecifier(
|
|
159
|
-
parser,
|
|
160
|
-
/** @type {Expression} */ (node.argument)
|
|
161
|
-
);
|
|
157
|
+
return findImportSpecifier(parser, node.argument);
|
|
162
158
|
case "LogicalExpression":
|
|
163
159
|
return (
|
|
164
|
-
findImportSpecifier(parser,
|
|
165
|
-
findImportSpecifier(parser,
|
|
160
|
+
findImportSpecifier(parser, node.left) ||
|
|
161
|
+
findImportSpecifier(parser, node.right)
|
|
166
162
|
);
|
|
167
163
|
case "MemberExpression":
|
|
168
164
|
return findImportSpecifier(
|
|
@@ -171,10 +167,7 @@ const findImportSpecifier = (parser, node) => {
|
|
|
171
167
|
);
|
|
172
168
|
case "BinaryExpression":
|
|
173
169
|
// `"x" in ns` presence guard
|
|
174
|
-
return (
|
|
175
|
-
node.operator === "in" &&
|
|
176
|
-
findImportSpecifier(parser, /** @type {Expression} */ (node.right))
|
|
177
|
-
);
|
|
170
|
+
return node.operator === "in" && findImportSpecifier(parser, node.right);
|
|
178
171
|
default:
|
|
179
172
|
return false;
|
|
180
173
|
}
|
|
@@ -444,8 +437,7 @@ class ESMImportDependencyParserPlugin {
|
|
|
444
437
|
* @returns {void}
|
|
445
438
|
*/
|
|
446
439
|
const bailOutOfConcatenation = () => {
|
|
447
|
-
|
|
448
|
-
(parser.state.module.buildInfo).moduleConcatenationBailout =
|
|
440
|
+
parser.state.module.buildInfo.moduleConcatenationBailout =
|
|
449
441
|
"assignment to an imported binding";
|
|
450
442
|
};
|
|
451
443
|
|
|
@@ -483,10 +475,7 @@ class ESMImportDependencyParserPlugin {
|
|
|
483
475
|
});
|
|
484
476
|
parser.hooks.write.for(harmonySpecifierTag).tap(PLUGIN_NAME, (node) => {
|
|
485
477
|
const written = writeTargetOf(node);
|
|
486
|
-
const target =
|
|
487
|
-
written.type === "Identifier"
|
|
488
|
-
? /** @type {Identifier} */ (written)
|
|
489
|
-
: undefined;
|
|
478
|
+
const target = written.type === "Identifier" ? written : undefined;
|
|
490
479
|
markImportedBindingWrite(node, target);
|
|
491
480
|
// A loop's binding walks nothing on its own, so the reference the
|
|
492
481
|
// write renders as has to be walked here to exist at all.
|
|
@@ -74,7 +74,7 @@ const buildLivenessFormula = (test, depByRangeStart) => {
|
|
|
74
74
|
*/
|
|
75
75
|
const build = (node) => {
|
|
76
76
|
if (node.type === "UnaryExpression" && node.operator === "!") {
|
|
77
|
-
return ["!", build(
|
|
77
|
+
return ["!", build(node.argument)];
|
|
78
78
|
}
|
|
79
79
|
if (
|
|
80
80
|
node.type === "LogicalExpression" &&
|
|
@@ -82,14 +82,9 @@ const buildLivenessFormula = (test, depByRangeStart) => {
|
|
|
82
82
|
node.operator === "||" ||
|
|
83
83
|
node.operator === "??")
|
|
84
84
|
) {
|
|
85
|
-
return [
|
|
86
|
-
node.operator,
|
|
87
|
-
build(/** @type {Expression} */ (node.left)),
|
|
88
|
-
build(/** @type {Expression} */ (node.right))
|
|
89
|
-
];
|
|
85
|
+
return [node.operator, build(node.left), build(node.right)];
|
|
90
86
|
}
|
|
91
|
-
const dep =
|
|
92
|
-
node.range && depByRangeStart.get(/** @type {number} */ (node.range[0]));
|
|
87
|
+
const dep = node.range && depByRangeStart.get(node.range[0]);
|
|
93
88
|
return dep ? ["v", dep] : ["?"];
|
|
94
89
|
};
|
|
95
90
|
|
|
@@ -243,23 +238,19 @@ const buildPresenceFormula = (parser, test, depByRangeStart) => {
|
|
|
243
238
|
*/
|
|
244
239
|
const build = (node) => {
|
|
245
240
|
if (node.type === "UnaryExpression" && node.operator === "!") {
|
|
246
|
-
return ["!", build(
|
|
241
|
+
return ["!", build(node.argument)];
|
|
247
242
|
}
|
|
248
243
|
if (node.type === "LogicalExpression") {
|
|
249
244
|
if (node.operator === "&&") {
|
|
250
|
-
return [
|
|
251
|
-
"&&",
|
|
252
|
-
build(/** @type {Expression} */ (node.left)),
|
|
253
|
-
build(/** @type {Expression} */ (node.right))
|
|
254
|
-
];
|
|
245
|
+
return ["&&", build(node.left), build(node.right)];
|
|
255
246
|
}
|
|
256
247
|
|
|
257
248
|
if (node.operator === "||") {
|
|
258
249
|
if (parser.evaluateExpression(node.left).asBool() === false) {
|
|
259
|
-
return build(
|
|
250
|
+
return build(node.right);
|
|
260
251
|
}
|
|
261
252
|
if (parser.evaluateExpression(node.right).asBool() === false) {
|
|
262
|
-
return build(
|
|
253
|
+
return build(node.left);
|
|
263
254
|
}
|
|
264
255
|
return ["?"];
|
|
265
256
|
}
|
|
@@ -267,16 +258,15 @@ const buildPresenceFormula = (parser, test, depByRangeStart) => {
|
|
|
267
258
|
if (node.operator === "??") {
|
|
268
259
|
const nullish = parser.evaluateExpression(node.left).asNullish();
|
|
269
260
|
if (nullish === true) {
|
|
270
|
-
return build(
|
|
261
|
+
return build(node.right);
|
|
271
262
|
}
|
|
272
263
|
if (nullish === false) {
|
|
273
|
-
return build(
|
|
264
|
+
return build(node.left);
|
|
274
265
|
}
|
|
275
266
|
return ["?"];
|
|
276
267
|
}
|
|
277
268
|
}
|
|
278
|
-
const dep =
|
|
279
|
-
node.range && depByRangeStart.get(/** @type {number} */ (node.range[0]));
|
|
269
|
+
const dep = node.range && depByRangeStart.get(node.range[0]);
|
|
280
270
|
return dep ? ["p", dep] : ["?"];
|
|
281
271
|
};
|
|
282
272
|
|
|
@@ -298,9 +288,7 @@ const buildPresenceFormula = (parser, test, depByRangeStart) => {
|
|
|
298
288
|
const evalPresenceFormula = (formula, name, member, needTruthy) => {
|
|
299
289
|
switch (formula[0]) {
|
|
300
290
|
case "p": {
|
|
301
|
-
const dep =
|
|
302
|
-
formula[1]
|
|
303
|
-
);
|
|
291
|
+
const dep = formula[1];
|
|
304
292
|
return (
|
|
305
293
|
needTruthy &&
|
|
306
294
|
dep.directImport === true &&
|
|
@@ -279,7 +279,7 @@ ESMImportSideEffectDependency.Template = class ESMImportSideEffectDependencyTemp
|
|
|
279
279
|
const exportsType = importedModule.getExportsType(
|
|
280
280
|
moduleGraph,
|
|
281
281
|
/** @type {JavascriptModuleBuildMeta} */
|
|
282
|
-
(
|
|
282
|
+
(module.buildMeta).strictHarmonyModule
|
|
283
283
|
);
|
|
284
284
|
if (exportsType !== "namespace") return;
|
|
285
285
|
const importVar = dep.getImportVar(moduleGraph);
|
|
@@ -169,7 +169,10 @@ class ESMImportSpecifierDependency extends ESMImportDependency {
|
|
|
169
169
|
* @returns {string | true | null} export name, true for all exports, null for none
|
|
170
170
|
*/
|
|
171
171
|
get forwardId() {
|
|
172
|
-
|
|
172
|
+
// SideEffectsFlagPlugin keeps a call with the namespace as `this` on the
|
|
173
|
+
// barrel, so the barrel runs whole
|
|
174
|
+
if (this.ids.length === 0 || this.namespaceObjectAsContext) return true;
|
|
175
|
+
return this.ids[0];
|
|
173
176
|
}
|
|
174
177
|
|
|
175
178
|
/**
|