@depup/webpack 5.106.0-depup.0 → 5.109.0-depup.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 +9 -11
- package/changes.json +16 -24
- package/hot/dev-server.js +2 -0
- package/lib/APIPlugin.js +60 -35
- package/lib/AsyncDependenciesBlock.js +3 -0
- package/lib/AutomaticPrefetchPlugin.js +6 -1
- package/lib/BannerPlugin.js +13 -5
- package/lib/Cache.js +27 -5
- package/lib/CacheFacade.js +41 -0
- package/lib/Chunk.js +71 -25
- package/lib/ChunkGraph.js +141 -9
- package/lib/ChunkGroup.js +115 -28
- package/lib/ChunkTemplate.js +9 -0
- package/lib/CircularModulesPlugin.js +190 -0
- package/lib/CleanPlugin.js +23 -26
- package/lib/CodeGenerationResults.js +19 -0
- package/lib/CompatibilityPlugin.js +54 -37
- package/lib/Compilation.js +635 -107
- package/lib/Compiler.js +93 -31
- package/lib/ConcatenationScope.js +34 -4
- package/lib/ConditionalInitFragment.js +6 -0
- package/lib/ConstPlugin.js +15 -12
- package/lib/ContextExclusionPlugin.js +3 -1
- package/lib/ContextModule.js +345 -55
- package/lib/ContextModuleFactory.js +193 -51
- package/lib/ContextReplacementPlugin.js +8 -1
- package/lib/DefinePlugin.js +498 -127
- package/lib/DependenciesBlock.js +6 -1
- package/lib/Dependency.js +159 -11
- package/lib/DependencyTemplate.js +7 -1
- package/lib/DependencyTemplates.js +4 -0
- package/lib/DotenvPlugin.js +3 -0
- package/lib/DynamicEntryPlugin.js +3 -1
- package/lib/EntryOptionPlugin.js +42 -2
- package/lib/EntryPlugin.js +4 -1
- package/lib/Entrypoint.js +5 -1
- package/lib/EnvironmentPlugin.js +3 -2
- package/lib/ErrorHelpers.js +7 -0
- package/lib/EvalDevToolModulePlugin.js +3 -1
- package/lib/EvalSourceMapDevToolPlugin.js +11 -11
- package/lib/ExportsInfo.js +399 -108
- package/lib/ExportsInfoApiPlugin.js +4 -3
- package/lib/ExternalModule.js +376 -78
- package/lib/ExternalModuleFactoryPlugin.js +75 -3
- package/lib/ExternalsPlugin.js +3 -1
- package/lib/FileSystemInfo.js +575 -149
- package/lib/FlagAllModulesAsUsedPlugin.js +3 -6
- package/lib/FlagDependencyExportsPlugin.js +82 -9
- package/lib/FlagDependencyUsagePlugin.js +92 -6
- package/lib/FlagEntryExportAsUsedPlugin.js +4 -1
- package/lib/Generator.js +24 -3
- package/lib/HotModuleReplacementPlugin.js +110 -44
- package/lib/IgnorePlugin.js +5 -2
- package/lib/IgnoreWarningsPlugin.js +2 -1
- package/lib/InitFragment.js +15 -0
- package/lib/JavascriptMetaInfoPlugin.js +9 -6
- package/lib/LazyBarrel.js +389 -0
- package/lib/LibraryTemplatePlugin.js +2 -1
- package/lib/LoaderOptionsPlugin.js +3 -1
- package/lib/LoaderTargetPlugin.js +3 -1
- package/lib/MainTemplate.js +15 -0
- package/lib/ManifestPlugin.js +9 -2
- package/lib/Module.js +121 -60
- package/lib/ModuleFactory.js +6 -1
- package/lib/ModuleFilenameHelpers.js +5 -2
- package/lib/ModuleGraph.js +69 -2
- package/lib/ModuleGraphConnection.js +9 -0
- package/lib/ModuleInfoHeaderPlugin.js +5 -0
- package/lib/ModuleNotFoundError.js +3 -83
- package/lib/ModuleProfile.js +27 -1
- package/lib/ModuleSourceTypeConstants.js +52 -19
- package/lib/ModuleTemplate.js +10 -0
- package/lib/ModuleTypeConstants.js +20 -4
- package/lib/MultiCompiler.js +59 -4
- package/lib/MultiStats.js +9 -0
- package/lib/MultiWatching.js +6 -0
- package/lib/NoEmitOnErrorsPlugin.js +1 -1
- package/lib/NodeStuffPlugin.js +78 -46
- package/lib/NormalModule.js +485 -181
- package/lib/NormalModuleFactory.js +148 -29
- package/lib/NormalModuleReplacementPlugin.js +3 -1
- package/lib/NullFactory.js +1 -0
- package/lib/OptionsApply.js +1 -0
- package/lib/Parser.js +3 -1
- package/lib/PlatformPlugin.js +2 -1
- package/lib/PrefetchPlugin.js +4 -1
- package/lib/ProgressPlugin.js +351 -161
- package/lib/ProvidePlugin.js +6 -3
- package/lib/RawModule.js +32 -16
- package/lib/RecordIdsPlugin.js +9 -0
- package/lib/RequestShortener.js +8 -0
- package/lib/ResolverFactory.js +5 -0
- package/lib/RuntimeGlobals.js +58 -5
- package/lib/RuntimeModule.js +22 -7
- package/lib/RuntimePlugin.js +104 -26
- package/lib/RuntimeTemplate.js +616 -37
- package/lib/SelfModuleFactory.js +3 -0
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -0
- package/lib/SourceMapDevToolPlugin.js +341 -63
- package/lib/Stats.js +6 -0
- package/lib/Template.js +29 -3
- package/lib/TemplatedPathPlugin.js +505 -138
- package/lib/UseStrictPlugin.js +3 -2
- package/lib/WarnCaseSensitiveModulesPlugin.js +72 -3
- package/lib/WarnDeprecatedOptionPlugin.js +6 -2
- package/lib/WarnNoModeSetPlugin.js +18 -2
- package/lib/WatchIgnorePlugin.js +5 -1
- package/lib/Watching.js +25 -3
- package/lib/WebpackError.js +3 -74
- package/lib/WebpackIsIncludedPlugin.js +4 -2
- package/lib/WebpackOptionsApply.js +88 -25
- package/lib/WebpackOptionsDefaulter.js +1 -0
- package/lib/asset/AssetBytesGenerator.js +28 -10
- package/lib/asset/AssetBytesParser.js +1 -0
- package/lib/asset/AssetGenerator.js +199 -60
- package/lib/asset/AssetModule.js +47 -0
- package/lib/asset/AssetModulesPlugin.js +115 -24
- package/lib/asset/AssetParser.js +4 -2
- package/lib/asset/AssetSourceGenerator.js +26 -8
- package/lib/asset/AssetSourceParser.js +1 -0
- package/lib/asset/RawDataUrlModule.js +23 -13
- package/lib/asset/WebManifestGenerator.js +164 -0
- package/lib/asset/WebManifestParser.js +130 -0
- package/lib/async-modules/AsyncModuleHelpers.js +1 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +18 -4
- package/lib/async-modules/InferAsyncModulesPlugin.js +1 -1
- package/lib/async-modules/isGeneratorLowered.js +26 -0
- package/lib/buildChunkGraph.js +107 -15
- package/lib/bun/BunTargetPlugin.js +42 -0
- package/lib/cache/AddBuildDependenciesPlugin.js +3 -1
- package/lib/cache/AddManagedPathsPlugin.js +5 -1
- package/lib/cache/IdleFileCachePlugin.js +6 -1
- package/lib/cache/MemoryCachePlugin.js +1 -1
- package/lib/cache/MemoryWithGcCachePlugin.js +4 -1
- package/lib/cache/PackFileCacheStrategy.js +43 -7
- package/lib/cache/ResolverCachePlugin.js +12 -1
- package/lib/cache/getLazyHashedEtag.js +13 -2
- package/lib/cache/mergeEtags.js +4 -0
- package/lib/cli.js +142 -20
- package/lib/config/browserslistTargetHandler.js +141 -0
- package/lib/config/defaults.js +591 -41
- package/lib/config/defineConfig.js +31 -0
- package/lib/config/normalization.js +46 -1
- package/lib/config/target.js +200 -2
- package/lib/container/ContainerEntryDependency.js +2 -0
- package/lib/container/ContainerEntryModule.js +27 -14
- package/lib/container/ContainerEntryModuleFactory.js +1 -0
- package/lib/container/ContainerExposedDependency.js +6 -2
- package/lib/container/ContainerPlugin.js +2 -1
- package/lib/container/ContainerReferencePlugin.js +3 -2
- package/lib/container/FallbackDependency.js +9 -7
- package/lib/container/FallbackItemDependency.js +1 -0
- package/lib/container/FallbackModule.js +22 -9
- package/lib/container/FallbackModuleFactory.js +1 -0
- package/lib/container/ModuleFederationPlugin.js +12 -26
- package/lib/container/RemoteModule.js +33 -10
- package/lib/container/RemoteRuntimeModule.js +15 -12
- package/lib/container/RemoteToExternalDependency.js +1 -0
- package/lib/container/options.js +7 -0
- package/lib/css/CssGenerator.js +534 -272
- package/lib/css/CssInjectStyleRuntimeModule.js +86 -70
- package/lib/css/CssLoadingRuntimeModule.js +156 -77
- package/lib/{CssModule.js → css/CssModule.js} +72 -37
- package/lib/css/CssModulesPlugin.js +356 -204
- package/lib/css/CssParser.js +3452 -1950
- package/lib/css/syntax.js +4058 -0
- package/lib/debug/ProfilingPlugin.js +33 -2
- package/lib/deno/DenoTargetPlugin.js +41 -0
- package/lib/dependencies/AMDDefineDependency.js +29 -17
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +19 -6
- package/lib/dependencies/AMDPlugin.js +6 -3
- package/lib/dependencies/AMDRequireArrayDependency.js +13 -11
- package/lib/dependencies/AMDRequireContextDependency.js +10 -11
- package/lib/dependencies/AMDRequireDependenciesBlock.js +1 -0
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -14
- package/lib/dependencies/AMDRequireDependency.js +28 -20
- package/lib/dependencies/AMDRequireItemDependency.js +1 -0
- package/lib/dependencies/AMDRuntimeModules.js +3 -0
- package/lib/dependencies/CachedConstDependency.js +9 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +104 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +138 -38
- package/lib/dependencies/CommonJsExportsDependency.js +74 -20
- package/lib/dependencies/CommonJsExportsParserPlugin.js +246 -15
- package/lib/dependencies/CommonJsFullRequireDependency.js +62 -27
- package/lib/dependencies/CommonJsImportsParserPlugin.js +187 -24
- package/lib/dependencies/CommonJsPlugin.js +7 -4
- package/lib/dependencies/CommonJsRequireContextDependency.js +13 -13
- package/lib/dependencies/CommonJsRequireDependency.js +135 -13
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +60 -16
- package/lib/dependencies/ConstDependency.js +22 -12
- package/lib/dependencies/ContextDependency.js +13 -2
- package/lib/dependencies/ContextDependencyHelpers.js +7 -4
- package/lib/dependencies/ContextDependencyTemplateAsId.js +2 -1
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/ContextElementDependency.js +27 -14
- package/lib/dependencies/CreateRequireParserPlugin.js +14 -7
- package/lib/dependencies/CreateScriptUrlDependency.js +9 -7
- package/lib/dependencies/CriticalDependencyWarning.js +3 -1
- package/lib/dependencies/CssIcssExportDependency.js +682 -368
- package/lib/dependencies/CssIcssImportDependency.js +62 -17
- package/lib/dependencies/CssIcssSymbolDependency.js +36 -17
- package/lib/dependencies/CssImportDependency.js +37 -1
- package/lib/dependencies/CssUrlDependency.js +87 -14
- package/lib/dependencies/DelegatedSourceDependency.js +1 -0
- package/lib/dependencies/DllEntryDependency.js +12 -13
- package/lib/dependencies/DynamicExports.js +5 -0
- package/lib/dependencies/EntryDependency.js +1 -0
- package/lib/dependencies/ExportBindingInitFragment.js +164 -0
- package/lib/dependencies/ExportsInfoDependency.js +18 -12
- package/lib/dependencies/ExternalModuleDependency.js +13 -5
- package/lib/dependencies/ExternalModuleInitFragment.js +10 -5
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +19 -12
- package/lib/dependencies/HarmonyAcceptDependency.js +24 -26
- package/lib/dependencies/HarmonyAcceptImportDependency.js +2 -0
- package/lib/dependencies/HarmonyCompatibilityDependency.js +33 -14
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +108 -30
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +32 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +70 -33
- package/lib/dependencies/HarmonyExportExpressionDependency.js +140 -46
- package/lib/dependencies/HarmonyExportHeaderDependency.js +11 -9
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +253 -37
- package/lib/dependencies/HarmonyExportInitFragment.js +28 -20
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +88 -18
- package/lib/dependencies/HarmonyExports.js +6 -1
- package/lib/dependencies/HarmonyImportDependency.js +59 -3
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +139 -146
- package/lib/dependencies/HarmonyImportGuard.js +426 -0
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +22 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +136 -17
- package/lib/{HarmonyLinkingError.js → dependencies/HarmonyLinkingError.js} +6 -3
- package/lib/dependencies/HarmonyModulesPlugin.js +11 -1
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +2 -1
- package/lib/dependencies/HtmlEntryDependency.js +1295 -0
- package/lib/dependencies/HtmlInlineHtmlDependency.js +107 -0
- package/lib/dependencies/HtmlInlineScriptDependency.js +126 -0
- package/lib/dependencies/HtmlInlineStyleDependency.js +152 -0
- package/lib/dependencies/HtmlSourceDependency.js +172 -0
- package/lib/dependencies/ImportContextDependency.js +9 -9
- package/lib/dependencies/ImportDependency.js +92 -3
- package/lib/dependencies/ImportEagerDependency.js +2 -0
- package/lib/dependencies/ImportMetaContextDependency.js +1 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +35 -19
- package/lib/dependencies/ImportMetaContextPlugin.js +40 -8
- package/lib/dependencies/ImportMetaGlobDependency.js +81 -0
- package/lib/dependencies/ImportMetaGlobDependencyParserPlugin.js +78 -0
- package/lib/dependencies/ImportMetaGlobHelpers.js +660 -0
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +2 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +2 -0
- package/lib/dependencies/ImportMetaPlugin.js +595 -209
- package/lib/dependencies/ImportMetaResolveDependency.js +90 -0
- package/lib/dependencies/ImportParserPlugin.js +114 -27
- package/lib/dependencies/ImportPhase.js +17 -11
- package/lib/dependencies/ImportPlugin.js +2 -1
- package/lib/dependencies/ImportWeakDependency.js +3 -0
- package/lib/dependencies/JsonExportsDependency.js +15 -10
- package/lib/dependencies/LoaderDependency.js +2 -0
- package/lib/dependencies/LoaderImportDependency.js +3 -0
- package/lib/dependencies/LoaderPlugin.js +9 -2
- package/lib/dependencies/LocalModule.js +15 -12
- package/lib/dependencies/LocalModuleDependency.js +15 -13
- package/lib/dependencies/LocalModulesHelpers.js +3 -0
- package/lib/dependencies/ModuleDecoratorDependency.js +16 -10
- package/lib/dependencies/ModuleDependency.js +14 -0
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +2 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +2 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +19 -11
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/PrefetchDependency.js +1 -0
- package/lib/dependencies/ProvidedDependency.js +36 -27
- package/lib/dependencies/PureExpressionDependency.js +14 -10
- package/lib/dependencies/RequireContextDependency.js +1 -0
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +2 -1
- package/lib/dependencies/RequireContextPlugin.js +2 -1
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +1 -0
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +4 -6
- package/lib/dependencies/RequireEnsureDependency.js +16 -13
- package/lib/dependencies/RequireEnsureItemDependency.js +1 -0
- package/lib/dependencies/RequireEnsurePlugin.js +2 -1
- package/lib/dependencies/RequireHeaderDependency.js +7 -4
- package/lib/dependencies/RequireIncludeDependency.js +2 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +11 -12
- package/lib/dependencies/RequireIncludePlugin.js +2 -1
- package/lib/{RequireJsStuffPlugin.js → dependencies/RequireJsStuffPlugin.js} +9 -8
- package/lib/dependencies/RequireResolveContextDependency.js +10 -11
- package/lib/dependencies/RequireResolveDependency.js +2 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +8 -5
- package/lib/dependencies/RuntimeRequirementsDependency.js +11 -8
- package/lib/dependencies/StaticExportsDependency.js +13 -10
- package/lib/dependencies/SystemPlugin.js +9 -6
- package/lib/dependencies/SystemRuntimeModule.js +1 -0
- package/lib/dependencies/TopLevelAwaitDependency.js +93 -0
- package/lib/dependencies/URLContextDependency.js +8 -7
- package/lib/dependencies/URLDependency.js +157 -33
- package/lib/dependencies/URLPlugin.js +2 -0
- package/lib/dependencies/UnsupportedDependency.js +12 -13
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +15 -16
- package/lib/dependencies/WebAssemblyImportDependency.js +19 -18
- package/lib/dependencies/WebpackIsIncludedDependency.js +3 -0
- package/lib/dependencies/{WorkerPlugin.js → WorkerAndWorkletPlugin.js} +364 -114
- package/lib/dependencies/WorkerDependency.js +111 -27
- package/lib/dependencies/WorkletDependency.js +278 -0
- package/lib/dependencies/getFunctionExpression.js +1 -0
- package/lib/dependencies/processExportInfo.js +14 -11
- package/lib/{DelegatedModule.js → dll/DelegatedModule.js} +71 -44
- package/lib/{DelegatedModuleFactoryPlugin.js → dll/DelegatedModuleFactoryPlugin.js} +27 -4
- package/lib/{DelegatedPlugin.js → dll/DelegatedPlugin.js} +5 -3
- package/lib/{DllEntryPlugin.js → dll/DllEntryPlugin.js} +9 -5
- package/lib/{DllModule.js → dll/DllModule.js} +36 -24
- package/lib/{DllModuleFactory.js → dll/DllModuleFactory.js} +5 -4
- package/lib/{DllPlugin.js → dll/DllPlugin.js} +24 -6
- package/lib/{DllReferencePlugin.js → dll/DllReferencePlugin.js} +26 -18
- package/lib/{LibManifestPlugin.js → dll/LibManifestPlugin.js} +14 -10
- package/lib/electron/ElectronTargetPlugin.js +24 -5
- package/lib/{AbstractMethodError.js → errors/AbstractMethodError.js} +10 -1
- package/lib/{AsyncDependencyToInitialChunkError.js → errors/AsyncDependencyToInitialChunkError.js} +8 -3
- package/lib/errors/BuildCycleError.js +1 -1
- package/lib/{ChunkRenderError.js → errors/ChunkRenderError.js} +1 -1
- package/lib/{CodeGenerationError.js → errors/CodeGenerationError.js} +1 -1
- package/lib/{CommentCompilationWarning.js → errors/CommentCompilationWarning.js} +9 -3
- package/lib/{ConcurrentCompilationError.js → errors/ConcurrentCompilationError.js} +5 -2
- package/lib/{EnvironmentNotSupportAsyncWarning.js → errors/EnvironmentNotSupportAsyncWarning.js} +5 -5
- package/lib/{HookWebpackError.js → errors/HookWebpackError.js} +20 -16
- package/lib/{IgnoreErrorModuleFactory.js → errors/IgnoreErrorModuleFactory.js} +7 -4
- package/lib/{InvalidDependenciesModuleWarning.js → errors/InvalidDependenciesModuleWarning.js} +6 -3
- package/lib/errors/JSONParseError.js +115 -0
- package/lib/errors/LoaderLoadingError.js +20 -0
- package/lib/{ModuleBuildError.js → errors/ModuleBuildError.js} +22 -16
- package/lib/{ModuleDependencyError.js → errors/ModuleDependencyError.js} +10 -3
- package/lib/{ModuleDependencyWarning.js → errors/ModuleDependencyWarning.js} +13 -5
- package/lib/{ModuleError.js → errors/ModuleError.js} +10 -14
- package/lib/{ModuleHashingError.js → errors/ModuleHashingError.js} +5 -1
- package/lib/errors/ModuleNotFoundError.js +94 -0
- package/lib/errors/ModuleParseError.js +141 -0
- package/lib/{ModuleRestoreError.js → errors/ModuleRestoreError.js} +4 -1
- package/lib/{ModuleStoreError.js → errors/ModuleStoreError.js} +5 -1
- package/lib/{ModuleWarning.js → errors/ModuleWarning.js} +13 -14
- package/lib/{NodeStuffInWebError.js → errors/NodeStuffInWebError.js} +7 -5
- package/lib/errors/NonErrorEmittedError.js +30 -0
- package/lib/{UnhandledSchemeError.js → errors/UnhandledSchemeError.js} +9 -2
- package/lib/{UnsupportedFeatureWarning.js → errors/UnsupportedFeatureWarning.js} +4 -3
- package/lib/errors/WebpackError.js +84 -0
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +2 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +52 -15
- package/lib/esm/ModuleChunkLoadingPlugin.js +11 -3
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +71 -49
- package/lib/hmr/HotModuleReplacement.runtime.js +175 -30
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +8 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +173 -26
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +154 -7
- package/lib/hmr/lazyCompilationBackend.js +34 -8
- package/lib/html/HtmlGenerator.js +1470 -0
- package/lib/html/HtmlModule.js +41 -0
- package/lib/html/HtmlModulesPlugin.js +1111 -0
- package/lib/html/HtmlParser.js +1970 -0
- package/lib/html/favicon.svg +1 -0
- package/lib/html/syntax.js +9020 -0
- package/lib/ids/ChunkModuleIdRangePlugin.js +3 -1
- package/lib/ids/DeterministicChunkIdsPlugin.js +3 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +3 -1
- package/lib/ids/HashedModuleIdsPlugin.js +2 -1
- package/lib/ids/IdHelpers.js +25 -2
- package/lib/ids/NamedChunkIdsPlugin.js +3 -1
- package/lib/ids/NamedModuleIdsPlugin.js +3 -1
- package/lib/ids/NaturalChunkIdsPlugin.js +1 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -1
- package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -1
- package/lib/ids/SyncModuleIdsPlugin.js +3 -1
- package/lib/index.js +66 -15
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +5 -6
- package/lib/javascript/BasicEvaluatedExpression.js +370 -49
- package/lib/javascript/ChunkFormatHelpers.js +2 -1
- package/lib/javascript/ChunkHelpers.js +1 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/EnableChunkLoadingPlugin.js +6 -1
- package/lib/javascript/JavascriptGenerator.js +213 -51
- package/lib/javascript/JavascriptModule.js +54 -0
- package/lib/javascript/JavascriptModulesPlugin.js +579 -183
- package/lib/javascript/JavascriptParser.js +1289 -462
- package/lib/javascript/JavascriptParserHelpers.js +10 -7
- package/lib/javascript/StartupHelpers.js +5 -0
- package/lib/javascript/syntax.js +4380 -0
- package/lib/json/JsonData.js +5 -0
- package/lib/json/JsonGenerator.js +21 -0
- package/lib/json/JsonModule.js +40 -0
- package/lib/json/JsonModulesPlugin.js +8 -1
- package/lib/json/JsonParser.js +18 -27
- package/lib/library/AbstractLibraryPlugin.js +17 -2
- package/lib/library/AmdLibraryPlugin.js +8 -0
- package/lib/library/AssignLibraryPlugin.js +21 -3
- package/lib/library/EnableLibraryPlugin.js +8 -2
- package/lib/library/ExportPropertyLibraryPlugin.js +10 -0
- package/lib/{FalseIIFEUmdWarning.js → library/FalseIIFEUmdWarning.js} +2 -1
- package/lib/library/JsonpLibraryPlugin.js +8 -0
- package/lib/library/ModuleLibraryPlugin.js +154 -7
- package/lib/library/SystemLibraryPlugin.js +11 -3
- package/lib/library/UmdLibraryPlugin.js +16 -0
- package/lib/loaders/LoaderRunner.js +714 -0
- package/lib/loaders/loadLoader.js +100 -0
- package/lib/logging/Logger.js +17 -0
- package/lib/logging/createConsoleLogger.js +7 -0
- package/lib/logging/runtime.js +2 -0
- package/lib/logging/truncateArgs.js +2 -0
- package/lib/node/CommonJsChunkLoadingPlugin.js +5 -1
- package/lib/node/NodeEnvironmentPlugin.js +7 -3
- package/lib/node/NodeSourcePlugin.js +1 -1
- package/lib/node/NodeTargetPlugin.js +4 -63
- package/lib/node/NodeTemplatePlugin.js +3 -1
- package/lib/node/NodeWatchFileSystem.js +40 -22
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +13 -9
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +23 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +18 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +21 -16
- package/lib/node/nodeBuiltins.js +80 -0
- package/lib/node/nodeConsole.js +116 -64
- package/lib/optimize/AggressiveMergingPlugin.js +3 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +6 -1
- package/lib/optimize/ConcatenatedModule.js +585 -116
- package/lib/optimize/ConstExportsPlugin.js +211 -0
- package/lib/optimize/EnsureChunkConditionsPlugin.js +2 -1
- package/lib/optimize/FlagIncludedChunksPlugin.js +15 -4
- package/lib/optimize/InlineExports.js +178 -0
- package/lib/optimize/InnerGraph.js +374 -262
- package/lib/optimize/InnerGraphPlugin.js +246 -117
- package/lib/optimize/LimitChunkCountPlugin.js +9 -0
- package/lib/optimize/MangleExportsPlugin.js +5 -1
- package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -0
- package/lib/optimize/MinChunkSizePlugin.js +2 -1
- package/lib/optimize/MinMaxSizeWarning.js +5 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +159 -34
- package/lib/optimize/RealContentHashPlugin.js +125 -50
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -1
- package/lib/optimize/RuntimeChunkPlugin.js +2 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +381 -55
- package/lib/optimize/SplitChunksPlugin.js +54 -6
- package/lib/performance/AssetsOverSizeLimitWarning.js +3 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +3 -2
- package/lib/performance/NoAsyncChunksWarning.js +5 -3
- package/lib/performance/SizeLimitsPlugin.js +8 -2
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +1 -0
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +21 -0
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +1 -0
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +5 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +25 -13
- package/lib/prefetch/ResourceHintPlugin.js +663 -0
- package/lib/prefetch/ResourceHintRuntimeModule.js +149 -0
- package/lib/prefetch/StartupAssetHintRuntimeModule.js +210 -0
- package/lib/prefetch/parseResourceHintOptions.js +103 -0
- package/lib/rules/BasicEffectRulePlugin.js +3 -0
- package/lib/rules/BasicMatcherRulePlugin.js +3 -0
- package/lib/rules/ObjectMatcherRulePlugin.js +3 -0
- package/lib/rules/RuleSetCompiler.js +132 -0
- package/lib/rules/UseEffectRulePlugin.js +10 -3
- package/lib/runtime/AsyncModuleGeneratorRuntimeModule.js +56 -0
- package/lib/runtime/AsyncModuleRuntimeModule.js +52 -33
- package/lib/runtime/AutoPublicPathRuntimeModule.js +22 -9
- package/lib/runtime/BaseUriRuntimeModule.js +1 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
- package/lib/runtime/CommonJsWrapRuntimeModule.js +37 -0
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +2 -1
- package/lib/runtime/CompatRuntimeModule.js +2 -0
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +7 -4
- package/lib/runtime/CreateScriptRuntimeModule.js +1 -0
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +1 -0
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +34 -4
- package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +88 -8
- package/lib/runtime/GetFullHashRuntimeModule.js +1 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +1 -0
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +2 -1
- package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +59 -0
- package/lib/runtime/GlobalRuntimeModule.js +1 -0
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +2 -1
- package/lib/runtime/HelperRuntimeModule.js +5 -0
- package/lib/runtime/LoadScriptRuntimeModule.js +28 -37
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +354 -37
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +2 -1
- package/lib/runtime/NonceRuntimeModule.js +1 -0
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +5 -4
- package/lib/runtime/PublicPathRuntimeModule.js +1 -0
- package/lib/runtime/RelativeUrlRuntimeModule.js +4 -2
- package/lib/runtime/RuntimeIdRuntimeModule.js +1 -0
- package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +38 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +13 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +2 -1
- package/lib/runtime/StartupEntrypointRuntimeModule.js +5 -3
- package/lib/runtime/SystemContextRuntimeModule.js +1 -0
- package/lib/runtime/ToBinaryRuntimeModule.js +1 -0
- package/lib/runtime/WorkerRuntimeModule.js +33 -0
- package/lib/schemes/DataUriPlugin.js +14 -2
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +86 -4
- package/lib/schemes/VirtualUrlPlugin.js +8 -4
- package/lib/serialization/AggregateErrorSerializer.js +9 -6
- package/lib/serialization/ArraySerializer.js +6 -8
- package/lib/serialization/BinaryMiddleware.js +552 -463
- package/lib/serialization/DateObjectSerializer.js +4 -2
- package/lib/serialization/ErrorObjectSerializer.js +10 -6
- package/lib/serialization/FileMiddleware.js +50 -3
- package/lib/serialization/MapObjectSerializer.js +7 -9
- package/lib/serialization/NullPrototypeObjectSerializer.js +9 -9
- package/lib/serialization/ObjectMiddleware.js +73 -13
- package/lib/serialization/PlainObjectSerializer.js +16 -8
- package/lib/serialization/RegExpObjectSerializer.js +4 -2
- package/lib/serialization/Serializer.js +6 -0
- package/lib/serialization/SerializerMiddleware.js +14 -2
- package/lib/serialization/SetObjectSerializer.js +6 -8
- package/lib/serialization/SingleItemMiddleware.js +3 -0
- package/lib/sharing/ConsumeSharedFallbackDependency.js +1 -0
- package/lib/sharing/ConsumeSharedModule.js +21 -7
- package/lib/sharing/ConsumeSharedPlugin.js +11 -11
- package/lib/sharing/ConsumeSharedRuntimeModule.js +55 -45
- package/lib/sharing/ProvideForSharedDependency.js +1 -0
- package/lib/sharing/ProvideSharedDependency.js +34 -15
- package/lib/sharing/ProvideSharedModule.js +42 -12
- package/lib/sharing/ProvideSharedModuleFactory.js +1 -0
- package/lib/sharing/ProvideSharedPlugin.js +13 -8
- package/lib/sharing/SharePlugin.js +5 -1
- package/lib/sharing/ShareRuntimeModule.js +19 -16
- package/lib/sharing/resolveMatchedConfigs.js +6 -2
- package/lib/sharing/utils.js +9 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +94 -12
- package/lib/stats/DefaultStatsPresetPlugin.js +14 -2
- package/lib/stats/DefaultStatsPrinterPlugin.js +64 -18
- package/lib/stats/StatsFactory.js +39 -18
- package/lib/stats/StatsPrinter.js +16 -2
- package/lib/typescript/TypeScriptPlugin.js +210 -0
- package/lib/url/URLParserPlugin.js +111 -23
- package/lib/util/ArrayHelpers.js +1 -0
- package/lib/util/ArrayQueue.js +10 -5
- package/lib/util/AsyncQueue.js +154 -74
- package/lib/util/Hash.js +2 -2
- package/lib/util/IterableHelpers.js +3 -0
- package/lib/util/LazyBucketSortedSet.js +26 -0
- package/lib/util/LazySet.js +45 -4
- package/lib/util/LocConverter.js +64 -0
- package/lib/util/ParallelismFactorCalculator.js +1 -0
- package/lib/util/Queue.js +6 -3
- package/lib/util/Semaphore.js +15 -1
- package/lib/util/SetHelpers.js +4 -1
- package/lib/util/SortableSet.js +7 -1
- package/lib/util/SourceProcessor.js +119 -0
- package/lib/util/StackedCacheMap.js +20 -3
- package/lib/util/StackedMap.js +162 -43
- package/lib/util/StringXor.js +1 -1
- package/lib/util/TupleQueue.js +7 -3
- package/lib/util/TupleSet.js +14 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -0
- package/lib/util/WeakTupleMap.js +60 -1
- package/lib/util/binarySearchBounds.js +3 -2
- package/lib/util/chainedImports.js +3 -3
- package/lib/util/cleverMerge.js +19 -2
- package/lib/util/comparators.js +35 -4
- package/lib/util/compileBooleanMatcher.js +9 -0
- package/lib/util/concatenate.js +80 -24
- package/lib/util/conventions.js +46 -1
- package/lib/util/createHash.js +0 -1
- package/lib/util/createHooksRegistry.js +43 -0
- package/lib/util/createMappings.js +118 -0
- package/lib/util/dataURL.js +3 -2
- package/lib/util/deprecation.js +19 -0
- package/lib/util/deterministicGrouping.js +46 -17
- package/lib/util/extractSourceMap.js +2 -1
- package/lib/util/extractUrlAndGlobal.js +1 -0
- package/lib/util/findGraphRoots.js +7 -0
- package/lib/{formatLocation.js → util/formatLocation.js} +4 -2
- package/lib/{SizeFormatHelpers.js → util/formatSize.js} +10 -3
- package/lib/util/fs.js +87 -14
- package/lib/util/generateDebugId.js +1 -0
- package/lib/util/globUtils.js +710 -0
- package/lib/util/hash/BatchedHash.js +1 -0
- package/lib/util/hash/BulkUpdateHash.js +1 -0
- package/lib/util/hash/DebugHash.js +1 -0
- package/lib/util/hash/hash-digest.js +32 -15
- package/lib/util/hash/md4.js +1 -1
- package/lib/util/hash/wasm-hash.js +5 -0
- package/lib/util/hash/xxhash64.js +1 -1
- package/lib/util/identifier.js +97 -6
- package/lib/util/implicitTypeLoaderFallback.js +62 -0
- package/lib/util/internalSerializables.js +102 -60
- package/lib/util/magicComment.js +149 -7
- package/lib/util/makeSerializable.js +7 -0
- package/lib/util/memoize.js +2 -0
- package/lib/util/mimeTypes.js +176 -0
- package/lib/util/nonNumericOnlyHash.js +31 -1
- package/lib/util/numberHash.js +2 -2
- package/lib/util/parseJson.js +41 -0
- package/lib/util/processAsyncTree.js +8 -0
- package/lib/util/property.js +9 -2
- package/lib/util/publicPathPlaceholder.js +64 -0
- package/lib/util/registerExternalSerializer.js +24 -4
- package/lib/util/removeBOM.js +1 -0
- package/lib/util/runtime.js +32 -0
- package/lib/util/semver.js +15 -0
- package/lib/util/serialization.js +2 -0
- package/lib/util/smartGrouping.js +8 -0
- package/lib/util/source.js +23 -0
- package/lib/util/topologicalSort.js +69 -0
- package/lib/validateSchema.js +1 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +15 -1
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +25 -18
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +34 -22
- package/lib/wasm-async/AsyncWasmModule.js +77 -0
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +6 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +22 -126
- package/lib/wasm-async/AsyncWebAssemblyParser.js +3 -2
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +13 -2
- package/lib/wasm-sync/SyncWasmModule.js +39 -0
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +7 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +86 -19
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +4 -3
- package/lib/wasm-sync/WebAssemblyGenerator.js +27 -1
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +9 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +4 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +20 -1
- package/lib/wasm-sync/WebAssemblyParser.js +9 -3
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -0
- package/lib/web/FetchCompileAsyncWasmPlugin.js +29 -1
- package/lib/web/FetchCompileWasmPlugin.js +27 -1
- package/lib/web/JsonpChunkLoadingPlugin.js +11 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +58 -64
- package/lib/web/JsonpTemplatePlugin.js +2 -1
- package/lib/webpack.js +78 -1
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +10 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +15 -10
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -1
- package/module.d.ts +21 -0
- package/package.json +79 -77
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +1117 -79
- package/schemas/plugins/{DllPlugin.check.d.ts → HtmlGeneratorOptions.check.d.ts} +1 -1
- package/schemas/plugins/HtmlGeneratorOptions.check.js +6 -0
- package/schemas/plugins/HtmlGeneratorOptions.json +3 -0
- package/schemas/plugins/{DllReferencePlugin.check.d.ts → HtmlParserOptions.check.d.ts} +1 -1
- package/schemas/plugins/HtmlParserOptions.check.js +6 -0
- package/schemas/plugins/HtmlParserOptions.json +3 -0
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +38 -0
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +2 -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 +2 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.json +3 -0
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/schemas/plugins/dll/DllPlugin.check.d.ts +7 -0
- package/schemas/plugins/dll/DllReferencePlugin.check.d.ts +7 -0
- package/types.d.ts +8608 -1159
- package/lib/CaseSensitiveModulesWarning.js +0 -72
- package/lib/GraphHelpers.js +0 -46
- package/lib/ModuleParseError.js +0 -125
- package/lib/NoModeWarning.js +0 -23
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +0 -56
- package/lib/css/walkCssTokens.js +0 -1843
- package/lib/util/AppendOnlyStackedSet.js +0 -78
- /package/schemas/plugins/{DllPlugin.check.js → dll/DllPlugin.check.js} +0 -0
- /package/schemas/plugins/{DllPlugin.json → dll/DllPlugin.json} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.check.js → dll/DllReferencePlugin.check.js} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.json → dll/DllReferencePlugin.json} +0 -0
|
@@ -14,6 +14,7 @@ const {
|
|
|
14
14
|
ReplaceSource
|
|
15
15
|
} = require("webpack-sources");
|
|
16
16
|
const ConcatenationScope = require("../ConcatenationScope");
|
|
17
|
+
const Dependency = require("../Dependency");
|
|
17
18
|
const { UsageState } = require("../ExportsInfo");
|
|
18
19
|
const Module = require("../Module");
|
|
19
20
|
const {
|
|
@@ -24,10 +25,12 @@ const { JAVASCRIPT_MODULE_TYPE_ESM } = require("../ModuleTypeConstants");
|
|
|
24
25
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
25
26
|
const Template = require("../Template");
|
|
26
27
|
const { DEFAULTS } = require("../config/defaults");
|
|
27
|
-
const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
|
|
28
28
|
const { ImportPhaseUtils } = require("../dependencies/ImportPhase");
|
|
29
|
+
const { isCommonJsWrapped } = require("../javascript/JavascriptGenerator");
|
|
29
30
|
const JavascriptParser = require("../javascript/JavascriptParser");
|
|
30
31
|
const {
|
|
32
|
+
getDeferredCycleModuleIds,
|
|
33
|
+
getDeferredCycleModules,
|
|
31
34
|
getMakeDeferredNamespaceModeFromExportsType,
|
|
32
35
|
getOptimizedDeferredModule
|
|
33
36
|
} = require("../runtime/MakeDeferredNamespaceObjectRuntime");
|
|
@@ -43,6 +46,7 @@ const {
|
|
|
43
46
|
getUsedNamesInScopeInfo
|
|
44
47
|
} = require("../util/concatenate");
|
|
45
48
|
const createHash = require("../util/createHash");
|
|
49
|
+
const createHooksRegistry = require("../util/createHooksRegistry");
|
|
46
50
|
const { makePathsRelative } = require("../util/identifier");
|
|
47
51
|
const makeSerializable = require("../util/makeSerializable");
|
|
48
52
|
const { propertyAccess, propertyName } = require("../util/property");
|
|
@@ -54,22 +58,23 @@ const {
|
|
|
54
58
|
runtimeConditionToString,
|
|
55
59
|
subtractRuntimeCondition
|
|
56
60
|
} = require("../util/runtime");
|
|
61
|
+
const { InlinedUsedName } = require("./InlineExports");
|
|
57
62
|
|
|
58
|
-
/** @typedef {import("eslint-scope").Reference} Reference */
|
|
59
|
-
/** @typedef {import("eslint-scope").Scope} Scope */
|
|
60
|
-
/** @typedef {import("eslint-scope").Variable} Variable */
|
|
61
63
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
62
64
|
/** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
63
65
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
64
66
|
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
|
65
67
|
/** @typedef {import("../Compilation")} Compilation */
|
|
66
68
|
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
|
69
|
+
/** @typedef {import("../dependencies/ModuleDependency")} ModuleDependency */
|
|
70
|
+
/** @typedef {import("../dependencies/HarmonyImportDependency")} HarmonyImportDependency */
|
|
67
71
|
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
|
68
72
|
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
|
|
69
73
|
/** @typedef {import("../Module").BuildCallback} BuildCallback */
|
|
70
74
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
71
75
|
/** @typedef {import("../Module").FileSystemDependencies} FileSystemDependencies */
|
|
72
76
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
77
|
+
/** @typedef {import("../Module").ExportsType} ExportsType */
|
|
73
78
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
|
74
79
|
/** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
|
|
75
80
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
|
@@ -80,19 +85,25 @@ const {
|
|
|
80
85
|
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
|
81
86
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
82
87
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
88
|
+
/** @typedef {import("../NormalModule")} NormalModule */
|
|
83
89
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
|
84
90
|
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
85
91
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
86
92
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
87
93
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
94
|
+
/** @typedef {import("../javascript/JavascriptModule").JavascriptModuleBuildInfo} JavascriptModuleBuildInfo */
|
|
95
|
+
/** @typedef {import("../javascript/JavascriptModule").JavascriptModuleBuildMeta} JavascriptModuleBuildMeta */
|
|
88
96
|
/** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
|
|
97
|
+
/** @typedef {import("../javascript/JavascriptModulesPlugin").Scope} Scope */
|
|
98
|
+
/** @typedef {import("../javascript/JavascriptModulesPlugin").Reference} Reference */
|
|
99
|
+
/** @typedef {import("../javascript/JavascriptModulesPlugin").Variable} Variable */
|
|
89
100
|
/** @typedef {import("../javascript/JavascriptParser").Program} Program */
|
|
90
101
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
91
102
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
92
103
|
/** @typedef {import("../util/Hash")} Hash */
|
|
93
104
|
/** @typedef {import("../util/Hash").HashFunction} HashFunction */
|
|
94
105
|
/** @typedef {import("../util/concatenate").UsedNames} UsedNames */
|
|
95
|
-
/** @typedef {import("../util/concatenate").
|
|
106
|
+
/** @typedef {import("../util/concatenate").UsedNamesInScopeInfo} UsedNamesInScopeInfo */
|
|
96
107
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
97
108
|
/** @typedef {import("../util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
|
98
109
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
@@ -146,6 +157,7 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
|
|
|
146
157
|
* @property {"concatenated"} type
|
|
147
158
|
* @property {Module} module
|
|
148
159
|
* @property {number} index
|
|
160
|
+
* @property {boolean=} cjsWrapped a "weird" CommonJS module executed via the CJS wrapper runtime helper with real module/exports objects
|
|
149
161
|
* @property {Program | undefined} ast
|
|
150
162
|
* @property {Source | undefined} internalSource
|
|
151
163
|
* @property {ReplaceSource | undefined} source
|
|
@@ -158,6 +170,7 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
|
|
|
158
170
|
* @property {ExportMap | undefined} rawExportMap
|
|
159
171
|
* @property {string=} namespaceExportSymbol
|
|
160
172
|
* @property {string | undefined} namespaceObjectName
|
|
173
|
+
* @property {string | undefined} escapeNamespaceObjectName decoupled namespace object that keeps original export names when the exports are mangled
|
|
161
174
|
* @property {ConcatenationScope | undefined} concatenationScope
|
|
162
175
|
* @property {boolean} interopNamespaceObjectUsed "default-with-named" namespace
|
|
163
176
|
* @property {string | undefined} interopNamespaceObjectName "default-with-named" namespace
|
|
@@ -165,6 +178,8 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
|
|
|
165
178
|
* @property {string | undefined} interopNamespaceObject2Name "default-only" namespace
|
|
166
179
|
* @property {boolean} interopDefaultAccessUsed runtime namespace object that detects "__esModule"
|
|
167
180
|
* @property {string | undefined} interopDefaultAccessName runtime namespace object that detects "__esModule"
|
|
181
|
+
* @property {ExportsType=} exportsTypeStrict memoized getExportsType(strict=true)
|
|
182
|
+
* @property {ExportsType=} exportsTypeNonStrict memoized getExportsType(strict=false)
|
|
168
183
|
*/
|
|
169
184
|
|
|
170
185
|
/**
|
|
@@ -175,6 +190,7 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
|
|
|
175
190
|
* @property {NonDeferAccess} nonDeferAccess
|
|
176
191
|
* @property {number} index
|
|
177
192
|
* @property {string | undefined} name module.exports / harmony namespace object
|
|
193
|
+
* @property {string | undefined} escapeNamespaceObjectName decoupled namespace object that keeps original export names when the exports are mangled
|
|
178
194
|
* @property {string | undefined} deferredName deferred module.exports / harmony namespace object
|
|
179
195
|
* @property {boolean} deferred the module is deferred at least once
|
|
180
196
|
* @property {boolean} deferredNamespaceObjectUsed deferred namespace object that being used in a not-analyzable way so it must be materialized
|
|
@@ -185,6 +201,8 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
|
|
|
185
201
|
* @property {string | undefined} interopNamespaceObject2Name "default-only" namespace
|
|
186
202
|
* @property {boolean} interopDefaultAccessUsed runtime namespace object that detects "__esModule"
|
|
187
203
|
* @property {string | undefined} interopDefaultAccessName runtime namespace object that detects "__esModule"
|
|
204
|
+
* @property {ExportsType=} exportsTypeStrict memoized getExportsType(strict=true)
|
|
205
|
+
* @property {ExportsType=} exportsTypeNonStrict memoized getExportsType(strict=false)
|
|
188
206
|
*/
|
|
189
207
|
|
|
190
208
|
/**
|
|
@@ -280,6 +298,27 @@ const subtractNonDeferAccess = (a, b) => a && !b;
|
|
|
280
298
|
|
|
281
299
|
/** @typedef {Map<Module, ModuleInfo>} ModuleToInfoMap */
|
|
282
300
|
|
|
301
|
+
/**
|
|
302
|
+
* getExportsType memoized on the info, which lives for one codeGeneration.
|
|
303
|
+
* The "dynamic" case walks the module graph, and is queried once per reference.
|
|
304
|
+
* @param {ModuleGraph} moduleGraph the module graph
|
|
305
|
+
* @param {ModuleInfo} info module info
|
|
306
|
+
* @param {boolean | undefined} strict strict harmony module (undefined is treated as non-strict)
|
|
307
|
+
* @returns {ExportsType} the exports type
|
|
308
|
+
*/
|
|
309
|
+
const getExportsType = (moduleGraph, info, strict) => {
|
|
310
|
+
if (strict) {
|
|
311
|
+
if (info.exportsTypeStrict === undefined) {
|
|
312
|
+
info.exportsTypeStrict = info.module.getExportsType(moduleGraph, true);
|
|
313
|
+
}
|
|
314
|
+
return info.exportsTypeStrict;
|
|
315
|
+
}
|
|
316
|
+
if (info.exportsTypeNonStrict === undefined) {
|
|
317
|
+
info.exportsTypeNonStrict = info.module.getExportsType(moduleGraph, false);
|
|
318
|
+
}
|
|
319
|
+
return info.exportsTypeNonStrict;
|
|
320
|
+
};
|
|
321
|
+
|
|
283
322
|
/**
|
|
284
323
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
285
324
|
* @param {ModuleInfo} info module info
|
|
@@ -293,7 +332,7 @@ const subtractNonDeferAccess = (a, b) => a && !b;
|
|
|
293
332
|
* @param {boolean} depDeferred the dependency is deferred
|
|
294
333
|
* @param {boolean | undefined} strictHarmonyModule strictHarmonyModule
|
|
295
334
|
* @param {boolean | undefined} asiSafe asiSafe
|
|
296
|
-
* @param {Set<ExportInfo
|
|
335
|
+
* @param {Set<ExportInfo>=} alreadyVisited alreadyVisited
|
|
297
336
|
* @returns {Binding} the final variable
|
|
298
337
|
*/
|
|
299
338
|
const getFinalBinding = (
|
|
@@ -309,12 +348,9 @@ const getFinalBinding = (
|
|
|
309
348
|
depDeferred,
|
|
310
349
|
strictHarmonyModule,
|
|
311
350
|
asiSafe,
|
|
312
|
-
alreadyVisited
|
|
351
|
+
alreadyVisited
|
|
313
352
|
) => {
|
|
314
|
-
const exportsType =
|
|
315
|
-
moduleGraph,
|
|
316
|
-
strictHarmonyModule
|
|
317
|
-
);
|
|
353
|
+
const exportsType = getExportsType(moduleGraph, info, strictHarmonyModule);
|
|
318
354
|
const moduleDeferred =
|
|
319
355
|
info.type === "external" &&
|
|
320
356
|
info.deferred &&
|
|
@@ -323,6 +359,9 @@ const getFinalBinding = (
|
|
|
323
359
|
if (exportName.length === 0) {
|
|
324
360
|
switch (exportsType) {
|
|
325
361
|
case "default-only":
|
|
362
|
+
// a concatenated CommonJS module has no runtime exports object;
|
|
363
|
+
// its fake namespace is built over the generated namespace object
|
|
364
|
+
if (info.type === "concatenated") neededNamespaceObjects.add(info);
|
|
326
365
|
if (deferred) info.deferredNamespaceObjectUsed = true;
|
|
327
366
|
else info.interopNamespaceObject2Used = true;
|
|
328
367
|
return {
|
|
@@ -336,6 +375,7 @@ const getFinalBinding = (
|
|
|
336
375
|
exportName
|
|
337
376
|
};
|
|
338
377
|
case "default-with-named":
|
|
378
|
+
if (info.type === "concatenated") neededNamespaceObjects.add(info);
|
|
339
379
|
if (deferred) info.deferredNamespaceObjectUsed = true;
|
|
340
380
|
else info.interopNamespaceObjectUsed = true;
|
|
341
381
|
return {
|
|
@@ -362,6 +402,20 @@ const getFinalBinding = (
|
|
|
362
402
|
switch (exportName[0]) {
|
|
363
403
|
case "default":
|
|
364
404
|
exportName = exportName.slice(1);
|
|
405
|
+
if (deferred) {
|
|
406
|
+
// `ns.default` for a deferred default-with-named external
|
|
407
|
+
// module must read through the optimized `.a` getter
|
|
408
|
+
// (which lazily evaluates the module and returns its
|
|
409
|
+
// exports), not the proxy namespace itself — otherwise
|
|
410
|
+
// `typeof ns.default` / `ns.default instanceof X`
|
|
411
|
+
// observe the proxy instead of the actual default.
|
|
412
|
+
return {
|
|
413
|
+
info,
|
|
414
|
+
rawName: `${info.deferredName}.a`,
|
|
415
|
+
ids: exportName,
|
|
416
|
+
exportName
|
|
417
|
+
};
|
|
418
|
+
}
|
|
365
419
|
break;
|
|
366
420
|
case "__esModule":
|
|
367
421
|
return {
|
|
@@ -392,6 +446,18 @@ const getFinalBinding = (
|
|
|
392
446
|
exportName
|
|
393
447
|
};
|
|
394
448
|
}
|
|
449
|
+
if (deferred) {
|
|
450
|
+
// As with default-with-named above, `ns.default` for a
|
|
451
|
+
// deferred default-only external must read through the
|
|
452
|
+
// optimized `.a` getter so that `typeof` / `instanceof`
|
|
453
|
+
// observe the actual default value rather than the proxy.
|
|
454
|
+
return {
|
|
455
|
+
info,
|
|
456
|
+
rawName: `${info.deferredName}.a`,
|
|
457
|
+
ids: exportName,
|
|
458
|
+
exportName
|
|
459
|
+
};
|
|
460
|
+
}
|
|
395
461
|
break;
|
|
396
462
|
}
|
|
397
463
|
case "dynamic":
|
|
@@ -476,6 +542,9 @@ const getFinalBinding = (
|
|
|
476
542
|
}
|
|
477
543
|
const exportsInfo = moduleGraph.getExportsInfo(info.module);
|
|
478
544
|
const exportInfo = exportsInfo.getExportInfo(exportName[0]);
|
|
545
|
+
// Lazily allocate: only the reexport-following recursion below needs it,
|
|
546
|
+
// most calls return before reaching this point.
|
|
547
|
+
if (alreadyVisited === undefined) alreadyVisited = new Set();
|
|
479
548
|
if (alreadyVisited.has(exportInfo)) {
|
|
480
549
|
return {
|
|
481
550
|
info,
|
|
@@ -500,9 +569,7 @@ const getFinalBinding = (
|
|
|
500
569
|
}
|
|
501
570
|
const directExport = info.exportMap && info.exportMap.get(exportId);
|
|
502
571
|
if (directExport) {
|
|
503
|
-
const usedName =
|
|
504
|
-
exportsInfo.getUsedName(exportName, runtime)
|
|
505
|
-
);
|
|
572
|
+
const usedName = exportsInfo.getUsedName(exportName, runtime);
|
|
506
573
|
if (!usedName) {
|
|
507
574
|
return {
|
|
508
575
|
info,
|
|
@@ -511,10 +578,26 @@ const getFinalBinding = (
|
|
|
511
578
|
exportName
|
|
512
579
|
};
|
|
513
580
|
}
|
|
581
|
+
if (usedName instanceof InlinedUsedName) {
|
|
582
|
+
return {
|
|
583
|
+
info,
|
|
584
|
+
// Render the inlined literal only (e.g. `"str"`), not its property
|
|
585
|
+
// suffix: that suffix is returned in `ids` and appended once by
|
|
586
|
+
// getFinalName. Using `usedName.render()` would emit it here too,
|
|
587
|
+
// duplicating the access (e.g. `"str".a.a`).
|
|
588
|
+
rawName: usedName.render(
|
|
589
|
+
Template.toNormalComment(
|
|
590
|
+
`inlined export ${propertyAccess(exportName)}`
|
|
591
|
+
)
|
|
592
|
+
),
|
|
593
|
+
ids: usedName.suffix,
|
|
594
|
+
exportName
|
|
595
|
+
};
|
|
596
|
+
}
|
|
514
597
|
return {
|
|
515
598
|
info,
|
|
516
599
|
name: directExport,
|
|
517
|
-
ids: usedName.slice(1),
|
|
600
|
+
ids: /** @type {ExportName} */ (usedName).slice(1),
|
|
518
601
|
exportName
|
|
519
602
|
};
|
|
520
603
|
}
|
|
@@ -531,6 +614,27 @@ const getFinalBinding = (
|
|
|
531
614
|
moduleToInfoMap.has(module)
|
|
532
615
|
);
|
|
533
616
|
if (reexport === false) {
|
|
617
|
+
// Source module was removed because all its exports were inlined;
|
|
618
|
+
// we render the inlined value here instead of binding to the now-absent module.
|
|
619
|
+
const target = exportInfo.getTarget(moduleGraph);
|
|
620
|
+
if (target && target.export) {
|
|
621
|
+
const usedName = moduleGraph
|
|
622
|
+
.getExportsInfo(target.module)
|
|
623
|
+
.getUsedName([...target.export, ...exportName.slice(1)], runtime);
|
|
624
|
+
if (usedName instanceof InlinedUsedName) {
|
|
625
|
+
return {
|
|
626
|
+
info,
|
|
627
|
+
// Literal only; suffix is appended once via `ids` (see directExport branch).
|
|
628
|
+
rawName: usedName.render(
|
|
629
|
+
Template.toNormalComment(
|
|
630
|
+
`inlined export ${propertyAccess(exportName)}`
|
|
631
|
+
)
|
|
632
|
+
),
|
|
633
|
+
ids: usedName.suffix,
|
|
634
|
+
exportName
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
}
|
|
534
638
|
throw new Error(
|
|
535
639
|
`Target module of reexport from '${info.module.readableIdentifier(
|
|
536
640
|
requestShortener
|
|
@@ -562,7 +666,9 @@ const getFinalBinding = (
|
|
|
562
666
|
alreadyVisited
|
|
563
667
|
);
|
|
564
668
|
}
|
|
565
|
-
|
|
669
|
+
// A wrapped module resolves every export through its live exports
|
|
670
|
+
// alias (namespaceObjectName), same as namespaceExportSymbol modules.
|
|
671
|
+
if (info.namespaceExportSymbol || info.cjsWrapped) {
|
|
566
672
|
const usedName = /** @type {ExportName} */ (
|
|
567
673
|
exportsInfo.getUsedName(exportName, runtime)
|
|
568
674
|
);
|
|
@@ -581,9 +687,7 @@ const getFinalBinding = (
|
|
|
581
687
|
}
|
|
582
688
|
|
|
583
689
|
case "external": {
|
|
584
|
-
const used =
|
|
585
|
-
exportsInfo.getUsedName(exportName, runtime)
|
|
586
|
-
);
|
|
690
|
+
const used = exportsInfo.getUsedName(exportName, runtime);
|
|
587
691
|
if (!used) {
|
|
588
692
|
return {
|
|
589
693
|
info,
|
|
@@ -592,7 +696,21 @@ const getFinalBinding = (
|
|
|
592
696
|
exportName
|
|
593
697
|
};
|
|
594
698
|
}
|
|
595
|
-
|
|
699
|
+
if (used instanceof InlinedUsedName) {
|
|
700
|
+
return {
|
|
701
|
+
info,
|
|
702
|
+
// Literal only; suffix is appended once via `ids` (see directExport branch).
|
|
703
|
+
rawName: used.render(
|
|
704
|
+
Template.toNormalComment(
|
|
705
|
+
`inlined export ${propertyAccess(exportName)}`
|
|
706
|
+
)
|
|
707
|
+
),
|
|
708
|
+
ids: used.suffix,
|
|
709
|
+
exportName
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
const usedName = /** @type {ExportName} */ (used);
|
|
713
|
+
const comment = equals(usedName, exportName)
|
|
596
714
|
? ""
|
|
597
715
|
: Template.toNormalComment(`${exportName.join(".")}`);
|
|
598
716
|
return {
|
|
@@ -601,7 +719,7 @@ const getFinalBinding = (
|
|
|
601
719
|
(deferred ? info.deferredName : info.name) +
|
|
602
720
|
(deferred ? ".a" : "") +
|
|
603
721
|
comment,
|
|
604
|
-
ids:
|
|
722
|
+
ids: usedName,
|
|
605
723
|
exportName
|
|
606
724
|
};
|
|
607
725
|
}
|
|
@@ -699,8 +817,17 @@ const getFinalName = (
|
|
|
699
817
|
|
|
700
818
|
/** @typedef {BuildInfo["topLevelDeclarations"]} TopLevelDeclarations */
|
|
701
819
|
|
|
702
|
-
/**
|
|
703
|
-
|
|
820
|
+
/**
|
|
821
|
+
* Defines the build info properties specific to concatenated modules.
|
|
822
|
+
* @typedef {object} KnownConcatenatedModuleBuildInfo
|
|
823
|
+
* @property {FileSystemDependencies=} fileDependencies
|
|
824
|
+
* @property {FileSystemDependencies=} contextDependencies
|
|
825
|
+
* @property {FileSystemDependencies=} missingDependencies
|
|
826
|
+
* @property {boolean=} needCreateRequire collected from the inner modules
|
|
827
|
+
* @property {boolean=} inlineExports taken over from the root module
|
|
828
|
+
*/
|
|
829
|
+
|
|
830
|
+
/** @typedef {BuildInfo & KnownConcatenatedModuleBuildInfo} ConcatenatedModuleBuildInfo */
|
|
704
831
|
|
|
705
832
|
class ConcatenatedModule extends Module {
|
|
706
833
|
/**
|
|
@@ -735,30 +862,6 @@ class ConcatenatedModule extends Module {
|
|
|
735
862
|
});
|
|
736
863
|
}
|
|
737
864
|
|
|
738
|
-
/**
|
|
739
|
-
* @param {Compilation} compilation the compilation
|
|
740
|
-
* @returns {ConcatenateModuleHooks} the attached hooks
|
|
741
|
-
*/
|
|
742
|
-
static getCompilationHooks(compilation) {
|
|
743
|
-
let hooks = compilationHooksMap.get(compilation);
|
|
744
|
-
if (hooks === undefined) {
|
|
745
|
-
hooks = {
|
|
746
|
-
onDemandExportsGeneration: new SyncBailHook([
|
|
747
|
-
"module",
|
|
748
|
-
"runtimes",
|
|
749
|
-
"exportsFinalName",
|
|
750
|
-
"exportsSource"
|
|
751
|
-
]),
|
|
752
|
-
concatenatedModuleInfo: new SyncBailHook([
|
|
753
|
-
"updatedInfo",
|
|
754
|
-
"concatenatedModuleInfo"
|
|
755
|
-
])
|
|
756
|
-
};
|
|
757
|
-
compilationHooksMap.set(compilation, hooks);
|
|
758
|
-
}
|
|
759
|
-
return hooks;
|
|
760
|
-
}
|
|
761
|
-
|
|
762
865
|
/**
|
|
763
866
|
* @param {object} options options
|
|
764
867
|
* @param {string} options.identifier the identifier of the module
|
|
@@ -770,6 +873,12 @@ class ConcatenatedModule extends Module {
|
|
|
770
873
|
constructor({ identifier, rootModule, modules, runtime, compilation }) {
|
|
771
874
|
super(JAVASCRIPT_MODULE_TYPE_ESM, null, rootModule && rootModule.layer);
|
|
772
875
|
|
|
876
|
+
// Redeclared with the concatenated module specific shape
|
|
877
|
+
/** @type {ConcatenatedModuleBuildInfo | undefined} */
|
|
878
|
+
this.buildInfo = undefined;
|
|
879
|
+
/** @type {JavascriptModuleBuildMeta | undefined} */
|
|
880
|
+
this.buildMeta = undefined;
|
|
881
|
+
|
|
773
882
|
// Info from Factory
|
|
774
883
|
/** @type {string} */
|
|
775
884
|
this._identifier = identifier;
|
|
@@ -777,6 +886,7 @@ class ConcatenatedModule extends Module {
|
|
|
777
886
|
this.rootModule = rootModule;
|
|
778
887
|
/** @type {Set<Module>} */
|
|
779
888
|
this._modules = modules;
|
|
889
|
+
/** @type {RuntimeSpec} */
|
|
780
890
|
this._runtime = runtime;
|
|
781
891
|
this.factoryMeta = rootModule && rootModule.factoryMeta;
|
|
782
892
|
/** @type {Compilation} */
|
|
@@ -795,6 +905,7 @@ class ConcatenatedModule extends Module {
|
|
|
795
905
|
}
|
|
796
906
|
|
|
797
907
|
/**
|
|
908
|
+
* Returns the source types this module can generate.
|
|
798
909
|
* @returns {SourceTypes} types available (do not mutate)
|
|
799
910
|
*/
|
|
800
911
|
getSourceTypes() {
|
|
@@ -806,6 +917,7 @@ class ConcatenatedModule extends Module {
|
|
|
806
917
|
}
|
|
807
918
|
|
|
808
919
|
/**
|
|
920
|
+
* Returns the unique identifier used to reference this module.
|
|
809
921
|
* @returns {string} a unique identifier of the module
|
|
810
922
|
*/
|
|
811
923
|
identifier() {
|
|
@@ -813,16 +925,18 @@ class ConcatenatedModule extends Module {
|
|
|
813
925
|
}
|
|
814
926
|
|
|
815
927
|
/**
|
|
928
|
+
* Returns a human-readable identifier for this module.
|
|
816
929
|
* @param {RequestShortener} requestShortener the request shortener
|
|
817
930
|
* @returns {string} a user readable identifier of the module
|
|
818
931
|
*/
|
|
819
932
|
readableIdentifier(requestShortener) {
|
|
820
|
-
return `${this.rootModule.readableIdentifier(
|
|
821
|
-
|
|
822
|
-
|
|
933
|
+
return `${this.rootModule.readableIdentifier(requestShortener)} + ${
|
|
934
|
+
this._modules.size - 1
|
|
935
|
+
} modules`;
|
|
823
936
|
}
|
|
824
937
|
|
|
825
938
|
/**
|
|
939
|
+
* Gets the library identifier.
|
|
826
940
|
* @param {LibIdentOptions} options options
|
|
827
941
|
* @returns {LibIdent | null} an identifier for library inclusion
|
|
828
942
|
*/
|
|
@@ -831,6 +945,7 @@ class ConcatenatedModule extends Module {
|
|
|
831
945
|
}
|
|
832
946
|
|
|
833
947
|
/**
|
|
948
|
+
* Returns the path used when matching this module against rule conditions.
|
|
834
949
|
* @returns {NameForCondition | null} absolute path which should be used for condition matching (usually the resource path)
|
|
835
950
|
*/
|
|
836
951
|
nameForCondition() {
|
|
@@ -838,6 +953,7 @@ class ConcatenatedModule extends Module {
|
|
|
838
953
|
}
|
|
839
954
|
|
|
840
955
|
/**
|
|
956
|
+
* Gets side effects connection state.
|
|
841
957
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
842
958
|
* @returns {ConnectionState} how this module should be connected to referencing modules when consumed for side-effects only
|
|
843
959
|
*/
|
|
@@ -846,6 +962,7 @@ class ConcatenatedModule extends Module {
|
|
|
846
962
|
}
|
|
847
963
|
|
|
848
964
|
/**
|
|
965
|
+
* Builds the module using the provided compilation context.
|
|
849
966
|
* @param {WebpackOptions} options webpack options
|
|
850
967
|
* @param {Compilation} compilation the compilation
|
|
851
968
|
* @param {ResolverWithOptions} resolver the resolver
|
|
@@ -858,7 +975,7 @@ class ConcatenatedModule extends Module {
|
|
|
858
975
|
const { moduleArgument, exportsArgument } =
|
|
859
976
|
/** @type {BuildInfo} */
|
|
860
977
|
(rootModule.buildInfo);
|
|
861
|
-
/** @type {
|
|
978
|
+
/** @type {ConcatenatedModuleBuildInfo} */
|
|
862
979
|
this.buildInfo = {
|
|
863
980
|
strict: true,
|
|
864
981
|
cacheable: true,
|
|
@@ -868,7 +985,10 @@ class ConcatenatedModule extends Module {
|
|
|
868
985
|
contextDependencies: new LazySet(),
|
|
869
986
|
missingDependencies: new LazySet(),
|
|
870
987
|
topLevelDeclarations: new Set(),
|
|
871
|
-
assets: undefined
|
|
988
|
+
assets: undefined,
|
|
989
|
+
inlineExports: /** @type {JavascriptModuleBuildInfo} */ (
|
|
990
|
+
rootModule.buildInfo
|
|
991
|
+
).inlineExports
|
|
872
992
|
};
|
|
873
993
|
this.buildMeta = rootModule.buildMeta;
|
|
874
994
|
this.clearDependenciesAndBlocks();
|
|
@@ -876,14 +996,25 @@ class ConcatenatedModule extends Module {
|
|
|
876
996
|
|
|
877
997
|
for (const m of this._modules) {
|
|
878
998
|
// populate cacheable
|
|
879
|
-
|
|
999
|
+
const { cacheable, notCacheableReasons } = /** @type {BuildInfo} */ (
|
|
1000
|
+
m.buildInfo
|
|
1001
|
+
);
|
|
1002
|
+
if (!cacheable) {
|
|
880
1003
|
this.buildInfo.cacheable = false;
|
|
1004
|
+
if (notCacheableReasons) {
|
|
1005
|
+
const reasons =
|
|
1006
|
+
this.buildInfo.notCacheableReasons ||
|
|
1007
|
+
(this.buildInfo.notCacheableReasons = []);
|
|
1008
|
+
for (const reason of notCacheableReasons) {
|
|
1009
|
+
if (!reasons.includes(reason)) reasons.push(reason);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
881
1012
|
}
|
|
882
1013
|
|
|
883
1014
|
// populate dependencies
|
|
884
1015
|
for (const d of m.dependencies.filter(
|
|
885
1016
|
(dep) =>
|
|
886
|
-
!(dep
|
|
1017
|
+
!Dependency.canConcatenate(dep) ||
|
|
887
1018
|
!this._modules.has(
|
|
888
1019
|
/** @type {Module} */
|
|
889
1020
|
(compilation.moduleGraph.getModule(dep))
|
|
@@ -891,6 +1022,20 @@ class ConcatenatedModule extends Module {
|
|
|
891
1022
|
)) {
|
|
892
1023
|
this.dependencies.push(d);
|
|
893
1024
|
}
|
|
1025
|
+
// populate codeGenerationDependencies — the inner modules'
|
|
1026
|
+
// templates are applied during ConcatenatedModule.codeGeneration,
|
|
1027
|
+
// so the referenced modules must have been code-generated by then.
|
|
1028
|
+
// Skip references that point back into the concat set itself.
|
|
1029
|
+
if (m.codeGenerationDependencies !== undefined) {
|
|
1030
|
+
for (const d of m.codeGenerationDependencies) {
|
|
1031
|
+
const referenced =
|
|
1032
|
+
/** @type {Module} */
|
|
1033
|
+
(compilation.moduleGraph.getModule(d));
|
|
1034
|
+
if (!this._modules.has(referenced)) {
|
|
1035
|
+
this.addCodeGenerationDependency(d);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
894
1039
|
// populate blocks
|
|
895
1040
|
for (const d of m.blocks) {
|
|
896
1041
|
this.blocks.push(d);
|
|
@@ -913,16 +1058,16 @@ class ConcatenatedModule extends Module {
|
|
|
913
1058
|
}
|
|
914
1059
|
|
|
915
1060
|
const { assets, assetsInfo, topLevelDeclarations, needCreateRequire } =
|
|
916
|
-
/** @type {
|
|
1061
|
+
/** @type {JavascriptModuleBuildInfo} */ (m.buildInfo);
|
|
917
1062
|
|
|
918
1063
|
const buildInfo = this.buildInfo;
|
|
919
1064
|
|
|
920
1065
|
// populate topLevelDeclarations
|
|
921
1066
|
if (topLevelDeclarations) {
|
|
922
|
-
const
|
|
923
|
-
if (
|
|
1067
|
+
const mergedTopLevelDeclarations = buildInfo.topLevelDeclarations;
|
|
1068
|
+
if (mergedTopLevelDeclarations !== undefined) {
|
|
924
1069
|
for (const decl of topLevelDeclarations) {
|
|
925
|
-
|
|
1070
|
+
mergedTopLevelDeclarations.add(decl);
|
|
926
1071
|
}
|
|
927
1072
|
}
|
|
928
1073
|
} else {
|
|
@@ -958,6 +1103,7 @@ class ConcatenatedModule extends Module {
|
|
|
958
1103
|
}
|
|
959
1104
|
|
|
960
1105
|
/**
|
|
1106
|
+
* Returns the estimated size for the requested source type.
|
|
961
1107
|
* @param {string=} type the source type for which the size should be estimated
|
|
962
1108
|
* @returns {number} the estimated size of the module (must be non-zero)
|
|
963
1109
|
*/
|
|
@@ -1000,7 +1146,10 @@ class ConcatenatedModule extends Module {
|
|
|
1000
1146
|
*/
|
|
1001
1147
|
const references = connections
|
|
1002
1148
|
.filter((connection) => {
|
|
1003
|
-
if (
|
|
1149
|
+
if (
|
|
1150
|
+
!connection.dependency ||
|
|
1151
|
+
!Dependency.canConcatenate(connection.dependency)
|
|
1152
|
+
) {
|
|
1004
1153
|
return false;
|
|
1005
1154
|
}
|
|
1006
1155
|
if (
|
|
@@ -1243,6 +1392,7 @@ class ConcatenatedModule extends Module {
|
|
|
1243
1392
|
}
|
|
1244
1393
|
|
|
1245
1394
|
/**
|
|
1395
|
+
* Adds the provided file dependencies to the module.
|
|
1246
1396
|
* @param {FileSystemDependencies} fileDependencies set where file dependencies are added to
|
|
1247
1397
|
* @param {FileSystemDependencies} contextDependencies set where context dependencies are added to
|
|
1248
1398
|
* @param {FileSystemDependencies} missingDependencies set where missing dependencies are added to
|
|
@@ -1265,6 +1415,7 @@ class ConcatenatedModule extends Module {
|
|
|
1265
1415
|
}
|
|
1266
1416
|
|
|
1267
1417
|
/**
|
|
1418
|
+
* Generates code and runtime requirements for this module.
|
|
1268
1419
|
* @param {CodeGenerationContext} context context for code generation
|
|
1269
1420
|
* @returns {CodeGenerationResult} result
|
|
1270
1421
|
*/
|
|
@@ -1296,6 +1447,11 @@ class ConcatenatedModule extends Module {
|
|
|
1296
1447
|
/** @type {NeededNamespaceObjects} */
|
|
1297
1448
|
const neededNamespaceObjects = new Set();
|
|
1298
1449
|
|
|
1450
|
+
// Set with modules whose mangled namespace escapes as a whole value and
|
|
1451
|
+
// therefore needs a decoupled namespace object keyed by the original names
|
|
1452
|
+
/** @type {Set<ConcatenatedModuleInfo | ExternalModuleInfo>} */
|
|
1453
|
+
const neededEscapeNamespaceObjects = new Set();
|
|
1454
|
+
|
|
1299
1455
|
// List of all used names to avoid conflicts
|
|
1300
1456
|
const allUsedNames = new Set(RESERVED_NAMES);
|
|
1301
1457
|
|
|
@@ -1321,17 +1477,69 @@ class ConcatenatedModule extends Module {
|
|
|
1321
1477
|
/** @type {TopLevelDeclarations} */
|
|
1322
1478
|
const topLevelDeclarations = new Set();
|
|
1323
1479
|
|
|
1480
|
+
// Free names remaining in the rendered source (runtime globals are
|
|
1481
|
+
// tracked by runtimeRequirements instead)
|
|
1482
|
+
/** @type {Set<string>} */
|
|
1483
|
+
const freeNames = new Set();
|
|
1484
|
+
|
|
1324
1485
|
// List of additional names in scope for module references
|
|
1325
|
-
/** @type {
|
|
1486
|
+
/** @type {UsedNamesInScopeInfo} */
|
|
1326
1487
|
const usedNamesInScopeInfo = new Map();
|
|
1327
1488
|
|
|
1328
1489
|
// Set of already checked scopes
|
|
1329
1490
|
/** @type {Set<Scope>} */
|
|
1330
1491
|
const ignoredScopes = new Set();
|
|
1331
1492
|
|
|
1493
|
+
/**
|
|
1494
|
+
* Lazily allocates a decoupled namespace object for a concatenated module
|
|
1495
|
+
* whose exports are mangled, so an escaping whole-namespace value still
|
|
1496
|
+
* exposes the original export names. Returns undefined when no export is
|
|
1497
|
+
* mangled (the regular namespace object can be used as-is).
|
|
1498
|
+
* @param {ConcatenatedModuleInfo | ExternalModuleInfo} info module info
|
|
1499
|
+
* @returns {string | undefined} the escape namespace object name
|
|
1500
|
+
*/
|
|
1501
|
+
const getEscapeNamespaceObjectName = (info) => {
|
|
1502
|
+
if (info.type === "concatenated" && info.namespaceExportSymbol) {
|
|
1503
|
+
return undefined;
|
|
1504
|
+
}
|
|
1505
|
+
// Deferred external modules keep their special deferred namespace object
|
|
1506
|
+
// and are rendered through a different path that wouldn't emit ours.
|
|
1507
|
+
if (info.type === "external" && info.deferred) return undefined;
|
|
1508
|
+
// Only real ES module namespaces are decoupled; non-harmony modules use
|
|
1509
|
+
// their interop/fake namespace object as before.
|
|
1510
|
+
const buildMeta = /** @type {BuildMeta} */ (info.module.buildMeta);
|
|
1511
|
+
if (!buildMeta || buildMeta.exportsType !== "namespace") return undefined;
|
|
1512
|
+
if (info.escapeNamespaceObjectName !== undefined) {
|
|
1513
|
+
return info.escapeNamespaceObjectName;
|
|
1514
|
+
}
|
|
1515
|
+
const exportsInfo = moduleGraph.getExportsInfo(info.module);
|
|
1516
|
+
let mangled = false;
|
|
1517
|
+
for (const exportInfo of exportsInfo.orderedExports) {
|
|
1518
|
+
if (exportInfo.provided === false) continue;
|
|
1519
|
+
const usedName = exportInfo.getUsedName(undefined, runtime);
|
|
1520
|
+
if (!usedName || usedName instanceof InlinedUsedName) continue;
|
|
1521
|
+
if (usedName[usedName.length - 1] !== exportInfo.name) {
|
|
1522
|
+
mangled = true;
|
|
1523
|
+
break;
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
if (!mangled) return undefined;
|
|
1527
|
+
const name = findNewName(
|
|
1528
|
+
"namespaceObject",
|
|
1529
|
+
allUsedNames,
|
|
1530
|
+
/** @type {UsedNames} */ (new Set()),
|
|
1531
|
+
info.module.readableIdentifier(requestShortener)
|
|
1532
|
+
);
|
|
1533
|
+
allUsedNames.add(name);
|
|
1534
|
+
topLevelDeclarations.add(name);
|
|
1535
|
+
info.escapeNamespaceObjectName = name;
|
|
1536
|
+
neededEscapeNamespaceObjects.add(info);
|
|
1537
|
+
return name;
|
|
1538
|
+
};
|
|
1539
|
+
|
|
1332
1540
|
// get all global names
|
|
1333
1541
|
for (const info of modulesWithInfo) {
|
|
1334
|
-
if (info.type === "concatenated") {
|
|
1542
|
+
if (info.type === "concatenated" && !info.cjsWrapped) {
|
|
1335
1543
|
// ignore symbols from moduleScope
|
|
1336
1544
|
if (info.moduleScope) {
|
|
1337
1545
|
ignoredScopes.add(info.moduleScope);
|
|
@@ -1381,6 +1589,18 @@ class ConcatenatedModule extends Module {
|
|
|
1381
1589
|
if (referencedInfo.type === "reference") {
|
|
1382
1590
|
throw new Error("Module reference can't point to a reference");
|
|
1383
1591
|
}
|
|
1592
|
+
// An escaping mangled namespace resolves to its own decoupled
|
|
1593
|
+
// namespace object (a unique top-level name), so it neither needs
|
|
1594
|
+
// the regular namespace object nor super-class scope handling.
|
|
1595
|
+
if (
|
|
1596
|
+
match.mangleableNamespace &&
|
|
1597
|
+
match.ids.length === 0 &&
|
|
1598
|
+
(referencedInfo.type === "concatenated" ||
|
|
1599
|
+
referencedInfo.type === "external") &&
|
|
1600
|
+
getEscapeNamespaceObjectName(referencedInfo) !== undefined
|
|
1601
|
+
) {
|
|
1602
|
+
continue;
|
|
1603
|
+
}
|
|
1384
1604
|
const binding = getFinalBinding(
|
|
1385
1605
|
moduleGraph,
|
|
1386
1606
|
referencedInfo,
|
|
@@ -1423,6 +1643,7 @@ class ConcatenatedModule extends Module {
|
|
|
1423
1643
|
);
|
|
1424
1644
|
} else {
|
|
1425
1645
|
allUsedNames.add(name);
|
|
1646
|
+
freeNames.add(name);
|
|
1426
1647
|
}
|
|
1427
1648
|
}
|
|
1428
1649
|
}
|
|
@@ -1508,6 +1729,23 @@ class ConcatenatedModule extends Module {
|
|
|
1508
1729
|
);
|
|
1509
1730
|
switch (info.type) {
|
|
1510
1731
|
case "concatenated": {
|
|
1732
|
+
if (info.cjsWrapped) {
|
|
1733
|
+
// Wrapped modules expose one shared-scope name: the final
|
|
1734
|
+
// exports object used as the namespace.
|
|
1735
|
+
const namespaceObjectName = findNewName(
|
|
1736
|
+
"namespaceObject",
|
|
1737
|
+
allUsedNames,
|
|
1738
|
+
namespaceObjectUsedNames,
|
|
1739
|
+
info.module.readableIdentifier(requestShortener)
|
|
1740
|
+
);
|
|
1741
|
+
allUsedNames.add(namespaceObjectName);
|
|
1742
|
+
topLevelDeclarations.add(namespaceObjectName);
|
|
1743
|
+
info.namespaceObjectName = namespaceObjectName;
|
|
1744
|
+
// Route every binding to the live exports alias and skip the
|
|
1745
|
+
// materialized namespace object generated for other modules.
|
|
1746
|
+
info.namespaceExportSymbol = namespaceObjectName;
|
|
1747
|
+
break;
|
|
1748
|
+
}
|
|
1511
1749
|
const variables = /** @type {Scope} */ (info.moduleScope).variables;
|
|
1512
1750
|
for (const variable of variables) {
|
|
1513
1751
|
const name = variable.name;
|
|
@@ -1644,7 +1882,7 @@ class ConcatenatedModule extends Module {
|
|
|
1644
1882
|
|
|
1645
1883
|
// Find and replace references to modules
|
|
1646
1884
|
for (const info of moduleToInfoMap.values()) {
|
|
1647
|
-
if (info.type === "concatenated") {
|
|
1885
|
+
if (info.type === "concatenated" && !info.cjsWrapped) {
|
|
1648
1886
|
const globalScope = /** @type {Scope} */ (info.globalScope);
|
|
1649
1887
|
// group references by name
|
|
1650
1888
|
/** @type {Map<string, Reference[]>} */
|
|
@@ -1690,22 +1928,35 @@ class ConcatenatedModule extends Module {
|
|
|
1690
1928
|
concatenationScope.setRawExportMap(exportId, newName);
|
|
1691
1929
|
}
|
|
1692
1930
|
}
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1931
|
+
// A whole-namespace value that escapes: when the module's exports
|
|
1932
|
+
// are mangled, point it at a decoupled namespace object that keeps
|
|
1933
|
+
// the original names so untracked access keeps working.
|
|
1934
|
+
const escapeName =
|
|
1935
|
+
match.mangleableNamespace &&
|
|
1936
|
+
match.ids.length === 0 &&
|
|
1937
|
+
(referencedInfo.type === "concatenated" ||
|
|
1938
|
+
referencedInfo.type === "external")
|
|
1939
|
+
? getEscapeNamespaceObjectName(referencedInfo)
|
|
1940
|
+
: undefined;
|
|
1941
|
+
const finalName =
|
|
1942
|
+
escapeName !== undefined
|
|
1943
|
+
? escapeName
|
|
1944
|
+
: getFinalName(
|
|
1945
|
+
moduleGraph,
|
|
1946
|
+
referencedInfo,
|
|
1947
|
+
match.ids,
|
|
1948
|
+
moduleToInfoMap,
|
|
1949
|
+
runtime,
|
|
1950
|
+
requestShortener,
|
|
1951
|
+
runtimeTemplate,
|
|
1952
|
+
neededNamespaceObjects,
|
|
1953
|
+
match.call,
|
|
1954
|
+
match.deferredImport,
|
|
1955
|
+
!match.directImport,
|
|
1956
|
+
/** @type {BuildMeta} */
|
|
1957
|
+
(info.module.buildMeta).strictHarmonyModule,
|
|
1958
|
+
match.asiSafe
|
|
1959
|
+
);
|
|
1709
1960
|
|
|
1710
1961
|
for (const reference of references) {
|
|
1711
1962
|
const r = /** @type {Range} */ (reference.identifier.range);
|
|
@@ -1725,6 +1976,9 @@ class ConcatenatedModule extends Module {
|
|
|
1725
1976
|
// Set with all root exposed unused exports
|
|
1726
1977
|
/** @type {Set<string>} */
|
|
1727
1978
|
const unusedExports = new Set();
|
|
1979
|
+
// Set with all root exposed exports that were substituted with inlined literals
|
|
1980
|
+
/** @type {Set<string>} */
|
|
1981
|
+
const inlinedExports = new Set();
|
|
1728
1982
|
|
|
1729
1983
|
const rootInfo =
|
|
1730
1984
|
/** @type {ConcatenatedModuleInfo} */
|
|
@@ -1743,6 +1997,10 @@ class ConcatenatedModule extends Module {
|
|
|
1743
1997
|
unusedExports.add(name);
|
|
1744
1998
|
continue;
|
|
1745
1999
|
}
|
|
2000
|
+
if (used instanceof InlinedUsedName) {
|
|
2001
|
+
inlinedExports.add(name);
|
|
2002
|
+
continue;
|
|
2003
|
+
}
|
|
1746
2004
|
exportsMap.set(used, (requestShortener) => {
|
|
1747
2005
|
try {
|
|
1748
2006
|
const finalName = getFinalName(
|
|
@@ -1813,9 +2071,9 @@ class ConcatenatedModule extends Module {
|
|
|
1813
2071
|
|
|
1814
2072
|
const exportsSource =
|
|
1815
2073
|
"\n// EXPORTS\n" +
|
|
1816
|
-
`${RuntimeGlobals.definePropertyGetters}(${
|
|
1817
|
-
|
|
1818
|
-
)}\n});\n`;
|
|
2074
|
+
`${RuntimeGlobals.definePropertyGetters}(${
|
|
2075
|
+
this.exportsArgument
|
|
2076
|
+
}, {${definitions.join(",")}\n});\n`;
|
|
1819
2077
|
|
|
1820
2078
|
const { onDemandExportsGeneration } =
|
|
1821
2079
|
ConcatenatedModule.getCompilationHooks(this.compilation);
|
|
@@ -1839,6 +2097,93 @@ class ConcatenatedModule extends Module {
|
|
|
1839
2097
|
);
|
|
1840
2098
|
}
|
|
1841
2099
|
|
|
2100
|
+
// list inlined exports
|
|
2101
|
+
if (inlinedExports.size > 0) {
|
|
2102
|
+
result.add(
|
|
2103
|
+
`\n// INLINED EXPORTS: ${joinIterableWithComma(inlinedExports)}\n`
|
|
2104
|
+
);
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
// generate decoupled namespace objects for escaping mangled namespaces:
|
|
2108
|
+
// same getters as the regular namespace object, but keyed by the original
|
|
2109
|
+
// export names so untracked access by name keeps working. Done before the
|
|
2110
|
+
// regular namespace objects so any nested namespace they pull in is built.
|
|
2111
|
+
/** @type {Map<ConcatenatedModuleInfo | ExternalModuleInfo, string>} */
|
|
2112
|
+
const escapeNamespaceObjectSources = new Map();
|
|
2113
|
+
for (const info of neededEscapeNamespaceObjects) {
|
|
2114
|
+
/** @type {string[]} */
|
|
2115
|
+
const nsObj = [];
|
|
2116
|
+
const exportsInfo = moduleGraph.getExportsInfo(info.module);
|
|
2117
|
+
for (const exportInfo of exportsInfo.orderedExports) {
|
|
2118
|
+
if (exportInfo.provided === false) continue;
|
|
2119
|
+
const usedName = exportInfo.getUsedName(undefined, runtime);
|
|
2120
|
+
if (!usedName) continue;
|
|
2121
|
+
if (usedName instanceof InlinedUsedName) {
|
|
2122
|
+
nsObj.push(
|
|
2123
|
+
`\n ${propertyName(
|
|
2124
|
+
exportInfo.name
|
|
2125
|
+
)}: ${runtimeTemplate.returningFunction(
|
|
2126
|
+
usedName.render(
|
|
2127
|
+
Template.toNormalComment(
|
|
2128
|
+
`inlined export ${propertyAccess([exportInfo.name])}`
|
|
2129
|
+
)
|
|
2130
|
+
)
|
|
2131
|
+
)}`
|
|
2132
|
+
);
|
|
2133
|
+
} else {
|
|
2134
|
+
// External (non-concatenated) modules are accessed through their
|
|
2135
|
+
// import variable; concatenated ones resolve to an internal binding.
|
|
2136
|
+
const finalName =
|
|
2137
|
+
info.type === "external"
|
|
2138
|
+
? `${/** @type {string} */ (info.name)}${propertyAccess([
|
|
2139
|
+
usedName
|
|
2140
|
+
])}`
|
|
2141
|
+
: getFinalName(
|
|
2142
|
+
moduleGraph,
|
|
2143
|
+
info,
|
|
2144
|
+
[exportInfo.name],
|
|
2145
|
+
moduleToInfoMap,
|
|
2146
|
+
runtime,
|
|
2147
|
+
requestShortener,
|
|
2148
|
+
runtimeTemplate,
|
|
2149
|
+
neededNamespaceObjects,
|
|
2150
|
+
false,
|
|
2151
|
+
false,
|
|
2152
|
+
undefined,
|
|
2153
|
+
/** @type {BuildMeta} */
|
|
2154
|
+
(info.module.buildMeta).strictHarmonyModule,
|
|
2155
|
+
true
|
|
2156
|
+
);
|
|
2157
|
+
nsObj.push(
|
|
2158
|
+
`\n ${propertyName(
|
|
2159
|
+
exportInfo.name
|
|
2160
|
+
)}: ${runtimeTemplate.returningFunction(finalName)}`
|
|
2161
|
+
);
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
const name = /** @type {string} */ (info.escapeNamespaceObjectName);
|
|
2165
|
+
const defineGetters =
|
|
2166
|
+
nsObj.length > 0
|
|
2167
|
+
? `${RuntimeGlobals.definePropertyGetters}(${name}, {${nsObj.join(
|
|
2168
|
+
","
|
|
2169
|
+
)}\n});\n`
|
|
2170
|
+
: "";
|
|
2171
|
+
if (nsObj.length > 0) {
|
|
2172
|
+
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
|
|
2173
|
+
}
|
|
2174
|
+
escapeNamespaceObjectSources.set(
|
|
2175
|
+
info,
|
|
2176
|
+
`
|
|
2177
|
+
// NAMESPACE OBJECT (decoupled): ${info.module.readableIdentifier(
|
|
2178
|
+
requestShortener
|
|
2179
|
+
)}
|
|
2180
|
+
var ${name} = {};
|
|
2181
|
+
${RuntimeGlobals.makeNamespaceObject}(${name});
|
|
2182
|
+
${defineGetters}`
|
|
2183
|
+
);
|
|
2184
|
+
runtimeRequirements.add(RuntimeGlobals.makeNamespaceObject);
|
|
2185
|
+
}
|
|
2186
|
+
|
|
1842
2187
|
// generate namespace objects
|
|
1843
2188
|
/** @type {Map<ConcatenatedModuleInfo, string>} */
|
|
1844
2189
|
const namespaceObjectSources = new Map();
|
|
@@ -1851,27 +2196,42 @@ class ConcatenatedModule extends Module {
|
|
|
1851
2196
|
if (exportInfo.provided === false) continue;
|
|
1852
2197
|
const usedName = exportInfo.getUsedName(undefined, runtime);
|
|
1853
2198
|
if (usedName) {
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
2199
|
+
// TODO: Replace with the inlined value directly at the call site
|
|
2200
|
+
if (usedName instanceof InlinedUsedName) {
|
|
2201
|
+
nsObj.push(
|
|
2202
|
+
`\n ${propertyName(
|
|
2203
|
+
exportInfo.name
|
|
2204
|
+
)}: ${runtimeTemplate.returningFunction(
|
|
2205
|
+
usedName.render(
|
|
2206
|
+
Template.toNormalComment(
|
|
2207
|
+
`inlined export ${propertyAccess([exportInfo.name])}`
|
|
2208
|
+
)
|
|
2209
|
+
)
|
|
2210
|
+
)}`
|
|
2211
|
+
);
|
|
2212
|
+
} else {
|
|
2213
|
+
const finalName = getFinalName(
|
|
2214
|
+
moduleGraph,
|
|
2215
|
+
info,
|
|
2216
|
+
[exportInfo.name],
|
|
2217
|
+
moduleToInfoMap,
|
|
2218
|
+
runtime,
|
|
2219
|
+
requestShortener,
|
|
2220
|
+
runtimeTemplate,
|
|
2221
|
+
neededNamespaceObjects,
|
|
2222
|
+
false,
|
|
2223
|
+
false,
|
|
2224
|
+
undefined,
|
|
2225
|
+
/** @type {BuildMeta} */
|
|
2226
|
+
(info.module.buildMeta).strictHarmonyModule,
|
|
2227
|
+
true
|
|
2228
|
+
);
|
|
2229
|
+
nsObj.push(
|
|
2230
|
+
`\n ${propertyName(
|
|
2231
|
+
usedName
|
|
2232
|
+
)}: ${runtimeTemplate.returningFunction(finalName)}`
|
|
2233
|
+
);
|
|
2234
|
+
}
|
|
1875
2235
|
}
|
|
1876
2236
|
}
|
|
1877
2237
|
const name = info.namespaceObjectName;
|
|
@@ -1899,26 +2259,43 @@ ${defineGetters}`
|
|
|
1899
2259
|
for (const info of modulesWithInfo) {
|
|
1900
2260
|
if (info.type === "concatenated") {
|
|
1901
2261
|
const source = namespaceObjectSources.get(info);
|
|
1902
|
-
if (
|
|
1903
|
-
|
|
2262
|
+
if (source) result.add(source);
|
|
2263
|
+
const escapeSource = escapeNamespaceObjectSources.get(
|
|
2264
|
+
/** @type {ConcatenatedModuleInfo} */ (info)
|
|
2265
|
+
);
|
|
2266
|
+
if (escapeSource) result.add(escapeSource);
|
|
2267
|
+
if (!source && !escapeSource) continue;
|
|
1904
2268
|
}
|
|
1905
2269
|
|
|
1906
2270
|
if (info.type === "external" && info.deferred) {
|
|
1907
2271
|
const moduleId = JSON.stringify(chunkGraph.getModuleId(info.module));
|
|
1908
2272
|
const loader = getOptimizedDeferredModule(
|
|
1909
2273
|
moduleId,
|
|
1910
|
-
|
|
2274
|
+
getExportsType(
|
|
1911
2275
|
moduleGraph,
|
|
2276
|
+
info,
|
|
1912
2277
|
/** @type {BuildMeta} */
|
|
1913
2278
|
(this.rootModule.buildMeta).strictHarmonyModule
|
|
1914
2279
|
),
|
|
1915
2280
|
// an async module will opt-out of the concat module optimization.
|
|
1916
2281
|
[],
|
|
2282
|
+
// A closure member absorbed into this concatenation shares this
|
|
2283
|
+
// module's runtime id (and thus its `evaluating` flag); resolve it
|
|
2284
|
+
// to that id instead of the member's now-absent standalone id.
|
|
2285
|
+
getDeferredCycleModuleIds(
|
|
2286
|
+
getDeferredCycleModules(moduleGraph, info.module),
|
|
2287
|
+
(mod) =>
|
|
2288
|
+
moduleToInfoMap.has(mod)
|
|
2289
|
+
? chunkGraph.getModuleId(this)
|
|
2290
|
+
: chunkGraph.getModuleId(mod)
|
|
2291
|
+
),
|
|
1917
2292
|
runtimeRequirements
|
|
1918
2293
|
);
|
|
1919
2294
|
runtimeRequirements.add(RuntimeGlobals.require);
|
|
1920
2295
|
result.add(
|
|
1921
|
-
`\n// DEFERRED EXTERNAL MODULE: ${info.module.readableIdentifier(
|
|
2296
|
+
`\n// DEFERRED EXTERNAL MODULE: ${info.module.readableIdentifier(
|
|
2297
|
+
requestShortener
|
|
2298
|
+
)}\nvar ${info.deferredName} = ${loader};`
|
|
1922
2299
|
);
|
|
1923
2300
|
if (info.deferredNamespaceObjectUsed) {
|
|
1924
2301
|
runtimeRequirements.add(RuntimeGlobals.makeDeferredNamespaceObject);
|
|
@@ -1928,7 +2305,7 @@ ${defineGetters}`
|
|
|
1928
2305
|
}(${JSON.stringify(
|
|
1929
2306
|
chunkGraph.getModuleId(info.module)
|
|
1930
2307
|
)}, ${getMakeDeferredNamespaceModeFromExportsType(
|
|
1931
|
-
|
|
2308
|
+
getExportsType(moduleGraph, info, strictHarmonyModule)
|
|
1932
2309
|
)});`
|
|
1933
2310
|
);
|
|
1934
2311
|
}
|
|
@@ -1949,7 +2326,18 @@ ${defineGetters}`
|
|
|
1949
2326
|
result.add(
|
|
1950
2327
|
`\n;// ${info.module.readableIdentifier(requestShortener)}\n`
|
|
1951
2328
|
);
|
|
1952
|
-
|
|
2329
|
+
if (info.cjsWrapped) {
|
|
2330
|
+
// Real CommonJS semantics via the runtime helper: it calls the
|
|
2331
|
+
// body with this = exports and returns the final module.exports.
|
|
2332
|
+
runtimeRequirements.add(RuntimeGlobals.commonJsWrap);
|
|
2333
|
+
result.add(
|
|
2334
|
+
`var ${info.namespaceObjectName} = /*#__PURE__*/${RuntimeGlobals.commonJsWrap}(function(${info.module.moduleArgument}, ${info.module.exportsArgument}) {\n`
|
|
2335
|
+
);
|
|
2336
|
+
result.add(/** @type {ReplaceSource} */ (info.source));
|
|
2337
|
+
result.add("\n});\n");
|
|
2338
|
+
} else {
|
|
2339
|
+
result.add(/** @type {ReplaceSource} */ (info.source));
|
|
2340
|
+
}
|
|
1953
2341
|
if (info.chunkInitFragments) {
|
|
1954
2342
|
for (const f of info.chunkInitFragments) chunkInitFragments.push(f);
|
|
1955
2343
|
}
|
|
@@ -1986,8 +2374,15 @@ ${defineGetters}`
|
|
|
1986
2374
|
const moduleId = JSON.stringify(
|
|
1987
2375
|
chunkGraph.getModuleId(info.module)
|
|
1988
2376
|
);
|
|
2377
|
+
// External module bindings may be wrapped in
|
|
2378
|
+
// runtime-condition `if` blocks but referenced outside,
|
|
2379
|
+
// so they must remain function-scoped (`var`).
|
|
1989
2380
|
result.add(`var ${info.name} = __webpack_require__(${moduleId});`);
|
|
1990
2381
|
name = info.name;
|
|
2382
|
+
// Decoupled namespace object for an escaping mangled external
|
|
2383
|
+
// module must come after its import variable is defined.
|
|
2384
|
+
const escapeSource = escapeNamespaceObjectSources.get(info);
|
|
2385
|
+
if (escapeSource) result.add(escapeSource);
|
|
1991
2386
|
}
|
|
1992
2387
|
// If a module is deferred in other places, but used as non-deferred here,
|
|
1993
2388
|
// the module itself will be emitted as mod_deferred (in the case "external"),
|
|
@@ -1997,7 +2392,9 @@ ${defineGetters}`
|
|
|
1997
2392
|
(rawInfo);
|
|
1998
2393
|
if (info.deferred && nonDeferAccess) {
|
|
1999
2394
|
result.add(
|
|
2000
|
-
`\n// non-deferred import to a deferred module (${info.module.readableIdentifier(
|
|
2395
|
+
`\n// non-deferred import to a deferred module (${info.module.readableIdentifier(
|
|
2396
|
+
requestShortener
|
|
2397
|
+
)})\nvar ${info.name} = ${info.deferredName}.a;`
|
|
2001
2398
|
);
|
|
2002
2399
|
}
|
|
2003
2400
|
break;
|
|
@@ -2035,6 +2432,7 @@ ${defineGetters}`
|
|
|
2035
2432
|
data.set("chunkInitFragments", chunkInitFragments);
|
|
2036
2433
|
}
|
|
2037
2434
|
data.set("topLevelDeclarations", topLevelDeclarations);
|
|
2435
|
+
data.set("freeNames", freeNames);
|
|
2038
2436
|
|
|
2039
2437
|
/** @type {CodeGenerationResult} */
|
|
2040
2438
|
const resultEntry = {
|
|
@@ -2073,6 +2471,33 @@ ${defineGetters}`
|
|
|
2073
2471
|
if (info.type === "concatenated") {
|
|
2074
2472
|
const m = info.module;
|
|
2075
2473
|
try {
|
|
2474
|
+
if (info.cjsWrapped) {
|
|
2475
|
+
// A wrapped module renders its normal module source (real
|
|
2476
|
+
// module/exports objects, own module ids) inside an IIFE, so it
|
|
2477
|
+
// needs no concatenation scope, reference rewriting, or scope
|
|
2478
|
+
// analysis — the wrapper isolates its top-level declarations.
|
|
2479
|
+
const codeGenResult = m.codeGeneration({
|
|
2480
|
+
dependencyTemplates,
|
|
2481
|
+
runtimeTemplate,
|
|
2482
|
+
moduleGraph,
|
|
2483
|
+
chunkGraph,
|
|
2484
|
+
runtime,
|
|
2485
|
+
runtimes,
|
|
2486
|
+
codeGenerationResults,
|
|
2487
|
+
sourceTypes: JAVASCRIPT_TYPES
|
|
2488
|
+
});
|
|
2489
|
+
const source =
|
|
2490
|
+
/** @type {Source} */
|
|
2491
|
+
(codeGenResult.sources.get(JAVASCRIPT_TYPE));
|
|
2492
|
+
const data = codeGenResult.data;
|
|
2493
|
+
info.runtimeRequirements =
|
|
2494
|
+
/** @type {ReadOnlyRuntimeRequirements} */
|
|
2495
|
+
(codeGenResult.runtimeRequirements);
|
|
2496
|
+
info.internalSource = source;
|
|
2497
|
+
info.source = new ReplaceSource(source);
|
|
2498
|
+
info.chunkInitFragments = data && data.get("chunkInitFragments");
|
|
2499
|
+
return;
|
|
2500
|
+
}
|
|
2076
2501
|
// Create a concatenation scope to track and capture information
|
|
2077
2502
|
const concatenationScope = new ConcatenationScope(
|
|
2078
2503
|
modulesMap,
|
|
@@ -2080,7 +2505,8 @@ ${defineGetters}`
|
|
|
2080
2505
|
usedNames
|
|
2081
2506
|
);
|
|
2082
2507
|
|
|
2083
|
-
//
|
|
2508
|
+
// Not cached: Compilation memoizes the outer codeGeneration per
|
|
2509
|
+
// (module, runtime), so inner generation never recomputes usefully.
|
|
2084
2510
|
const codeGenResult = m.codeGeneration({
|
|
2085
2511
|
dependencyTemplates,
|
|
2086
2512
|
runtimeTemplate,
|
|
@@ -2103,11 +2529,17 @@ ${defineGetters}`
|
|
|
2103
2529
|
let ast;
|
|
2104
2530
|
|
|
2105
2531
|
try {
|
|
2532
|
+
const { experiments } = this.compilation.options;
|
|
2533
|
+
|
|
2106
2534
|
({ ast } = JavascriptParser._parse(
|
|
2107
2535
|
code,
|
|
2108
2536
|
{
|
|
2109
2537
|
sourceType: "module",
|
|
2110
|
-
ranges: true
|
|
2538
|
+
ranges: true,
|
|
2539
|
+
// generated code contains phase imports when the experiments are on
|
|
2540
|
+
importPhases: Boolean(
|
|
2541
|
+
experiments.deferImport || experiments.sourceImport
|
|
2542
|
+
)
|
|
2111
2543
|
},
|
|
2112
2544
|
JavascriptParser._getModuleParseFunction(this.compilation, m)
|
|
2113
2545
|
));
|
|
@@ -2180,7 +2612,11 @@ ${defineGetters}`
|
|
|
2180
2612
|
type: "concatenated",
|
|
2181
2613
|
module: info.module,
|
|
2182
2614
|
index,
|
|
2615
|
+
cjsWrapped: isCommonJsWrapped(
|
|
2616
|
+
/** @type {NormalModule} */ (info.module)
|
|
2617
|
+
),
|
|
2183
2618
|
ast: undefined,
|
|
2619
|
+
chunkInitFragments: undefined,
|
|
2184
2620
|
internalSource: undefined,
|
|
2185
2621
|
runtimeRequirements: undefined,
|
|
2186
2622
|
source: undefined,
|
|
@@ -2191,13 +2627,16 @@ ${defineGetters}`
|
|
|
2191
2627
|
rawExportMap: undefined,
|
|
2192
2628
|
namespaceExportSymbol: undefined,
|
|
2193
2629
|
namespaceObjectName: undefined,
|
|
2630
|
+
escapeNamespaceObjectName: undefined,
|
|
2194
2631
|
interopNamespaceObjectUsed: false,
|
|
2195
2632
|
interopNamespaceObjectName: undefined,
|
|
2196
2633
|
interopNamespaceObject2Used: false,
|
|
2197
2634
|
interopNamespaceObject2Name: undefined,
|
|
2198
2635
|
interopDefaultAccessUsed: false,
|
|
2199
2636
|
interopDefaultAccessName: undefined,
|
|
2200
|
-
concatenationScope: undefined
|
|
2637
|
+
concatenationScope: undefined,
|
|
2638
|
+
exportsTypeStrict: undefined,
|
|
2639
|
+
exportsTypeNonStrict: undefined
|
|
2201
2640
|
};
|
|
2202
2641
|
break;
|
|
2203
2642
|
case "external":
|
|
@@ -2208,6 +2647,7 @@ ${defineGetters}`
|
|
|
2208
2647
|
nonDeferAccess: info.nonDeferAccess,
|
|
2209
2648
|
index,
|
|
2210
2649
|
name: undefined,
|
|
2650
|
+
escapeNamespaceObjectName: undefined,
|
|
2211
2651
|
deferredName: undefined,
|
|
2212
2652
|
interopNamespaceObjectUsed: false,
|
|
2213
2653
|
interopNamespaceObjectName: undefined,
|
|
@@ -2215,9 +2655,13 @@ ${defineGetters}`
|
|
|
2215
2655
|
interopNamespaceObject2Name: undefined,
|
|
2216
2656
|
interopDefaultAccessUsed: false,
|
|
2217
2657
|
interopDefaultAccessName: undefined,
|
|
2218
|
-
deferred:
|
|
2658
|
+
deferred: this.compilation.options.experiments.deferImport
|
|
2659
|
+
? moduleGraph.isDeferred(info.module)
|
|
2660
|
+
: false,
|
|
2219
2661
|
deferredNamespaceObjectName: undefined,
|
|
2220
|
-
deferredNamespaceObjectUsed: false
|
|
2662
|
+
deferredNamespaceObjectUsed: false,
|
|
2663
|
+
exportsTypeStrict: undefined,
|
|
2664
|
+
exportsTypeNonStrict: undefined
|
|
2221
2665
|
};
|
|
2222
2666
|
break;
|
|
2223
2667
|
default:
|
|
@@ -2244,6 +2688,7 @@ ${defineGetters}`
|
|
|
2244
2688
|
}
|
|
2245
2689
|
|
|
2246
2690
|
/**
|
|
2691
|
+
* Updates the hash with the data contributed by this instance.
|
|
2247
2692
|
* @param {Hash} hash the hash used to track dependencies
|
|
2248
2693
|
* @param {UpdateHashContext} context context
|
|
2249
2694
|
* @returns {void}
|
|
@@ -2261,8 +2706,16 @@ ${defineGetters}`
|
|
|
2261
2706
|
info.module.updateHash(hash, context);
|
|
2262
2707
|
break;
|
|
2263
2708
|
case "external":
|
|
2264
|
-
hash.update(
|
|
2265
|
-
|
|
2709
|
+
hash.update(
|
|
2710
|
+
`${chunkGraph.getModuleId(info.module)}|${runtimeConditionToString(
|
|
2711
|
+
info.runtimeCondition
|
|
2712
|
+
)}|${info.nonDeferAccess ? "1" : "0"}|${
|
|
2713
|
+
this.compilation.options.experiments.deferImport &&
|
|
2714
|
+
chunkGraph.moduleGraph.isDeferred(info.module)
|
|
2715
|
+
? "1"
|
|
2716
|
+
: "0"
|
|
2717
|
+
}`
|
|
2718
|
+
);
|
|
2266
2719
|
break;
|
|
2267
2720
|
}
|
|
2268
2721
|
}
|
|
@@ -2286,6 +2739,22 @@ ${defineGetters}`
|
|
|
2286
2739
|
}
|
|
2287
2740
|
}
|
|
2288
2741
|
|
|
2742
|
+
ConcatenatedModule.getCompilationHooks = createHooksRegistry(
|
|
2743
|
+
() =>
|
|
2744
|
+
/** @type {ConcatenateModuleHooks} */ ({
|
|
2745
|
+
onDemandExportsGeneration: new SyncBailHook([
|
|
2746
|
+
"module",
|
|
2747
|
+
"runtimes",
|
|
2748
|
+
"exportsFinalName",
|
|
2749
|
+
"exportsSource"
|
|
2750
|
+
]),
|
|
2751
|
+
concatenatedModuleInfo: new SyncBailHook([
|
|
2752
|
+
"updatedInfo",
|
|
2753
|
+
"concatenatedModuleInfo"
|
|
2754
|
+
])
|
|
2755
|
+
})
|
|
2756
|
+
);
|
|
2757
|
+
|
|
2289
2758
|
makeSerializable(ConcatenatedModule, "webpack/lib/optimize/ConcatenatedModule");
|
|
2290
2759
|
|
|
2291
2760
|
module.exports = ConcatenatedModule;
|