webpack 5.92.1 → 5.94.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 +8 -5
- package/bin/webpack.js +6 -7
- package/hot/log.js +1 -2
- package/hot/only-dev-server.js +1 -1
- package/hot/poll.js +1 -1
- package/hot/signal.js +1 -1
- package/lib/APIPlugin.js +4 -3
- package/lib/AbstractMethodError.js +10 -5
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +12 -6
- package/lib/Cache.js +8 -10
- package/lib/CacheFacade.js +3 -3
- package/lib/CaseSensitiveModulesWarning.js +5 -7
- package/lib/Chunk.js +14 -11
- package/lib/ChunkGraph.js +58 -36
- package/lib/ChunkGroup.js +2 -3
- package/lib/ChunkTemplate.js +43 -0
- package/lib/CleanPlugin.js +10 -11
- package/lib/CodeGenerationResults.js +6 -5
- package/lib/CommentCompilationWarning.js +0 -1
- package/lib/Compilation.js +223 -191
- package/lib/Compiler.js +81 -82
- package/lib/ConcatenationScope.js +3 -6
- package/lib/ConditionalInitFragment.js +6 -7
- package/lib/ConstPlugin.js +7 -15
- package/lib/ContextExclusionPlugin.js +3 -3
- package/lib/ContextModule.js +36 -21
- package/lib/ContextModuleFactory.js +89 -44
- package/lib/ContextReplacementPlugin.js +10 -9
- package/lib/DefinePlugin.js +76 -69
- package/lib/DelegatedModule.js +7 -3
- package/lib/DelegatedModuleFactoryPlugin.js +36 -22
- package/lib/DelegatedPlugin.js +4 -0
- package/lib/DependenciesBlock.js +0 -1
- package/lib/Dependency.js +10 -14
- package/lib/DllEntryPlugin.js +4 -2
- package/lib/DllModuleFactory.js +1 -0
- package/lib/DllPlugin.js +9 -7
- package/lib/DllReferencePlugin.js +30 -15
- package/lib/EntryPlugin.js +1 -3
- package/lib/EnvironmentPlugin.js +5 -2
- package/lib/ErrorHelpers.js +11 -12
- package/lib/EvalDevToolModulePlugin.js +10 -12
- package/lib/EvalSourceMapDevToolPlugin.js +15 -13
- package/lib/ExportsInfo.js +185 -120
- package/lib/ExternalModule.js +104 -64
- package/lib/ExternalModuleFactoryPlugin.js +23 -10
- package/lib/FileSystemInfo.js +791 -422
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -1
- package/lib/FlagDependencyExportsPlugin.js +12 -11
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +2 -5
- package/lib/GraphHelpers.js +3 -2
- package/lib/HookWebpackError.js +8 -10
- package/lib/HotModuleReplacementPlugin.js +78 -64
- package/lib/IgnoreErrorModuleFactory.js +3 -3
- package/lib/IgnorePlugin.js +1 -3
- package/lib/IgnoreWarningsPlugin.js +6 -9
- package/lib/InitFragment.js +2 -3
- package/lib/LibManifestPlugin.js +4 -3
- package/lib/MainTemplate.js +72 -19
- package/lib/Module.js +25 -9
- package/lib/ModuleBuildError.js +4 -11
- package/lib/ModuleDependencyError.js +5 -5
- package/lib/ModuleDependencyWarning.js +5 -5
- package/lib/ModuleError.js +1 -5
- package/lib/ModuleFilenameHelpers.js +29 -46
- package/lib/ModuleGraph.js +7 -6
- package/lib/ModuleGraphConnection.js +6 -6
- package/lib/ModuleInfoHeaderPlugin.js +82 -30
- package/lib/ModuleParseError.js +8 -9
- package/lib/ModuleRestoreError.js +1 -1
- package/lib/ModuleStoreError.js +1 -1
- package/lib/ModuleTemplate.js +33 -1
- package/lib/ModuleTypeConstants.js +21 -22
- package/lib/ModuleWarning.js +1 -5
- package/lib/MultiCompiler.js +24 -26
- package/lib/MultiStats.js +73 -31
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +132 -70
- package/lib/NormalModuleFactory.js +53 -49
- package/lib/OptimizationStages.js +3 -3
- package/lib/ProgressPlugin.js +9 -9
- package/lib/ProvidePlugin.js +4 -4
- package/lib/RuntimeGlobals.js +71 -70
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +24 -12
- package/lib/RuntimeTemplate.js +40 -44
- package/lib/SizeFormatHelpers.js +2 -4
- package/lib/SourceMapDevToolPlugin.js +42 -34
- package/lib/Stats.js +5 -11
- package/lib/Template.js +18 -24
- package/lib/TemplatedPathPlugin.js +12 -10
- package/lib/UseStrictPlugin.js +8 -1
- package/lib/WarnDeprecatedOptionPlugin.js +0 -1
- package/lib/WatchIgnorePlugin.js +26 -9
- package/lib/Watching.js +10 -5
- package/lib/WebpackOptionsApply.js +89 -62
- package/lib/asset/AssetGenerator.js +107 -42
- package/lib/asset/AssetModulesPlugin.js +29 -23
- package/lib/asset/AssetSourceGenerator.js +2 -7
- package/lib/async-modules/AwaitDependenciesInitFragment.js +6 -7
- package/lib/buildChunkGraph.js +14 -19
- package/lib/cache/IdleFileCachePlugin.js +4 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +5 -5
- package/lib/cache/PackFileCacheStrategy.js +51 -50
- package/lib/cache/ResolverCachePlugin.js +6 -6
- package/lib/cache/mergeEtags.js +16 -21
- package/lib/cli.js +148 -104
- package/lib/config/browserslistTargetHandler.js +16 -13
- package/lib/config/defaults.js +31 -28
- package/lib/config/normalization.js +335 -344
- package/lib/config/target.js +42 -52
- package/lib/container/ContainerEntryModule.js +2 -2
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/RemoteRuntimeModule.js +11 -8
- package/lib/container/options.js +18 -4
- package/lib/css/CssExportsGenerator.js +39 -40
- package/lib/css/CssGenerator.js +11 -14
- package/lib/css/CssLoadingRuntimeModule.js +10 -10
- package/lib/css/CssModulesPlugin.js +127 -47
- package/lib/css/CssParser.js +20 -18
- package/lib/css/walkCssTokens.js +80 -95
- package/lib/debug/ProfilingPlugin.js +19 -20
- package/lib/dependencies/AMDDefineDependency.js +1 -1
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +83 -47
- package/lib/dependencies/AMDRequireArrayDependency.js +9 -10
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +22 -16
- package/lib/dependencies/AMDRuntimeModules.js +2 -2
- package/lib/dependencies/CommonJsDependencyHelpers.js +6 -2
- package/lib/dependencies/CommonJsExportRequireDependency.js +37 -41
- package/lib/dependencies/CommonJsExportsDependency.js +0 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +19 -23
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +52 -61
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +6 -8
- package/lib/dependencies/ConstDependency.js +1 -1
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +31 -34
- package/lib/dependencies/ContextElementDependency.js +2 -2
- package/lib/dependencies/CriticalDependencyWarning.js +1 -1
- package/lib/dependencies/CssExportDependency.js +72 -9
- package/lib/dependencies/CssImportDependency.js +0 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +68 -21
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +4 -5
- package/lib/dependencies/DynamicExports.js +5 -5
- package/lib/dependencies/ExportsInfoDependency.js +1 -2
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +27 -16
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +107 -64
- package/lib/dependencies/HarmonyExports.js +2 -2
- package/lib/dependencies/HarmonyImportDependency.js +2 -4
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +41 -16
- package/lib/dependencies/ImportDependency.js +1 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +5 -5
- package/lib/dependencies/ImportMetaPlugin.js +11 -13
- package/lib/dependencies/ImportParserPlugin.js +39 -44
- package/lib/dependencies/JsonExportsDependency.js +22 -18
- package/lib/dependencies/LoaderPlugin.js +47 -36
- package/lib/dependencies/LocalModule.js +1 -1
- package/lib/dependencies/LocalModulesHelpers.js +4 -4
- package/lib/dependencies/ModuleDecoratorDependency.js +1 -1
- package/lib/dependencies/ProvidedDependency.js +1 -1
- package/lib/dependencies/PureExpressionDependency.js +6 -6
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLDependency.js +3 -3
- package/lib/dependencies/URLPlugin.js +66 -12
- package/lib/dependencies/WorkerPlugin.js +25 -24
- package/lib/dependencies/processExportInfo.js +3 -1
- package/lib/electron/ElectronTargetPlugin.js +1 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +11 -12
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -3
- package/lib/formatLocation.js +1 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +4 -5
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +9 -12
- package/lib/hmr/LazyCompilationPlugin.js +27 -12
- package/lib/hmr/lazyCompilationBackend.js +64 -40
- package/lib/ids/ChunkModuleIdRangePlugin.js +1 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +2 -4
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +5 -1
- package/lib/ids/IdHelpers.js +29 -39
- package/lib/ids/SyncModuleIdsPlugin.js +7 -2
- package/lib/index.js +1 -5
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +6 -4
- package/lib/javascript/BasicEvaluatedExpression.js +4 -19
- package/lib/javascript/ChunkHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +10 -11
- package/lib/javascript/EnableChunkLoadingPlugin.js +7 -6
- package/lib/javascript/JavascriptGenerator.js +23 -7
- package/lib/javascript/JavascriptModulesPlugin.js +97 -70
- package/lib/javascript/JavascriptParser.js +179 -200
- package/lib/javascript/JavascriptParserHelpers.js +20 -21
- package/lib/javascript/StartupHelpers.js +41 -13
- package/lib/json/JsonGenerator.js +7 -13
- package/lib/json/JsonModulesPlugin.js +1 -4
- package/lib/json/JsonParser.js +5 -3
- package/lib/library/AmdLibraryPlugin.js +12 -16
- package/lib/library/AssignLibraryPlugin.js +9 -11
- package/lib/library/EnableLibraryPlugin.js +25 -15
- package/lib/library/ExportPropertyLibraryPlugin.js +8 -2
- package/lib/library/JsonpLibraryPlugin.js +2 -1
- package/lib/library/ModernModuleLibraryPlugin.js +144 -0
- package/lib/library/ModuleLibraryPlugin.js +2 -1
- package/lib/library/SystemLibraryPlugin.js +2 -1
- package/lib/library/UmdLibraryPlugin.js +66 -92
- package/lib/logging/Logger.js +32 -4
- package/lib/logging/createConsoleLogger.js +12 -13
- package/lib/logging/runtime.js +7 -8
- package/lib/logging/truncateArgs.js +5 -8
- package/lib/node/NodeWatchFileSystem.js +3 -18
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/nodeConsole.js +22 -22
- package/lib/optimize/AggressiveMergingPlugin.js +2 -4
- package/lib/optimize/AggressiveSplittingPlugin.js +16 -19
- package/lib/optimize/ConcatenatedModule.js +144 -61
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -3
- package/lib/optimize/InnerGraph.js +17 -17
- package/lib/optimize/InnerGraphPlugin.js +8 -7
- package/lib/optimize/LimitChunkCountPlugin.js +2 -3
- package/lib/optimize/MangleExportsPlugin.js +1 -0
- package/lib/optimize/MinMaxSizeWarning.js +1 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +56 -78
- package/lib/optimize/RealContentHashPlugin.js +7 -10
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -2
- package/lib/optimize/SplitChunksPlugin.js +34 -30
- package/lib/performance/SizeLimitsPlugin.js +2 -2
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +1 -0
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -1
- package/lib/rules/BasicEffectRulePlugin.js +3 -1
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +4 -1
- package/lib/rules/RuleSetCompiler.js +41 -22
- package/lib/rules/UseEffectRulePlugin.js +36 -32
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -1
- package/lib/runtime/EnsureChunkRuntimeModule.js +10 -11
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +11 -17
- package/lib/runtime/LoadScriptRuntimeModule.js +17 -18
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -3
- package/lib/schemes/DataUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +241 -126
- package/lib/serialization/BinaryMiddleware.js +44 -28
- package/lib/serialization/DateObjectSerializer.js +1 -0
- package/lib/serialization/ErrorObjectSerializer.js +2 -0
- package/lib/serialization/FileMiddleware.js +154 -106
- package/lib/serialization/MapObjectSerializer.js +2 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +3 -2
- package/lib/serialization/ObjectMiddleware.js +52 -56
- package/lib/serialization/PlainObjectSerializer.js +32 -6
- package/lib/serialization/RegExpObjectSerializer.js +1 -0
- package/lib/serialization/Serializer.js +4 -5
- package/lib/serialization/SerializerMiddleware.js +6 -6
- package/lib/serialization/SetObjectSerializer.js +2 -1
- package/lib/sharing/ConsumeSharedModule.js +19 -14
- package/lib/sharing/ConsumeSharedPlugin.js +116 -97
- package/lib/sharing/ConsumeSharedRuntimeModule.js +108 -141
- package/lib/sharing/ProvideForSharedDependency.js +0 -1
- package/lib/sharing/ProvideSharedPlugin.js +2 -2
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +15 -27
- package/lib/stats/DefaultStatsFactoryPlugin.js +424 -281
- package/lib/stats/DefaultStatsPresetPlugin.js +73 -18
- package/lib/stats/DefaultStatsPrinterPlugin.js +370 -101
- package/lib/stats/StatsFactory.js +127 -56
- package/lib/stats/StatsPrinter.js +75 -44
- package/lib/util/ArrayHelpers.js +8 -4
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +31 -12
- package/lib/util/IterableHelpers.js +3 -4
- package/lib/util/LazyBucketSortedSet.js +60 -44
- package/lib/util/LazySet.js +1 -0
- package/lib/util/MapHelpers.js +1 -3
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/Queue.js +1 -1
- package/lib/util/Semaphore.js +4 -7
- package/lib/util/SetHelpers.js +5 -5
- package/lib/util/SortableSet.js +4 -3
- package/lib/util/StackedCacheMap.js +4 -6
- package/lib/util/StackedMap.js +1 -3
- package/lib/util/StringXor.js +0 -5
- package/lib/util/TupleQueue.js +1 -1
- package/lib/util/TupleSet.js +15 -5
- package/lib/util/URLAbsoluteSpecifier.js +7 -7
- package/lib/util/WeakTupleMap.js +19 -21
- package/lib/util/binarySearchBounds.js +5 -12
- package/lib/util/chainedImports.js +1 -1
- package/lib/util/cleverMerge.js +21 -19
- package/lib/util/comparators.js +57 -52
- package/lib/util/compileBooleanMatcher.js +3 -6
- package/lib/util/conventions.js +10 -13
- package/lib/util/createHash.js +9 -6
- package/lib/util/deprecation.js +22 -12
- package/lib/util/deterministicGrouping.js +19 -26
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +31 -31
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +7 -7
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +81 -59
- package/lib/util/memoize.js +8 -10
- package/lib/util/mergeScope.js +6 -9
- package/lib/util/nonNumericOnlyHash.js +2 -2
- package/lib/util/numberHash.js +1 -6
- package/lib/util/objectToMap.js +0 -1
- package/lib/util/propertyAccess.js +2 -5
- package/lib/util/propertyName.js +1 -3
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/util/runtime.js +103 -113
- package/lib/util/semver.js +29 -27
- package/lib/util/serialization.js +16 -1
- package/lib/util/smartGrouping.js +5 -5
- package/lib/util/source.js +1 -1
- package/lib/wasm/EnableWasmLoadingPlugin.js +5 -4
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -6
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +20 -19
- package/lib/wasm-sync/WebAssemblyGenerator.js +14 -29
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +17 -16
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +17 -0
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
- package/types.d.ts +682 -347
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const ConditionalInitFragment = require("../ConditionalInitFragment");
|
8
9
|
const Dependency = require("../Dependency");
|
9
10
|
const { UsageState } = require("../ExportsInfo");
|
10
11
|
const HarmonyLinkingError = require("../HarmonyLinkingError");
|
@@ -16,7 +17,11 @@ const { first, combine } = require("../util/SetHelpers");
|
|
16
17
|
const makeSerializable = require("../util/makeSerializable");
|
17
18
|
const propertyAccess = require("../util/propertyAccess");
|
18
19
|
const { propertyName } = require("../util/propertyName");
|
19
|
-
const {
|
20
|
+
const {
|
21
|
+
getRuntimeKey,
|
22
|
+
keyToRuntime,
|
23
|
+
filterRuntime
|
24
|
+
} = require("../util/runtime");
|
20
25
|
const HarmonyExportInitFragment = require("./HarmonyExportInitFragment");
|
21
26
|
const HarmonyImportDependency = require("./HarmonyImportDependency");
|
22
27
|
const processExportInfo = require("./processExportInfo");
|
@@ -31,6 +36,7 @@ const processExportInfo = require("./processExportInfo");
|
|
31
36
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
32
37
|
/** @typedef {import("../ExportsInfo")} ExportsInfo */
|
33
38
|
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
|
39
|
+
/** @typedef {import("../ExportsInfo").UsedName} UsedName */
|
34
40
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
35
41
|
/** @typedef {import("../Module")} Module */
|
36
42
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
@@ -45,6 +51,7 @@ const processExportInfo = require("./processExportInfo");
|
|
45
51
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
46
52
|
/** @typedef {import("../util/Hash")} Hash */
|
47
53
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
54
|
+
/** @typedef {import("./processExportInfo").ReferencedExports} ReferencedExports */
|
48
55
|
|
49
56
|
/** @typedef {"missing"|"unused"|"empty-star"|"reexport-dynamic-default"|"reexport-named-default"|"reexport-namespace-object"|"reexport-fake-namespace-object"|"reexport-undefined"|"normal-reexport"|"dynamic-reexport"} ExportModeType */
|
50
57
|
|
@@ -69,6 +76,9 @@ class NormalReexportItem {
|
|
69
76
|
}
|
70
77
|
}
|
71
78
|
|
79
|
+
/** @typedef {Set<string>} ExportModeIgnored */
|
80
|
+
/** @typedef {Set<string>} ExportModeHidden */
|
81
|
+
|
72
82
|
class ExportMode {
|
73
83
|
/**
|
74
84
|
* @param {ExportModeType} type type of the mode
|
@@ -88,11 +98,11 @@ class ExportMode {
|
|
88
98
|
this.partialNamespaceExportInfo = null;
|
89
99
|
|
90
100
|
// for "dynamic-reexport":
|
91
|
-
/** @type {
|
101
|
+
/** @type {ExportModeIgnored | null} */
|
92
102
|
this.ignored = null;
|
93
103
|
|
94
104
|
// for "dynamic-reexport" | "empty-star":
|
95
|
-
/** @type {
|
105
|
+
/** @type {ExportModeHidden | null} */
|
96
106
|
this.hidden = null;
|
97
107
|
|
98
108
|
// for "missing":
|
@@ -306,7 +316,8 @@ const getMode = (moduleGraph, dep, runtimeKey) => {
|
|
306
316
|
exportName,
|
307
317
|
[exportName],
|
308
318
|
exportsInfo.getReadOnlyExportInfo(exportName),
|
309
|
-
|
319
|
+
/** @type {Set<string>} */
|
320
|
+
(checked).has(exportName),
|
310
321
|
false
|
311
322
|
)
|
312
323
|
);
|
@@ -327,11 +338,17 @@ const getMode = (moduleGraph, dep, runtimeKey) => {
|
|
327
338
|
return mode;
|
328
339
|
};
|
329
340
|
|
341
|
+
/** @typedef {string[]} Ids */
|
342
|
+
/** @typedef {Set<string>} Exports */
|
343
|
+
/** @typedef {Set<string>} Checked */
|
344
|
+
/** @typedef {Set<string>} Hidden */
|
345
|
+
/** @typedef {Set<string>} IgnoredExports */
|
346
|
+
|
330
347
|
class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
331
348
|
/**
|
332
349
|
* @param {string} request the request string
|
333
350
|
* @param {number} sourceOrder the order in the original source file
|
334
|
-
* @param {
|
351
|
+
* @param {Ids} ids the requested export name of the imported module
|
335
352
|
* @param {string | null} name the export name of for this module
|
336
353
|
* @param {Set<string>} activeExports other named exports in the module
|
337
354
|
* @param {ReadonlyArray<HarmonyExportImportedSpecifierDependency> | Iterable<HarmonyExportImportedSpecifierDependency> | null} otherStarExports other star exports in the module before this import
|
@@ -388,7 +405,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
388
405
|
|
389
406
|
/**
|
390
407
|
* @param {ModuleGraph} moduleGraph the module graph
|
391
|
-
* @returns {
|
408
|
+
* @returns {Ids} the imported id
|
392
409
|
*/
|
393
410
|
getIds(moduleGraph) {
|
394
411
|
return moduleGraph.getMeta(this)[idsSymbol] || this.ids;
|
@@ -396,7 +413,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
396
413
|
|
397
414
|
/**
|
398
415
|
* @param {ModuleGraph} moduleGraph the module graph
|
399
|
-
* @param {
|
416
|
+
* @param {Ids} ids the imported ids
|
400
417
|
* @returns {void}
|
401
418
|
*/
|
402
419
|
setIds(moduleGraph, ids) {
|
@@ -421,7 +438,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
421
438
|
* @param {RuntimeSpec} runtime the runtime
|
422
439
|
* @param {ExportsInfo} exportsInfo exports info about the current module (optional)
|
423
440
|
* @param {Module} importedModule the imported module (optional)
|
424
|
-
* @returns {{exports?:
|
441
|
+
* @returns {{exports?: Exports, checked?: Checked, ignoredExports: IgnoredExports, hidden?: Hidden}} information
|
425
442
|
*/
|
426
443
|
getStarReexports(
|
427
444
|
moduleGraph,
|
@@ -439,7 +456,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
439
456
|
|
440
457
|
const ignoredExports = new Set(["default", ...this.activeExports]);
|
441
458
|
|
442
|
-
let hiddenExports
|
459
|
+
let hiddenExports;
|
443
460
|
const otherStarExports =
|
444
461
|
this._discoverActiveExportsFromOtherStarExports(moduleGraph);
|
445
462
|
if (otherStarExports !== undefined) {
|
@@ -457,11 +474,11 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
457
474
|
};
|
458
475
|
}
|
459
476
|
|
460
|
-
/** @type {
|
477
|
+
/** @type {Exports} */
|
461
478
|
const exports = new Set();
|
462
|
-
/** @type {
|
479
|
+
/** @type {Checked} */
|
463
480
|
const checked = new Set();
|
464
|
-
/** @type {
|
481
|
+
/** @type {Hidden | undefined} */
|
465
482
|
const hidden = hiddenExports !== undefined ? new Set() : undefined;
|
466
483
|
|
467
484
|
if (noExtraImports) {
|
@@ -489,7 +506,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
489
506
|
const exportInfo = exportsInfo.getReadOnlyExportInfo(name);
|
490
507
|
if (exportInfo.getUsed(runtime) === UsageState.Unused) continue;
|
491
508
|
if (hiddenExports !== undefined && hiddenExports.has(name)) {
|
492
|
-
/** @type {
|
509
|
+
/** @type {ExportModeHidden} */
|
493
510
|
(hidden).add(name);
|
494
511
|
continue;
|
495
512
|
}
|
@@ -543,7 +560,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
543
560
|
case "reexport-named-default": {
|
544
561
|
if (!mode.partialNamespaceExportInfo)
|
545
562
|
return Dependency.EXPORTS_OBJECT_REFERENCED;
|
546
|
-
/** @type {
|
563
|
+
/** @type {ReferencedExports} */
|
547
564
|
const referencedExports = [];
|
548
565
|
processExportInfo(
|
549
566
|
runtime,
|
@@ -558,7 +575,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
558
575
|
case "reexport-fake-namespace-object": {
|
559
576
|
if (!mode.partialNamespaceExportInfo)
|
560
577
|
return Dependency.EXPORTS_OBJECT_REFERENCED;
|
561
|
-
/** @type {
|
578
|
+
/** @type {ReferencedExports} */
|
562
579
|
const referencedExports = [];
|
563
580
|
processExportInfo(
|
564
581
|
runtime,
|
@@ -574,6 +591,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
574
591
|
return Dependency.EXPORTS_OBJECT_REFERENCED;
|
575
592
|
|
576
593
|
case "normal-reexport": {
|
594
|
+
/** @type {ReferencedExports} */
|
577
595
|
const referencedExports = [];
|
578
596
|
for (const { ids, exportInfo, hidden } of mode.items) {
|
579
597
|
if (hidden) continue;
|
@@ -592,13 +610,13 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
592
610
|
* @returns {{ names: string[], namesSlice: number, dependencyIndices: number[], dependencyIndex: number } | undefined} exported names and their origin dependency
|
593
611
|
*/
|
594
612
|
_discoverActiveExportsFromOtherStarExports(moduleGraph) {
|
595
|
-
if (!this.otherStarExports) return
|
613
|
+
if (!this.otherStarExports) return;
|
596
614
|
|
597
615
|
const i =
|
598
616
|
"length" in this.otherStarExports
|
599
617
|
? this.otherStarExports.length
|
600
618
|
: countIterable(this.otherStarExports);
|
601
|
-
if (i === 0) return
|
619
|
+
if (i === 0) return;
|
602
620
|
|
603
621
|
if (this.allStarExports) {
|
604
622
|
const { names, dependencyIndices } = moduleGraph.cached(
|
@@ -638,7 +656,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
638
656
|
|
639
657
|
switch (mode.type) {
|
640
658
|
case "missing":
|
641
|
-
return
|
659
|
+
return;
|
642
660
|
case "dynamic-reexport": {
|
643
661
|
const from =
|
644
662
|
/** @type {ModuleGraphConnection} */
|
@@ -648,8 +666,11 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
648
666
|
from,
|
649
667
|
canMangle: false,
|
650
668
|
excludeExports: mode.hidden
|
651
|
-
? combine(
|
652
|
-
|
669
|
+
? combine(
|
670
|
+
/** @type {ExportModeIgnored} */ (mode.ignored),
|
671
|
+
mode.hidden
|
672
|
+
)
|
673
|
+
: /** @type {ExportModeIgnored} */ (mode.ignored),
|
653
674
|
hideExports: mode.hidden,
|
654
675
|
dependencies: [from.module]
|
655
676
|
};
|
@@ -677,22 +698,20 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
677
698
|
};
|
678
699
|
}
|
679
700
|
case "reexport-dynamic-default": {
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
{
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
};
|
695
|
-
}
|
701
|
+
const from =
|
702
|
+
/** @type {ModuleGraphConnection} */
|
703
|
+
(moduleGraph.getConnection(this));
|
704
|
+
return {
|
705
|
+
exports: [
|
706
|
+
{
|
707
|
+
name: /** @type {string} */ (mode.name),
|
708
|
+
from,
|
709
|
+
export: ["default"]
|
710
|
+
}
|
711
|
+
],
|
712
|
+
priority: 1,
|
713
|
+
dependencies: [from.module]
|
714
|
+
};
|
696
715
|
}
|
697
716
|
case "reexport-undefined":
|
698
717
|
return {
|
@@ -825,6 +844,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
825
844
|
const importedModule = moduleGraph.getModule(this);
|
826
845
|
if (importedModule) {
|
827
846
|
const exportsInfo = moduleGraph.getExportsInfo(importedModule);
|
847
|
+
/** @type {Map<string, string[]>} */
|
828
848
|
const conflicts = new Map();
|
829
849
|
for (const exportInfo of exportsInfo.orderedExports) {
|
830
850
|
if (exportInfo.provided !== true) continue;
|
@@ -841,12 +861,12 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
841
861
|
if (!conflictingDependency) continue;
|
842
862
|
const target = exportInfo.getTerminalBinding(moduleGraph);
|
843
863
|
if (!target) continue;
|
844
|
-
const conflictingModule =
|
845
|
-
|
846
|
-
|
864
|
+
const conflictingModule =
|
865
|
+
/** @type {Module} */
|
866
|
+
(moduleGraph.getModule(conflictingDependency));
|
847
867
|
if (conflictingModule === importedModule) continue;
|
848
868
|
const conflictingExportInfo = moduleGraph.getExportInfo(
|
849
|
-
|
869
|
+
conflictingModule,
|
850
870
|
exportInfo.name
|
851
871
|
);
|
852
872
|
const conflictingTarget =
|
@@ -944,7 +964,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
944
964
|
switch (mode.type) {
|
945
965
|
case "reexport-undefined":
|
946
966
|
concatenationScope.registerRawExport(
|
947
|
-
mode.name,
|
967
|
+
/** @type {NonNullable<ExportMode["name"]>} */ (mode.name),
|
948
968
|
"/* reexport non-default export from non-harmony */ undefined"
|
949
969
|
);
|
950
970
|
}
|
@@ -1080,23 +1100,36 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
1080
1100
|
break;
|
1081
1101
|
|
1082
1102
|
case "normal-reexport":
|
1083
|
-
for (const {
|
1103
|
+
for (const {
|
1104
|
+
name,
|
1105
|
+
ids,
|
1106
|
+
checked,
|
1107
|
+
hidden
|
1108
|
+
} of /** @type {NormalReexportItem[]} */ (mode.items)) {
|
1084
1109
|
if (hidden) continue;
|
1085
1110
|
if (checked) {
|
1111
|
+
const connection = moduleGraph.getConnection(dep);
|
1112
|
+
const key = `harmony reexport (checked) ${importVar} ${name}`;
|
1113
|
+
const runtimeCondition = dep.weak
|
1114
|
+
? false
|
1115
|
+
: connection
|
1116
|
+
? filterRuntime(runtime, r => connection.isTargetActive(r))
|
1117
|
+
: true;
|
1086
1118
|
initFragments.push(
|
1087
|
-
new
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
),
|
1119
|
+
new ConditionalInitFragment(
|
1120
|
+
`/* harmony reexport (checked) */ ${this.getConditionalReexportStatement(
|
1121
|
+
module,
|
1122
|
+
name,
|
1123
|
+
importVar,
|
1124
|
+
ids,
|
1125
|
+
runtimeRequirements
|
1126
|
+
)}`,
|
1096
1127
|
moduleGraph.isAsync(importedModule)
|
1097
1128
|
? InitFragment.STAGE_ASYNC_HARMONY_IMPORTS
|
1098
1129
|
: InitFragment.STAGE_HARMONY_IMPORTS,
|
1099
|
-
dep.sourceOrder
|
1130
|
+
dep.sourceOrder,
|
1131
|
+
key,
|
1132
|
+
runtimeCondition
|
1100
1133
|
)
|
1101
1134
|
);
|
1102
1135
|
} else {
|
@@ -1118,8 +1151,12 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
1118
1151
|
|
1119
1152
|
case "dynamic-reexport": {
|
1120
1153
|
const ignored = mode.hidden
|
1121
|
-
? combine(
|
1122
|
-
|
1154
|
+
? combine(
|
1155
|
+
/** @type {ExportModeIgnored} */
|
1156
|
+
(mode.ignored),
|
1157
|
+
mode.hidden
|
1158
|
+
)
|
1159
|
+
: /** @type {ExportModeIgnored} */ (mode.ignored);
|
1123
1160
|
const modern =
|
1124
1161
|
runtimeTemplate.supportsConst() &&
|
1125
1162
|
runtimeTemplate.supportsArrowFunction();
|
@@ -1132,22 +1169,19 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
1132
1169
|
// Filter out exports which are defined by other exports
|
1133
1170
|
// and filter out default export because it cannot be reexported with *
|
1134
1171
|
if (ignored.size > 1) {
|
1135
|
-
content +=
|
1136
|
-
|
1137
|
-
|
1138
|
-
".indexOf(__WEBPACK_IMPORT_KEY__) < 0) ";
|
1172
|
+
content += `if(${JSON.stringify(
|
1173
|
+
Array.from(ignored)
|
1174
|
+
)}.indexOf(__WEBPACK_IMPORT_KEY__) < 0) `;
|
1139
1175
|
} else if (ignored.size === 1) {
|
1140
1176
|
content += `if(__WEBPACK_IMPORT_KEY__ !== ${JSON.stringify(
|
1141
1177
|
first(ignored)
|
1142
1178
|
)}) `;
|
1143
1179
|
}
|
1144
1180
|
|
1145
|
-
content +=
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
content += `function(key) { return ${importVar}[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)`;
|
1150
|
-
}
|
1181
|
+
content += "__WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = ";
|
1182
|
+
content += modern
|
1183
|
+
? `() => ${importVar}[__WEBPACK_IMPORT_KEY__]`
|
1184
|
+
: `function(key) { return ${importVar}[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)`;
|
1151
1185
|
|
1152
1186
|
runtimeRequirements.add(RuntimeGlobals.exports);
|
1153
1187
|
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
|
@@ -1170,6 +1204,15 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
1170
1204
|
}
|
1171
1205
|
}
|
1172
1206
|
|
1207
|
+
/**
|
1208
|
+
* @param {Module} module the current module
|
1209
|
+
* @param {string} comment comment
|
1210
|
+
* @param {UsedName} key key
|
1211
|
+
* @param {string} name name
|
1212
|
+
* @param {string | string[] | null | false} valueKey value key
|
1213
|
+
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
|
1214
|
+
* @returns {HarmonyExportInitFragment} harmony export init fragment
|
1215
|
+
*/
|
1173
1216
|
getReexportFragment(
|
1174
1217
|
module,
|
1175
1218
|
comment,
|
@@ -19,7 +19,7 @@ const parserStateExportsState = new WeakMap();
|
|
19
19
|
* @param {boolean} isStrictHarmony strict harmony mode should be enabled
|
20
20
|
* @returns {void}
|
21
21
|
*/
|
22
|
-
exports.enable = (parserState, isStrictHarmony) => {
|
22
|
+
module.exports.enable = (parserState, isStrictHarmony) => {
|
23
23
|
const value = parserStateExportsState.get(parserState);
|
24
24
|
if (value === false) return;
|
25
25
|
parserStateExportsState.set(parserState, true);
|
@@ -40,7 +40,7 @@ exports.enable = (parserState, isStrictHarmony) => {
|
|
40
40
|
* @param {ParserState} parserState parser state
|
41
41
|
* @returns {boolean} true, when enabled
|
42
42
|
*/
|
43
|
-
exports.isEnabled = parserState => {
|
43
|
+
module.exports.isEnabled = parserState => {
|
44
44
|
const value = parserStateExportsState.get(parserState);
|
45
45
|
return value === true;
|
46
46
|
};
|
@@ -59,7 +59,6 @@ const ExportPresenceModes = {
|
|
59
59
|
|
60
60
|
class HarmonyImportDependency extends ModuleDependency {
|
61
61
|
/**
|
62
|
-
*
|
63
62
|
* @param {string} request request string
|
64
63
|
* @param {number} sourceOrder source order
|
65
64
|
* @param {ImportAttributes=} attributes import attributes
|
@@ -89,7 +88,7 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
89
88
|
* @returns {string} name of the variable for the import
|
90
89
|
*/
|
91
90
|
getImportVar(moduleGraph) {
|
92
|
-
const module = moduleGraph.getParentModule(this);
|
91
|
+
const module = /** @type {Module} */ (moduleGraph.getParentModule(this));
|
93
92
|
const meta = /** @type {TODO} */ (moduleGraph.getMeta(module));
|
94
93
|
let importVarMap = meta.importVarMap;
|
95
94
|
if (!importVarMap) meta.importVarMap = importVarMap = new Map();
|
@@ -351,7 +350,7 @@ HarmonyImportDependency.Template = class HarmonyImportDependencyTemplate extends
|
|
351
350
|
importStatement[1],
|
352
351
|
InitFragment.STAGE_ASYNC_HARMONY_IMPORTS,
|
353
352
|
dep.sourceOrder,
|
354
|
-
key
|
353
|
+
`${key} compat`,
|
355
354
|
runtimeCondition
|
356
355
|
)
|
357
356
|
);
|
@@ -369,7 +368,6 @@ HarmonyImportDependency.Template = class HarmonyImportDependencyTemplate extends
|
|
369
368
|
}
|
370
369
|
|
371
370
|
/**
|
372
|
-
*
|
373
371
|
* @param {Module} module the module
|
374
372
|
* @param {Module} referencedModule the referenced module
|
375
373
|
* @returns {RuntimeSpec | boolean} runtimeCondition in which this import has been emitted
|
@@ -50,7 +50,7 @@ const harmonySpecifierTag = Symbol("harmony import");
|
|
50
50
|
|
51
51
|
/**
|
52
52
|
* @param {ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration | (ImportExpression & { arguments?: ObjectExpression[] })} node node with assertions
|
53
|
-
* @returns {ImportAttributes} import attributes
|
53
|
+
* @returns {ImportAttributes | undefined} import attributes
|
54
54
|
*/
|
55
55
|
function getAttributes(node) {
|
56
56
|
if (
|
@@ -96,7 +96,7 @@ function getAttributes(node) {
|
|
96
96
|
? /** @type {{ assertions?: ImportAttributeNode[] }} */ (node).assertions
|
97
97
|
: /** @type {{ attributes?: ImportAttributeNode[] }} */ (node).attributes;
|
98
98
|
if (attributes === undefined) {
|
99
|
-
return
|
99
|
+
return;
|
100
100
|
}
|
101
101
|
const result = /** @type {ImportAttributes} */ ({});
|
102
102
|
for (const attribute of attributes) {
|
@@ -138,12 +138,22 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
138
138
|
apply(parser) {
|
139
139
|
const { exportPresenceMode } = this;
|
140
140
|
|
141
|
+
/**
|
142
|
+
* @param {string[]} members members
|
143
|
+
* @param {boolean[]} membersOptionals members Optionals
|
144
|
+
* @returns {string[]} a non optional part
|
145
|
+
*/
|
141
146
|
function getNonOptionalPart(members, membersOptionals) {
|
142
147
|
let i = 0;
|
143
148
|
while (i < members.length && membersOptionals[i] === false) i++;
|
144
149
|
return i !== members.length ? members.slice(0, i) : members;
|
145
150
|
}
|
146
151
|
|
152
|
+
/**
|
153
|
+
* @param {TODO} node member expression
|
154
|
+
* @param {number} count count
|
155
|
+
* @returns {TODO} member expression
|
156
|
+
*/
|
147
157
|
function getNonOptionalMemberChain(node, count) {
|
148
158
|
while (count--) node = node.object;
|
149
159
|
return node;
|
@@ -221,7 +231,9 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
221
231
|
)
|
222
232
|
return;
|
223
233
|
const settings = rootInfo.tagInfo.data;
|
224
|
-
const members =
|
234
|
+
const members =
|
235
|
+
/** @type {(() => string[])} */
|
236
|
+
(rightPart.getMembers)();
|
225
237
|
const dep = new HarmonyEvaluatedImportSpecifierDependency(
|
226
238
|
settings.source,
|
227
239
|
settings.sourceOrder,
|
@@ -280,6 +292,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
280
292
|
members,
|
281
293
|
membersOptionals
|
282
294
|
);
|
295
|
+
/** @type {Range[]} */
|
283
296
|
const ranges = memberRanges.slice(
|
284
297
|
0,
|
285
298
|
memberRanges.length - (members.length - nonOptionalMembers.length)
|
@@ -326,6 +339,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
326
339
|
members,
|
327
340
|
membersOptionals
|
328
341
|
);
|
342
|
+
/** @type {Range[]} */
|
329
343
|
const ranges = memberRanges.slice(
|
330
344
|
0,
|
331
345
|
memberRanges.length - (members.length - nonOptionalMembers.length)
|
@@ -355,7 +369,8 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
355
369
|
);
|
356
370
|
// only in case when we strictly follow the spec we need a special case here
|
357
371
|
dep.namespaceObjectAsContext =
|
358
|
-
members.length > 0 &&
|
372
|
+
members.length > 0 &&
|
373
|
+
/** @type {boolean} */ (this.strictThisContextOnImports);
|
359
374
|
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
360
375
|
parser.state.module.addDependency(dep);
|
361
376
|
if (args) parser.walkExpressions(args);
|
@@ -42,7 +42,7 @@ const { ExportPresenceModes } = HarmonyImportDependency;
|
|
42
42
|
|
43
43
|
class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
44
44
|
/**
|
45
|
-
* @param {
|
45
|
+
* @param {string} request request
|
46
46
|
* @param {number} sourceOrder source order
|
47
47
|
* @param {string[]} ids ids
|
48
48
|
* @param {string} name name
|
@@ -67,7 +67,6 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
67
67
|
this.range = range;
|
68
68
|
this.idRanges = idRanges;
|
69
69
|
this.exportPresenceMode = exportPresenceMode;
|
70
|
-
/** @type {boolean | undefined} */
|
71
70
|
this.namespaceObjectAsContext = false;
|
72
71
|
this.call = undefined;
|
73
72
|
this.directImport = undefined;
|
@@ -105,7 +104,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
105
104
|
getIds(moduleGraph) {
|
106
105
|
const meta = moduleGraph.getMetaIfExisting(this);
|
107
106
|
if (meta === undefined) return this.ids;
|
108
|
-
const ids = meta[idsSymbol];
|
107
|
+
const ids = meta[/** @type {keyof object} */ (idsSymbol)];
|
109
108
|
return ids !== undefined ? ids : this.ids;
|
110
109
|
}
|
111
110
|
|
@@ -149,7 +148,9 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
149
148
|
if (ids.length === 0) return this._getReferencedExportsInDestructuring();
|
150
149
|
let namespaceObjectAsContext = this.namespaceObjectAsContext;
|
151
150
|
if (ids[0] === "default") {
|
152
|
-
const selfModule =
|
151
|
+
const selfModule =
|
152
|
+
/** @type {Module} */
|
153
|
+
(moduleGraph.getParentModule(this));
|
153
154
|
const importedModule =
|
154
155
|
/** @type {Module} */
|
155
156
|
(moduleGraph.getModule(this));
|
@@ -196,9 +197,8 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
196
197
|
refs.push(ids ? ids.concat([id]) : [id]);
|
197
198
|
}
|
198
199
|
return refs;
|
199
|
-
} else {
|
200
|
-
return ids ? [ids] : Dependency.EXPORTS_OBJECT_REFERENCED;
|
201
200
|
}
|
201
|
+
return ids ? [ids] : Dependency.EXPORTS_OBJECT_REFERENCED;
|
202
202
|
}
|
203
203
|
|
204
204
|
/**
|
@@ -208,9 +208,12 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
208
208
|
_getEffectiveExportPresenceLevel(moduleGraph) {
|
209
209
|
if (this.exportPresenceMode !== ExportPresenceModes.AUTO)
|
210
210
|
return this.exportPresenceMode;
|
211
|
-
const buildMeta =
|
212
|
-
|
213
|
-
|
211
|
+
const buildMeta =
|
212
|
+
/** @type {BuildMeta} */
|
213
|
+
(
|
214
|
+
/** @type {Module} */
|
215
|
+
(moduleGraph.getParentModule(this)).buildMeta
|
216
|
+
);
|
214
217
|
return buildMeta.strictHarmonyModule
|
215
218
|
? ExportPresenceModes.ERROR
|
216
219
|
: ExportPresenceModes.WARN;
|
@@ -344,14 +347,34 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
|
344
347
|
}
|
345
348
|
|
346
349
|
if (dep.referencedPropertiesInDestructuring) {
|
347
|
-
|
350
|
+
let prefixedIds = ids;
|
351
|
+
|
352
|
+
if (ids[0] === "default") {
|
353
|
+
const selfModule = moduleGraph.getParentModule(dep);
|
354
|
+
const importedModule =
|
355
|
+
/** @type {Module} */
|
356
|
+
(moduleGraph.getModule(dep));
|
357
|
+
const exportsType = importedModule.getExportsType(
|
358
|
+
moduleGraph,
|
359
|
+
/** @type {BuildMeta} */
|
360
|
+
(selfModule.buildMeta).strictHarmonyModule
|
361
|
+
);
|
362
|
+
if (
|
363
|
+
(exportsType === "default-only" ||
|
364
|
+
exportsType === "default-with-named") &&
|
365
|
+
ids.length >= 1
|
366
|
+
) {
|
367
|
+
prefixedIds = ids.slice(1);
|
368
|
+
}
|
369
|
+
}
|
370
|
+
|
371
|
+
for (const {
|
348
372
|
id,
|
349
373
|
shorthand,
|
350
374
|
range
|
351
375
|
} of dep.referencedPropertiesInDestructuring) {
|
352
|
-
const concatedIds =
|
353
|
-
|
354
|
-
const module = moduleGraph.getModule(dep);
|
376
|
+
const concatedIds = prefixedIds.concat([id]);
|
377
|
+
const module = /** @type {Module} */ (moduleGraph.getModule(dep));
|
355
378
|
const used = moduleGraph
|
356
379
|
.getExportsInfo(module)
|
357
380
|
.getUsedName(concatedIds, runtime);
|
@@ -360,11 +383,13 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
|
360
383
|
const name = concatedIds[concatedIds.length - 1];
|
361
384
|
if (newName === name) continue;
|
362
385
|
|
363
|
-
const comment = Template.toNormalComment(name)
|
386
|
+
const comment = `${Template.toNormalComment(name)} `;
|
364
387
|
const key = comment + JSON.stringify(newName);
|
365
388
|
source.replace(
|
366
|
-
|
367
|
-
range[
|
389
|
+
/** @type {Range} */
|
390
|
+
(range)[0],
|
391
|
+
/** @type {Range} */
|
392
|
+
(range)[1] - 1,
|
368
393
|
shorthand ? `${key}: ${name}` : `${key}`
|
369
394
|
);
|
370
395
|
}
|
@@ -124,7 +124,7 @@ ImportDependency.Template = class ImportDependencyTemplate extends (
|
|
124
124
|
);
|
125
125
|
const content = runtimeTemplate.moduleNamespacePromise({
|
126
126
|
chunkGraph,
|
127
|
-
block
|
127
|
+
block,
|
128
128
|
module: /** @type {Module} */ (moduleGraph.getModule(dep)),
|
129
129
|
request: dep.request,
|
130
130
|
strict: /** @type {BuildMeta} */ (module.buildMeta).strictHarmonyModule,
|
@@ -57,14 +57,14 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|
57
57
|
apply(parser) {
|
58
58
|
parser.hooks.evaluateIdentifier
|
59
59
|
.for("import.meta.webpackContext")
|
60
|
-
.tap("ImportMetaContextDependencyParserPlugin", expr =>
|
61
|
-
|
60
|
+
.tap("ImportMetaContextDependencyParserPlugin", expr =>
|
61
|
+
evaluateToIdentifier(
|
62
62
|
"import.meta.webpackContext",
|
63
63
|
"import.meta",
|
64
64
|
() => ["webpackContext"],
|
65
65
|
true
|
66
|
-
)(expr)
|
67
|
-
|
66
|
+
)(expr)
|
67
|
+
);
|
68
68
|
parser.hooks.call
|
69
69
|
.for("import.meta.webpackContext")
|
70
70
|
.tap("ImportMetaContextDependencyParserPlugin", expr => {
|
@@ -293,7 +293,7 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|
293
293
|
/** @type {Range} */ (expr.range)
|
294
294
|
);
|
295
295
|
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
296
|
-
dep.optional =
|
296
|
+
dep.optional = Boolean(parser.scope.inTry);
|
297
297
|
parser.state.current.addDependency(dep);
|
298
298
|
return true;
|
299
299
|
});
|