webpack 5.99.8 → 5.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -3
- package/bin/webpack.js +8 -2
- package/hot/log.js +15 -15
- package/hot/poll.js +1 -0
- package/lib/APIPlugin.js +3 -3
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -0
- package/lib/BannerPlugin.js +1 -1
- package/lib/CacheFacade.js +2 -1
- package/lib/CaseSensitiveModulesWarning.js +4 -4
- package/lib/Chunk.js +6 -6
- package/lib/ChunkGraph.js +37 -32
- package/lib/ChunkGroup.js +17 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +94 -17
- package/lib/CodeGenerationResults.js +1 -1
- package/lib/CompatibilityPlugin.js +5 -2
- package/lib/Compilation.js +77 -71
- package/lib/Compiler.js +46 -16
- package/lib/ConcatenationScope.js +15 -6
- package/lib/ConstPlugin.js +65 -45
- package/lib/ContextModule.js +16 -12
- package/lib/ContextModuleFactory.js +4 -3
- package/lib/ContextReplacementPlugin.js +4 -2
- package/lib/CssModule.js +2 -3
- package/lib/DefinePlugin.js +111 -3
- package/lib/DelegatedModuleFactoryPlugin.js +18 -18
- package/lib/Dependency.js +16 -12
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DllEntryPlugin.js +3 -1
- package/lib/DllPlugin.js +4 -3
- package/lib/DllReferencePlugin.js +2 -2
- package/lib/DynamicEntryPlugin.js +1 -1
- package/lib/EntryOptionPlugin.js +5 -0
- package/lib/ErrorHelpers.js +4 -4
- package/lib/EvalDevToolModulePlugin.js +3 -3
- package/lib/EvalSourceMapDevToolPlugin.js +7 -7
- package/lib/ExportsInfo.js +48 -39
- package/lib/ExternalModule.js +15 -11
- package/lib/ExternalModuleFactoryPlugin.js +5 -2
- package/lib/FileSystemInfo.js +51 -38
- package/lib/FlagDependencyExportsPlugin.js +14 -7
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +14 -1
- package/lib/HookWebpackError.js +1 -0
- package/lib/HotModuleReplacementPlugin.js +77 -50
- package/lib/IgnorePlugin.js +1 -1
- package/lib/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +0 -1
- package/lib/LibManifestPlugin.js +4 -2
- package/lib/LoaderOptionsPlugin.js +6 -4
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +21 -6
- package/lib/ModuleFactory.js +1 -0
- package/lib/ModuleGraph.js +24 -2
- package/lib/ModuleGraphConnection.js +5 -5
- package/lib/ModuleInfoHeaderPlugin.js +2 -1
- package/lib/ModuleParseError.js +1 -0
- package/lib/ModuleSourceTypesConstants.js +12 -12
- package/lib/ModuleTemplate.js +1 -1
- package/lib/ModuleTypeConstants.js +21 -21
- package/lib/MultiCompiler.js +6 -6
- package/lib/NormalModule.js +61 -56
- package/lib/NormalModuleFactory.js +52 -37
- package/lib/NormalModuleReplacementPlugin.js +1 -1
- package/lib/NullFactory.js +1 -0
- package/lib/OptimizationStages.js +1 -1
- package/lib/Parser.js +1 -0
- package/lib/ProgressPlugin.js +12 -5
- package/lib/ProvidePlugin.js +5 -1
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/RuntimeGlobals.js +175 -155
- package/lib/RuntimeModule.js +1 -0
- package/lib/RuntimePlugin.js +34 -8
- package/lib/RuntimeTemplate.js +111 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
- package/lib/SourceMapDevToolPlugin.js +19 -17
- package/lib/Template.js +2 -2
- package/lib/TemplatedPathPlugin.js +1 -1
- package/lib/WarnDeprecatedOptionPlugin.js +7 -8
- package/lib/WatchIgnorePlugin.js +4 -3
- package/lib/WebpackIsIncludedPlugin.js +2 -1
- package/lib/WebpackOptionsApply.js +115 -27
- package/lib/asset/AssetGenerator.js +26 -21
- package/lib/asset/AssetModulesPlugin.js +19 -17
- package/lib/asset/AssetSourceGenerator.js +11 -9
- package/lib/asset/RawDataUrlModule.js +4 -2
- package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
- package/lib/buildChunkGraph.js +6 -3
- package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
- package/lib/cache/IdleFileCachePlugin.js +7 -4
- package/lib/cache/MemoryCachePlugin.js +1 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +26 -20
- package/lib/cache/ResolverCachePlugin.js +16 -8
- package/lib/cli.js +15 -10
- package/lib/config/browserslistTargetHandler.js +3 -3
- package/lib/config/defaults.js +25 -17
- package/lib/config/normalization.js +2 -1
- package/lib/config/target.js +6 -5
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackModule.js +2 -1
- package/lib/container/HoistContainerReferencesPlugin.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +2 -2
- package/lib/container/RemoteModule.js +1 -1
- package/lib/css/CssGenerator.js +9 -6
- package/lib/css/CssModulesPlugin.js +44 -31
- package/lib/css/CssParser.js +6 -4
- package/lib/css/walkCssTokens.js +33 -37
- package/lib/debug/ProfilingPlugin.js +6 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
- package/lib/dependencies/AMDPlugin.js +12 -8
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
- package/lib/dependencies/CachedConstDependency.js +1 -5
- package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
- package/lib/dependencies/CommonJsPlugin.js +15 -16
- package/lib/dependencies/ContextDependencyHelpers.js +2 -1
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +1 -1
- package/lib/dependencies/DynamicExports.js +9 -9
- package/lib/dependencies/ExportsInfoDependency.js +1 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +11 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
- package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
- package/lib/dependencies/ImportMetaPlugin.js +2 -2
- package/lib/dependencies/ImportParserPlugin.js +40 -9
- package/lib/dependencies/ImportPlugin.js +3 -1
- package/lib/dependencies/LoaderPlugin.js +1 -0
- package/lib/dependencies/ModuleDependency.js +1 -1
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +3 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +3 -0
- package/lib/dependencies/RequireEnsurePlugin.js +6 -6
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
- package/lib/dependencies/RequireIncludePlugin.js +1 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLContextDependency.js +65 -0
- package/lib/dependencies/URLDependency.js +1 -1
- package/lib/dependencies/URLPlugin.js +17 -157
- package/lib/dependencies/WorkerPlugin.js +23 -10
- package/lib/dependencies/processExportInfo.js +2 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
- package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +73 -6
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
- package/lib/hmr/LazyCompilationPlugin.js +4 -2
- package/lib/hmr/lazyCompilationBackend.js +4 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
- package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
- package/lib/ids/HashedModuleIdsPlugin.js +5 -4
- package/lib/ids/IdHelpers.js +21 -17
- package/lib/ids/NamedChunkIdsPlugin.js +5 -5
- package/lib/ids/NamedModuleIdsPlugin.js +4 -4
- package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -3
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
- package/lib/javascript/BasicEvaluatedExpression.js +2 -1
- package/lib/javascript/ChunkHelpers.js +1 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
- package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
- package/lib/javascript/JavascriptGenerator.js +14 -2
- package/lib/javascript/JavascriptModulesPlugin.js +68 -27
- package/lib/javascript/JavascriptParser.js +136 -81
- package/lib/javascript/JavascriptParserHelpers.js +41 -41
- package/lib/javascript/StartupHelpers.js +17 -17
- package/lib/json/JsonGenerator.js +4 -2
- package/lib/json/JsonModulesPlugin.js +2 -2
- package/lib/json/JsonParser.js +1 -1
- package/lib/library/AbstractLibraryPlugin.js +6 -2
- package/lib/library/AssignLibraryPlugin.js +21 -6
- package/lib/library/EnableLibraryPlugin.js +23 -3
- package/lib/library/ModuleLibraryPlugin.js +4 -1
- package/lib/library/UmdLibraryPlugin.js +15 -6
- package/lib/logging/createConsoleLogger.js +3 -3
- package/lib/logging/runtime.js +9 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/nodeConsole.js +4 -2
- package/lib/optimize/AggressiveMergingPlugin.js +45 -46
- package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
- package/lib/optimize/ConcatenatedModule.js +227 -57
- package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
- package/lib/optimize/InnerGraph.js +115 -112
- package/lib/optimize/InnerGraphPlugin.js +2 -2
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +4 -3
- package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
- package/lib/optimize/MinChunkSizePlugin.js +6 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
- package/lib/optimize/RealContentHashPlugin.js +26 -20
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
- package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -3
- package/lib/optimize/SplitChunksPlugin.js +16 -13
- package/lib/rules/BasicEffectRulePlugin.js +4 -2
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
- package/lib/rules/RuleSetCompiler.js +7 -4
- package/lib/rules/UseEffectRulePlugin.js +3 -1
- package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
- package/lib/schemes/DataUriPlugin.js +3 -1
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +27 -19
- package/lib/schemes/VirtualUrlPlugin.js +222 -0
- package/lib/serialization/AggregateErrorSerializer.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +5 -4
- package/lib/serialization/FileMiddleware.js +7 -4
- package/lib/serialization/ObjectMiddleware.js +14 -8
- package/lib/serialization/Serializer.js +5 -3
- package/lib/serialization/SerializerMiddleware.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ConsumeSharedPlugin.js +3 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +6 -3
- package/lib/sharing/SharePlugin.js +2 -1
- package/lib/sharing/ShareRuntimeModule.js +3 -5
- package/lib/sharing/utils.js +34 -34
- package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
- package/lib/stats/DefaultStatsPresetPlugin.js +4 -2
- package/lib/stats/DefaultStatsPrinterPlugin.js +28 -22
- package/lib/stats/StatsFactory.js +4 -2
- package/lib/stats/StatsPrinter.js +3 -2
- package/lib/url/URLParserPlugin.js +266 -0
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Hash.js +2 -0
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/LazyBucketSortedSet.js +2 -1
- package/lib/util/LazySet.js +11 -6
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/SetHelpers.js +3 -3
- package/lib/util/SortableSet.js +2 -2
- package/lib/util/StackedCacheMap.js +3 -1
- package/lib/util/StackedMap.js +2 -2
- package/lib/util/StringXor.js +1 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -1
- package/lib/util/cleverMerge.js +12 -8
- package/lib/util/comparators.js +154 -127
- package/lib/util/compileBooleanMatcher.js +8 -3
- package/lib/util/concatenate.js +8 -7
- package/lib/util/conventions.js +72 -73
- package/lib/util/create-schema-validation.js +2 -1
- package/lib/util/createHash.js +10 -4
- package/lib/util/deprecation.js +69 -66
- package/lib/util/deterministicGrouping.js +4 -2
- package/lib/util/extractUrlAndGlobal.js +1 -1
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +30 -23
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +4 -2
- package/lib/util/identifier.js +13 -12
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/magicComment.js +5 -5
- package/lib/util/processAsyncTree.js +1 -1
- package/lib/util/propertyAccess.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -2
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +29 -21
- package/lib/util/semver.js +1 -1
- package/lib/util/serialization.js +3 -0
- package/lib/util/source.js +3 -2
- package/lib/validateSchema.js +1 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
- package/lib/webpack.js +4 -5
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
- package/package.json +121 -114
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +17 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
- package/types.d.ts +1261 -366
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
const WebpackError = require("../WebpackError");
|
|
8
9
|
const { getImportAttributes } = require("../javascript/JavascriptParser");
|
|
9
10
|
const InnerGraph = require("../optimize/InnerGraph");
|
|
10
11
|
const ConstDependency = require("./ConstDependency");
|
|
@@ -14,6 +15,7 @@ const HarmonyExportImportedSpecifierDependency = require("./HarmonyExportImporte
|
|
|
14
15
|
const HarmonyExportSpecifierDependency = require("./HarmonyExportSpecifierDependency");
|
|
15
16
|
const { ExportPresenceModes } = require("./HarmonyImportDependency");
|
|
16
17
|
const {
|
|
18
|
+
getImportMode,
|
|
17
19
|
harmonySpecifierTag
|
|
18
20
|
} = require("./HarmonyImportDependencyParserPlugin");
|
|
19
21
|
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
|
|
@@ -26,11 +28,14 @@ const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDepe
|
|
|
26
28
|
|
|
27
29
|
const { HarmonyStarExportsList } = HarmonyExportImportedSpecifierDependency;
|
|
28
30
|
|
|
31
|
+
const PLUGIN_NAME = "HarmonyExportDependencyParserPlugin";
|
|
32
|
+
|
|
29
33
|
module.exports = class HarmonyExportDependencyParserPlugin {
|
|
30
34
|
/**
|
|
31
35
|
* @param {import("../../declarations/WebpackOptions").JavascriptParserOptions} options options
|
|
36
|
+
* @param {boolean=} deferImport defer import enabled
|
|
32
37
|
*/
|
|
33
|
-
constructor(options) {
|
|
38
|
+
constructor(options, deferImport) {
|
|
34
39
|
this.exportPresenceMode =
|
|
35
40
|
options.reexportExportsPresence !== undefined
|
|
36
41
|
? ExportPresenceModes.fromUserOption(options.reexportExportsPresence)
|
|
@@ -39,6 +44,7 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
|
39
44
|
: options.strictExportPresence
|
|
40
45
|
? ExportPresenceModes.ERROR
|
|
41
46
|
: ExportPresenceModes.AUTO;
|
|
47
|
+
this.deferImport = deferImport;
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
/**
|
|
@@ -47,107 +53,111 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
|
47
53
|
*/
|
|
48
54
|
apply(parser) {
|
|
49
55
|
const { exportPresenceMode } = this;
|
|
50
|
-
parser.hooks.export.tap(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
parser.hooks.export.tap(PLUGIN_NAME, statement => {
|
|
57
|
+
const dep = new HarmonyExportHeaderDependency(
|
|
58
|
+
/** @type {Range | false} */ (
|
|
59
|
+
statement.declaration && statement.declaration.range
|
|
60
|
+
),
|
|
61
|
+
/** @type {Range} */ (statement.range)
|
|
62
|
+
);
|
|
63
|
+
dep.loc = Object.create(
|
|
64
|
+
/** @type {DependencyLocation} */ (statement.loc)
|
|
65
|
+
);
|
|
66
|
+
dep.loc.index = -1;
|
|
67
|
+
parser.state.module.addPresentationalDependency(dep);
|
|
68
|
+
return true;
|
|
69
|
+
});
|
|
70
|
+
parser.hooks.exportImport.tap(PLUGIN_NAME, (statement, source) => {
|
|
71
|
+
parser.state.lastHarmonyImportOrder =
|
|
72
|
+
(parser.state.lastHarmonyImportOrder || 0) + 1;
|
|
73
|
+
const clearDep = new ConstDependency(
|
|
74
|
+
"",
|
|
75
|
+
/** @type {Range} */ (statement.range)
|
|
76
|
+
);
|
|
77
|
+
clearDep.loc = /** @type {DependencyLocation} */ (statement.loc);
|
|
78
|
+
clearDep.loc.index = -1;
|
|
79
|
+
parser.state.module.addPresentationalDependency(clearDep);
|
|
80
|
+
const { defer } = getImportMode(
|
|
81
|
+
parser,
|
|
82
|
+
statement,
|
|
83
|
+
this.deferImport,
|
|
84
|
+
true
|
|
85
|
+
);
|
|
86
|
+
if (defer) {
|
|
87
|
+
const error = new WebpackError(
|
|
88
|
+
"Deferred re-export (`export defer * as namespace from '...'`) is not a part of the Import Defer proposal.\nUse the following code instead:\n import defer * as namespace from '...';\n export { namespace };"
|
|
61
89
|
);
|
|
62
|
-
|
|
63
|
-
parser.state.
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
parser.hooks.exportImport.tap(
|
|
68
|
-
"HarmonyExportDependencyParserPlugin",
|
|
69
|
-
(statement, source) => {
|
|
70
|
-
parser.state.lastHarmonyImportOrder =
|
|
71
|
-
(parser.state.lastHarmonyImportOrder || 0) + 1;
|
|
72
|
-
const clearDep = new ConstDependency(
|
|
73
|
-
"",
|
|
74
|
-
/** @type {Range} */ (statement.range)
|
|
75
|
-
);
|
|
76
|
-
clearDep.loc = /** @type {DependencyLocation} */ (statement.loc);
|
|
77
|
-
clearDep.loc.index = -1;
|
|
78
|
-
parser.state.module.addPresentationalDependency(clearDep);
|
|
79
|
-
const sideEffectDep = new HarmonyImportSideEffectDependency(
|
|
80
|
-
/** @type {string} */ (source),
|
|
81
|
-
parser.state.lastHarmonyImportOrder,
|
|
82
|
-
getImportAttributes(statement)
|
|
83
|
-
);
|
|
84
|
-
sideEffectDep.loc = Object.create(
|
|
85
|
-
/** @type {DependencyLocation} */ (statement.loc)
|
|
86
|
-
);
|
|
87
|
-
sideEffectDep.loc.index = -1;
|
|
88
|
-
parser.state.current.addDependency(sideEffectDep);
|
|
89
|
-
return true;
|
|
90
|
+
error.loc = statement.loc || undefined;
|
|
91
|
+
parser.state.current.addError(error);
|
|
90
92
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
93
|
+
const sideEffectDep = new HarmonyImportSideEffectDependency(
|
|
94
|
+
/** @type {string} */ (source),
|
|
95
|
+
parser.state.lastHarmonyImportOrder,
|
|
96
|
+
getImportAttributes(statement),
|
|
97
|
+
defer
|
|
98
|
+
);
|
|
99
|
+
sideEffectDep.loc = Object.create(
|
|
100
|
+
/** @type {DependencyLocation} */ (statement.loc)
|
|
101
|
+
);
|
|
102
|
+
sideEffectDep.loc.index = -1;
|
|
103
|
+
parser.state.current.addDependency(sideEffectDep);
|
|
104
|
+
return true;
|
|
105
|
+
});
|
|
106
|
+
parser.hooks.exportExpression.tap(PLUGIN_NAME, (statement, node) => {
|
|
107
|
+
const isFunctionDeclaration = node.type === "FunctionDeclaration";
|
|
108
|
+
const exprRange = /** @type {Range} */ (node.range);
|
|
109
|
+
const statementRange = /** @type {Range} */ (statement.range);
|
|
110
|
+
const comments = parser.getComments([statementRange[0], exprRange[0]]);
|
|
111
|
+
const dep = new HarmonyExportExpressionDependency(
|
|
112
|
+
exprRange,
|
|
113
|
+
statementRange,
|
|
114
|
+
comments
|
|
115
|
+
.map(c => {
|
|
116
|
+
switch (c.type) {
|
|
117
|
+
case "Block":
|
|
118
|
+
return `/*${c.value}*/`;
|
|
119
|
+
case "Line":
|
|
120
|
+
return `//${c.value}\n`;
|
|
121
|
+
}
|
|
122
|
+
return "";
|
|
123
|
+
})
|
|
124
|
+
.join(""),
|
|
125
|
+
node.type.endsWith("Declaration") &&
|
|
126
|
+
/** @type {FunctionDeclaration | ClassDeclaration} */ (node).id
|
|
127
|
+
? /** @type {FunctionDeclaration | ClassDeclaration} */
|
|
128
|
+
(node).id.name
|
|
129
|
+
: isFunctionDeclaration
|
|
130
|
+
? {
|
|
131
|
+
range: [
|
|
132
|
+
exprRange[0],
|
|
133
|
+
node.params.length > 0
|
|
134
|
+
? /** @type {Range} */ (node.params[0].range)[0]
|
|
135
|
+
: /** @type {Range} */ (node.body.range)[0]
|
|
136
|
+
],
|
|
137
|
+
prefix: `${node.async ? "async " : ""}function${
|
|
138
|
+
node.generator ? "*" : ""
|
|
139
|
+
} `,
|
|
140
|
+
suffix: `(${node.params.length > 0 ? "" : ") "}`
|
|
109
141
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
142
|
+
: undefined
|
|
143
|
+
);
|
|
144
|
+
dep.loc = Object.create(
|
|
145
|
+
/** @type {DependencyLocation} */ (statement.loc)
|
|
146
|
+
);
|
|
147
|
+
dep.loc.index = -1;
|
|
148
|
+
parser.state.current.addDependency(dep);
|
|
149
|
+
InnerGraph.addVariableUsage(
|
|
150
|
+
parser,
|
|
151
|
+
node.type.endsWith("Declaration") &&
|
|
114
152
|
/** @type {FunctionDeclaration | ClassDeclaration} */ (node).id
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
node.params.length > 0
|
|
122
|
-
? /** @type {Range} */ (node.params[0].range)[0]
|
|
123
|
-
: /** @type {Range} */ (node.body.range)[0]
|
|
124
|
-
],
|
|
125
|
-
prefix: `${node.async ? "async " : ""}function${
|
|
126
|
-
node.generator ? "*" : ""
|
|
127
|
-
} `,
|
|
128
|
-
suffix: `(${node.params.length > 0 ? "" : ") "}`
|
|
129
|
-
}
|
|
130
|
-
: undefined
|
|
131
|
-
);
|
|
132
|
-
dep.loc = Object.create(
|
|
133
|
-
/** @type {DependencyLocation} */ (statement.loc)
|
|
134
|
-
);
|
|
135
|
-
dep.loc.index = -1;
|
|
136
|
-
parser.state.current.addDependency(dep);
|
|
137
|
-
InnerGraph.addVariableUsage(
|
|
138
|
-
parser,
|
|
139
|
-
node.type.endsWith("Declaration") &&
|
|
140
|
-
/** @type {FunctionDeclaration | ClassDeclaration} */ (node).id
|
|
141
|
-
? /** @type {FunctionDeclaration | ClassDeclaration} */ (node).id
|
|
142
|
-
.name
|
|
143
|
-
: "*default*",
|
|
144
|
-
"default"
|
|
145
|
-
);
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
);
|
|
153
|
+
? /** @type {FunctionDeclaration | ClassDeclaration} */ (node).id.name
|
|
154
|
+
: "*default*",
|
|
155
|
+
"default"
|
|
156
|
+
);
|
|
157
|
+
return true;
|
|
158
|
+
});
|
|
149
159
|
parser.hooks.exportSpecifier.tap(
|
|
150
|
-
|
|
160
|
+
PLUGIN_NAME,
|
|
151
161
|
(statement, id, name, idx) => {
|
|
152
162
|
const settings = parser.getTagData(id, harmonySpecifierTag);
|
|
153
163
|
const harmonyNamedExports = (parser.state.harmonyNamedExports =
|
|
@@ -164,7 +174,8 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
|
164
174
|
null,
|
|
165
175
|
exportPresenceMode,
|
|
166
176
|
null,
|
|
167
|
-
settings.attributes
|
|
177
|
+
settings.attributes,
|
|
178
|
+
settings.defer
|
|
168
179
|
)
|
|
169
180
|
: new HarmonyExportSpecifierDependency(id, name);
|
|
170
181
|
dep.loc = Object.create(
|
|
@@ -183,10 +194,11 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
|
183
194
|
}
|
|
184
195
|
);
|
|
185
196
|
parser.hooks.exportImportSpecifier.tap(
|
|
186
|
-
|
|
197
|
+
PLUGIN_NAME,
|
|
187
198
|
(statement, source, id, name, idx) => {
|
|
188
199
|
const harmonyNamedExports = (parser.state.harmonyNamedExports =
|
|
189
200
|
parser.state.harmonyNamedExports || new Set());
|
|
201
|
+
/** @type {InstanceType<HarmonyStarExportsList> | null} */
|
|
190
202
|
let harmonyStarExports = null;
|
|
191
203
|
if (name) {
|
|
192
204
|
harmonyNamedExports.add(name);
|
|
@@ -195,16 +207,25 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
|
195
207
|
parser.state.harmonyStarExports || new HarmonyStarExportsList();
|
|
196
208
|
}
|
|
197
209
|
const attributes = getImportAttributes(statement);
|
|
210
|
+
const { defer } = getImportMode(
|
|
211
|
+
parser,
|
|
212
|
+
statement,
|
|
213
|
+
this.deferImport,
|
|
214
|
+
false
|
|
215
|
+
);
|
|
198
216
|
const dep = new HarmonyExportImportedSpecifierDependency(
|
|
199
|
-
/** @type {string} */
|
|
217
|
+
/** @type {string} */
|
|
218
|
+
(source),
|
|
200
219
|
parser.state.lastHarmonyImportOrder,
|
|
201
220
|
id ? [id] : [],
|
|
202
221
|
name,
|
|
203
222
|
harmonyNamedExports,
|
|
223
|
+
// eslint-disable-next-line unicorn/prefer-spread
|
|
204
224
|
harmonyStarExports && harmonyStarExports.slice(),
|
|
205
225
|
exportPresenceMode,
|
|
206
226
|
harmonyStarExports,
|
|
207
|
-
attributes
|
|
227
|
+
attributes,
|
|
228
|
+
defer
|
|
208
229
|
);
|
|
209
230
|
if (harmonyStarExports) {
|
|
210
231
|
harmonyStarExports.push(dep);
|
|
@@ -27,7 +27,7 @@ class HarmonyExportExpressionDependency extends NullDependency {
|
|
|
27
27
|
* @param {Range} range range
|
|
28
28
|
* @param {Range} rangeStatement range statement
|
|
29
29
|
* @param {string} prefix prefix
|
|
30
|
-
* @param {string | { range: Range, prefix: string, suffix: string }=} declarationId declaration id
|
|
30
|
+
* @param {string | { id?: string | undefined, range: Range, prefix: string, suffix: string }=} declarationId declaration id
|
|
31
31
|
*/
|
|
32
32
|
constructor(range, rangeStatement, prefix, declarationId) {
|
|
33
33
|
super();
|
|
@@ -12,15 +12,18 @@ const HarmonyLinkingError = require("../HarmonyLinkingError");
|
|
|
12
12
|
const InitFragment = require("../InitFragment");
|
|
13
13
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
14
14
|
const Template = require("../Template");
|
|
15
|
+
const {
|
|
16
|
+
getMakeDeferredNamespaceModeFromExportsType
|
|
17
|
+
} = require("../runtime/MakeDeferredNamespaceObjectRuntime");
|
|
15
18
|
const { countIterable } = require("../util/IterableHelpers");
|
|
16
|
-
const {
|
|
19
|
+
const { combine, first } = require("../util/SetHelpers");
|
|
17
20
|
const makeSerializable = require("../util/makeSerializable");
|
|
18
21
|
const propertyAccess = require("../util/propertyAccess");
|
|
19
22
|
const { propertyName } = require("../util/propertyName");
|
|
20
23
|
const {
|
|
24
|
+
filterRuntime,
|
|
21
25
|
getRuntimeKey,
|
|
22
|
-
keyToRuntime
|
|
23
|
-
filterRuntime
|
|
26
|
+
keyToRuntime
|
|
24
27
|
} = require("../util/runtime");
|
|
25
28
|
const HarmonyExportInitFragment = require("./HarmonyExportInitFragment");
|
|
26
29
|
const HarmonyImportDependency = require("./HarmonyImportDependency");
|
|
@@ -121,7 +124,7 @@ class ExportMode {
|
|
|
121
124
|
|
|
122
125
|
/**
|
|
123
126
|
* @param {ModuleGraph} moduleGraph module graph
|
|
124
|
-
* @param {HarmonyExportImportedSpecifierDependency
|
|
127
|
+
* @param {ReadonlyArray<HarmonyExportImportedSpecifierDependency>} dependencies dependencies
|
|
125
128
|
* @param {TODO=} additionalDependency additional dependency
|
|
126
129
|
* @returns {{ names: Names, dependencyIndices: DependencyIndices }} result
|
|
127
130
|
*/
|
|
@@ -130,12 +133,13 @@ const determineExportAssignments = (
|
|
|
130
133
|
dependencies,
|
|
131
134
|
additionalDependency
|
|
132
135
|
) => {
|
|
136
|
+
/** @type {Set<string>} */
|
|
133
137
|
const names = new Set();
|
|
134
138
|
/** @type {number[]} */
|
|
135
139
|
const dependencyIndices = [];
|
|
136
140
|
|
|
137
141
|
if (additionalDependency) {
|
|
138
|
-
dependencies = dependencies
|
|
142
|
+
dependencies = [...dependencies, additionalDependency];
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
for (const dep of dependencies) {
|
|
@@ -158,7 +162,7 @@ const determineExportAssignments = (
|
|
|
158
162
|
}
|
|
159
163
|
dependencyIndices.push(names.size);
|
|
160
164
|
|
|
161
|
-
return { names:
|
|
165
|
+
return { names: [...names], dependencyIndices };
|
|
162
166
|
};
|
|
163
167
|
|
|
164
168
|
/**
|
|
@@ -166,7 +170,7 @@ const determineExportAssignments = (
|
|
|
166
170
|
* @param {Names} options.names names
|
|
167
171
|
* @param {DependencyIndices} options.dependencyIndices dependency indices
|
|
168
172
|
* @param {string} name name
|
|
169
|
-
* @param {
|
|
173
|
+
* @param {ReadonlyArray<HarmonyExportImportedSpecifierDependency>} dependencies dependencies
|
|
170
174
|
* @returns {HarmonyExportImportedSpecifierDependency | undefined} found dependency or nothing
|
|
171
175
|
*/
|
|
172
176
|
const findDependencyForName = (
|
|
@@ -302,7 +306,6 @@ const getMode = (moduleGraph, dep, runtimeKey) => {
|
|
|
302
306
|
}
|
|
303
307
|
|
|
304
308
|
// Star reexporting
|
|
305
|
-
|
|
306
309
|
const { ignoredExports, exports, checked, hidden } = dep.getStarReexports(
|
|
307
310
|
moduleGraph,
|
|
308
311
|
runtime,
|
|
@@ -371,10 +374,11 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
|
371
374
|
* @param {Ids} ids the requested export name of the imported module
|
|
372
375
|
* @param {string | null} name the export name of for this module
|
|
373
376
|
* @param {Set<string>} activeExports other named exports in the module
|
|
374
|
-
* @param {ReadonlyArray<HarmonyExportImportedSpecifierDependency> |
|
|
377
|
+
* @param {ReadonlyArray<HarmonyExportImportedSpecifierDependency> | null} otherStarExports other star exports in the module before this import
|
|
375
378
|
* @param {ExportPresenceMode} exportPresenceMode mode of checking export names
|
|
376
379
|
* @param {HarmonyStarExportsList | null} allStarExports all star exports in the module
|
|
377
380
|
* @param {ImportAttributes=} attributes import attributes
|
|
381
|
+
* @param {boolean=} deferEvaluation defer evaluation
|
|
378
382
|
*/
|
|
379
383
|
constructor(
|
|
380
384
|
request,
|
|
@@ -385,7 +389,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
|
385
389
|
otherStarExports,
|
|
386
390
|
exportPresenceMode,
|
|
387
391
|
allStarExports,
|
|
388
|
-
attributes
|
|
392
|
+
attributes,
|
|
393
|
+
deferEvaluation
|
|
389
394
|
) {
|
|
390
395
|
super(request, sourceOrder, attributes);
|
|
391
396
|
|
|
@@ -395,6 +400,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
|
395
400
|
this.otherStarExports = otherStarExports;
|
|
396
401
|
this.exportPresenceMode = exportPresenceMode;
|
|
397
402
|
this.allStarExports = allStarExports;
|
|
403
|
+
this.defer = deferEvaluation;
|
|
398
404
|
}
|
|
399
405
|
|
|
400
406
|
/**
|
|
@@ -578,8 +584,9 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
|
578
584
|
return Dependency.EXPORTS_OBJECT_REFERENCED;
|
|
579
585
|
|
|
580
586
|
case "reexport-named-default": {
|
|
581
|
-
if (!mode.partialNamespaceExportInfo)
|
|
587
|
+
if (!mode.partialNamespaceExportInfo) {
|
|
582
588
|
return Dependency.EXPORTS_OBJECT_REFERENCED;
|
|
589
|
+
}
|
|
583
590
|
/** @type {ReferencedExports} */
|
|
584
591
|
const referencedExports = [];
|
|
585
592
|
processExportInfo(
|
|
@@ -593,8 +600,9 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
|
593
600
|
|
|
594
601
|
case "reexport-namespace-object":
|
|
595
602
|
case "reexport-fake-namespace-object": {
|
|
596
|
-
if (!mode.partialNamespaceExportInfo)
|
|
603
|
+
if (!mode.partialNamespaceExportInfo) {
|
|
597
604
|
return Dependency.EXPORTS_OBJECT_REFERENCED;
|
|
605
|
+
}
|
|
598
606
|
/** @type {ReferencedExports} */
|
|
599
607
|
const referencedExports = [];
|
|
600
608
|
processExportInfo(
|
|
@@ -658,7 +666,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
|
658
666
|
|
|
659
667
|
const { names, dependencyIndices } = moduleGraph.cached(
|
|
660
668
|
determineExportAssignments,
|
|
661
|
-
|
|
669
|
+
/** @type {HarmonyExportImportedSpecifierDependency[]} */
|
|
670
|
+
(this.otherStarExports),
|
|
662
671
|
this
|
|
663
672
|
);
|
|
664
673
|
|
|
@@ -811,8 +820,9 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
|
811
820
|
* @returns {ExportPresenceMode} effective mode
|
|
812
821
|
*/
|
|
813
822
|
_getEffectiveExportPresenceLevel(moduleGraph) {
|
|
814
|
-
if (this.exportPresenceMode !== ExportPresenceModes.AUTO)
|
|
823
|
+
if (this.exportPresenceMode !== ExportPresenceModes.AUTO) {
|
|
815
824
|
return this.exportPresenceMode;
|
|
825
|
+
}
|
|
816
826
|
const module = /** @type {Module} */ (moduleGraph.getParentModule(this));
|
|
817
827
|
return /** @type {BuildMeta} */ (module.buildMeta).strictHarmonyModule
|
|
818
828
|
? ExportPresenceModes.ERROR
|
|
@@ -884,7 +894,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
|
884
894
|
this.allStarExports
|
|
885
895
|
? this.allStarExports.dependencies
|
|
886
896
|
: [
|
|
887
|
-
.../** @type {
|
|
897
|
+
.../** @type {ReadonlyArray<HarmonyExportImportedSpecifierDependency>} */
|
|
888
898
|
(this.otherStarExports),
|
|
889
899
|
this
|
|
890
900
|
]
|
|
@@ -1011,6 +1021,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
|
1011
1021
|
mode,
|
|
1012
1022
|
templateContext.module,
|
|
1013
1023
|
moduleGraph,
|
|
1024
|
+
templateContext.chunkGraph,
|
|
1014
1025
|
runtime,
|
|
1015
1026
|
templateContext.runtimeTemplate,
|
|
1016
1027
|
templateContext.runtimeRequirements
|
|
@@ -1024,6 +1035,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
|
1024
1035
|
* @param {ExportMode} mode the export mode
|
|
1025
1036
|
* @param {Module} module the current module
|
|
1026
1037
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
1038
|
+
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
1027
1039
|
* @param {RuntimeSpec} runtime the runtime
|
|
1028
1040
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
|
1029
1041
|
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
|
|
@@ -1035,6 +1047,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
|
1035
1047
|
mode,
|
|
1036
1048
|
module,
|
|
1037
1049
|
moduleGraph,
|
|
1050
|
+
chunkGraph,
|
|
1038
1051
|
runtime,
|
|
1039
1052
|
runtimeTemplate,
|
|
1040
1053
|
runtimeRequirements
|
|
@@ -1042,6 +1055,29 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
|
1042
1055
|
const importedModule = /** @type {Module} */ (moduleGraph.getModule(dep));
|
|
1043
1056
|
const importVar = dep.getImportVar(moduleGraph);
|
|
1044
1057
|
|
|
1058
|
+
if (
|
|
1059
|
+
(mode.type === "reexport-namespace-object" ||
|
|
1060
|
+
mode.type === "reexport-fake-namespace-object") &&
|
|
1061
|
+
dep.defer &&
|
|
1062
|
+
!moduleGraph.isAsync(importedModule)
|
|
1063
|
+
) {
|
|
1064
|
+
initFragments.push(
|
|
1065
|
+
...this.getReexportDeferredNamespaceObjectFragments(
|
|
1066
|
+
importedModule,
|
|
1067
|
+
chunkGraph,
|
|
1068
|
+
moduleGraph
|
|
1069
|
+
.getExportsInfo(module)
|
|
1070
|
+
.getUsedName(mode.name ? mode.name : [], runtime),
|
|
1071
|
+
importVar,
|
|
1072
|
+
importedModule.getExportsType(
|
|
1073
|
+
moduleGraph,
|
|
1074
|
+
module.buildMeta && module.buildMeta.strictHarmonyModule
|
|
1075
|
+
),
|
|
1076
|
+
runtimeRequirements
|
|
1077
|
+
)
|
|
1078
|
+
);
|
|
1079
|
+
return;
|
|
1080
|
+
}
|
|
1045
1081
|
switch (mode.type) {
|
|
1046
1082
|
case "missing":
|
|
1047
1083
|
case "empty-star":
|
|
@@ -1210,9 +1246,9 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
|
1210
1246
|
// Filter out exports which are defined by other exports
|
|
1211
1247
|
// and filter out default export because it cannot be reexported with *
|
|
1212
1248
|
if (ignored.size > 1) {
|
|
1213
|
-
content += `if(${JSON.stringify(
|
|
1214
|
-
|
|
1215
|
-
)}.indexOf(__WEBPACK_IMPORT_KEY__) < 0) `;
|
|
1249
|
+
content += `if(${JSON.stringify([
|
|
1250
|
+
...ignored
|
|
1251
|
+
])}.indexOf(__WEBPACK_IMPORT_KEY__) < 0) `;
|
|
1216
1252
|
} else if (ignored.size === 1) {
|
|
1217
1253
|
content += `if(__WEBPACK_IMPORT_KEY__ !== ${JSON.stringify(
|
|
1218
1254
|
first(ignored)
|
|
@@ -1311,6 +1347,46 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
|
1311
1347
|
];
|
|
1312
1348
|
}
|
|
1313
1349
|
|
|
1350
|
+
/**
|
|
1351
|
+
* @param {Module} module module
|
|
1352
|
+
* @param {ChunkGraph} chunkGraph chunkGraph
|
|
1353
|
+
* @param {string | false | string[]} key key
|
|
1354
|
+
* @param {string} name name
|
|
1355
|
+
* @param {import("../Module").ExportsType} exportsType exportsType
|
|
1356
|
+
* @param {Set<string>} runtimeRequirements runtimeRequirements
|
|
1357
|
+
* @returns {InitFragment<GenerateContext>[]} fragments
|
|
1358
|
+
*/
|
|
1359
|
+
getReexportDeferredNamespaceObjectFragments(
|
|
1360
|
+
module,
|
|
1361
|
+
chunkGraph,
|
|
1362
|
+
key,
|
|
1363
|
+
name,
|
|
1364
|
+
exportsType,
|
|
1365
|
+
runtimeRequirements
|
|
1366
|
+
) {
|
|
1367
|
+
runtimeRequirements.add(RuntimeGlobals.exports);
|
|
1368
|
+
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
|
|
1369
|
+
runtimeRequirements.add(RuntimeGlobals.makeDeferredNamespaceObject);
|
|
1370
|
+
|
|
1371
|
+
const map = new Map();
|
|
1372
|
+
const moduleId = JSON.stringify(chunkGraph.getModuleId(module));
|
|
1373
|
+
const mode = getMakeDeferredNamespaceModeFromExportsType(exportsType);
|
|
1374
|
+
map.set(
|
|
1375
|
+
key,
|
|
1376
|
+
`/* reexport deferred namespace object */ ${name}_deferred_namespace_cache || (${name}_deferred_namespace_cache = ${RuntimeGlobals.makeDeferredNamespaceObject}(${moduleId}, ${mode}))`
|
|
1377
|
+
);
|
|
1378
|
+
|
|
1379
|
+
return [
|
|
1380
|
+
new InitFragment(
|
|
1381
|
+
`var ${name}_deferred_namespace_cache;\n`,
|
|
1382
|
+
InitFragment.STAGE_CONSTANTS,
|
|
1383
|
+
-1,
|
|
1384
|
+
`${name}_deferred_namespace_cache`
|
|
1385
|
+
),
|
|
1386
|
+
new HarmonyExportInitFragment(module.exportsArgument, map)
|
|
1387
|
+
];
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1314
1390
|
/**
|
|
1315
1391
|
* @param {Module} module module
|
|
1316
1392
|
* @param {string} key key
|
|
@@ -1383,7 +1459,7 @@ class HarmonyStarExportsList {
|
|
|
1383
1459
|
}
|
|
1384
1460
|
|
|
1385
1461
|
slice() {
|
|
1386
|
-
return this.dependencies
|
|
1462
|
+
return [...this.dependencies];
|
|
1387
1463
|
}
|
|
1388
1464
|
|
|
1389
1465
|
/**
|
|
@@ -154,7 +154,7 @@ class HarmonyExportInitFragment extends InitFragment {
|
|
|
154
154
|
? `/* unused harmony export ${first(this.unusedExports)} */\n`
|
|
155
155
|
: "";
|
|
156
156
|
const definitions = [];
|
|
157
|
-
const orderedExportMap =
|
|
157
|
+
const orderedExportMap = [...this.exportMap].sort(([a], [b]) =>
|
|
158
158
|
a < b ? -1 : 1
|
|
159
159
|
);
|
|
160
160
|
for (const [key, value] of orderedExportMap) {
|
|
@@ -92,15 +92,19 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
|
92
92
|
getImportVar(moduleGraph) {
|
|
93
93
|
const module = /** @type {Module} */ (moduleGraph.getParentModule(this));
|
|
94
94
|
const meta = moduleGraph.getMeta(module);
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
const defer = this.defer;
|
|
96
|
+
|
|
97
|
+
const metaKey = defer ? "deferredImportVarMap" : "importVarMap";
|
|
98
|
+
let importVarMap = meta[metaKey];
|
|
99
|
+
if (!importVarMap) meta[metaKey] = importVarMap = new Map();
|
|
100
|
+
|
|
97
101
|
let importVar = importVarMap.get(
|
|
98
102
|
/** @type {Module} */ (moduleGraph.getModule(this))
|
|
99
103
|
);
|
|
100
104
|
if (importVar) return importVar;
|
|
101
105
|
importVar = `${Template.toIdentifier(
|
|
102
106
|
`${this.userRequest}`
|
|
103
|
-
)}
|
|
107
|
+
)}__WEBPACK_${this.defer ? "DEFERRED_" : ""}IMPORTED_MODULE_${importVarMap.size}__`;
|
|
104
108
|
importVarMap.set(
|
|
105
109
|
/** @type {Module} */ (moduleGraph.getModule(this)),
|
|
106
110
|
importVar
|
|
@@ -120,11 +124,13 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
|
120
124
|
return runtimeTemplate.importStatement({
|
|
121
125
|
update,
|
|
122
126
|
module: /** @type {Module} */ (moduleGraph.getModule(this)),
|
|
127
|
+
moduleGraph,
|
|
123
128
|
chunkGraph,
|
|
124
129
|
importVar: this.getImportVar(moduleGraph),
|
|
125
130
|
request: this.request,
|
|
126
131
|
originModule: module,
|
|
127
|
-
runtimeRequirements
|
|
132
|
+
runtimeRequirements,
|
|
133
|
+
defer: this.defer
|
|
128
134
|
});
|
|
129
135
|
}
|
|
130
136
|
|
|
@@ -299,7 +305,7 @@ HarmonyImportDependency.Template = class HarmonyImportDependencyTemplate extends
|
|
|
299
305
|
const moduleKey = referencedModule
|
|
300
306
|
? referencedModule.identifier()
|
|
301
307
|
: dep.request;
|
|
302
|
-
const key =
|
|
308
|
+
const key = `${dep.defer ? "deferred " : ""}harmony import ${moduleKey}`;
|
|
303
309
|
|
|
304
310
|
const runtimeCondition = dep.weak
|
|
305
311
|
? false
|