webpack 5.107.2 → 5.108.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/hot/dev-server.js +2 -0
- package/lib/APIPlugin.js +8 -4
- package/lib/CacheFacade.js +7 -0
- package/lib/Chunk.js +4 -0
- package/lib/ChunkGraph.js +30 -9
- package/lib/CircularModulesPlugin.js +190 -0
- package/lib/CleanPlugin.js +2 -1
- package/lib/Compilation.js +396 -65
- package/lib/Compiler.js +25 -11
- package/lib/ConcatenationScope.js +10 -3
- package/lib/ContextExclusionPlugin.js +1 -0
- package/lib/ContextModule.js +92 -47
- package/lib/ContextReplacementPlugin.js +4 -0
- package/lib/DefinePlugin.js +89 -15
- package/lib/Dependency.js +111 -7
- package/lib/EntryOptionPlugin.js +39 -2
- package/lib/EntryPlugin.js +2 -0
- package/lib/ExportsInfo.js +314 -73
- package/lib/ExternalModule.js +82 -34
- package/lib/ExternalModuleFactoryPlugin.js +1 -0
- package/lib/ExternalsPlugin.js +1 -0
- package/lib/FileSystemInfo.js +173 -23
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -5
- package/lib/FlagDependencyExportsPlugin.js +23 -0
- package/lib/FlagDependencyUsagePlugin.js +87 -5
- package/lib/FlagEntryExportAsUsedPlugin.js +2 -0
- package/lib/Generator.js +8 -0
- package/lib/HotModuleReplacementPlugin.js +65 -28
- package/lib/IgnorePlugin.js +1 -0
- package/lib/InitFragment.js +5 -0
- package/lib/JavascriptMetaInfoPlugin.js +7 -5
- package/lib/LazyBarrel.js +361 -0
- package/lib/LoaderTargetPlugin.js +1 -0
- package/lib/Module.js +21 -42
- package/lib/ModuleGraph.js +3 -2
- package/lib/ModuleProfile.js +27 -1
- package/lib/ModuleTemplate.js +2 -0
- package/lib/MultiCompiler.js +2 -0
- package/lib/MultiStats.js +1 -0
- package/lib/MultiWatching.js +2 -0
- package/lib/NodeStuffPlugin.js +22 -17
- package/lib/NormalModule.js +142 -80
- package/lib/NormalModuleReplacementPlugin.js +2 -0
- package/lib/PrefetchPlugin.js +2 -0
- package/lib/ProgressPlugin.js +8 -0
- package/lib/ProvidePlugin.js +1 -0
- package/lib/RawModule.js +20 -16
- package/lib/RecordIdsPlugin.js +1 -0
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimePlugin.js +58 -26
- package/lib/RuntimeTemplate.js +278 -21
- package/lib/SelfModuleFactory.js +1 -0
- package/lib/SourceMapDevToolPlugin.js +3 -5
- package/lib/Stats.js +1 -0
- package/lib/Template.js +8 -2
- package/lib/TemplatedPathPlugin.js +473 -131
- package/lib/WarnCaseSensitiveModulesPlugin.js +1 -0
- package/lib/WarnDeprecatedOptionPlugin.js +4 -0
- package/lib/WarnNoModeSetPlugin.js +1 -0
- package/lib/WatchIgnorePlugin.js +1 -0
- package/lib/Watching.js +9 -0
- package/lib/WebpackOptionsApply.js +50 -5
- package/lib/asset/AssetBytesGenerator.js +11 -3
- package/lib/asset/AssetGenerator.js +47 -22
- package/lib/asset/AssetModule.js +47 -0
- package/lib/asset/AssetModulesPlugin.js +14 -14
- package/lib/asset/AssetParser.js +2 -2
- package/lib/asset/AssetSourceGenerator.js +8 -0
- package/lib/asset/RawDataUrlModule.js +12 -13
- package/lib/buildChunkGraph.js +64 -7
- package/lib/bun/BunTargetPlugin.js +48 -0
- package/lib/cache/AddBuildDependenciesPlugin.js +1 -0
- package/lib/cache/AddManagedPathsPlugin.js +3 -0
- package/lib/cache/IdleFileCachePlugin.js +4 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +1 -0
- package/lib/cache/ResolverCachePlugin.js +2 -0
- package/lib/cache/mergeEtags.js +2 -0
- package/lib/cli.js +109 -19
- package/lib/config/browserslistTargetHandler.js +99 -0
- package/lib/config/defaults.js +147 -7
- package/lib/config/defineConfig.js +31 -0
- package/lib/config/normalization.js +5 -0
- package/lib/config/target.js +181 -2
- package/lib/container/ContainerEntryModule.js +15 -14
- package/lib/container/ContainerExposedDependency.js +2 -2
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackDependency.js +5 -7
- package/lib/container/FallbackModule.js +10 -9
- package/lib/container/RemoteModule.js +20 -10
- package/lib/container/RemoteRuntimeModule.js +14 -12
- package/lib/css/CssGenerator.js +353 -327
- package/lib/css/CssInjectStyleRuntimeModule.js +36 -8
- package/lib/css/CssLoadingRuntimeModule.js +118 -47
- package/lib/css/CssModule.js +52 -23
- package/lib/css/CssModulesPlugin.js +107 -124
- package/lib/css/CssParser.js +2759 -2205
- package/lib/css/syntax.js +2859 -0
- package/lib/debug/ProfilingPlugin.js +2 -0
- package/lib/deno/DenoTargetPlugin.js +47 -0
- package/lib/dependencies/AMDDefineDependency.js +22 -17
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +1 -0
- package/lib/dependencies/AMDRequireArrayDependency.js +7 -11
- package/lib/dependencies/AMDRequireContextDependency.js +7 -11
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -0
- package/lib/dependencies/AMDRequireDependency.js +24 -20
- package/lib/dependencies/CachedConstDependency.js +3 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +1 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +79 -31
- package/lib/dependencies/CommonJsExportsDependency.js +21 -16
- package/lib/dependencies/CommonJsExportsParserPlugin.js +230 -7
- package/lib/dependencies/CommonJsFullRequireDependency.js +27 -19
- package/lib/dependencies/CommonJsImportsParserPlugin.js +51 -16
- package/lib/dependencies/CommonJsPlugin.js +1 -1
- package/lib/dependencies/CommonJsRequireContextDependency.js +10 -13
- package/lib/dependencies/CommonJsRequireDependency.js +42 -11
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +22 -14
- package/lib/dependencies/ConstDependency.js +16 -11
- package/lib/dependencies/ContextDependency.js +4 -0
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +23 -14
- package/lib/dependencies/CreateRequireParserPlugin.js +1 -0
- package/lib/dependencies/CreateScriptUrlDependency.js +5 -7
- package/lib/dependencies/CriticalDependencyWarning.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +512 -574
- package/lib/dependencies/CssIcssImportDependency.js +9 -9
- package/lib/dependencies/CssIcssSymbolDependency.js +22 -15
- package/lib/dependencies/CssImportDependency.js +25 -1
- package/lib/dependencies/CssUrlDependency.js +23 -14
- package/lib/dependencies/DllEntryDependency.js +9 -13
- package/lib/dependencies/ExportBindingInitFragment.js +164 -0
- package/lib/dependencies/ExportsInfoDependency.js +12 -12
- package/lib/dependencies/ExternalModuleDependency.js +8 -5
- package/lib/dependencies/ExternalModuleInitFragment.js +7 -5
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +13 -10
- package/lib/dependencies/HarmonyAcceptDependency.js +11 -11
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +47 -22
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +28 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +46 -22
- package/lib/dependencies/HarmonyExportExpressionDependency.js +107 -30
- package/lib/dependencies/HarmonyExportHeaderDependency.js +7 -9
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +109 -31
- package/lib/dependencies/HarmonyExportInitFragment.js +18 -15
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +83 -18
- package/lib/dependencies/HarmonyExports.js +4 -1
- package/lib/dependencies/HarmonyImportDependency.js +24 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +110 -74
- package/lib/dependencies/HarmonyImportGuard.js +254 -0
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +18 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +118 -14
- package/lib/dependencies/HarmonyLinkingError.js +1 -0
- package/lib/dependencies/HarmonyModulesPlugin.js +1 -0
- package/lib/dependencies/{HtmlScriptSrcDependency.js → HtmlEntryDependency.js} +261 -109
- package/lib/dependencies/HtmlInlineHtmlDependency.js +107 -0
- package/lib/dependencies/HtmlInlineScriptDependency.js +17 -13
- package/lib/dependencies/HtmlInlineStyleDependency.js +45 -11
- package/lib/dependencies/ImportContextDependency.js +5 -9
- package/lib/dependencies/ImportDependency.js +44 -2
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +1 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +74 -30
- package/lib/dependencies/ImportParserPlugin.js +19 -0
- package/lib/dependencies/ImportWeakDependency.js +1 -0
- package/lib/dependencies/JsonExportsDependency.js +9 -9
- package/lib/dependencies/LoaderImportDependency.js +1 -0
- package/lib/dependencies/LocalModule.js +11 -12
- package/lib/dependencies/LocalModuleDependency.js +11 -13
- package/lib/dependencies/ModuleDecoratorDependency.js +9 -9
- package/lib/dependencies/ModuleDependency.js +7 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +15 -11
- package/lib/dependencies/ProvidedDependency.js +31 -27
- package/lib/dependencies/PureExpressionDependency.js +7 -9
- package/lib/dependencies/RequireEnsureDependency.js +12 -13
- package/lib/dependencies/RequireHeaderDependency.js +3 -4
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -0
- package/lib/dependencies/RequireResolveContextDependency.js +7 -11
- package/lib/dependencies/RequireResolveDependency.js +1 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +3 -5
- package/lib/dependencies/RuntimeRequirementsDependency.js +6 -7
- package/lib/dependencies/StaticExportsDependency.js +10 -10
- package/lib/dependencies/SystemPlugin.js +2 -0
- package/lib/dependencies/URLContextDependency.js +5 -7
- package/lib/dependencies/URLDependency.js +14 -16
- package/lib/dependencies/UnsupportedDependency.js +8 -13
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +11 -16
- package/lib/dependencies/WebAssemblyImportDependency.js +14 -16
- package/lib/dependencies/WebpackIsIncludedDependency.js +1 -0
- package/lib/dependencies/WorkerDependency.js +19 -8
- package/lib/dependencies/WorkerPlugin.js +22 -6
- package/lib/dependencies/processExportInfo.js +13 -11
- package/lib/dll/DelegatedModule.js +29 -15
- package/lib/dll/DelegatedModuleFactoryPlugin.js +1 -0
- package/lib/dll/DelegatedPlugin.js +1 -0
- package/lib/dll/DllEntryPlugin.js +3 -0
- package/lib/dll/DllModule.js +3 -2
- package/lib/dll/DllPlugin.js +16 -0
- package/lib/dll/DllReferencePlugin.js +3 -0
- package/lib/dll/LibManifestPlugin.js +1 -0
- package/lib/electron/ElectronTargetPlugin.js +22 -4
- package/lib/errors/ConcurrentCompilationError.js +1 -0
- package/lib/errors/HookWebpackError.js +11 -13
- package/lib/errors/IgnoreErrorModuleFactory.js +1 -0
- package/lib/errors/InvalidDependenciesModuleWarning.js +2 -0
- package/lib/errors/JSONParseError.js +9 -8
- package/lib/errors/ModuleBuildError.js +16 -13
- package/lib/errors/ModuleDependencyError.js +8 -1
- package/lib/errors/ModuleDependencyWarning.js +8 -1
- package/lib/errors/ModuleError.js +5 -11
- package/lib/errors/ModuleHashingError.js +4 -0
- package/lib/errors/ModuleNotFoundError.js +3 -0
- package/lib/errors/ModuleParseError.js +5 -11
- package/lib/errors/ModuleRestoreError.js +2 -0
- package/lib/errors/ModuleStoreError.js +3 -0
- package/lib/errors/ModuleWarning.js +7 -11
- package/lib/errors/NodeStuffInWebError.js +1 -0
- package/lib/errors/NonErrorEmittedError.js +2 -0
- package/lib/errors/UnhandledSchemeError.js +1 -0
- package/lib/esm/ModuleChunkLoadingPlugin.js +0 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +28 -23
- package/lib/hmr/HotModuleReplacement.runtime.js +175 -30
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +7 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +173 -26
- package/lib/hmr/LazyCompilationPlugin.js +30 -6
- package/lib/html/HtmlGenerator.js +217 -23
- package/lib/html/HtmlModule.js +40 -0
- package/lib/html/HtmlModulesPlugin.js +219 -55
- package/lib/html/HtmlParser.js +1108 -1099
- package/lib/html/{walkHtmlTokens.js → syntax.js} +4701 -212
- package/lib/ids/IdHelpers.js +4 -2
- package/lib/index.js +19 -0
- package/lib/javascript/BasicEvaluatedExpression.js +1 -0
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -0
- package/lib/javascript/JavascriptGenerator.js +6 -2
- package/lib/javascript/JavascriptModule.js +54 -0
- package/lib/javascript/JavascriptModulesPlugin.js +257 -102
- package/lib/javascript/JavascriptParser.js +285 -158
- package/lib/json/JsonModule.js +40 -0
- package/lib/json/JsonModulesPlugin.js +7 -0
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AssignLibraryPlugin.js +5 -3
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -0
- package/lib/library/FalseIIFEUmdWarning.js +1 -0
- package/lib/library/ModuleLibraryPlugin.js +24 -5
- package/lib/library/SystemLibraryPlugin.js +3 -3
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +1 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -9
- package/lib/node/RequireChunkLoadingRuntimeModule.js +18 -16
- package/lib/optimize/ConcatenatedModule.js +395 -77
- package/lib/optimize/ConstExportsPlugin.js +211 -0
- package/lib/optimize/InlineExports.js +178 -0
- package/lib/optimize/InnerGraph.js +372 -275
- package/lib/optimize/InnerGraphPlugin.js +196 -99
- package/lib/optimize/ModuleConcatenationPlugin.js +56 -25
- package/lib/optimize/RealContentHashPlugin.js +14 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +234 -64
- package/lib/runtime/AsyncModuleRuntimeModule.js +32 -30
- package/lib/runtime/AutoPublicPathRuntimeModule.js +11 -5
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +1 -1
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +6 -4
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +33 -4
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +82 -3
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +1 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +18 -13
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +39 -26
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -4
- package/lib/runtime/RelativeUrlRuntimeModule.js +3 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -1
- package/lib/runtime/StartupEntrypointRuntimeModule.js +4 -3
- package/lib/runtime/WorkerRuntimeModule.js +33 -0
- package/lib/schemes/HttpUriPlugin.js +3 -2
- package/lib/serialization/AggregateErrorSerializer.js +7 -6
- package/lib/serialization/ArraySerializer.js +4 -8
- package/lib/serialization/BinaryMiddleware.js +538 -468
- package/lib/serialization/DateObjectSerializer.js +2 -2
- package/lib/serialization/ErrorObjectSerializer.js +7 -6
- package/lib/serialization/MapObjectSerializer.js +5 -9
- package/lib/serialization/NullPrototypeObjectSerializer.js +7 -9
- package/lib/serialization/ObjectMiddleware.js +50 -13
- package/lib/serialization/PlainObjectSerializer.js +9 -8
- package/lib/serialization/RegExpObjectSerializer.js +2 -2
- package/lib/serialization/Serializer.js +1 -0
- package/lib/serialization/SetObjectSerializer.js +4 -8
- package/lib/sharing/ConsumeSharedModule.js +6 -7
- package/lib/sharing/ConsumeSharedPlugin.js +1 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +46 -41
- package/lib/sharing/ProvideSharedDependency.js +30 -15
- package/lib/sharing/ProvideSharedModule.js +30 -11
- package/lib/sharing/ProvideSharedPlugin.js +4 -2
- package/lib/sharing/SharePlugin.js +3 -0
- package/lib/sharing/ShareRuntimeModule.js +18 -16
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +4 -6
- package/lib/stats/DefaultStatsPrinterPlugin.js +14 -14
- package/lib/stats/StatsFactory.js +11 -9
- package/lib/stats/StatsPrinter.js +9 -2
- package/lib/url/URLParserPlugin.js +5 -2
- package/lib/util/AsyncQueue.js +10 -0
- package/lib/util/LazyBucketSortedSet.js +5 -0
- package/lib/util/LazySet.js +6 -4
- package/lib/util/LocConverter.js +11 -1
- package/lib/util/Semaphore.js +1 -0
- package/lib/util/SourceProcessor.js +106 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/WeakTupleMap.js +27 -1
- package/lib/util/chainedImports.js +3 -3
- package/lib/util/comparators.js +2 -2
- package/lib/util/concatenate.js +31 -7
- package/lib/util/createHash.js +0 -1
- package/lib/util/deterministicGrouping.js +19 -12
- package/lib/util/extractSourceMap.js +1 -1
- package/lib/util/findGraphRoots.js +2 -0
- package/lib/util/fs.js +10 -5
- package/lib/util/hash/DebugHash.js +1 -0
- package/lib/util/hash/hash-digest.js +24 -15
- package/lib/util/identifier.js +7 -0
- package/lib/util/internalSerializables.js +11 -2
- package/lib/util/magicComment.js +42 -0
- package/lib/util/makeSerializable.js +1 -0
- package/lib/util/nonNumericOnlyHash.js +30 -1
- package/lib/util/property.js +7 -1
- package/lib/util/publicPathPlaceholder.js +64 -0
- package/lib/util/registerExternalSerializer.js +4 -4
- package/lib/wasm-async/AsyncWasmModule.js +77 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -96
- package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +1 -1
- package/lib/wasm-sync/SyncWasmModule.js +39 -0
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +1 -0
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +10 -0
- package/lib/wasm-sync/WebAssemblyParser.js +7 -3
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +45 -39
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +11 -10
- package/package.json +35 -27
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +212 -3
- package/schemas/plugins/HtmlGeneratorOptions.check.js +1 -1
- package/schemas/plugins/HtmlParserOptions.check.d.ts +7 -0
- package/schemas/plugins/HtmlParserOptions.check.js +6 -0
- package/schemas/plugins/HtmlParserOptions.json +3 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/types.d.ts +1456 -290
- package/lib/css/walkCssTokens.js +0 -2020
- package/lib/util/AppendOnlyStackedSet.js +0 -93
|
@@ -11,6 +11,11 @@ const { UsageState } = require("../ExportsInfo");
|
|
|
11
11
|
const InitFragment = require("../InitFragment");
|
|
12
12
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
13
13
|
const Template = require("../Template");
|
|
14
|
+
const {
|
|
15
|
+
InlinedUsedName,
|
|
16
|
+
isExportInlined,
|
|
17
|
+
isInlineEnabled
|
|
18
|
+
} = require("../optimize/InlineExports");
|
|
14
19
|
const {
|
|
15
20
|
getMakeDeferredNamespaceModeFromExportsType
|
|
16
21
|
} = require("../runtime/MakeDeferredNamespaceObjectRuntime");
|
|
@@ -33,6 +38,7 @@ const processExportInfo = require("./processExportInfo");
|
|
|
33
38
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
34
39
|
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
|
35
40
|
/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
|
|
41
|
+
/** @typedef {import("../Dependency").LazyUntil} LazyUntil */
|
|
36
42
|
/** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */
|
|
37
43
|
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
|
38
44
|
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
|
|
@@ -52,13 +58,17 @@ const processExportInfo = require("./processExportInfo");
|
|
|
52
58
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
53
59
|
/** @typedef {import("../errors/WebpackError")} WebpackError */
|
|
54
60
|
/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
|
55
|
-
/** @typedef {
|
|
56
|
-
/** @typedef {import("../serialization/ObjectMiddleware").
|
|
61
|
+
/** @typedef {[Ids, string | null, Set<string>, ReadonlyArray<HarmonyExportImportedSpecifierDependency> | null, ExportPresenceMode, HarmonyStarExportsList | null]} SerializedData */
|
|
62
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<SerializedData>} ObjectDeserializerContext */
|
|
63
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<SerializedData>} ObjectSerializerContext */
|
|
64
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[HarmonyExportImportedSpecifierDependency[]]>} StarListDeserializerContext */
|
|
65
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[HarmonyExportImportedSpecifierDependency[]]>} StarListSerializerContext */
|
|
57
66
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
58
67
|
/** @typedef {import("./HarmonyImportDependency").Ids} Ids */
|
|
59
68
|
/** @typedef {import("./HarmonyImportDependency").ExportPresenceMode} ExportPresenceMode */
|
|
60
69
|
/** @typedef {import("./HarmonyExportInitFragment").ExportMap} ExportMap */
|
|
61
70
|
/** @typedef {import("../dependencies/ImportPhase").ImportPhaseType} ImportPhaseType */
|
|
71
|
+
/** @typedef {import("../javascript/JavascriptModule").JavascriptModuleBuildMeta} JavascriptModuleBuildMeta */
|
|
62
72
|
|
|
63
73
|
/** @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 */
|
|
64
74
|
|
|
@@ -78,10 +88,15 @@ class NormalReexportItem {
|
|
|
78
88
|
* @param {boolean} hidden true, if it is hidden behind another active export in the same module
|
|
79
89
|
*/
|
|
80
90
|
constructor(name, ids, exportInfo, checked, hidden) {
|
|
91
|
+
/** @type {string} */
|
|
81
92
|
this.name = name;
|
|
93
|
+
/** @type {Ids} */
|
|
82
94
|
this.ids = ids;
|
|
95
|
+
/** @type {ExportInfo} */
|
|
83
96
|
this.exportInfo = exportInfo;
|
|
97
|
+
/** @type {boolean} */
|
|
84
98
|
this.checked = checked;
|
|
99
|
+
/** @type {boolean} */
|
|
85
100
|
this.hidden = hidden;
|
|
86
101
|
}
|
|
87
102
|
}
|
|
@@ -486,11 +501,16 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
|
486
501
|
) {
|
|
487
502
|
super(request, sourceOrder, phase, attributes);
|
|
488
503
|
|
|
504
|
+
/** @type {Ids} */
|
|
489
505
|
this.ids = ids;
|
|
506
|
+
/** @type {string | null} */
|
|
490
507
|
this.name = name;
|
|
508
|
+
/** @type {Set<string>} */
|
|
491
509
|
this.activeExports = activeExports;
|
|
492
510
|
this.otherStarExports = otherStarExports;
|
|
511
|
+
/** @type {ExportPresenceMode} */
|
|
493
512
|
this.exportPresenceMode = exportPresenceMode;
|
|
513
|
+
/** @type {HarmonyStarExportsList | null} */
|
|
494
514
|
this.allStarExports = allStarExports;
|
|
495
515
|
}
|
|
496
516
|
|
|
@@ -533,6 +553,32 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
|
533
553
|
return "harmony export imported specifier";
|
|
534
554
|
}
|
|
535
555
|
|
|
556
|
+
/**
|
|
557
|
+
* Returns the export name this dependency requests from its target module (lazy barrel optimization).
|
|
558
|
+
* @returns {string | true | null} export name, true for all exports, null for none
|
|
559
|
+
*/
|
|
560
|
+
getForwardId() {
|
|
561
|
+
return this.ids.length > 0 ? this.ids[0] : true;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Returns how this dependency may be deferred when its parent module is side-effect-free (lazy barrel optimization).
|
|
566
|
+
* @returns {LazyUntil | null} lazy classification, null when it must be processed eagerly
|
|
567
|
+
*/
|
|
568
|
+
getLazyUntil() {
|
|
569
|
+
return this.name !== null
|
|
570
|
+
? Dependency.LAZY_UNTIL_ID
|
|
571
|
+
: Dependency.LAZY_UNTIL_FALLBACK;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Returns the export name for a `LAZY_UNTIL_LOCAL`/`LAZY_UNTIL_ID` classification (lazy barrel optimization).
|
|
576
|
+
* @returns {string | null} export name, null when not applicable
|
|
577
|
+
*/
|
|
578
|
+
getLazyName() {
|
|
579
|
+
return this.name;
|
|
580
|
+
}
|
|
581
|
+
|
|
536
582
|
/**
|
|
537
583
|
* Returns the imported id.
|
|
538
584
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
@@ -688,7 +734,24 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
|
688
734
|
getCondition(moduleGraph) {
|
|
689
735
|
return (connection, runtime) => {
|
|
690
736
|
const mode = this.getMode(moduleGraph, runtime);
|
|
691
|
-
|
|
737
|
+
const active = mode.type !== "unused" && mode.type !== "empty-star";
|
|
738
|
+
if (!active) return active;
|
|
739
|
+
|
|
740
|
+
const module = connection.module;
|
|
741
|
+
if (!isInlineEnabled(module)) return true;
|
|
742
|
+
if (mode.type !== "normal-reexport") return true;
|
|
743
|
+
const exportsInfo = moduleGraph.getExportsInfo(module);
|
|
744
|
+
if (exportsInfo.otherExportsInfo.getUsed(runtime) !== UsageState.Unused) {
|
|
745
|
+
return true;
|
|
746
|
+
}
|
|
747
|
+
for (const item of /** @type {NormalReexportItem[]} */ (mode.items)) {
|
|
748
|
+
// Hidden/checked items can't be statically inlined away
|
|
749
|
+
if (item.hidden || item.checked) return true;
|
|
750
|
+
if (!isExportInlined(moduleGraph, module, item.ids, runtime)) {
|
|
751
|
+
return true;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
return false;
|
|
692
755
|
};
|
|
693
756
|
}
|
|
694
757
|
|
|
@@ -1086,15 +1149,14 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
|
1086
1149
|
* @param {ObjectSerializerContext} context context
|
|
1087
1150
|
*/
|
|
1088
1151
|
serialize(context) {
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
write(this.allStarExports);
|
|
1152
|
+
context.setCircularReference(this);
|
|
1153
|
+
context
|
|
1154
|
+
.write(this.ids)
|
|
1155
|
+
.write(this.name)
|
|
1156
|
+
.write(this.activeExports)
|
|
1157
|
+
.write(this.otherStarExports)
|
|
1158
|
+
.write(this.exportPresenceMode)
|
|
1159
|
+
.write(this.allStarExports);
|
|
1098
1160
|
|
|
1099
1161
|
super.serialize(context);
|
|
1100
1162
|
}
|
|
@@ -1104,17 +1166,20 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
|
1104
1166
|
* @param {ObjectDeserializerContext} context context
|
|
1105
1167
|
*/
|
|
1106
1168
|
deserialize(context) {
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
this.
|
|
1111
|
-
|
|
1112
|
-
this.activeExports = read();
|
|
1113
|
-
|
|
1114
|
-
this.
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1169
|
+
context.setCircularReference(this);
|
|
1170
|
+
this.ids = context.read();
|
|
1171
|
+
const c1 = context.rest;
|
|
1172
|
+
this.name = c1.read();
|
|
1173
|
+
const c2 = c1.rest;
|
|
1174
|
+
this.activeExports = c2.read();
|
|
1175
|
+
const c3 = c2.rest;
|
|
1176
|
+
this.otherStarExports = c3.read();
|
|
1177
|
+
const c4 = c3.rest;
|
|
1178
|
+
this.exportPresenceMode = c4.read();
|
|
1179
|
+
const c5 = c4.rest;
|
|
1180
|
+
this.allStarExports = c5.read();
|
|
1181
|
+
|
|
1182
|
+
super.deserialize(c5.rest);
|
|
1118
1183
|
}
|
|
1119
1184
|
}
|
|
1120
1185
|
|
|
@@ -1215,7 +1280,9 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
|
1215
1280
|
importVar,
|
|
1216
1281
|
importedModule.getExportsType(
|
|
1217
1282
|
moduleGraph,
|
|
1218
|
-
module.buildMeta &&
|
|
1283
|
+
module.buildMeta &&
|
|
1284
|
+
/** @type {JavascriptModuleBuildMeta} */ (module.buildMeta)
|
|
1285
|
+
.strictHarmonyModule
|
|
1219
1286
|
),
|
|
1220
1287
|
runtimeRequirements
|
|
1221
1288
|
)
|
|
@@ -1363,7 +1430,8 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
|
1363
1430
|
moduleGraph
|
|
1364
1431
|
.getExportsInfo(importedModule)
|
|
1365
1432
|
.getUsedName(ids, runtime),
|
|
1366
|
-
runtimeRequirements
|
|
1433
|
+
runtimeRequirements,
|
|
1434
|
+
ids
|
|
1367
1435
|
)
|
|
1368
1436
|
);
|
|
1369
1437
|
}
|
|
@@ -1430,6 +1498,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
|
1430
1498
|
* @param {string} name name
|
|
1431
1499
|
* @param {UsedName | null} valueKey value key
|
|
1432
1500
|
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
|
|
1501
|
+
* @param {string[]=} ids original ids on the imported side (for inline-rendering comment)
|
|
1433
1502
|
* @returns {HarmonyExportInitFragment} harmony export init fragment
|
|
1434
1503
|
*/
|
|
1435
1504
|
getReexportFragment(
|
|
@@ -1438,9 +1507,10 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
|
1438
1507
|
key,
|
|
1439
1508
|
name,
|
|
1440
1509
|
valueKey,
|
|
1441
|
-
runtimeRequirements
|
|
1510
|
+
runtimeRequirements,
|
|
1511
|
+
ids
|
|
1442
1512
|
) {
|
|
1443
|
-
const returnValue = this.getReturnValue(name, valueKey);
|
|
1513
|
+
const returnValue = this.getReturnValue(name, valueKey, ids);
|
|
1444
1514
|
|
|
1445
1515
|
runtimeRequirements.add(RuntimeGlobals.exports);
|
|
1446
1516
|
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
|
|
@@ -1573,10 +1643,11 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
|
1573
1643
|
/**
|
|
1574
1644
|
* Returns value.
|
|
1575
1645
|
* @param {string} name name
|
|
1576
|
-
* @param {null | false | string | string[]} valueKey value key
|
|
1646
|
+
* @param {null | false | string | string[] | import("../optimize/InlineExports").InlinedUsedName} valueKey value key
|
|
1647
|
+
* @param {string[]=} ids original imported ids (for inline-rendering comment)
|
|
1577
1648
|
* @returns {string | undefined} value
|
|
1578
1649
|
*/
|
|
1579
|
-
getReturnValue(name, valueKey) {
|
|
1650
|
+
getReturnValue(name, valueKey, ids) {
|
|
1580
1651
|
if (valueKey === null) {
|
|
1581
1652
|
return `${name}_default.a`;
|
|
1582
1653
|
}
|
|
@@ -1589,6 +1660,13 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
|
1589
1660
|
return "/* unused export */ undefined";
|
|
1590
1661
|
}
|
|
1591
1662
|
|
|
1663
|
+
if (valueKey instanceof InlinedUsedName) {
|
|
1664
|
+
// Re-export forwards the source export's inlined literal as its own runtime value
|
|
1665
|
+
return valueKey.render(
|
|
1666
|
+
Template.toNormalComment(`inlined export ${propertyAccess(ids || [])}`)
|
|
1667
|
+
);
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1592
1670
|
return `${name}${propertyAccess(valueKey)}`;
|
|
1593
1671
|
}
|
|
1594
1672
|
};
|
|
@@ -1614,7 +1692,7 @@ class HarmonyStarExportsList {
|
|
|
1614
1692
|
|
|
1615
1693
|
/**
|
|
1616
1694
|
* Serializes this instance into the provided serializer context.
|
|
1617
|
-
* @param {
|
|
1695
|
+
* @param {StarListSerializerContext} context context
|
|
1618
1696
|
*/
|
|
1619
1697
|
serialize({ write, setCircularReference }) {
|
|
1620
1698
|
setCircularReference(this);
|
|
@@ -1623,7 +1701,7 @@ class HarmonyStarExportsList {
|
|
|
1623
1701
|
|
|
1624
1702
|
/**
|
|
1625
1703
|
* Restores this instance from the provided deserializer context.
|
|
1626
|
-
* @param {
|
|
1704
|
+
* @param {StarListDeserializerContext} context context
|
|
1627
1705
|
*/
|
|
1628
1706
|
deserialize({ read, setCircularReference }) {
|
|
1629
1707
|
setCircularReference(this);
|
|
@@ -169,25 +169,28 @@ class HarmonyExportInitFragment extends InitFragment {
|
|
|
169
169
|
: this.unusedExports.size > 0
|
|
170
170
|
? `/* unused harmony export ${first(this.unusedExports)} */\n`
|
|
171
171
|
: "";
|
|
172
|
-
/** @type {string[]} */
|
|
173
|
-
const definitions = [];
|
|
174
|
-
const orderedExportMap = [...this.exportMap].sort(([a], [b]) =>
|
|
175
|
-
a < b ? -1 : 1
|
|
176
|
-
);
|
|
177
|
-
for (const [key, value] of orderedExportMap) {
|
|
178
|
-
definitions.push(
|
|
179
|
-
`\n/* harmony export */ ${propertyName(
|
|
180
|
-
/** @type {string} */ (key)
|
|
181
|
-
)}: ${runtimeTemplate.returningFunction(value)}`
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
172
|
let definePart = "";
|
|
185
173
|
if (this.exportMap.size > 0) {
|
|
174
|
+
/** @type {string[]} */
|
|
175
|
+
const definitions = [];
|
|
176
|
+
const orderedExportMap =
|
|
177
|
+
this.exportMap.size > 1
|
|
178
|
+
? [...this.exportMap].sort(([a], [b]) => (a < b ? -1 : 1))
|
|
179
|
+
: this.exportMap;
|
|
180
|
+
for (const [key, value] of orderedExportMap) {
|
|
181
|
+
definitions.push(
|
|
182
|
+
`\n/* harmony export */ ${propertyName(
|
|
183
|
+
/** @type {string} */ (key)
|
|
184
|
+
)}: ${runtimeTemplate.returningFunction(value)}`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
186
187
|
runtimeRequirements.add(RuntimeGlobals.exports);
|
|
187
188
|
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
|
|
188
|
-
definePart = `/* harmony export */ ${
|
|
189
|
-
|
|
190
|
-
}, {${definitions.join(
|
|
189
|
+
definePart = `/* harmony export */ ${
|
|
190
|
+
RuntimeGlobals.definePropertyGetters
|
|
191
|
+
}(${this.exportsArgument}, {${definitions.join(
|
|
192
|
+
","
|
|
193
|
+
)}\n/* harmony export */ });\n`;
|
|
191
194
|
}
|
|
192
195
|
return `${definePart}${unusedPart}`;
|
|
193
196
|
}
|
|
@@ -5,45 +5,84 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
const Dependency = require("../Dependency");
|
|
9
|
+
const { InlinedUsedName } = require("../optimize/InlineExports");
|
|
8
10
|
const makeSerializable = require("../util/makeSerializable");
|
|
11
|
+
const ExportBindingInitFragment = require("./ExportBindingInitFragment");
|
|
9
12
|
const HarmonyExportInitFragment = require("./HarmonyExportInitFragment");
|
|
10
13
|
const NullDependency = require("./NullDependency");
|
|
11
14
|
|
|
12
15
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
13
|
-
/** @typedef {import("../Dependency")} Dependency */
|
|
14
16
|
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
|
17
|
+
/** @typedef {import("../Dependency").LazyUntil} LazyUntil */
|
|
15
18
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
16
19
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
17
20
|
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
18
|
-
/** @typedef {import("../
|
|
19
|
-
/** @typedef {import("../serialization/ObjectMiddleware").
|
|
21
|
+
/** @typedef {import("../optimize/InlineExports").InlinedValue} InlinedValue */
|
|
22
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[string, string, InlinedValue | null | undefined]>} ObjectDeserializerContext */
|
|
23
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[string, string, InlinedValue | null | undefined]>} ObjectSerializerContext */
|
|
20
24
|
/** @typedef {import("./HarmonyExportInitFragment").UnusedExports} UnusedExports */
|
|
21
25
|
/** @typedef {import("./HarmonyExportInitFragment").ExportMap} ExportMap */
|
|
26
|
+
/** @typedef {import("../javascript/JavascriptModule").JavascriptModuleBuildInfo} JavascriptModuleBuildInfo */
|
|
22
27
|
|
|
23
28
|
class HarmonyExportSpecifierDependency extends NullDependency {
|
|
24
29
|
/**
|
|
25
30
|
* Creates an instance of HarmonyExportSpecifierDependency.
|
|
26
31
|
* @param {string} id the id
|
|
27
32
|
* @param {string} name the name
|
|
33
|
+
* @param {InlinedValue | null=} constValue undefined = not const, null = const but not inline-eligible, InlinedValue = const and inline-eligible
|
|
28
34
|
*/
|
|
29
|
-
constructor(id, name) {
|
|
35
|
+
constructor(id, name, constValue) {
|
|
30
36
|
super();
|
|
37
|
+
/** @type {string} */
|
|
31
38
|
this.id = id;
|
|
39
|
+
/** @type {string} */
|
|
32
40
|
this.name = name;
|
|
41
|
+
/** @type {InlinedValue | null | undefined} */
|
|
42
|
+
this.constValue = constValue;
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
get type() {
|
|
36
46
|
return "harmony export specifier";
|
|
37
47
|
}
|
|
38
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Returns how this dependency may be deferred when its parent module is side-effect-free (lazy barrel optimization).
|
|
51
|
+
* @returns {LazyUntil | null} lazy classification, null when it must be processed eagerly
|
|
52
|
+
*/
|
|
53
|
+
getLazyUntil() {
|
|
54
|
+
return Dependency.LAZY_UNTIL_LOCAL;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns the export name for a `LAZY_UNTIL_LOCAL`/`LAZY_UNTIL_ID` classification (lazy barrel optimization).
|
|
59
|
+
* @returns {string | null} export name, null when not applicable
|
|
60
|
+
*/
|
|
61
|
+
getLazyName() {
|
|
62
|
+
return this.name;
|
|
63
|
+
}
|
|
64
|
+
|
|
39
65
|
/**
|
|
40
66
|
* Returns the exported names
|
|
41
67
|
* @param {ModuleGraph} moduleGraph module graph
|
|
42
68
|
* @returns {ExportsSpec | undefined} export names
|
|
43
69
|
*/
|
|
44
70
|
getExports(moduleGraph) {
|
|
71
|
+
const module = moduleGraph.getParentModule(this);
|
|
72
|
+
const pureFunctions =
|
|
73
|
+
module &&
|
|
74
|
+
module.buildInfo &&
|
|
75
|
+
/** @type {JavascriptModuleBuildInfo} */ (module.buildInfo).pureFunctions;
|
|
76
|
+
const isPure = Boolean(pureFunctions && pureFunctions.has(this.id));
|
|
77
|
+
|
|
45
78
|
return {
|
|
46
|
-
exports: [
|
|
79
|
+
exports: [
|
|
80
|
+
{
|
|
81
|
+
name: this.name,
|
|
82
|
+
isPure: isPure || undefined,
|
|
83
|
+
inlined: this.constValue || undefined
|
|
84
|
+
}
|
|
85
|
+
],
|
|
47
86
|
priority: 1,
|
|
48
87
|
terminalBinding: true,
|
|
49
88
|
dependencies: undefined
|
|
@@ -64,9 +103,7 @@ class HarmonyExportSpecifierDependency extends NullDependency {
|
|
|
64
103
|
* @param {ObjectSerializerContext} context context
|
|
65
104
|
*/
|
|
66
105
|
serialize(context) {
|
|
67
|
-
|
|
68
|
-
write(this.id);
|
|
69
|
-
write(this.name);
|
|
106
|
+
context.write(this.id).write(this.name).write(this.constValue);
|
|
70
107
|
super.serialize(context);
|
|
71
108
|
}
|
|
72
109
|
|
|
@@ -75,10 +112,12 @@ class HarmonyExportSpecifierDependency extends NullDependency {
|
|
|
75
112
|
* @param {ObjectDeserializerContext} context context
|
|
76
113
|
*/
|
|
77
114
|
deserialize(context) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this.name = read();
|
|
81
|
-
|
|
115
|
+
this.id = context.read();
|
|
116
|
+
const c1 = context.rest;
|
|
117
|
+
this.name = c1.read();
|
|
118
|
+
const c2 = c1.rest;
|
|
119
|
+
this.constValue = c2.read();
|
|
120
|
+
super.deserialize(c2.rest);
|
|
82
121
|
}
|
|
83
122
|
}
|
|
84
123
|
|
|
@@ -120,12 +159,38 @@ HarmonyExportSpecifierDependency.Template = class HarmonyExportSpecifierDependen
|
|
|
120
159
|
return;
|
|
121
160
|
}
|
|
122
161
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
162
|
+
if (used instanceof InlinedUsedName) {
|
|
163
|
+
// Inlined: importing side substitutes the literal directly, skip export init
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const canUseValueBinding =
|
|
168
|
+
dep.constValue !== undefined &&
|
|
169
|
+
/** @type {import("../Module").BuildInfo} */ (module.buildInfo)
|
|
170
|
+
.isCircular === false;
|
|
171
|
+
|
|
172
|
+
if (canUseValueBinding) {
|
|
173
|
+
initFragments.push(
|
|
174
|
+
new ExportBindingInitFragment(
|
|
175
|
+
module.exportsArgument,
|
|
176
|
+
[
|
|
177
|
+
{
|
|
178
|
+
name: used,
|
|
179
|
+
value: `/* binding */ ${dep.id}`,
|
|
180
|
+
bindingType: "value"
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
true
|
|
184
|
+
)
|
|
185
|
+
);
|
|
186
|
+
} else {
|
|
187
|
+
/** @type {ExportMap} */
|
|
188
|
+
const map = new Map();
|
|
189
|
+
map.set(used, `/* binding */ ${dep.id}`);
|
|
190
|
+
initFragments.push(
|
|
191
|
+
new HarmonyExportInitFragment(module.exportsArgument, map, undefined)
|
|
192
|
+
);
|
|
193
|
+
}
|
|
129
194
|
}
|
|
130
195
|
};
|
|
131
196
|
|
|
@@ -9,6 +9,7 @@ const RuntimeGlobals = require("../RuntimeGlobals");
|
|
|
9
9
|
|
|
10
10
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
11
11
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
12
|
+
/** @typedef {import("../javascript/JavascriptModule").JavascriptModuleBuildMeta} JavascriptModuleBuildMeta */
|
|
12
13
|
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
|
|
13
14
|
|
|
14
15
|
/** @type {WeakMap<JavascriptParserState, boolean>} */
|
|
@@ -25,7 +26,9 @@ module.exports.enable = (parserState, isStrictHarmony) => {
|
|
|
25
26
|
if (value === false) return;
|
|
26
27
|
parserStateExportsState.set(parserState, true);
|
|
27
28
|
if (value !== true) {
|
|
28
|
-
const buildMeta =
|
|
29
|
+
const buildMeta =
|
|
30
|
+
/** @type {JavascriptModuleBuildMeta} */
|
|
31
|
+
(parserState.module.buildMeta);
|
|
29
32
|
buildMeta.exportsType = "namespace";
|
|
30
33
|
const buildInfo = /** @type {BuildInfo} */ (parserState.module.buildInfo);
|
|
31
34
|
buildInfo.strict = true;
|
|
@@ -104,14 +104,34 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
|
104
104
|
attributes = undefined
|
|
105
105
|
) {
|
|
106
106
|
super(request, sourceOrder);
|
|
107
|
+
/** @type {ImportPhaseType} */
|
|
107
108
|
this.phase = phase;
|
|
109
|
+
/** @type {ImportAttributes | undefined} */
|
|
108
110
|
this.attributes = attributes;
|
|
111
|
+
/** @type {boolean} */
|
|
112
|
+
this._lazyMake = false;
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
get category() {
|
|
112
116
|
return "esm";
|
|
113
117
|
}
|
|
114
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Whether the lazy barrel currently defers creating this dependency's target module (lazy barrel optimization).
|
|
121
|
+
* @returns {boolean} true while deferred, so it must not be processed or rendered
|
|
122
|
+
*/
|
|
123
|
+
isLazy() {
|
|
124
|
+
return this._lazyMake;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Sets whether the lazy barrel defers creating this dependency's target module (lazy barrel optimization).
|
|
129
|
+
* @param {boolean} value true to defer, false to create it now
|
|
130
|
+
*/
|
|
131
|
+
setLazy(value) {
|
|
132
|
+
this._lazyMake = value;
|
|
133
|
+
}
|
|
134
|
+
|
|
115
135
|
/**
|
|
116
136
|
* Returns true if this dependency can be concatenated
|
|
117
137
|
* @returns {boolean} true if this dependency can be concatenated
|
|
@@ -381,6 +401,10 @@ HarmonyImportDependency.Template = class HarmonyImportDependencyTemplate extends
|
|
|
381
401
|
const { module, chunkGraph, moduleGraph, runtime } = templateContext;
|
|
382
402
|
|
|
383
403
|
const connection = moduleGraph.getConnection(dep);
|
|
404
|
+
// deferred by lazy barrel: never resolved, must not render a missing module
|
|
405
|
+
if (connection === undefined && dep.isLazy()) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
384
408
|
if (connection && !connection.isTargetActive(runtime)) return;
|
|
385
409
|
|
|
386
410
|
const referencedModule = connection && connection.module;
|