webpack 5.106.1 → 5.107.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 +2 -2
- package/lib/APIPlugin.js +4 -2
- package/lib/AsyncDependenciesBlock.js +3 -0
- package/lib/AutomaticPrefetchPlugin.js +6 -1
- package/lib/BannerPlugin.js +10 -1
- package/lib/Cache.js +27 -5
- package/lib/CacheFacade.js +26 -0
- package/lib/Chunk.js +46 -0
- package/lib/ChunkGraph.js +111 -0
- package/lib/ChunkGroup.js +57 -13
- package/lib/ChunkTemplate.js +9 -0
- package/lib/CleanPlugin.js +14 -1
- package/lib/CodeGenerationResults.js +19 -0
- package/lib/CompatibilityPlugin.js +23 -8
- package/lib/Compilation.js +161 -27
- package/lib/Compiler.js +41 -17
- package/lib/ConcatenationScope.js +24 -1
- package/lib/ConditionalInitFragment.js +6 -0
- package/lib/ConstPlugin.js +4 -1
- package/lib/ContextExclusionPlugin.js +2 -1
- package/lib/ContextModule.js +14 -2
- package/lib/ContextModuleFactory.js +10 -0
- package/lib/ContextReplacementPlugin.js +4 -1
- package/lib/DefinePlugin.js +22 -9
- package/lib/DependenciesBlock.js +6 -1
- package/lib/Dependency.js +48 -4
- 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 +3 -0
- package/lib/EntryPlugin.js +2 -1
- package/lib/Entrypoint.js +4 -0
- package/lib/EnvironmentPlugin.js +3 -2
- package/lib/ErrorHelpers.js +7 -0
- package/lib/EvalDevToolModulePlugin.js +3 -1
- package/lib/EvalSourceMapDevToolPlugin.js +11 -10
- package/lib/ExportsInfo.js +56 -2
- package/lib/ExportsInfoApiPlugin.js +2 -1
- package/lib/ExternalModule.js +114 -15
- package/lib/ExternalModuleFactoryPlugin.js +15 -0
- package/lib/ExternalsPlugin.js +2 -1
- package/lib/FileSystemInfo.js +291 -71
- package/lib/FlagAllModulesAsUsedPlugin.js +2 -1
- package/lib/FlagDependencyExportsPlugin.js +4 -1
- package/lib/FlagDependencyUsagePlugin.js +5 -1
- package/lib/FlagEntryExportAsUsedPlugin.js +2 -1
- package/lib/Generator.js +16 -3
- package/lib/HotModuleReplacementPlugin.js +35 -9
- package/lib/IgnorePlugin.js +4 -2
- package/lib/IgnoreWarningsPlugin.js +2 -1
- package/lib/InitFragment.js +10 -0
- package/lib/JavascriptMetaInfoPlugin.js +2 -1
- package/lib/LibraryTemplatePlugin.js +2 -1
- package/lib/LoaderOptionsPlugin.js +3 -1
- package/lib/LoaderTargetPlugin.js +2 -1
- package/lib/MainTemplate.js +15 -0
- package/lib/ManifestPlugin.js +9 -2
- package/lib/Module.js +101 -19
- package/lib/ModuleFactory.js +6 -1
- package/lib/ModuleFilenameHelpers.js +3 -0
- package/lib/ModuleGraph.js +66 -0
- package/lib/ModuleGraphConnection.js +9 -0
- package/lib/ModuleInfoHeaderPlugin.js +5 -0
- package/lib/ModuleSourceTypeConstants.js +32 -1
- package/lib/ModuleTemplate.js +8 -0
- package/lib/ModuleTypeConstants.js +12 -3
- package/lib/MultiCompiler.js +30 -2
- package/lib/MultiStats.js +8 -0
- package/lib/MultiWatching.js +3 -0
- package/lib/NoEmitOnErrorsPlugin.js +1 -1
- package/lib/NodeStuffPlugin.js +11 -2
- package/lib/NormalModule.js +43 -33
- package/lib/NormalModuleFactory.js +35 -2
- package/lib/NormalModuleReplacementPlugin.js +1 -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 +2 -1
- package/lib/ProgressPlugin.js +158 -68
- package/lib/ProvidePlugin.js +3 -1
- package/lib/RawModule.js +12 -0
- package/lib/RecordIdsPlugin.js +8 -0
- package/lib/RequestShortener.js +8 -0
- package/lib/ResolverFactory.js +5 -0
- package/lib/RuntimeGlobals.js +6 -5
- package/lib/RuntimeModule.js +22 -7
- package/lib/RuntimePlugin.js +13 -0
- package/lib/RuntimeTemplate.js +35 -1
- package/lib/SelfModuleFactory.js +2 -0
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -0
- package/lib/SourceMapDevToolPlugin.js +3 -1
- package/lib/Stats.js +5 -0
- package/lib/Template.js +20 -0
- package/lib/TemplatedPathPlugin.js +10 -3
- package/lib/UseStrictPlugin.js +2 -1
- package/lib/WarnCaseSensitiveModulesPlugin.js +71 -3
- package/lib/WarnDeprecatedOptionPlugin.js +2 -2
- package/lib/WarnNoModeSetPlugin.js +17 -2
- package/lib/WatchIgnorePlugin.js +4 -1
- package/lib/Watching.js +16 -3
- package/lib/WebpackError.js +3 -74
- package/lib/WebpackIsIncludedPlugin.js +3 -1
- package/lib/WebpackOptionsApply.js +14 -1
- package/lib/WebpackOptionsDefaulter.js +1 -0
- package/lib/asset/AssetBytesGenerator.js +12 -2
- package/lib/asset/AssetBytesParser.js +1 -0
- package/lib/asset/AssetGenerator.js +42 -10
- package/lib/asset/AssetModulesPlugin.js +7 -2
- package/lib/asset/AssetParser.js +2 -0
- package/lib/asset/AssetSourceGenerator.js +12 -2
- package/lib/asset/AssetSourceParser.js +1 -0
- package/lib/asset/RawDataUrlModule.js +11 -0
- package/lib/async-modules/AsyncModuleHelpers.js +1 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -0
- package/lib/async-modules/InferAsyncModulesPlugin.js +1 -1
- package/lib/buildChunkGraph.js +19 -6
- package/lib/cache/AddBuildDependenciesPlugin.js +2 -1
- package/lib/cache/AddManagedPathsPlugin.js +2 -1
- package/lib/cache/IdleFileCachePlugin.js +2 -1
- package/lib/cache/MemoryCachePlugin.js +1 -1
- package/lib/cache/MemoryWithGcCachePlugin.js +3 -1
- package/lib/cache/PackFileCacheStrategy.js +33 -4
- package/lib/cache/ResolverCachePlugin.js +10 -1
- package/lib/cache/getLazyHashedEtag.js +4 -0
- package/lib/cache/mergeEtags.js +2 -0
- package/lib/cli.js +33 -1
- package/lib/config/browserslistTargetHandler.js +2 -0
- package/lib/config/defaults.js +232 -12
- package/lib/config/normalization.js +15 -1
- package/lib/config/target.js +11 -0
- package/lib/container/ContainerEntryDependency.js +2 -0
- package/lib/container/ContainerEntryModule.js +12 -0
- package/lib/container/ContainerEntryModuleFactory.js +1 -0
- package/lib/container/ContainerExposedDependency.js +4 -0
- package/lib/container/ContainerPlugin.js +2 -1
- package/lib/container/ContainerReferencePlugin.js +2 -1
- package/lib/container/FallbackDependency.js +4 -0
- package/lib/container/FallbackItemDependency.js +1 -0
- package/lib/container/FallbackModule.js +12 -0
- package/lib/container/FallbackModuleFactory.js +1 -0
- package/lib/container/ModuleFederationPlugin.js +3 -1
- package/lib/container/RemoteModule.js +13 -0
- package/lib/container/RemoteRuntimeModule.js +1 -0
- package/lib/container/RemoteToExternalDependency.js +1 -0
- package/lib/container/options.js +7 -0
- package/lib/css/CssGenerator.js +336 -100
- package/lib/css/CssInjectStyleRuntimeModule.js +45 -42
- package/lib/css/CssLoadingRuntimeModule.js +23 -4
- package/lib/{CssModule.js → css/CssModule.js} +21 -15
- package/lib/css/CssModulesPlugin.js +235 -89
- package/lib/css/CssParser.js +616 -261
- package/lib/css/walkCssTokens.js +179 -2
- package/lib/debug/ProfilingPlugin.js +19 -1
- package/lib/dependencies/AMDDefineDependency.js +7 -0
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -0
- package/lib/dependencies/AMDPlugin.js +4 -1
- package/lib/dependencies/AMDRequireArrayDependency.js +6 -0
- package/lib/dependencies/AMDRequireContextDependency.js +3 -0
- package/lib/dependencies/AMDRequireDependenciesBlock.js +1 -0
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +14 -1
- package/lib/dependencies/AMDRequireDependency.js +4 -0
- package/lib/dependencies/AMDRequireItemDependency.js +1 -0
- package/lib/dependencies/AMDRuntimeModules.js +3 -0
- package/lib/dependencies/CachedConstDependency.js +6 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +64 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +62 -10
- package/lib/dependencies/CommonJsExportsDependency.js +4 -0
- package/lib/dependencies/CommonJsExportsParserPlugin.js +9 -1
- package/lib/dependencies/CommonJsFullRequireDependency.js +36 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +24 -3
- package/lib/dependencies/CommonJsPlugin.js +4 -1
- package/lib/dependencies/CommonJsRequireContextDependency.js +3 -0
- package/lib/dependencies/CommonJsRequireDependency.js +70 -4
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +5 -0
- package/lib/dependencies/ConstDependency.js +6 -1
- package/lib/dependencies/ContextDependency.js +9 -2
- package/lib/dependencies/ContextDependencyHelpers.js +4 -1
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/ContextElementDependency.js +4 -0
- package/lib/dependencies/CreateRequireParserPlugin.js +7 -1
- package/lib/dependencies/CreateScriptUrlDependency.js +4 -0
- package/lib/dependencies/CriticalDependencyWarning.js +2 -1
- package/lib/dependencies/CssIcssExportDependency.js +339 -66
- package/lib/dependencies/CssIcssImportDependency.js +53 -8
- package/lib/dependencies/CssIcssSymbolDependency.js +16 -4
- package/lib/dependencies/CssImportDependency.js +12 -0
- package/lib/dependencies/CssUrlDependency.js +32 -0
- package/lib/dependencies/DelegatedSourceDependency.js +1 -0
- package/lib/dependencies/DllEntryDependency.js +3 -0
- package/lib/dependencies/DynamicExports.js +5 -0
- package/lib/dependencies/EntryDependency.js +1 -0
- package/lib/dependencies/ExportsInfoDependency.js +6 -0
- package/lib/dependencies/ExternalModuleDependency.js +5 -0
- package/lib/dependencies/ExternalModuleInitFragment.js +3 -0
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +4 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +6 -0
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -0
- package/lib/dependencies/HarmonyCompatibilityDependency.js +1 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -0
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +10 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +27 -14
- package/lib/dependencies/HarmonyExportHeaderDependency.js +4 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +143 -5
- package/lib/dependencies/HarmonyExportInitFragment.js +6 -0
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +5 -0
- package/lib/dependencies/HarmonyExports.js +2 -0
- package/lib/dependencies/HarmonyImportDependency.js +21 -2
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +31 -1
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -0
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +18 -3
- package/lib/{HarmonyLinkingError.js → dependencies/HarmonyLinkingError.js} +5 -3
- package/lib/dependencies/HarmonyModulesPlugin.js +4 -1
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -0
- package/lib/dependencies/HtmlInlineScriptDependency.js +133 -0
- package/lib/dependencies/HtmlInlineStyleDependency.js +101 -0
- package/lib/dependencies/HtmlScriptSrcDependency.js +318 -0
- package/lib/dependencies/HtmlSourceDependency.js +127 -0
- package/lib/dependencies/ImportContextDependency.js +4 -0
- package/lib/dependencies/ImportDependency.js +5 -0
- package/lib/dependencies/ImportEagerDependency.js +2 -0
- package/lib/dependencies/ImportMetaContextDependency.js +1 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -1
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +1 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +6 -0
- package/lib/dependencies/ImportParserPlugin.js +9 -2
- package/lib/dependencies/ImportPhase.js +7 -3
- package/lib/dependencies/ImportPlugin.js +2 -1
- package/lib/dependencies/ImportWeakDependency.js +2 -0
- package/lib/dependencies/JsonExportsDependency.js +6 -1
- package/lib/dependencies/LoaderDependency.js +2 -0
- package/lib/dependencies/LoaderImportDependency.js +2 -0
- package/lib/dependencies/LoaderPlugin.js +4 -1
- package/lib/dependencies/LocalModule.js +4 -0
- package/lib/dependencies/LocalModuleDependency.js +4 -0
- package/lib/dependencies/LocalModulesHelpers.js +3 -0
- package/lib/dependencies/ModuleDecoratorDependency.js +7 -1
- package/lib/dependencies/ModuleDependency.js +7 -0
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +4 -0
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/PrefetchDependency.js +1 -0
- package/lib/dependencies/ProvidedDependency.js +6 -1
- package/lib/dependencies/PureExpressionDependency.js +7 -1
- package/lib/dependencies/RequireContextDependency.js +1 -0
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +2 -1
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +1 -0
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -0
- package/lib/dependencies/RequireEnsureDependency.js +4 -0
- package/lib/dependencies/RequireEnsureItemDependency.js +1 -0
- package/lib/dependencies/RequireEnsurePlugin.js +2 -1
- package/lib/dependencies/RequireHeaderDependency.js +4 -0
- package/lib/dependencies/RequireIncludeDependency.js +2 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +4 -1
- package/lib/dependencies/RequireIncludePlugin.js +2 -1
- package/lib/{RequireJsStuffPlugin.js → dependencies/RequireJsStuffPlugin.js} +9 -8
- package/lib/dependencies/RequireResolveContextDependency.js +3 -0
- package/lib/dependencies/RequireResolveDependency.js +1 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +5 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +5 -1
- package/lib/dependencies/StaticExportsDependency.js +3 -0
- package/lib/dependencies/SystemPlugin.js +5 -2
- package/lib/dependencies/SystemRuntimeModule.js +1 -0
- package/lib/dependencies/URLContextDependency.js +3 -0
- package/lib/dependencies/URLDependency.js +6 -0
- package/lib/dependencies/URLPlugin.js +2 -0
- package/lib/dependencies/UnsupportedDependency.js +4 -0
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +4 -0
- package/lib/dependencies/WebAssemblyImportDependency.js +5 -2
- package/lib/dependencies/WebpackIsIncludedDependency.js +2 -0
- package/lib/dependencies/WorkerDependency.js +6 -1
- package/lib/dependencies/WorkerPlugin.js +11 -3
- package/lib/dependencies/getFunctionExpression.js +1 -0
- package/lib/dependencies/processExportInfo.js +1 -0
- package/lib/{DelegatedModule.js → dll/DelegatedModule.js} +44 -31
- package/lib/{DelegatedModuleFactoryPlugin.js → dll/DelegatedModuleFactoryPlugin.js} +7 -4
- package/lib/{DelegatedPlugin.js → dll/DelegatedPlugin.js} +4 -3
- package/lib/{DllEntryPlugin.js → dll/DllEntryPlugin.js} +6 -5
- package/lib/{DllModule.js → dll/DllModule.js} +35 -24
- package/lib/{DllModuleFactory.js → dll/DllModuleFactory.js} +5 -4
- package/lib/{DllPlugin.js → dll/DllPlugin.js} +8 -6
- package/lib/{DllReferencePlugin.js → dll/DllReferencePlugin.js} +23 -18
- package/lib/{LibManifestPlugin.js → dll/LibManifestPlugin.js} +13 -10
- package/lib/electron/ElectronTargetPlugin.js +2 -1
- 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} +4 -2
- package/lib/{EnvironmentNotSupportAsyncWarning.js → errors/EnvironmentNotSupportAsyncWarning.js} +4 -4
- package/lib/{HookWebpackError.js → errors/HookWebpackError.js} +11 -5
- package/lib/{IgnoreErrorModuleFactory.js → errors/IgnoreErrorModuleFactory.js} +6 -4
- package/lib/{InvalidDependenciesModuleWarning.js → errors/InvalidDependenciesModuleWarning.js} +4 -3
- package/lib/errors/JSONParseError.js +114 -0
- package/lib/{ModuleBuildError.js → errors/ModuleBuildError.js} +8 -5
- package/lib/{ModuleDependencyError.js → errors/ModuleDependencyError.js} +2 -2
- package/lib/{ModuleDependencyWarning.js → errors/ModuleDependencyWarning.js} +5 -4
- package/lib/{ModuleError.js → errors/ModuleError.js} +7 -5
- package/lib/{ModuleHashingError.js → errors/ModuleHashingError.js} +1 -1
- package/lib/{ModuleNotFoundError.js → errors/ModuleNotFoundError.js} +3 -2
- package/lib/{ModuleParseError.js → errors/ModuleParseError.js} +11 -6
- package/lib/{ModuleRestoreError.js → errors/ModuleRestoreError.js} +2 -1
- package/lib/{ModuleStoreError.js → errors/ModuleStoreError.js} +2 -1
- package/lib/{ModuleWarning.js → errors/ModuleWarning.js} +8 -5
- package/lib/{NodeStuffInWebError.js → errors/NodeStuffInWebError.js} +5 -4
- package/lib/errors/NonErrorEmittedError.js +28 -0
- package/lib/{UnhandledSchemeError.js → errors/UnhandledSchemeError.js} +8 -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 +5 -1
- package/lib/esm/ModuleChunkLoadingPlugin.js +3 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +5 -0
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +20 -1
- package/lib/hmr/lazyCompilationBackend.js +2 -0
- package/lib/html/HtmlGenerator.js +379 -0
- package/lib/html/HtmlModulesPlugin.js +433 -0
- package/lib/html/HtmlParser.js +1489 -0
- package/lib/html/walkHtmlTokens.js +2733 -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 +22 -1
- 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 +39 -15
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -1
- package/lib/javascript/BasicEvaluatedExpression.js +4 -2
- 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 +5 -1
- package/lib/javascript/JavascriptGenerator.js +10 -0
- package/lib/javascript/JavascriptModulesPlugin.js +112 -9
- package/lib/javascript/JavascriptParser.js +360 -16
- package/lib/javascript/JavascriptParserHelpers.js +7 -1
- package/lib/javascript/StartupHelpers.js +5 -0
- package/lib/json/JsonData.js +5 -0
- package/lib/json/JsonGenerator.js +21 -0
- package/lib/json/JsonModulesPlugin.js +1 -1
- package/lib/json/JsonParser.js +14 -25
- package/lib/library/AbstractLibraryPlugin.js +17 -2
- package/lib/library/AmdLibraryPlugin.js +8 -0
- package/lib/library/AssignLibraryPlugin.js +16 -0
- package/lib/library/EnableLibraryPlugin.js +8 -2
- package/lib/library/ExportPropertyLibraryPlugin.js +9 -0
- package/lib/{FalseIIFEUmdWarning.js → library/FalseIIFEUmdWarning.js} +1 -1
- package/lib/library/JsonpLibraryPlugin.js +8 -0
- package/lib/library/ModuleLibraryPlugin.js +86 -1
- package/lib/library/SystemLibraryPlugin.js +8 -0
- package/lib/library/UmdLibraryPlugin.js +16 -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 +2 -1
- package/lib/node/NodeTemplatePlugin.js +3 -1
- package/lib/node/NodeWatchFileSystem.js +2 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +3 -0
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +4 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +4 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +3 -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 +62 -6
- package/lib/optimize/EnsureChunkConditionsPlugin.js +2 -1
- package/lib/optimize/FlagIncludedChunksPlugin.js +2 -1
- package/lib/optimize/InnerGraph.js +16 -1
- package/lib/optimize/InnerGraphPlugin.js +14 -2
- 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 +36 -8
- package/lib/optimize/RealContentHashPlugin.js +104 -26
- 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 +118 -4
- package/lib/optimize/SplitChunksPlugin.js +50 -2
- 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 +6 -0
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +1 -0
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +5 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -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 +18 -0
- package/lib/rules/UseEffectRulePlugin.js +10 -3
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
- package/lib/runtime/AutoPublicPathRuntimeModule.js +1 -0
- package/lib/runtime/BaseUriRuntimeModule.js +1 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +1 -0
- package/lib/runtime/CompatRuntimeModule.js +2 -0
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -0
- package/lib/runtime/CreateScriptRuntimeModule.js +1 -0
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +1 -0
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +1 -0
- package/lib/runtime/GetFullHashRuntimeModule.js +1 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +1 -0
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
- package/lib/runtime/GlobalRuntimeModule.js +1 -0
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +1 -0
- package/lib/runtime/HelperRuntimeModule.js +5 -0
- package/lib/runtime/LoadScriptRuntimeModule.js +1 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +121 -13
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +1 -0
- package/lib/runtime/NonceRuntimeModule.js +1 -0
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +1 -0
- package/lib/runtime/PublicPathRuntimeModule.js +1 -0
- package/lib/runtime/RelativeUrlRuntimeModule.js +1 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +1 -0
- package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +35 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +13 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
- package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
- package/lib/runtime/SystemContextRuntimeModule.js +1 -0
- package/lib/runtime/ToBinaryRuntimeModule.js +1 -0
- package/lib/schemes/DataUriPlugin.js +14 -2
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +43 -1
- package/lib/schemes/VirtualUrlPlugin.js +7 -2
- package/lib/serialization/AggregateErrorSerializer.js +2 -0
- package/lib/serialization/ArraySerializer.js +2 -0
- package/lib/serialization/BinaryMiddleware.js +20 -1
- package/lib/serialization/DateObjectSerializer.js +2 -0
- package/lib/serialization/ErrorObjectSerializer.js +3 -0
- package/lib/serialization/FileMiddleware.js +21 -0
- package/lib/serialization/MapObjectSerializer.js +2 -0
- package/lib/serialization/NullPrototypeObjectSerializer.js +2 -0
- package/lib/serialization/ObjectMiddleware.js +23 -0
- package/lib/serialization/PlainObjectSerializer.js +7 -0
- package/lib/serialization/RegExpObjectSerializer.js +2 -0
- package/lib/serialization/Serializer.js +5 -0
- package/lib/serialization/SerializerMiddleware.js +14 -2
- package/lib/serialization/SetObjectSerializer.js +2 -0
- package/lib/serialization/SingleItemMiddleware.js +3 -0
- package/lib/sharing/ConsumeSharedFallbackDependency.js +1 -0
- package/lib/sharing/ConsumeSharedModule.js +15 -0
- package/lib/sharing/ConsumeSharedPlugin.js +8 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -4
- package/lib/sharing/ProvideForSharedDependency.js +1 -0
- package/lib/sharing/ProvideSharedDependency.js +4 -0
- package/lib/sharing/ProvideSharedModule.js +12 -1
- package/lib/sharing/ProvideSharedModuleFactory.js +1 -0
- package/lib/sharing/ProvideSharedPlugin.js +5 -2
- package/lib/sharing/SharePlugin.js +2 -1
- package/lib/sharing/ShareRuntimeModule.js +1 -0
- package/lib/sharing/resolveMatchedConfigs.js +4 -1
- package/lib/sharing/utils.js +8 -0
- package/lib/stats/DefaultStatsFactoryPlugin.js +58 -3
- package/lib/stats/DefaultStatsPresetPlugin.js +12 -2
- package/lib/stats/DefaultStatsPrinterPlugin.js +38 -2
- package/lib/stats/StatsFactory.js +13 -1
- package/lib/stats/StatsPrinter.js +7 -0
- package/lib/typescript/TypeScriptPlugin.js +210 -0
- package/lib/url/URLParserPlugin.js +8 -2
- package/lib/util/AppendOnlyStackedSet.js +15 -0
- package/lib/util/ArrayHelpers.js +1 -0
- package/lib/util/ArrayQueue.js +10 -5
- package/lib/util/AsyncQueue.js +22 -2
- package/lib/util/Hash.js +2 -2
- package/lib/util/IterableHelpers.js +3 -0
- package/lib/util/LazyBucketSortedSet.js +21 -0
- package/lib/util/LazySet.js +39 -0
- package/lib/util/LocConverter.js +53 -0
- package/lib/util/ParallelismFactorCalculator.js +1 -0
- package/lib/util/Queue.js +6 -3
- package/lib/util/Semaphore.js +14 -1
- package/lib/util/SetHelpers.js +3 -0
- package/lib/util/SortableSet.js +7 -1
- package/lib/util/StackedCacheMap.js +20 -3
- package/lib/util/StackedMap.js +45 -0
- package/lib/util/StringXor.js +1 -1
- package/lib/util/TupleQueue.js +7 -3
- package/lib/util/TupleSet.js +13 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -0
- package/lib/util/WeakTupleMap.js +33 -0
- package/lib/util/binarySearchBounds.js +1 -0
- package/lib/util/cleverMerge.js +19 -2
- package/lib/util/comparators.js +34 -3
- package/lib/util/compileBooleanMatcher.js +9 -0
- package/lib/util/concatenate.js +9 -3
- package/lib/util/conventions.js +46 -1
- package/lib/util/createMappings.js +118 -0
- package/lib/util/dataURL.js +1 -0
- package/lib/util/deprecation.js +19 -0
- package/lib/util/deterministicGrouping.js +20 -0
- package/lib/util/extractSourceMap.js +1 -0
- package/lib/util/extractUrlAndGlobal.js +1 -0
- package/lib/util/findGraphRoots.js +5 -0
- package/lib/{formatLocation.js → util/formatLocation.js} +4 -2
- package/lib/{SizeFormatHelpers.js → util/formatSize.js} +4 -1
- package/lib/util/fs.js +71 -8
- package/lib/util/generateDebugId.js +1 -0
- package/lib/util/hash/BatchedHash.js +1 -0
- package/lib/util/hash/BulkUpdateHash.js +1 -0
- package/lib/util/hash/hash-digest.js +8 -0
- 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 +67 -0
- package/lib/util/internalSerializables.js +35 -19
- package/lib/util/magicComment.js +10 -6
- package/lib/util/makeSerializable.js +6 -0
- package/lib/util/memoize.js +2 -0
- package/lib/util/mimeTypes.js +176 -0
- package/lib/util/nonNumericOnlyHash.js +1 -0
- package/lib/util/parseJson.js +41 -0
- package/lib/util/processAsyncTree.js +8 -0
- package/lib/util/property.js +1 -0
- package/lib/util/registerExternalSerializer.js +20 -0
- 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 +1 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +1 -0
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +12 -3
- package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +12 -1
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +6 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +1 -0
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +26 -1
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +7 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +4 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +10 -1
- package/lib/wasm-sync/WebAssemblyParser.js +2 -0
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -0
- package/lib/web/FetchCompileAsyncWasmPlugin.js +10 -1
- package/lib/web/FetchCompileWasmPlugin.js +13 -1
- package/lib/web/JsonpChunkLoadingPlugin.js +11 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
- package/lib/web/JsonpTemplatePlugin.js +2 -1
- package/lib/webpack.js +13 -1
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +10 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -0
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -1
- package/package.json +31 -31
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +161 -57
- 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/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +22 -0
- package/schemas/plugins/{DllReferencePlugin.check.d.ts → css/CssAutoOrModuleParserOptions.check.d.ts} +1 -1
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.json +3 -0
- package/schemas/plugins/dll/DllPlugin.check.d.ts +7 -0
- package/schemas/plugins/dll/DllReferencePlugin.check.d.ts +7 -0
- package/types.d.ts +5325 -353
- package/lib/CaseSensitiveModulesWarning.js +0 -72
- package/lib/GraphHelpers.js +0 -46
- package/lib/NoModeWarning.js +0 -23
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +0 -56
- /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
|
@@ -46,6 +46,7 @@ const PLUGIN_NAME = "AMDPlugin";
|
|
|
46
46
|
|
|
47
47
|
class AMDPlugin {
|
|
48
48
|
/**
|
|
49
|
+
* Creates an instance of AMDPlugin.
|
|
49
50
|
* @param {AmdOptions} amdOptions the AMD options
|
|
50
51
|
*/
|
|
51
52
|
constructor(amdOptions) {
|
|
@@ -53,7 +54,7 @@ class AMDPlugin {
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
/**
|
|
56
|
-
*
|
|
57
|
+
* Applies the plugin by registering its hooks on the compiler.
|
|
57
58
|
* @param {Compiler} compiler the compiler instance
|
|
58
59
|
* @returns {void}
|
|
59
60
|
*/
|
|
@@ -133,6 +134,7 @@ class AMDPlugin {
|
|
|
133
134
|
});
|
|
134
135
|
|
|
135
136
|
/**
|
|
137
|
+
* Handles the hook callback for this code path.
|
|
136
138
|
* @param {Parser} parser parser parser
|
|
137
139
|
* @param {JavascriptParserOptions} parserOptions parserOptions
|
|
138
140
|
* @returns {void}
|
|
@@ -141,6 +143,7 @@ class AMDPlugin {
|
|
|
141
143
|
if (parserOptions.amd !== undefined && !parserOptions.amd) return;
|
|
142
144
|
|
|
143
145
|
/**
|
|
146
|
+
* Processes the provided option expr.
|
|
144
147
|
* @param {string} optionExpr option expression
|
|
145
148
|
* @param {string} rootName root name
|
|
146
149
|
* @param {GetMembers} getMembers callback
|
|
@@ -20,6 +20,7 @@ const NullDependency = require("./NullDependency");
|
|
|
20
20
|
|
|
21
21
|
class AMDRequireArrayDependency extends NullDependency {
|
|
22
22
|
/**
|
|
23
|
+
* Creates an instance of AMDRequireArrayDependency.
|
|
23
24
|
* @param {(string | LocalModuleDependency | AMDRequireItemDependency)[]} depsArray deps array
|
|
24
25
|
* @param {Range} range range
|
|
25
26
|
*/
|
|
@@ -39,6 +40,7 @@ class AMDRequireArrayDependency extends NullDependency {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/**
|
|
43
|
+
* Serializes this instance into the provided serializer context.
|
|
42
44
|
* @param {ObjectSerializerContext} context context
|
|
43
45
|
*/
|
|
44
46
|
serialize(context) {
|
|
@@ -51,6 +53,7 @@ class AMDRequireArrayDependency extends NullDependency {
|
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
/**
|
|
56
|
+
* Restores this instance from the provided deserializer context.
|
|
54
57
|
* @param {ObjectDeserializerContext} context context
|
|
55
58
|
*/
|
|
56
59
|
deserialize(context) {
|
|
@@ -72,6 +75,7 @@ AMDRequireArrayDependency.Template = class AMDRequireArrayDependencyTemplate ext
|
|
|
72
75
|
DependencyTemplate
|
|
73
76
|
) {
|
|
74
77
|
/**
|
|
78
|
+
* Applies the plugin by registering its hooks on the compiler.
|
|
75
79
|
* @param {Dependency} dependency the dependency for which the template should be applied
|
|
76
80
|
* @param {ReplaceSource} source the current replace source which can be modified
|
|
77
81
|
* @param {DependencyTemplateContext} templateContext the context object
|
|
@@ -84,6 +88,7 @@ AMDRequireArrayDependency.Template = class AMDRequireArrayDependencyTemplate ext
|
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
/**
|
|
91
|
+
* Returns content.
|
|
87
92
|
* @param {AMDRequireArrayDependency} dep the dependency for which the template should be applied
|
|
88
93
|
* @param {DependencyTemplateContext} templateContext the context object
|
|
89
94
|
* @returns {string} content
|
|
@@ -96,6 +101,7 @@ AMDRequireArrayDependency.Template = class AMDRequireArrayDependencyTemplate ext
|
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
/**
|
|
104
|
+
* Content for dependency.
|
|
99
105
|
* @param {string | LocalModuleDependency | AMDRequireItemDependency} dep the dependency for which the template should be applied
|
|
100
106
|
* @param {DependencyTemplateContext} templateContext the context object
|
|
101
107
|
* @returns {string} content
|
|
@@ -15,6 +15,7 @@ const ContextDependency = require("./ContextDependency");
|
|
|
15
15
|
|
|
16
16
|
class AMDRequireContextDependency extends ContextDependency {
|
|
17
17
|
/**
|
|
18
|
+
* Creates an instance of AMDRequireContextDependency.
|
|
18
19
|
* @param {ContextDependencyOptions} options options
|
|
19
20
|
* @param {Range} range range
|
|
20
21
|
* @param {Range} valueRange value range
|
|
@@ -35,6 +36,7 @@ class AMDRequireContextDependency extends ContextDependency {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
/**
|
|
39
|
+
* Serializes this instance into the provided serializer context.
|
|
38
40
|
* @param {ObjectSerializerContext} context context
|
|
39
41
|
*/
|
|
40
42
|
serialize(context) {
|
|
@@ -47,6 +49,7 @@ class AMDRequireContextDependency extends ContextDependency {
|
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
/**
|
|
52
|
+
* Restores this instance from the provided deserializer context.
|
|
50
53
|
* @param {ObjectDeserializerContext} context context
|
|
51
54
|
*/
|
|
52
55
|
deserialize(context) {
|
|
@@ -12,6 +12,7 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
12
12
|
|
|
13
13
|
class AMDRequireDependenciesBlock extends AsyncDependenciesBlock {
|
|
14
14
|
/**
|
|
15
|
+
* Creates an instance of AMDRequireDependenciesBlock.
|
|
15
16
|
* @param {DependencyLocation} loc location info
|
|
16
17
|
* @param {string=} request request
|
|
17
18
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
9
|
-
const UnsupportedFeatureWarning = require("../UnsupportedFeatureWarning");
|
|
9
|
+
const UnsupportedFeatureWarning = require("../errors/UnsupportedFeatureWarning");
|
|
10
10
|
const AMDRequireArrayDependency = require("./AMDRequireArrayDependency");
|
|
11
11
|
const AMDRequireContextDependency = require("./AMDRequireContextDependency");
|
|
12
12
|
const AMDRequireDependenciesBlock = require("./AMDRequireDependenciesBlock");
|
|
@@ -36,6 +36,7 @@ const PLUGIN_NAME = "AMDRequireDependenciesBlockParserPlugin";
|
|
|
36
36
|
|
|
37
37
|
class AMDRequireDependenciesBlockParserPlugin {
|
|
38
38
|
/**
|
|
39
|
+
* Creates an instance of AMDRequireDependenciesBlockParserPlugin.
|
|
39
40
|
* @param {JavascriptParserOptions} options parserOptions
|
|
40
41
|
*/
|
|
41
42
|
constructor(options) {
|
|
@@ -43,6 +44,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/**
|
|
47
|
+
* Process function argument.
|
|
46
48
|
* @param {JavascriptParser} parser the parser
|
|
47
49
|
* @param {Expression | SpreadElement} expression expression
|
|
48
50
|
* @returns {boolean} need bind this
|
|
@@ -78,6 +80,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
/**
|
|
83
|
+
* Applies the plugin by registering its hooks on the compiler.
|
|
81
84
|
* @param {JavascriptParser} parser the parser
|
|
82
85
|
* @returns {void}
|
|
83
86
|
*/
|
|
@@ -88,6 +91,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
/**
|
|
94
|
+
* Processes the provided parser.
|
|
91
95
|
* @param {JavascriptParser} parser the parser
|
|
92
96
|
* @param {CallExpression} expr call expression
|
|
93
97
|
* @param {BasicEvaluatedExpression} param param
|
|
@@ -140,6 +144,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
140
144
|
}
|
|
141
145
|
|
|
142
146
|
/**
|
|
147
|
+
* Processes the provided parser.
|
|
143
148
|
* @param {JavascriptParser} parser the parser
|
|
144
149
|
* @param {CallExpression} expr call expression
|
|
145
150
|
* @param {BasicEvaluatedExpression} param param
|
|
@@ -209,6 +214,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
209
214
|
}
|
|
210
215
|
|
|
211
216
|
/**
|
|
217
|
+
* Processes the provided parser.
|
|
212
218
|
* @param {JavascriptParser} parser the parser
|
|
213
219
|
* @param {CallExpression} expr call expression
|
|
214
220
|
* @param {BasicEvaluatedExpression} param param
|
|
@@ -235,6 +241,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
235
241
|
}
|
|
236
242
|
|
|
237
243
|
/**
|
|
244
|
+
* Process array for request string.
|
|
238
245
|
* @param {BasicEvaluatedExpression} param param
|
|
239
246
|
* @returns {string | undefined} result
|
|
240
247
|
*/
|
|
@@ -250,6 +257,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
250
257
|
}
|
|
251
258
|
|
|
252
259
|
/**
|
|
260
|
+
* Process item for request string.
|
|
253
261
|
* @param {BasicEvaluatedExpression} param param
|
|
254
262
|
* @returns {string | undefined} result
|
|
255
263
|
*/
|
|
@@ -265,6 +273,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
265
273
|
}
|
|
266
274
|
|
|
267
275
|
/**
|
|
276
|
+
* Process call require.
|
|
268
277
|
* @param {JavascriptParser} parser the parser
|
|
269
278
|
* @param {CallExpression} expr call expression
|
|
270
279
|
* @returns {boolean | undefined} result
|
|
@@ -375,6 +384,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
375
384
|
}
|
|
376
385
|
|
|
377
386
|
/**
|
|
387
|
+
* New require dependencies block.
|
|
378
388
|
* @param {DependencyLocation} loc location
|
|
379
389
|
* @param {string=} request request
|
|
380
390
|
* @returns {AMDRequireDependenciesBlock} AMDRequireDependenciesBlock
|
|
@@ -384,6 +394,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
384
394
|
}
|
|
385
395
|
|
|
386
396
|
/**
|
|
397
|
+
* New require dependency.
|
|
387
398
|
* @param {Range} outerRange outer range
|
|
388
399
|
* @param {Range} arrayRange array range
|
|
389
400
|
* @param {Range | null} functionRange function range
|
|
@@ -405,6 +416,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
405
416
|
}
|
|
406
417
|
|
|
407
418
|
/**
|
|
419
|
+
* New require item dependency.
|
|
408
420
|
* @param {string} request request
|
|
409
421
|
* @param {Range=} range range
|
|
410
422
|
* @returns {AMDRequireItemDependency} AMDRequireItemDependency
|
|
@@ -414,6 +426,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
414
426
|
}
|
|
415
427
|
|
|
416
428
|
/**
|
|
429
|
+
* New require array dependency.
|
|
417
430
|
* @param {(string | LocalModuleDependency | AMDRequireItemDependency)[]} depsArray deps array
|
|
418
431
|
* @param {Range} range range
|
|
419
432
|
* @returns {AMDRequireArrayDependency} AMDRequireArrayDependency
|
|
@@ -19,6 +19,7 @@ const NullDependency = require("./NullDependency");
|
|
|
19
19
|
|
|
20
20
|
class AMDRequireDependency extends NullDependency {
|
|
21
21
|
/**
|
|
22
|
+
* Creates an instance of AMDRequireDependency.
|
|
22
23
|
* @param {Range} outerRange outer range
|
|
23
24
|
* @param {Range} arrayRange array range
|
|
24
25
|
* @param {Range | null} functionRange function range
|
|
@@ -40,6 +41,7 @@ class AMDRequireDependency extends NullDependency {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
/**
|
|
44
|
+
* Serializes this instance into the provided serializer context.
|
|
43
45
|
* @param {ObjectSerializerContext} context context
|
|
44
46
|
*/
|
|
45
47
|
serialize(context) {
|
|
@@ -56,6 +58,7 @@ class AMDRequireDependency extends NullDependency {
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
/**
|
|
61
|
+
* Restores this instance from the provided deserializer context.
|
|
59
62
|
* @param {ObjectDeserializerContext} context context
|
|
60
63
|
*/
|
|
61
64
|
deserialize(context) {
|
|
@@ -81,6 +84,7 @@ AMDRequireDependency.Template = class AMDRequireDependencyTemplate extends (
|
|
|
81
84
|
NullDependency.Template
|
|
82
85
|
) {
|
|
83
86
|
/**
|
|
87
|
+
* Applies the plugin by registering its hooks on the compiler.
|
|
84
88
|
* @param {Dependency} dependency the dependency for which the template should be applied
|
|
85
89
|
* @param {ReplaceSource} source the current replace source which can be modified
|
|
86
90
|
* @param {DependencyTemplateContext} templateContext the context object
|
|
@@ -13,6 +13,7 @@ const ModuleDependencyTemplateAsRequireId = require("./ModuleDependencyTemplateA
|
|
|
13
13
|
|
|
14
14
|
class AMDRequireItemDependency extends ModuleDependency {
|
|
15
15
|
/**
|
|
16
|
+
* Creates an instance of AMDRequireItemDependency.
|
|
16
17
|
* @param {string} request the request string
|
|
17
18
|
* @param {Range=} range location in source code
|
|
18
19
|
*/
|
|
@@ -16,6 +16,7 @@ class AMDDefineRuntimeModule extends RuntimeModule {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
+
* Generates runtime code for this runtime module.
|
|
19
20
|
* @returns {string | null} runtime code
|
|
20
21
|
*/
|
|
21
22
|
generate() {
|
|
@@ -29,6 +30,7 @@ class AMDDefineRuntimeModule extends RuntimeModule {
|
|
|
29
30
|
|
|
30
31
|
class AMDOptionsRuntimeModule extends RuntimeModule {
|
|
31
32
|
/**
|
|
33
|
+
* Creates an instance of AMDOptionsRuntimeModule.
|
|
32
34
|
* @param {AmdOptions} options the AMD options
|
|
33
35
|
*/
|
|
34
36
|
constructor(options) {
|
|
@@ -37,6 +39,7 @@ class AMDOptionsRuntimeModule extends RuntimeModule {
|
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
/**
|
|
42
|
+
* Generates runtime code for this runtime module.
|
|
40
43
|
* @returns {string | null} runtime code
|
|
41
44
|
*/
|
|
42
45
|
generate() {
|
|
@@ -21,6 +21,7 @@ const NullDependency = require("./NullDependency");
|
|
|
21
21
|
|
|
22
22
|
class CachedConstDependency extends NullDependency {
|
|
23
23
|
/**
|
|
24
|
+
* Creates an instance of CachedConstDependency.
|
|
24
25
|
* @param {string} expression expression
|
|
25
26
|
* @param {Range | null} range range
|
|
26
27
|
* @param {string} identifier identifier
|
|
@@ -43,6 +44,7 @@ class CachedConstDependency extends NullDependency {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/**
|
|
47
|
+
* Create hash update.
|
|
46
48
|
* @returns {string} hash update
|
|
47
49
|
*/
|
|
48
50
|
_createHashUpdate() {
|
|
@@ -50,7 +52,7 @@ class CachedConstDependency extends NullDependency {
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
/**
|
|
53
|
-
*
|
|
55
|
+
* Updates the hash with the data contributed by this instance.
|
|
54
56
|
* @param {Hash} hash hash to be updated
|
|
55
57
|
* @param {UpdateHashContext} context context
|
|
56
58
|
* @returns {void}
|
|
@@ -63,6 +65,7 @@ class CachedConstDependency extends NullDependency {
|
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
/**
|
|
68
|
+
* Serializes this instance into the provided serializer context.
|
|
66
69
|
* @param {ObjectSerializerContext} context context
|
|
67
70
|
*/
|
|
68
71
|
serialize(context) {
|
|
@@ -77,6 +80,7 @@ class CachedConstDependency extends NullDependency {
|
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
/**
|
|
83
|
+
* Restores this instance from the provided deserializer context.
|
|
80
84
|
* @param {ObjectDeserializerContext} context context
|
|
81
85
|
*/
|
|
82
86
|
deserialize(context) {
|
|
@@ -103,6 +107,7 @@ CachedConstDependency.Template = class CachedConstDependencyTemplate extends (
|
|
|
103
107
|
DependencyTemplate
|
|
104
108
|
) {
|
|
105
109
|
/**
|
|
110
|
+
* Applies the plugin by registering its hooks on the compiler.
|
|
106
111
|
* @param {Dependency} dependency the dependency for which the template should be applied
|
|
107
112
|
* @param {ReplaceSource} source the current replace source which can be modified
|
|
108
113
|
* @param {DependencyTemplateContext} templateContext the context object
|
|
@@ -6,12 +6,74 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
9
|
+
const { propertyAccess } = require("../util/property");
|
|
9
10
|
|
|
10
11
|
/** @typedef {import("../Module")} Module */
|
|
11
12
|
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
|
13
|
+
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
14
|
+
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
12
15
|
/** @typedef {"exports" | "module.exports" | "this" | "Object.defineProperty(exports)" | "Object.defineProperty(module.exports)" | "Object.defineProperty(this)"} CommonJSDependencyBaseKeywords */
|
|
13
16
|
|
|
14
17
|
/**
|
|
18
|
+
* The well-known name of the ESM named export that, when present, is unwrapped
|
|
19
|
+
* by CommonJS `require()` to match Node.js v23+ `require(esm)` semantics:
|
|
20
|
+
* https://nodejs.org/docs/latest/api/modules.html#loading-ecmascript-modules-using-require
|
|
21
|
+
*/
|
|
22
|
+
const ESM_MODULE_EXPORTS_NAME = "module.exports";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Whether `require()` of `importedModule` would trigger Node.js's
|
|
26
|
+
* `require(esm)` `"module.exports"` named-export unwrap. This is the
|
|
27
|
+
* usage-independent eligibility check: it only looks at module type and
|
|
28
|
+
* whether the export is declared, so it can be safely used from
|
|
29
|
+
* `getReferencedExports` before usage info is finalized (otherwise the
|
|
30
|
+
* check would be circular — we'd need `"module.exports"` to already be
|
|
31
|
+
* marked used in order to ask whether to mark it used).
|
|
32
|
+
* @param {Module} importedModule the imported module
|
|
33
|
+
* @param {ModuleGraph} moduleGraph the module graph
|
|
34
|
+
* @returns {boolean} true if `require()` should unwrap `"module.exports"`
|
|
35
|
+
*/
|
|
36
|
+
const isRequireEsmModuleExportsModule = (importedModule, moduleGraph) => {
|
|
37
|
+
if (importedModule.getExportsType(moduleGraph, false) !== "namespace") {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
const exportsInfo = moduleGraph.getExportsInfo(importedModule);
|
|
41
|
+
const exportInfo = exportsInfo.getReadOnlyExportInfo(ESM_MODULE_EXPORTS_NAME);
|
|
42
|
+
return exportInfo.provided === true;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* When CommonJS `require()` resolves to an ES module that has a named export
|
|
47
|
+
* with the literal string name `"module.exports"`, Node.js returns the value of
|
|
48
|
+
* that export instead of the namespace object. Returns the property-access
|
|
49
|
+
* expression to apply to the require result for that unwrapping, or `null` if
|
|
50
|
+
* the imported module is not eligible (not strictly ESM, or no such export,
|
|
51
|
+
* or the export was tree-shaken away).
|
|
52
|
+
* @param {Module} importedModule the imported module
|
|
53
|
+
* @param {ModuleGraph} moduleGraph the module graph
|
|
54
|
+
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
|
55
|
+
* @returns {string | null} property-access expression (e.g. `["module.exports"]`), or `null`
|
|
56
|
+
*/
|
|
57
|
+
const getRequireEsmModuleExportsAccess = (
|
|
58
|
+
importedModule,
|
|
59
|
+
moduleGraph,
|
|
60
|
+
runtime
|
|
61
|
+
) => {
|
|
62
|
+
if (!isRequireEsmModuleExportsModule(importedModule, moduleGraph)) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const exportsInfo = moduleGraph.getExportsInfo(importedModule);
|
|
66
|
+
const usedName = exportsInfo.getUsedName([ESM_MODULE_EXPORTS_NAME], runtime);
|
|
67
|
+
if (usedName === false) return null;
|
|
68
|
+
return propertyAccess(/** @type {readonly string[]} */ (usedName));
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
module.exports.ESM_MODULE_EXPORTS_NAME = ESM_MODULE_EXPORTS_NAME;
|
|
72
|
+
module.exports.getRequireEsmModuleExportsAccess =
|
|
73
|
+
getRequireEsmModuleExportsAccess;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns type and base.
|
|
15
77
|
* @param {CommonJSDependencyBaseKeywords} depBase commonjs dependency base
|
|
16
78
|
* @param {Module} module module
|
|
17
79
|
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
|
|
@@ -63,3 +125,5 @@ module.exports.handleDependencyBase = (
|
|
|
63
125
|
|
|
64
126
|
return [type, base];
|
|
65
127
|
};
|
|
128
|
+
module.exports.isRequireEsmModuleExportsModule =
|
|
129
|
+
isRequireEsmModuleExportsModule;
|
|
@@ -11,7 +11,12 @@ const Template = require("../Template");
|
|
|
11
11
|
const { equals } = require("../util/ArrayHelpers");
|
|
12
12
|
const makeSerializable = require("../util/makeSerializable");
|
|
13
13
|
const { propertyAccess } = require("../util/property");
|
|
14
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
ESM_MODULE_EXPORTS_NAME,
|
|
16
|
+
getRequireEsmModuleExportsAccess,
|
|
17
|
+
handleDependencyBase,
|
|
18
|
+
isRequireEsmModuleExportsModule
|
|
19
|
+
} = require("./CommonJsDependencyHelpers");
|
|
15
20
|
const ModuleDependency = require("./ModuleDependency");
|
|
16
21
|
const processExportInfo = require("./processExportInfo");
|
|
17
22
|
|
|
@@ -43,6 +48,7 @@ const EMPTY_OBJECT = {};
|
|
|
43
48
|
|
|
44
49
|
class CommonJsExportRequireDependency extends ModuleDependency {
|
|
45
50
|
/**
|
|
51
|
+
* Creates an instance of CommonJsExportRequireDependency.
|
|
46
52
|
* @param {Range} range range
|
|
47
53
|
* @param {Range | null} valueRange value range
|
|
48
54
|
* @param {CommonJSDependencyBaseKeywords} base base
|
|
@@ -72,6 +78,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
/**
|
|
81
|
+
* Could affect referencing module.
|
|
75
82
|
* @returns {boolean | TRANSITIVE} true, when changes to the referenced module could affect the referencing module; TRANSITIVE, when changes to the referenced module could affect referencing modules of the referencing module
|
|
76
83
|
*/
|
|
77
84
|
couldAffectReferencingModule() {
|
|
@@ -79,6 +86,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
79
86
|
}
|
|
80
87
|
|
|
81
88
|
/**
|
|
89
|
+
* Returns the imported id.
|
|
82
90
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
83
91
|
* @returns {ExportInfoName[]} the imported id
|
|
84
92
|
*/
|
|
@@ -87,6 +95,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
87
95
|
}
|
|
88
96
|
|
|
89
97
|
/**
|
|
98
|
+
* Updates ids using the provided module graph.
|
|
90
99
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
91
100
|
* @param {ExportInfoName[]} ids the imported ids
|
|
92
101
|
* @returns {void}
|
|
@@ -103,6 +112,16 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
103
112
|
*/
|
|
104
113
|
getReferencedExports(moduleGraph, runtime) {
|
|
105
114
|
const ids = this.getIds(moduleGraph);
|
|
115
|
+
const importedModule = moduleGraph.getModule(this);
|
|
116
|
+
if (
|
|
117
|
+
importedModule &&
|
|
118
|
+
isRequireEsmModuleExportsModule(importedModule, moduleGraph)
|
|
119
|
+
) {
|
|
120
|
+
// `require(esm)` unwraps the "module.exports" named export; any
|
|
121
|
+
// further property access lands on that value (which webpack does
|
|
122
|
+
// not model), so only the "module.exports" export is observable.
|
|
123
|
+
return [[ESM_MODULE_EXPORTS_NAME]];
|
|
124
|
+
}
|
|
106
125
|
const getFullResult = () => {
|
|
107
126
|
if (ids.length === 0) {
|
|
108
127
|
return Dependency.EXPORTS_OBJECT_REFERENCED;
|
|
@@ -155,17 +174,26 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
155
174
|
* @returns {ExportsSpec | undefined} export names
|
|
156
175
|
*/
|
|
157
176
|
getExports(moduleGraph) {
|
|
177
|
+
const importedModule = moduleGraph.getModule(this);
|
|
178
|
+
const esmUnwrap =
|
|
179
|
+
importedModule &&
|
|
180
|
+
isRequireEsmModuleExportsModule(importedModule, moduleGraph);
|
|
158
181
|
if (this.names.length === 1) {
|
|
159
182
|
const ids = this.getIds(moduleGraph);
|
|
160
183
|
const name = this.names[0];
|
|
161
184
|
const from = moduleGraph.getConnection(this);
|
|
162
185
|
if (!from) return;
|
|
186
|
+
const exportChain = esmUnwrap
|
|
187
|
+
? [ESM_MODULE_EXPORTS_NAME, ...ids]
|
|
188
|
+
: ids.length === 0
|
|
189
|
+
? null
|
|
190
|
+
: ids;
|
|
163
191
|
return {
|
|
164
192
|
exports: [
|
|
165
193
|
{
|
|
166
194
|
name,
|
|
167
195
|
from,
|
|
168
|
-
export:
|
|
196
|
+
export: exportChain,
|
|
169
197
|
// we can't mangle names that are in an empty object
|
|
170
198
|
// because one could access the prototype property
|
|
171
199
|
// when export isn't set yet
|
|
@@ -191,6 +219,17 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
191
219
|
}
|
|
192
220
|
const from = moduleGraph.getConnection(this);
|
|
193
221
|
if (!from) return;
|
|
222
|
+
if (esmUnwrap) {
|
|
223
|
+
// Full re-export `module.exports = require("./esm")` of a module
|
|
224
|
+
// with a `"module.exports"` named export: the wrapping module's
|
|
225
|
+
// `module.exports` becomes the unwrapped value, whose own
|
|
226
|
+
// properties webpack cannot enumerate statically.
|
|
227
|
+
return {
|
|
228
|
+
exports: true,
|
|
229
|
+
canMangle: false,
|
|
230
|
+
dependencies: [from.module]
|
|
231
|
+
};
|
|
232
|
+
}
|
|
194
233
|
const reexportInfo = this.getStarReexports(
|
|
195
234
|
moduleGraph,
|
|
196
235
|
undefined,
|
|
@@ -222,6 +261,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
222
261
|
}
|
|
223
262
|
|
|
224
263
|
/**
|
|
264
|
+
* Gets star reexports.
|
|
225
265
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
226
266
|
* @param {RuntimeSpec} runtime the runtime
|
|
227
267
|
* @param {Module} importedModule the imported module (optional)
|
|
@@ -308,6 +348,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
308
348
|
}
|
|
309
349
|
|
|
310
350
|
/**
|
|
351
|
+
* Serializes this instance into the provided serializer context.
|
|
311
352
|
* @param {ObjectSerializerContext} context context
|
|
312
353
|
*/
|
|
313
354
|
serialize(context) {
|
|
@@ -323,6 +364,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
323
364
|
}
|
|
324
365
|
|
|
325
366
|
/**
|
|
367
|
+
* Restores this instance from the provided deserializer context.
|
|
326
368
|
* @param {ObjectDeserializerContext} context context
|
|
327
369
|
*/
|
|
328
370
|
deserialize(context) {
|
|
@@ -347,6 +389,7 @@ CommonJsExportRequireDependency.Template = class CommonJsExportRequireDependency
|
|
|
347
389
|
ModuleDependency.Template
|
|
348
390
|
) {
|
|
349
391
|
/**
|
|
392
|
+
* Applies the plugin by registering its hooks on the compiler.
|
|
350
393
|
* @param {Dependency} dependency the dependency for which the template should be applied
|
|
351
394
|
* @param {ReplaceSource} source the current replace source which can be modified
|
|
352
395
|
* @param {DependencyTemplateContext} templateContext the context object
|
|
@@ -385,14 +428,23 @@ CommonJsExportRequireDependency.Template = class CommonJsExportRequireDependency
|
|
|
385
428
|
});
|
|
386
429
|
if (importedModule) {
|
|
387
430
|
const ids = dep.getIds(moduleGraph);
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
431
|
+
const esmRequireAccess = getRequireEsmModuleExportsAccess(
|
|
432
|
+
importedModule,
|
|
433
|
+
moduleGraph,
|
|
434
|
+
runtime
|
|
435
|
+
);
|
|
436
|
+
if (esmRequireAccess !== null) {
|
|
437
|
+
requireExpr += `${esmRequireAccess}${propertyAccess(ids)}`;
|
|
438
|
+
} else {
|
|
439
|
+
const usedImported = moduleGraph
|
|
440
|
+
.getExportsInfo(importedModule)
|
|
441
|
+
.getUsedName(ids, runtime);
|
|
442
|
+
if (usedImported) {
|
|
443
|
+
const comment = equals(usedImported, ids)
|
|
444
|
+
? ""
|
|
445
|
+
: `${Template.toNormalComment(propertyAccess(ids))} `;
|
|
446
|
+
requireExpr += `${comment}${propertyAccess(usedImported)}`;
|
|
447
|
+
}
|
|
396
448
|
}
|
|
397
449
|
}
|
|
398
450
|
|
|
@@ -26,6 +26,7 @@ const EMPTY_OBJECT = {};
|
|
|
26
26
|
|
|
27
27
|
class CommonJsExportsDependency extends NullDependency {
|
|
28
28
|
/**
|
|
29
|
+
* Creates an instance of CommonJsExportsDependency.
|
|
29
30
|
* @param {Range} range range
|
|
30
31
|
* @param {Range | null} valueRange value range
|
|
31
32
|
* @param {CommonJSDependencyBaseKeywords} base base
|
|
@@ -65,6 +66,7 @@ class CommonJsExportsDependency extends NullDependency {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
/**
|
|
69
|
+
* Serializes this instance into the provided serializer context.
|
|
68
70
|
* @param {ObjectSerializerContext} context context
|
|
69
71
|
*/
|
|
70
72
|
serialize(context) {
|
|
@@ -77,6 +79,7 @@ class CommonJsExportsDependency extends NullDependency {
|
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
/**
|
|
82
|
+
* Restores this instance from the provided deserializer context.
|
|
80
83
|
* @param {ObjectDeserializerContext} context context
|
|
81
84
|
*/
|
|
82
85
|
deserialize(context) {
|
|
@@ -98,6 +101,7 @@ CommonJsExportsDependency.Template = class CommonJsExportsDependencyTemplate ext
|
|
|
98
101
|
NullDependency.Template
|
|
99
102
|
) {
|
|
100
103
|
/**
|
|
104
|
+
* Applies the plugin by registering its hooks on the compiler.
|
|
101
105
|
* @param {Dependency} dependency the dependency for which the template should be applied
|
|
102
106
|
* @param {ReplaceSource} source the current replace source which can be modified
|
|
103
107
|
* @param {DependencyTemplateContext} templateContext the context object
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
9
|
-
const formatLocation = require("../formatLocation");
|
|
10
9
|
const { evaluateToString } = require("../javascript/JavascriptParserHelpers");
|
|
10
|
+
const formatLocation = require("../util/formatLocation");
|
|
11
11
|
const { propertyAccess } = require("../util/property");
|
|
12
12
|
const CommonJsExportRequireDependency = require("./CommonJsExportRequireDependency");
|
|
13
13
|
const CommonJsExportsDependency = require("./CommonJsExportsDependency");
|
|
@@ -94,6 +94,7 @@ const isFalsyLiteral = (expr) => {
|
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
+
* Parses require call.
|
|
97
98
|
* @param {JavascriptParser} parser the parser
|
|
98
99
|
* @param {Expression} expr expression
|
|
99
100
|
* @returns {{ argument: BasicEvaluatedExpression, ids: ExportInfoName[] } | undefined} parsed call
|
|
@@ -132,6 +133,7 @@ const PLUGIN_NAME = "CommonJsExportsParserPlugin";
|
|
|
132
133
|
|
|
133
134
|
class CommonJsExportsParserPlugin {
|
|
134
135
|
/**
|
|
136
|
+
* Creates an instance of CommonJsExportsParserPlugin.
|
|
135
137
|
* @param {ModuleGraph} moduleGraph module graph
|
|
136
138
|
*/
|
|
137
139
|
constructor(moduleGraph) {
|
|
@@ -139,6 +141,7 @@ class CommonJsExportsParserPlugin {
|
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
/**
|
|
144
|
+
* Applies the plugin by registering its hooks on the compiler.
|
|
142
145
|
* @param {JavascriptParser} parser the parser
|
|
143
146
|
* @returns {void}
|
|
144
147
|
*/
|
|
@@ -148,6 +151,7 @@ class CommonJsExportsParserPlugin {
|
|
|
148
151
|
};
|
|
149
152
|
|
|
150
153
|
/**
|
|
154
|
+
* Checks namespace.
|
|
151
155
|
* @param {boolean} topLevel true, when the export is on top level
|
|
152
156
|
* @param {Members} members members of the export
|
|
153
157
|
* @param {Expression | undefined} valueExpr expression for the value
|
|
@@ -164,6 +168,7 @@ class CommonJsExportsParserPlugin {
|
|
|
164
168
|
}
|
|
165
169
|
};
|
|
166
170
|
/**
|
|
171
|
+
* Processes the provided reason.
|
|
167
172
|
* @param {string=} reason reason
|
|
168
173
|
*/
|
|
169
174
|
const bailout = (reason) => {
|
|
@@ -171,6 +176,7 @@ class CommonJsExportsParserPlugin {
|
|
|
171
176
|
if (reason) bailoutHint(reason);
|
|
172
177
|
};
|
|
173
178
|
/**
|
|
179
|
+
* Processes the provided reason.
|
|
174
180
|
* @param {string} reason reason
|
|
175
181
|
*/
|
|
176
182
|
const bailoutHint = (reason) => {
|
|
@@ -190,6 +196,7 @@ class CommonJsExportsParserPlugin {
|
|
|
190
196
|
// exporting //
|
|
191
197
|
|
|
192
198
|
/**
|
|
199
|
+
* Handle assign export.
|
|
193
200
|
* @param {AssignmentExpression} expr expression
|
|
194
201
|
* @param {CommonJSDependencyBaseKeywords} base commonjs base keywords
|
|
195
202
|
* @param {Members} members members of the export
|
|
@@ -313,6 +320,7 @@ class CommonJsExportsParserPlugin {
|
|
|
313
320
|
// Self reference //
|
|
314
321
|
|
|
315
322
|
/**
|
|
323
|
+
* Handle access export.
|
|
316
324
|
* @param {Expression | Super} expr expression
|
|
317
325
|
* @param {CommonJSDependencyBaseKeywords} base commonjs base keywords
|
|
318
326
|
* @param {Members} members members of the export
|