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
|
@@ -36,7 +36,6 @@ const {
|
|
|
36
36
|
/** @import ExportsInfo, { ExportInfo } from "../../graph/ExportsInfo" */
|
|
37
37
|
/** @import Module from "../../module/Module" */
|
|
38
38
|
/** @import ModuleGraph from "../../graph/ModuleGraph" */
|
|
39
|
-
/** @import ModuleGraphConnection from "../../graph/ModuleGraphConnection" */
|
|
40
39
|
/** @import { Range } from "../../javascript/JavascriptParser" */
|
|
41
40
|
/** @import { RuntimeSpec } from "../../util/runtime" */
|
|
42
41
|
/** @import CommonJsRequireDependency from "./CommonJsRequireDependency" */
|
|
@@ -576,9 +575,7 @@ CommonJsExportRequireDependency.Template = class CommonJsExportRequireDependency
|
|
|
576
575
|
moduleGraph.getExportsInfo(module).getUsedName(dep.names, runtime)
|
|
577
576
|
);
|
|
578
577
|
|
|
579
|
-
const connection =
|
|
580
|
-
moduleGraph.getConnection(dep)
|
|
581
|
-
);
|
|
578
|
+
const connection = moduleGraph.getConnection(dep);
|
|
582
579
|
// Inactive unused reexport: no module id; drop to a no-op.
|
|
583
580
|
// Missing connection (e.g. IgnorePlugin) must keep the require so it throws.
|
|
584
581
|
if (!used && connection && !connection.isTargetActive(runtime)) {
|
|
@@ -52,7 +52,6 @@ const FUNCTION_PROPERTY_DROP_HEAD =
|
|
|
52
52
|
*/
|
|
53
53
|
/** @import CommonJsRequireDependency from "./CommonJsRequireDependency" */
|
|
54
54
|
/** @import { ExportInfoName } from "../../graph/Dependency" */
|
|
55
|
-
/** @import { BuildInfo } from "../../module/Module" */
|
|
56
55
|
|
|
57
56
|
/**
|
|
58
57
|
* @import JavascriptParser, {
|
|
@@ -72,11 +71,6 @@ const FUNCTION_PROPERTY_DROP_HEAD =
|
|
|
72
71
|
* } from "./CommonJsObjectExportDependency"
|
|
73
72
|
*/
|
|
74
73
|
/** @import { RequireBindingData } from "./CommonJsImportsParserPlugin" */
|
|
75
|
-
/**
|
|
76
|
-
* @import {
|
|
77
|
-
* JavascriptModuleBuildMeta
|
|
78
|
-
* } from "../../javascript/JavascriptModule"
|
|
79
|
-
*/
|
|
80
74
|
|
|
81
75
|
/**
|
|
82
76
|
* This function takes a generic expression and detects whether it is an ObjectExpression.
|
|
@@ -165,7 +159,7 @@ const getReexportOfPropertyDescriptor = (expr) => {
|
|
|
165
159
|
if (getFn.async || getFn.generator) return;
|
|
166
160
|
// Arrow with expression body: `() => require("./x")`.
|
|
167
161
|
if (getFn.body.type !== "BlockStatement") {
|
|
168
|
-
return { expr:
|
|
162
|
+
return { expr: getFn.body, getter: true };
|
|
169
163
|
}
|
|
170
164
|
// Function body must be exactly `return <expr>;`.
|
|
171
165
|
if (
|
|
@@ -264,15 +258,18 @@ const parseRequireCall = (parser, expr) => {
|
|
|
264
258
|
};
|
|
265
259
|
};
|
|
266
260
|
|
|
261
|
+
/** @typedef {Node extends infer N ? (N extends Node ? N[keyof N] : never) : never} NodeFieldValue */
|
|
262
|
+
|
|
267
263
|
/**
|
|
268
264
|
* Checks if a value is an AST node.
|
|
269
|
-
* @
|
|
270
|
-
* @
|
|
265
|
+
* @template V
|
|
266
|
+
* @param {V} value candidate
|
|
267
|
+
* @returns {value is Extract<V, Node>} true when the value is an AST node
|
|
271
268
|
*/
|
|
272
269
|
const isNode = (value) =>
|
|
273
270
|
typeof value === "object" &&
|
|
274
271
|
value !== null &&
|
|
275
|
-
typeof (/** @type {
|
|
272
|
+
typeof (/** @type {Partial<Node>} */ (value).type) === "string";
|
|
276
273
|
|
|
277
274
|
/** Positional/metadata keys that never hold child AST nodes. */
|
|
278
275
|
const NON_CHILD_KEYS = new Set([
|
|
@@ -337,8 +334,8 @@ const findOwnThisExpression = (body, params) => {
|
|
|
337
334
|
break;
|
|
338
335
|
default: {
|
|
339
336
|
const children =
|
|
340
|
-
/** @type {Record<string,
|
|
341
|
-
(
|
|
337
|
+
/** @type {Node & Record<string, NodeFieldValue>} */
|
|
338
|
+
(node);
|
|
342
339
|
const keys = getChildKeys(node);
|
|
343
340
|
for (let i = 0; i < keys.length; i++) {
|
|
344
341
|
const value = children[keys[i]];
|
|
@@ -462,11 +459,11 @@ class CommonJsExportsParserPlugin {
|
|
|
462
459
|
*/
|
|
463
460
|
const bailoutHint = (reason) => {
|
|
464
461
|
recordOptimizationBailout(
|
|
465
|
-
|
|
462
|
+
parser.state.module.buildInfo,
|
|
466
463
|
`CommonJS bailout: ${reason}`
|
|
467
464
|
);
|
|
468
465
|
};
|
|
469
|
-
/** @type {
|
|
466
|
+
/** @type {JavascriptParser["state"] | undefined} */
|
|
470
467
|
let keptAllExportsForState;
|
|
471
468
|
/**
|
|
472
469
|
* An exported function accessing its own `this` may reach any export
|
|
@@ -547,9 +544,7 @@ class CommonJsExportsParserPlugin {
|
|
|
547
544
|
dep.loc = parser.getLocation(expr);
|
|
548
545
|
dep.optional = Boolean(parser.scope.inTry);
|
|
549
546
|
parser.state.module.addDependency(dep);
|
|
550
|
-
|
|
551
|
-
parser.state.module.buildMeta
|
|
552
|
-
).treatAsCommonJs = true;
|
|
547
|
+
parser.state.module.buildMeta.treatAsCommonJs = true;
|
|
553
548
|
|
|
554
549
|
return true;
|
|
555
550
|
}
|
|
@@ -574,9 +569,7 @@ class CommonJsExportsParserPlugin {
|
|
|
574
569
|
);
|
|
575
570
|
dep.loc = parser.getLocation(expr);
|
|
576
571
|
parser.state.module.addDependency(dep);
|
|
577
|
-
|
|
578
|
-
parser.state.module.buildMeta
|
|
579
|
-
).treatAsCommonJs = true;
|
|
572
|
+
parser.state.module.buildMeta.treatAsCommonJs = true;
|
|
580
573
|
keepAllExportsOnThisAccess(expr.right, base);
|
|
581
574
|
parser.walkExpression(expr.right);
|
|
582
575
|
return true;
|
|
@@ -600,9 +593,7 @@ class CommonJsExportsParserPlugin {
|
|
|
600
593
|
if (object.type !== "ObjectExpression") return;
|
|
601
594
|
|
|
602
595
|
const module = parser.state.module;
|
|
603
|
-
|
|
604
|
-
module.buildMeta
|
|
605
|
-
).treatAsCommonJs = true;
|
|
596
|
+
module.buildMeta.treatAsCommonJs = true;
|
|
606
597
|
// LHS stays as the text `module.exports` (moduleArgument is "module"
|
|
607
598
|
// unless a top-level `module` binding shadows it, which prevents this hook).
|
|
608
599
|
module.addPresentationalDependency(
|
|
@@ -697,7 +688,7 @@ class CommonJsExportsParserPlugin {
|
|
|
697
688
|
parser.hooks.call
|
|
698
689
|
.for("Object.defineProperty")
|
|
699
690
|
.tap(PLUGIN_NAME, (expression) => {
|
|
700
|
-
const expr =
|
|
691
|
+
const expr = expression;
|
|
701
692
|
if (!parser.isStatementLevelExpression(expr)) return;
|
|
702
693
|
if (expr.arguments.length !== 3) return;
|
|
703
694
|
if (expr.arguments[0].type === "SpreadElement") return;
|
|
@@ -747,9 +738,7 @@ class CommonJsExportsParserPlugin {
|
|
|
747
738
|
dep.loc = parser.getLocation(expr);
|
|
748
739
|
dep.optional = Boolean(parser.scope.inTry);
|
|
749
740
|
parser.state.module.addDependency(dep);
|
|
750
|
-
|
|
751
|
-
parser.state.module.buildMeta
|
|
752
|
-
).treatAsCommonJs = true;
|
|
741
|
+
parser.state.module.buildMeta.treatAsCommonJs = true;
|
|
753
742
|
|
|
754
743
|
return true;
|
|
755
744
|
}
|
|
@@ -768,9 +757,7 @@ class CommonJsExportsParserPlugin {
|
|
|
768
757
|
);
|
|
769
758
|
dep.loc = parser.getLocation(expr);
|
|
770
759
|
parser.state.module.addDependency(dep);
|
|
771
|
-
|
|
772
|
-
parser.state.module.buildMeta
|
|
773
|
-
).treatAsCommonJs = true;
|
|
760
|
+
parser.state.module.buildMeta.treatAsCommonJs = true;
|
|
774
761
|
|
|
775
762
|
if (descArg.type === "ObjectExpression") {
|
|
776
763
|
// `value`, `get` and `set` descriptor functions are all called
|
|
@@ -824,9 +811,7 @@ class CommonJsExportsParserPlugin {
|
|
|
824
811
|
);
|
|
825
812
|
dep.loc = parser.getLocation(expr);
|
|
826
813
|
parser.state.module.addDependency(dep);
|
|
827
|
-
|
|
828
|
-
parser.state.module.buildMeta
|
|
829
|
-
).treatAsCommonJs = true;
|
|
814
|
+
parser.state.module.buildMeta.treatAsCommonJs = true;
|
|
830
815
|
|
|
831
816
|
if (call) {
|
|
832
817
|
parser.walkExpressions(call.arguments);
|
|
@@ -189,9 +189,7 @@ const createRequireCallHandler = (
|
|
|
189
189
|
parser,
|
|
190
190
|
expr
|
|
191
191
|
);
|
|
192
|
-
const binding =
|
|
193
|
-
requireBindingData &&
|
|
194
|
-
requireBindingData.get(/** @type {CallExpression} */ (expr));
|
|
192
|
+
const binding = requireBindingData && requireBindingData.get(expr);
|
|
195
193
|
if (binding && !referencedExports) {
|
|
196
194
|
// `const NAME = require(LITERAL)` — let later member-access walks
|
|
197
195
|
// on `NAME` populate the dependency's referenced exports.
|
|
@@ -136,10 +136,10 @@ CommonJsObjectExportDependency.Template = class CommonJsObjectExportDependencyTe
|
|
|
136
136
|
if (!used) {
|
|
137
137
|
// Object spread rewrite needs environment.spread.
|
|
138
138
|
if (!runtimeTemplate.supportsSpread()) return;
|
|
139
|
-
const range =
|
|
139
|
+
const range = dep.range;
|
|
140
140
|
if (FUNCTION_PROPERTY_DROP_HEAD.has(dep.kind)) {
|
|
141
141
|
// Keep the function body so nested dependency replaces stay valid.
|
|
142
|
-
const valueRange =
|
|
142
|
+
const valueRange = dep.valueRange;
|
|
143
143
|
source.replace(
|
|
144
144
|
range[0],
|
|
145
145
|
valueRange[0] - 1,
|
|
@@ -153,7 +153,7 @@ CommonJsObjectExportDependency.Template = class CommonJsObjectExportDependencyTe
|
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
155
|
// keyValue: keep the value's side effects in place.
|
|
156
|
-
const valueRange =
|
|
156
|
+
const valueRange = dep.valueRange;
|
|
157
157
|
if (dep.pure) {
|
|
158
158
|
// spreading null adds nothing; the text stays so nested replaces hold
|
|
159
159
|
source.replace(
|
|
@@ -170,7 +170,7 @@ CommonJsObjectExportDependency.Template = class CommonJsObjectExportDependencyTe
|
|
|
170
170
|
}
|
|
171
171
|
if (used === dep.name) return;
|
|
172
172
|
// Rename the key to the mangled export name.
|
|
173
|
-
const keyRange =
|
|
173
|
+
const keyRange = dep.keyRange;
|
|
174
174
|
if (dep.kind === "shorthand") {
|
|
175
175
|
source.replace(
|
|
176
176
|
keyRange[0],
|
|
@@ -42,7 +42,6 @@ const TopLevelThisParserPlugin = require("./TopLevelThisParserPlugin");
|
|
|
42
42
|
*/
|
|
43
43
|
/** @import Compilation from "../../Compilation" */
|
|
44
44
|
/** @import Compiler from "../../Compiler" */
|
|
45
|
-
/** @import { BuildInfo } from "../../module/Module" */
|
|
46
45
|
/** @import Parser from "../../javascript/JavascriptParser" */
|
|
47
46
|
|
|
48
47
|
const PLUGIN_NAME = "CommonJsPlugin";
|
|
@@ -232,8 +231,7 @@ class CommonJsPlugin {
|
|
|
232
231
|
parser.hooks.expression
|
|
233
232
|
.for(RuntimeGlobals.moduleLoaded)
|
|
234
233
|
.tap(PLUGIN_NAME, (expr) => {
|
|
235
|
-
|
|
236
|
-
(parser.state.module.buildInfo).moduleConcatenationBailout =
|
|
234
|
+
parser.state.module.buildInfo.moduleConcatenationBailout =
|
|
237
235
|
RuntimeGlobals.moduleLoaded;
|
|
238
236
|
const dep = new RuntimeRequirementsDependency([
|
|
239
237
|
RuntimeGlobals.moduleLoaded
|
|
@@ -246,8 +244,7 @@ class CommonJsPlugin {
|
|
|
246
244
|
parser.hooks.expression
|
|
247
245
|
.for(RuntimeGlobals.moduleId)
|
|
248
246
|
.tap(PLUGIN_NAME, (expr) => {
|
|
249
|
-
|
|
250
|
-
(parser.state.module.buildInfo).moduleConcatenationBailout =
|
|
247
|
+
parser.state.module.buildInfo.moduleConcatenationBailout =
|
|
251
248
|
RuntimeGlobals.moduleId;
|
|
252
249
|
const dep = new RuntimeRequirementsDependency([
|
|
253
250
|
RuntimeGlobals.moduleId
|
|
@@ -12,6 +12,7 @@ const RequireEnsureItemDependency = require("./RequireEnsureItemDependency");
|
|
|
12
12
|
|
|
13
13
|
/** @import { Expression, SpreadElement } from "estree" */
|
|
14
14
|
/** @import { GroupOptions } from "../../graph/AsyncDependenciesBlock" */
|
|
15
|
+
/** @import DependenciesBlock from "../../graph/DependenciesBlock" */
|
|
15
16
|
/** @import BasicEvaluatedExpression from "../../javascript/BasicEvaluatedExpression" */
|
|
16
17
|
/** @import JavascriptParser, { Range } from "../../javascript/JavascriptParser" */
|
|
17
18
|
/** @import { FunctionExpressionResult } from "../helpers/getFunctionExpression" */
|
|
@@ -87,7 +88,9 @@ module.exports = class RequireEnsureDependenciesBlockParserPlugin {
|
|
|
87
88
|
dep.loc = parser.getLocation(expr);
|
|
88
89
|
depBlock.addDependency(dep);
|
|
89
90
|
const old = parser.state.current;
|
|
90
|
-
parser.state.current = /** @type {
|
|
91
|
+
parser.state.current = /** @type {typeof parser.state.current} */ (
|
|
92
|
+
/** @type {DependenciesBlock} */ (depBlock)
|
|
93
|
+
);
|
|
91
94
|
try {
|
|
92
95
|
let failed = false;
|
|
93
96
|
parser.inFunctionScope(true, [], () => {
|
|
@@ -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) {
|