webpack 5.101.3 → 5.102.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 +21 -26
- package/lib/APIPlugin.js +30 -36
- package/lib/AsyncDependenciesBlock.js +1 -4
- package/lib/BannerPlugin.js +0 -1
- package/lib/Cache.js +7 -6
- package/lib/CacheFacade.js +0 -1
- package/lib/Chunk.js +49 -31
- package/lib/ChunkGraph.js +35 -25
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +2 -1
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +204 -185
- package/lib/Compiler.js +36 -35
- package/lib/ConcatenationScope.js +6 -1
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +6 -5
- package/lib/ContextExclusionPlugin.js +0 -1
- package/lib/ContextModule.js +22 -20
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +4 -8
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +1 -3
- package/lib/DllModule.js +1 -7
- package/lib/DllReferencePlugin.js +2 -4
- package/lib/DynamicEntryPlugin.js +0 -2
- package/lib/EntryOptionPlugin.js +0 -5
- package/lib/EnvironmentNotSupportAsyncWarning.js +0 -3
- package/lib/EvalDevToolModulePlugin.js +4 -3
- package/lib/EvalSourceMapDevToolPlugin.js +3 -4
- package/lib/ExportsInfo.js +50 -49
- package/lib/ExternalModule.js +84 -52
- package/lib/ExternalModuleFactoryPlugin.js +27 -7
- package/lib/ExternalsPlugin.js +24 -17
- package/lib/FileSystemInfo.js +96 -78
- package/lib/FlagDependencyUsagePlugin.js +3 -4
- package/lib/Generator.js +2 -13
- package/lib/GraphHelpers.js +0 -3
- package/lib/HookWebpackError.js +0 -2
- package/lib/HotModuleReplacementPlugin.js +22 -24
- package/lib/HotUpdateChunk.js +0 -3
- package/lib/IgnorePlugin.js +5 -2
- package/lib/InitFragment.js +41 -29
- package/lib/InvalidDependenciesModuleWarning.js +0 -1
- package/lib/LibManifestPlugin.js +4 -6
- package/lib/LoaderOptionsPlugin.js +1 -10
- package/lib/MainTemplate.js +8 -19
- package/lib/Module.js +32 -20
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleFilenameHelpers.js +41 -24
- package/lib/ModuleGraph.js +30 -16
- package/lib/ModuleInfoHeaderPlugin.js +0 -1
- package/lib/ModuleTemplate.js +0 -2
- package/lib/ModuleTypeConstants.js +11 -1
- package/lib/MultiCompiler.js +23 -15
- package/lib/MultiWatching.js +6 -10
- package/lib/NodeStuffPlugin.js +2 -10
- package/lib/NormalModule.js +145 -88
- package/lib/NormalModuleFactory.js +59 -40
- package/lib/OptionsApply.js +1 -1
- package/lib/Parser.js +1 -1
- package/lib/ProgressPlugin.js +6 -10
- package/lib/ProvidePlugin.js +5 -7
- package/lib/RawModule.js +1 -6
- package/lib/RecordIdsPlugin.js +10 -6
- package/lib/ResolverFactory.js +0 -2
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimeModule.js +1 -3
- package/lib/RuntimePlugin.js +26 -22
- package/lib/RuntimeTemplate.js +12 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +6 -11
- package/lib/Stats.js +0 -1
- package/lib/Template.js +6 -11
- package/lib/TemplatedPathPlugin.js +2 -1
- package/lib/WatchIgnorePlugin.js +2 -3
- package/lib/Watching.js +15 -15
- package/lib/WebpackIsIncludedPlugin.js +0 -2
- package/lib/WebpackOptionsApply.js +74 -107
- package/lib/asset/AssetBytesGenerator.js +166 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +20 -34
- package/lib/asset/AssetModulesPlugin.js +34 -16
- package/lib/asset/AssetParser.js +7 -3
- package/lib/asset/AssetSourceGenerator.js +1 -1
- package/lib/asset/RawDataUrlModule.js +3 -2
- package/lib/async-modules/AsyncModuleHelpers.js +6 -4
- package/lib/buildChunkGraph.js +0 -1
- package/lib/cache/MemoryCachePlugin.js +0 -2
- package/lib/cache/MemoryWithGcCachePlugin.js +0 -2
- package/lib/cache/PackFileCacheStrategy.js +14 -1
- package/lib/cache/ResolverCachePlugin.js +9 -15
- package/lib/config/defaults.js +155 -21
- package/lib/config/normalization.js +18 -3
- package/lib/container/ContainerEntryDependency.js +0 -1
- package/lib/container/ContainerEntryModule.js +3 -7
- package/lib/container/ContainerPlugin.js +1 -2
- package/lib/container/ContainerReferencePlugin.js +0 -1
- package/lib/container/FallbackDependency.js +2 -1
- package/lib/container/FallbackModule.js +6 -7
- package/lib/container/ModuleFederationPlugin.js +0 -1
- package/lib/container/RemoteModule.js +8 -8
- package/lib/container/RemoteRuntimeModule.js +2 -2
- package/lib/css/CssGenerator.js +3 -6
- package/lib/css/CssLoadingRuntimeModule.js +6 -9
- package/lib/css/CssModulesPlugin.js +11 -13
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +1 -1
- package/lib/debug/ProfilingPlugin.js +35 -8
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
- package/lib/dependencies/AMDPlugin.js +2 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/CachedConstDependency.js +0 -4
- package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
- package/lib/dependencies/CommonJsExportsDependency.js +2 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
- package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +9 -4
- package/lib/dependencies/ContextDependencyHelpers.js +2 -2
- package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
- package/lib/dependencies/ContextElementDependency.js +22 -11
- package/lib/dependencies/CssIcssImportDependency.js +0 -2
- package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
- package/lib/dependencies/CssImportDependency.js +0 -8
- package/lib/dependencies/CssLocalIdentifierDependency.js +3 -4
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssUrlDependency.js +0 -6
- package/lib/dependencies/ExportsInfoDependency.js +7 -9
- package/lib/dependencies/ExternalModuleDependency.js +0 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
- package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
- package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
- package/lib/dependencies/HarmonyImportDependency.js +30 -14
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
- package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
- package/lib/dependencies/ImportDependency.js +18 -6
- package/lib/dependencies/ImportEagerDependency.js +2 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
- package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
- package/lib/dependencies/ImportMetaPlugin.js +2 -1
- package/lib/dependencies/ImportParserPlugin.js +288 -45
- package/lib/dependencies/ImportWeakDependency.js +2 -3
- package/lib/dependencies/JsonExportsDependency.js +0 -1
- package/lib/dependencies/LoaderDependency.js +0 -3
- package/lib/dependencies/LoaderImportDependency.js +0 -3
- package/lib/dependencies/LoaderPlugin.js +11 -5
- package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
- package/lib/dependencies/ModuleDependency.js +3 -9
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/ProvidedDependency.js +6 -8
- package/lib/dependencies/PureExpressionDependency.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/RequireIncludeDependency.js +2 -2
- package/lib/dependencies/RequireResolveDependency.js +2 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
- package/lib/dependencies/StaticExportsDependency.js +3 -5
- package/lib/dependencies/URLDependency.js +2 -7
- package/lib/dependencies/URLPlugin.js +1 -2
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
- package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
- package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
- package/lib/dependencies/WorkerDependency.js +2 -3
- package/lib/dependencies/WorkerPlugin.js +3 -9
- package/lib/dependencies/processExportInfo.js +2 -3
- package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
- package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
- package/lib/hmr/LazyCompilationPlugin.js +6 -4
- package/lib/hmr/lazyCompilationBackend.js +13 -10
- package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
- package/lib/ids/NamedChunkIdsPlugin.js +1 -6
- package/lib/ids/NamedModuleIdsPlugin.js +1 -5
- package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
- package/lib/ids/SyncModuleIdsPlugin.js +4 -3
- package/lib/index.js +8 -7
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
- package/lib/javascript/BasicEvaluatedExpression.js +13 -6
- package/lib/javascript/ChunkFormatHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
- package/lib/javascript/JavascriptGenerator.js +2 -3
- package/lib/javascript/JavascriptModulesPlugin.js +44 -21
- package/lib/javascript/JavascriptParser.js +119 -54
- package/lib/javascript/JavascriptParserHelpers.js +2 -2
- package/lib/javascript/StartupHelpers.js +2 -4
- package/lib/json/JsonData.js +1 -1
- package/lib/json/JsonGenerator.js +4 -5
- package/lib/json/JsonModulesPlugin.js +0 -3
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +0 -1
- package/lib/library/AssignLibraryPlugin.js +23 -12
- package/lib/library/EnableLibraryPlugin.js +7 -11
- package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
- package/lib/library/JsonpLibraryPlugin.js +5 -2
- package/lib/library/ModuleLibraryPlugin.js +88 -43
- package/lib/library/SystemLibraryPlugin.js +0 -1
- package/lib/library/UmdLibraryPlugin.js +12 -18
- package/lib/logging/Logger.js +12 -10
- package/lib/logging/createConsoleLogger.js +15 -14
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeWatchFileSystem.js +4 -4
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
- package/lib/node/nodeConsole.js +2 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
- package/lib/optimize/ConcatenatedModule.js +142 -100
- package/lib/optimize/InnerGraph.js +17 -11
- package/lib/optimize/InnerGraphPlugin.js +0 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
- package/lib/optimize/RuntimeChunkPlugin.js +0 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
- package/lib/optimize/SplitChunksPlugin.js +46 -40
- package/lib/performance/SizeLimitsPlugin.js +2 -1
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
- package/lib/rules/BasicMatcherRulePlugin.js +0 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
- package/lib/rules/RuleSetCompiler.js +8 -6
- package/lib/runtime/BaseUriRuntimeModule.js +2 -2
- package/lib/runtime/CompatRuntimeModule.js +0 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
- package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
- package/lib/runtime/PublicPathRuntimeModule.js +2 -2
- package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
- package/lib/runtime/SystemContextRuntimeModule.js +0 -2
- package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
- package/lib/schemes/DataUriPlugin.js +2 -28
- package/lib/schemes/FileUriPlugin.js +5 -2
- package/lib/schemes/HttpUriPlugin.js +4 -2
- package/lib/schemes/VirtualUrlPlugin.js +11 -11
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +30 -19
- package/lib/serialization/SerializerMiddleware.js +1 -3
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +3 -5
- package/lib/sharing/ConsumeSharedPlugin.js +2 -4
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
- package/lib/sharing/ProvideSharedModule.js +3 -7
- package/lib/sharing/SharePlugin.js +0 -2
- package/lib/sharing/ShareRuntimeModule.js +4 -1
- package/lib/sharing/resolveMatchedConfigs.js +14 -6
- package/lib/sharing/utils.js +0 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +178 -94
- package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
- package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
- package/lib/stats/StatsFactory.js +14 -11
- package/lib/url/URLParserPlugin.js +2 -4
- package/lib/util/ArrayHelpers.js +4 -4
- package/lib/util/AsyncQueue.js +1 -0
- package/lib/util/LazySet.js +2 -2
- package/lib/util/StackedCacheMap.js +0 -2
- package/lib/util/TupleSet.js +9 -4
- package/lib/util/URLAbsoluteSpecifier.js +0 -1
- package/lib/util/WeakTupleMap.js +1 -1
- package/lib/util/chainedImports.js +3 -1
- package/lib/util/cleverMerge.js +15 -18
- package/lib/util/comparators.js +2 -4
- package/lib/util/compileBooleanMatcher.js +11 -9
- package/lib/util/concatenate.js +1 -2
- package/lib/util/create-schema-validation.js +0 -1
- package/lib/util/dataURL.js +39 -0
- package/lib/util/deprecation.js +29 -31
- package/lib/util/deterministicGrouping.js +34 -30
- package/lib/util/extractSourceMap.js +319 -0
- package/lib/util/findGraphRoots.js +15 -5
- package/lib/util/fs.js +29 -8
- package/lib/util/semver.js +9 -8
- package/lib/util/smartGrouping.js +41 -26
- package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
- package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
- package/lib/wasm-sync/WebAssemblyParser.js +1 -4
- package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/web/JsonpTemplatePlugin.js +0 -1
- package/lib/webpack.js +21 -8
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +12 -12
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +77 -93
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +4 -0
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +5 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1129 -530
- package/SECURITY.md +0 -9
|
@@ -23,6 +23,7 @@ const Template = require("../Template");
|
|
|
23
23
|
const { DEFAULTS } = require("../config/defaults");
|
|
24
24
|
const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
|
|
25
25
|
const HarmonyImportSideEffectDependency = require("../dependencies/HarmonyImportSideEffectDependency");
|
|
26
|
+
const HarmonyImportSpecifierDependency = require("../dependencies/HarmonyImportSpecifierDependency");
|
|
26
27
|
const JavascriptParser = require("../javascript/JavascriptParser");
|
|
27
28
|
const {
|
|
28
29
|
getMakeDeferredNamespaceModeFromExportsType,
|
|
@@ -57,33 +58,31 @@ const {
|
|
|
57
58
|
/** @typedef {import("eslint-scope").Scope} Scope */
|
|
58
59
|
/** @typedef {import("eslint-scope").Variable} Variable */
|
|
59
60
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
60
|
-
/** @typedef {import("
|
|
61
|
+
/** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
61
62
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
62
63
|
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
|
63
64
|
/** @typedef {import("../Compilation")} Compilation */
|
|
64
|
-
/** @typedef {import("../Dependency")} Dependency */
|
|
65
65
|
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
|
66
|
-
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
67
66
|
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
|
68
67
|
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
|
|
69
|
-
/** @typedef {import("../ExternalModule")} ExternalModule */
|
|
70
68
|
/** @typedef {import("../Module").BuildCallback} BuildCallback */
|
|
71
69
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
70
|
+
/** @typedef {import("../Module").FileSystemDependencies} FileSystemDependencies */
|
|
72
71
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
73
72
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
|
74
73
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
|
75
74
|
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
|
75
|
+
/** @typedef {import("../Module").LibIdent} LibIdent */
|
|
76
|
+
/** @typedef {import("../Module").NameForCondition} NameForCondition */
|
|
76
77
|
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
|
77
78
|
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
|
78
79
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
79
80
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
80
81
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
|
81
82
|
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
82
|
-
/** @typedef {import("../ModuleParseError")} ModuleParseError */
|
|
83
83
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
84
84
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
85
85
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
86
|
-
/** @typedef {import("../WebpackError")} WebpackError */
|
|
87
86
|
/** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
|
|
88
87
|
/** @typedef {import("../javascript/JavascriptParser").Program} Program */
|
|
89
88
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
@@ -91,7 +90,6 @@ const {
|
|
|
91
90
|
/** @typedef {import("../util/Hash")} Hash */
|
|
92
91
|
/** @typedef {typeof import("../util/Hash")} HashConstructor */
|
|
93
92
|
/** @typedef {import("../util/concatenate").ScopeInfo} ScopeInfo */
|
|
94
|
-
/** @typedef {import("../util/concatenate").UsedNames} UsedNames */
|
|
95
93
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
96
94
|
/** @typedef {import("../util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
|
97
95
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
@@ -107,27 +105,23 @@ const {
|
|
|
107
105
|
|
|
108
106
|
// fix eslint-scope to support class properties correctly
|
|
109
107
|
// cspell:word Referencer
|
|
110
|
-
const ReferencerClass =
|
|
108
|
+
const ReferencerClass = Referencer;
|
|
111
109
|
if (!ReferencerClass.prototype.PropertyDefinition) {
|
|
112
110
|
ReferencerClass.prototype.PropertyDefinition =
|
|
113
111
|
ReferencerClass.prototype.Property;
|
|
114
112
|
}
|
|
115
113
|
|
|
116
|
-
/**
|
|
117
|
-
* @typedef {object} ReexportInfo
|
|
118
|
-
* @property {Module} module
|
|
119
|
-
* @property {string[]} export
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
114
|
/** @typedef {RawBinding | SymbolBinding} Binding */
|
|
123
115
|
|
|
116
|
+
/** @typedef {string[]} ExportName */
|
|
117
|
+
|
|
124
118
|
/**
|
|
125
119
|
* @typedef {object} RawBinding
|
|
126
120
|
* @property {ModuleInfo} info
|
|
127
121
|
* @property {string} rawName
|
|
128
122
|
* @property {string=} comment
|
|
129
|
-
* @property {
|
|
130
|
-
* @property {
|
|
123
|
+
* @property {ExportName} ids
|
|
124
|
+
* @property {ExportName} exportName
|
|
131
125
|
*/
|
|
132
126
|
|
|
133
127
|
/**
|
|
@@ -135,8 +129,8 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
|
|
|
135
129
|
* @property {ConcatenatedModuleInfo} info
|
|
136
130
|
* @property {string} name
|
|
137
131
|
* @property {string=} comment
|
|
138
|
-
* @property {
|
|
139
|
-
* @property {
|
|
132
|
+
* @property {ExportName} ids
|
|
133
|
+
* @property {ExportName} exportName
|
|
140
134
|
*/
|
|
141
135
|
|
|
142
136
|
/** @typedef {ConcatenatedModuleInfo | ExternalModuleInfo } ModuleInfo */
|
|
@@ -238,6 +232,8 @@ const moveDeferToLast = (
|
|
|
238
232
|
return -1;
|
|
239
233
|
};
|
|
240
234
|
|
|
235
|
+
const INITIAL_USED_NAMES = new Set(RESERVED_NAMES);
|
|
236
|
+
|
|
241
237
|
/**
|
|
242
238
|
* @param {Iterable<string>} iterable iterable object
|
|
243
239
|
* @returns {string} joined iterable object
|
|
@@ -265,15 +261,19 @@ const joinIterableWithComma = (iterable) => {
|
|
|
265
261
|
* @property {RuntimeSpec | boolean} runtimeCondition
|
|
266
262
|
*/
|
|
267
263
|
|
|
264
|
+
/** @typedef {Set<ConcatenatedModuleInfo>} NeededNamespaceObjects */
|
|
265
|
+
|
|
266
|
+
/** @typedef {Map<Module, ModuleInfo>} ModuleToInfoMap */
|
|
267
|
+
|
|
268
268
|
/**
|
|
269
269
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
270
270
|
* @param {ModuleInfo} info module info
|
|
271
|
-
* @param {
|
|
272
|
-
* @param {
|
|
271
|
+
* @param {ExportName} exportName exportName
|
|
272
|
+
* @param {ModuleToInfoMap} moduleToInfoMap moduleToInfoMap
|
|
273
273
|
* @param {RuntimeSpec} runtime for which runtime
|
|
274
274
|
* @param {RequestShortener} requestShortener the request shortener
|
|
275
275
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
|
276
|
-
* @param {
|
|
276
|
+
* @param {NeededNamespaceObjects} neededNamespaceObjects modules for which a namespace object should be generated
|
|
277
277
|
* @param {boolean} asCall asCall
|
|
278
278
|
* @param {boolean} depDeferred the dependency is deferred
|
|
279
279
|
* @param {boolean | undefined} strictHarmonyModule strictHarmonyModule
|
|
@@ -477,7 +477,7 @@ const getFinalBinding = (
|
|
|
477
477
|
}
|
|
478
478
|
const directExport = info.exportMap && info.exportMap.get(exportId);
|
|
479
479
|
if (directExport) {
|
|
480
|
-
const usedName = /** @type {
|
|
480
|
+
const usedName = /** @type {ExportName} */ (
|
|
481
481
|
exportsInfo.getUsedName(exportName, runtime)
|
|
482
482
|
);
|
|
483
483
|
if (!usedName) {
|
|
@@ -540,7 +540,7 @@ const getFinalBinding = (
|
|
|
540
540
|
);
|
|
541
541
|
}
|
|
542
542
|
if (info.namespaceExportSymbol) {
|
|
543
|
-
const usedName = /** @type {
|
|
543
|
+
const usedName = /** @type {ExportName} */ (
|
|
544
544
|
exportsInfo.getUsedName(exportName, runtime)
|
|
545
545
|
);
|
|
546
546
|
return {
|
|
@@ -558,7 +558,7 @@ const getFinalBinding = (
|
|
|
558
558
|
}
|
|
559
559
|
|
|
560
560
|
case "external": {
|
|
561
|
-
const used = /** @type {
|
|
561
|
+
const used = /** @type {ExportName} */ (
|
|
562
562
|
exportsInfo.getUsedName(exportName, runtime)
|
|
563
563
|
);
|
|
564
564
|
if (!used) {
|
|
@@ -588,12 +588,12 @@ const getFinalBinding = (
|
|
|
588
588
|
/**
|
|
589
589
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
590
590
|
* @param {ModuleInfo} info module info
|
|
591
|
-
* @param {
|
|
592
|
-
* @param {
|
|
591
|
+
* @param {ExportName} exportName exportName
|
|
592
|
+
* @param {ModuleToInfoMap} moduleToInfoMap moduleToInfoMap
|
|
593
593
|
* @param {RuntimeSpec} runtime for which runtime
|
|
594
594
|
* @param {RequestShortener} requestShortener the request shortener
|
|
595
595
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
|
596
|
-
* @param {
|
|
596
|
+
* @param {NeededNamespaceObjects} neededNamespaceObjects modules for which a namespace object should be generated
|
|
597
597
|
* @param {boolean} asCall asCall
|
|
598
598
|
* @param {boolean} depDeferred the dependency is deferred
|
|
599
599
|
* @param {boolean | undefined} callContext callContext
|
|
@@ -672,6 +672,8 @@ const getFinalName = (
|
|
|
672
672
|
* @property {SyncBailHook<[Partial<ConcatenatedModuleInfo>, ConcatenatedModuleInfo], boolean | void>} concatenatedModuleInfo
|
|
673
673
|
*/
|
|
674
674
|
|
|
675
|
+
/** @typedef {BuildInfo["topLevelDeclarations"]} TopLevelDeclarations */
|
|
676
|
+
|
|
675
677
|
/** @type {WeakMap<Compilation, ConcatenateModuleHooks>} */
|
|
676
678
|
const compilationHooksMap = new WeakMap();
|
|
677
679
|
|
|
@@ -747,7 +749,7 @@ class ConcatenatedModule extends Module {
|
|
|
747
749
|
this._modules = modules;
|
|
748
750
|
this._runtime = runtime;
|
|
749
751
|
this.factoryMeta = rootModule && rootModule.factoryMeta;
|
|
750
|
-
/** @type {Compilation
|
|
752
|
+
/** @type {Compilation} */
|
|
751
753
|
this.compilation = compilation;
|
|
752
754
|
}
|
|
753
755
|
|
|
@@ -792,14 +794,14 @@ class ConcatenatedModule extends Module {
|
|
|
792
794
|
|
|
793
795
|
/**
|
|
794
796
|
* @param {LibIdentOptions} options options
|
|
795
|
-
* @returns {
|
|
797
|
+
* @returns {LibIdent | null} an identifier for library inclusion
|
|
796
798
|
*/
|
|
797
799
|
libIdent(options) {
|
|
798
800
|
return this.rootModule.libIdent(options);
|
|
799
801
|
}
|
|
800
802
|
|
|
801
803
|
/**
|
|
802
|
-
* @returns {
|
|
804
|
+
* @returns {NameForCondition | null} absolute path which should be used for condition matching (usually the resource path)
|
|
803
805
|
*/
|
|
804
806
|
nameForCondition() {
|
|
805
807
|
return this.rootModule.nameForCondition();
|
|
@@ -831,13 +833,9 @@ class ConcatenatedModule extends Module {
|
|
|
831
833
|
cacheable: true,
|
|
832
834
|
moduleArgument,
|
|
833
835
|
exportsArgument,
|
|
834
|
-
/** @type {LazySet<string>} */
|
|
835
836
|
fileDependencies: new LazySet(),
|
|
836
|
-
/** @type {LazySet<string>} */
|
|
837
837
|
contextDependencies: new LazySet(),
|
|
838
|
-
/** @type {LazySet<string>} */
|
|
839
838
|
missingDependencies: new LazySet(),
|
|
840
|
-
/** @type {Set<string>} */
|
|
841
839
|
topLevelDeclarations: new Set(),
|
|
842
840
|
assets: undefined
|
|
843
841
|
};
|
|
@@ -884,7 +882,7 @@ class ConcatenatedModule extends Module {
|
|
|
884
882
|
}
|
|
885
883
|
}
|
|
886
884
|
|
|
887
|
-
const { assets, assetsInfo, topLevelDeclarations } =
|
|
885
|
+
const { assets, assetsInfo, topLevelDeclarations, needCreateRequire } =
|
|
888
886
|
/** @type {BuildInfo} */ (m.buildInfo);
|
|
889
887
|
|
|
890
888
|
const buildInfo = /** @type {BuildInfo} */ (this.buildInfo);
|
|
@@ -901,6 +899,11 @@ class ConcatenatedModule extends Module {
|
|
|
901
899
|
buildInfo.topLevelDeclarations = undefined;
|
|
902
900
|
}
|
|
903
901
|
|
|
902
|
+
// populate needCreateRequire
|
|
903
|
+
if (needCreateRequire) {
|
|
904
|
+
this.buildInfo.needCreateRequire = true;
|
|
905
|
+
}
|
|
906
|
+
|
|
904
907
|
// populate assets
|
|
905
908
|
if (assets) {
|
|
906
909
|
if (buildInfo.assets === undefined) {
|
|
@@ -950,9 +953,7 @@ class ConcatenatedModule extends Module {
|
|
|
950
953
|
const list = [];
|
|
951
954
|
/** @type {Map<Module, RuntimeSpec | true>} */
|
|
952
955
|
const existingEntries = new Map();
|
|
953
|
-
const deferEnabled =
|
|
954
|
-
/** @type {Compilation} */
|
|
955
|
-
(this.compilation).options.experiments.deferImport;
|
|
956
|
+
const deferEnabled = this.compilation.options.experiments.deferImport;
|
|
956
957
|
|
|
957
958
|
/**
|
|
958
959
|
* @param {Module} module a module
|
|
@@ -966,7 +967,7 @@ class ConcatenatedModule extends Module {
|
|
|
966
967
|
}
|
|
967
968
|
}
|
|
968
969
|
/**
|
|
969
|
-
* @type {
|
|
970
|
+
* @type {{ connection: ModuleGraphConnection, sourceOrder: number, rangeStart: number | undefined, defer?: boolean }[]}
|
|
970
971
|
*/
|
|
971
972
|
const references = connections
|
|
972
973
|
.filter((connection) => {
|
|
@@ -981,9 +982,9 @@ class ConcatenatedModule extends Module {
|
|
|
981
982
|
);
|
|
982
983
|
})
|
|
983
984
|
.map((connection) => {
|
|
984
|
-
const dep =
|
|
985
|
-
|
|
986
|
-
|
|
985
|
+
const dep =
|
|
986
|
+
/** @type {HarmonyImportDependency} */
|
|
987
|
+
(connection.dependency);
|
|
987
988
|
return {
|
|
988
989
|
connection,
|
|
989
990
|
sourceOrder: dep.sourceOrder,
|
|
@@ -1154,10 +1155,10 @@ class ConcatenatedModule extends Module {
|
|
|
1154
1155
|
}
|
|
1155
1156
|
|
|
1156
1157
|
/**
|
|
1157
|
-
* @param {
|
|
1158
|
-
* @param {
|
|
1159
|
-
* @param {
|
|
1160
|
-
* @param {
|
|
1158
|
+
* @param {FileSystemDependencies} fileDependencies set where file dependencies are added to
|
|
1159
|
+
* @param {FileSystemDependencies} contextDependencies set where context dependencies are added to
|
|
1160
|
+
* @param {FileSystemDependencies} missingDependencies set where missing dependencies are added to
|
|
1161
|
+
* @param {FileSystemDependencies} buildDependencies set where build dependencies are added to
|
|
1161
1162
|
*/
|
|
1162
1163
|
addCacheDependencies(
|
|
1163
1164
|
fileDependencies,
|
|
@@ -1188,7 +1189,7 @@ class ConcatenatedModule extends Module {
|
|
|
1188
1189
|
codeGenerationResults
|
|
1189
1190
|
}) {
|
|
1190
1191
|
const { concatenatedModuleInfo } = ConcatenatedModule.getCompilationHooks(
|
|
1191
|
-
|
|
1192
|
+
this.compilation
|
|
1192
1193
|
);
|
|
1193
1194
|
|
|
1194
1195
|
/** @type {RuntimeRequirements} */
|
|
@@ -1203,11 +1204,21 @@ class ConcatenatedModule extends Module {
|
|
|
1203
1204
|
);
|
|
1204
1205
|
|
|
1205
1206
|
// Set with modules that need a generated namespace object
|
|
1206
|
-
/** @type {
|
|
1207
|
+
/** @type {NeededNamespaceObjects} */
|
|
1207
1208
|
const neededNamespaceObjects = new Set();
|
|
1208
1209
|
|
|
1209
|
-
//
|
|
1210
|
-
const allUsedNames = new Set(
|
|
1210
|
+
// Default disallowed names
|
|
1211
|
+
const allUsedNames = new Set(INITIAL_USED_NAMES);
|
|
1212
|
+
const chunks = chunkGraph.getModuleChunks(this);
|
|
1213
|
+
|
|
1214
|
+
// Add names already used in the current chunk scope
|
|
1215
|
+
for (const chunk of chunks) {
|
|
1216
|
+
if (ConcatenationScope.chunkUsedNames.has(chunk)) {
|
|
1217
|
+
for (const name of ConcatenationScope.chunkUsedNames.get(chunk) || []) {
|
|
1218
|
+
allUsedNames.add(name);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1211
1222
|
|
|
1212
1223
|
// Generate source code and analyse scopes
|
|
1213
1224
|
// Prepare a ReplaceSource for the final source
|
|
@@ -1226,8 +1237,25 @@ class ConcatenatedModule extends Module {
|
|
|
1226
1237
|
);
|
|
1227
1238
|
}
|
|
1228
1239
|
|
|
1240
|
+
// Record the names registered by the current ConcatenatedModule into the chunk scope
|
|
1241
|
+
if (INITIAL_USED_NAMES.size !== allUsedNames.size) {
|
|
1242
|
+
for (const name of allUsedNames) {
|
|
1243
|
+
if (INITIAL_USED_NAMES.has(name)) continue;
|
|
1244
|
+
|
|
1245
|
+
for (const chunk of chunks) {
|
|
1246
|
+
if (!ConcatenationScope.chunkUsedNames.has(chunk)) {
|
|
1247
|
+
ConcatenationScope.chunkUsedNames.set(chunk, new Set([name]));
|
|
1248
|
+
} else {
|
|
1249
|
+
/** @type {Set<string>} */ (
|
|
1250
|
+
ConcatenationScope.chunkUsedNames.get(chunk)
|
|
1251
|
+
).add(name);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1229
1257
|
// Updated Top level declarations are created by renaming
|
|
1230
|
-
/** @type {
|
|
1258
|
+
/** @type {TopLevelDeclarations} */
|
|
1231
1259
|
const topLevelDeclarations = new Set();
|
|
1232
1260
|
|
|
1233
1261
|
// List of additional names in scope for module references
|
|
@@ -1683,9 +1711,11 @@ class ConcatenatedModule extends Module {
|
|
|
1683
1711
|
|
|
1684
1712
|
// add harmony compatibility flag (must be first because of possible circular dependencies)
|
|
1685
1713
|
let shouldAddHarmonyFlag = false;
|
|
1714
|
+
const rootExportsInfo = moduleGraph.getExportsInfo(this);
|
|
1686
1715
|
if (
|
|
1687
|
-
|
|
1688
|
-
|
|
1716
|
+
rootExportsInfo.otherExportsInfo.getUsed(runtime) !== UsageState.Unused ||
|
|
1717
|
+
rootExportsInfo.getReadOnlyExportInfo("__esModule").getUsed(runtime) !==
|
|
1718
|
+
UsageState.Unused
|
|
1689
1719
|
) {
|
|
1690
1720
|
shouldAddHarmonyFlag = true;
|
|
1691
1721
|
}
|
|
@@ -1702,10 +1732,7 @@ class ConcatenatedModule extends Module {
|
|
|
1702
1732
|
}
|
|
1703
1733
|
|
|
1704
1734
|
const { onDemandExportsGeneration } =
|
|
1705
|
-
ConcatenatedModule.getCompilationHooks(
|
|
1706
|
-
/** @type {Compilation} */
|
|
1707
|
-
(this.compilation)
|
|
1708
|
-
);
|
|
1735
|
+
ConcatenatedModule.getCompilationHooks(this.compilation);
|
|
1709
1736
|
|
|
1710
1737
|
runtimeRequirements.add(RuntimeGlobals.exports);
|
|
1711
1738
|
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
|
|
@@ -1806,13 +1833,30 @@ ${defineGetters}`
|
|
|
1806
1833
|
if (!source) continue;
|
|
1807
1834
|
result.add(source);
|
|
1808
1835
|
}
|
|
1836
|
+
|
|
1837
|
+
if (info.type === "external" && info.deferred) {
|
|
1838
|
+
const moduleId = JSON.stringify(chunkGraph.getModuleId(info.module));
|
|
1839
|
+
const loader = getOptimizedDeferredModule(
|
|
1840
|
+
runtimeTemplate,
|
|
1841
|
+
info.module.getExportsType(
|
|
1842
|
+
moduleGraph,
|
|
1843
|
+
/** @type {BuildMeta} */
|
|
1844
|
+
(this.rootModule.buildMeta).strictHarmonyModule
|
|
1845
|
+
),
|
|
1846
|
+
moduleId,
|
|
1847
|
+
// an async module will opt-out of the concat module optimization.
|
|
1848
|
+
[]
|
|
1849
|
+
);
|
|
1850
|
+
runtimeRequirements.add(RuntimeGlobals.require);
|
|
1851
|
+
result.add(
|
|
1852
|
+
`\n// DEFERRED EXTERNAL MODULE: ${info.module.readableIdentifier(requestShortener)}\nvar ${info.deferredName} = ${loader};`
|
|
1853
|
+
);
|
|
1854
|
+
}
|
|
1809
1855
|
}
|
|
1810
1856
|
|
|
1811
1857
|
/** @type {InitFragment<ChunkRenderContext>[]} */
|
|
1812
1858
|
const chunkInitFragments = [];
|
|
1813
|
-
const deferEnabled =
|
|
1814
|
-
/** @type {Compilation} */
|
|
1815
|
-
(this.compilation).options.experiments.deferImport;
|
|
1859
|
+
const deferEnabled = this.compilation.options.experiments.deferImport;
|
|
1816
1860
|
|
|
1817
1861
|
// evaluate modules in order
|
|
1818
1862
|
for (const rawInfo of modulesWithInfo) {
|
|
@@ -1830,11 +1874,20 @@ ${defineGetters}`
|
|
|
1830
1874
|
if (deferEnabled) {
|
|
1831
1875
|
for (const dep of info.module.dependencies) {
|
|
1832
1876
|
if (
|
|
1833
|
-
!dep.defer &&
|
|
1834
|
-
dep instanceof HarmonyImportSideEffectDependency
|
|
1877
|
+
!(/** @type {HarmonyImportDependency} */ (dep).defer) &&
|
|
1878
|
+
(dep instanceof HarmonyImportSideEffectDependency ||
|
|
1879
|
+
dep instanceof HarmonyImportSpecifierDependency)
|
|
1835
1880
|
) {
|
|
1836
1881
|
const referredModule = moduleGraph.getModule(dep);
|
|
1837
|
-
if (!referredModule)
|
|
1882
|
+
if (!referredModule) {
|
|
1883
|
+
if (dep instanceof HarmonyImportSideEffectDependency) {
|
|
1884
|
+
continue;
|
|
1885
|
+
} else {
|
|
1886
|
+
throw new Error(
|
|
1887
|
+
"Deferred module used, but no module in the graph."
|
|
1888
|
+
);
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1838
1891
|
if (moduleGraph.isDeferred(referredModule)) {
|
|
1839
1892
|
const deferredModuleInfo = /** @type {ExternalModuleInfo} */ (
|
|
1840
1893
|
modulesWithInfo.find(
|
|
@@ -1863,41 +1916,30 @@ ${defineGetters}`
|
|
|
1863
1916
|
break;
|
|
1864
1917
|
}
|
|
1865
1918
|
case "external": {
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
const
|
|
1888
|
-
|
|
1889
|
-
info.module.getExportsType(
|
|
1890
|
-
moduleGraph,
|
|
1891
|
-
/** @type {BuildMeta} */
|
|
1892
|
-
(this.rootModule.buildMeta).strictHarmonyModule
|
|
1893
|
-
),
|
|
1894
|
-
moduleId,
|
|
1895
|
-
// an async module will opt-out of the concat module optimization.
|
|
1896
|
-
[]
|
|
1919
|
+
// deferred case is handled in the "const info of modulesWithInfo" loop above
|
|
1920
|
+
if (!info.deferred) {
|
|
1921
|
+
result.add(
|
|
1922
|
+
`\n// EXTERNAL MODULE: ${info.module.readableIdentifier(
|
|
1923
|
+
requestShortener
|
|
1924
|
+
)}\n`
|
|
1925
|
+
);
|
|
1926
|
+
runtimeRequirements.add(RuntimeGlobals.require);
|
|
1927
|
+
const { runtimeCondition } =
|
|
1928
|
+
/** @type {ExternalModuleInfo | ReferenceToModuleInfo} */
|
|
1929
|
+
(rawInfo);
|
|
1930
|
+
const condition = runtimeTemplate.runtimeConditionExpression({
|
|
1931
|
+
chunkGraph,
|
|
1932
|
+
runtimeCondition,
|
|
1933
|
+
runtime,
|
|
1934
|
+
runtimeRequirements
|
|
1935
|
+
});
|
|
1936
|
+
if (condition !== "true") {
|
|
1937
|
+
isConditional = true;
|
|
1938
|
+
result.add(`if (${condition}) {\n`);
|
|
1939
|
+
}
|
|
1940
|
+
const moduleId = JSON.stringify(
|
|
1941
|
+
chunkGraph.getModuleId(info.module)
|
|
1897
1942
|
);
|
|
1898
|
-
result.add(`var ${info.deferredName} = ${loader};`);
|
|
1899
|
-
name = info.deferredName;
|
|
1900
|
-
} else {
|
|
1901
1943
|
result.add(`var ${info.name} = __webpack_require__(${moduleId});`);
|
|
1902
1944
|
name = info.name;
|
|
1903
1945
|
}
|
|
@@ -1959,7 +2001,7 @@ ${defineGetters}`
|
|
|
1959
2001
|
}
|
|
1960
2002
|
|
|
1961
2003
|
/**
|
|
1962
|
-
* @param {
|
|
2004
|
+
* @param {ModuleToInfoMap} modulesMap modulesMap
|
|
1963
2005
|
* @param {ModuleInfo} info info
|
|
1964
2006
|
* @param {DependencyTemplates} dependencyTemplates dependencyTemplates
|
|
1965
2007
|
* @param {RuntimeTemplate} runtimeTemplate runtimeTemplate
|
|
@@ -2061,7 +2103,7 @@ ${defineGetters}`
|
|
|
2061
2103
|
/**
|
|
2062
2104
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
2063
2105
|
* @param {RuntimeSpec} runtime the runtime
|
|
2064
|
-
* @returns {[ModuleInfoOrReference[],
|
|
2106
|
+
* @returns {[ModuleInfoOrReference[], ModuleToInfoMap]} module info items
|
|
2065
2107
|
*/
|
|
2066
2108
|
_getModulesWithInfo(moduleGraph, runtime) {
|
|
2067
2109
|
const orderedConcatenationList = this._createConcatenationList(
|
|
@@ -2070,7 +2112,7 @@ ${defineGetters}`
|
|
|
2070
2112
|
runtime,
|
|
2071
2113
|
moduleGraph
|
|
2072
2114
|
);
|
|
2073
|
-
/** @type {
|
|
2115
|
+
/** @type {ModuleToInfoMap} */
|
|
2074
2116
|
const map = new Map();
|
|
2075
2117
|
const list = orderedConcatenationList.map((info, index) => {
|
|
2076
2118
|
let item = map.get(info.module);
|
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
const { UsageState } = require("../ExportsInfo");
|
|
9
9
|
const JavascriptParser = require("../javascript/JavascriptParser");
|
|
10
10
|
|
|
11
|
-
/** @typedef {import("estree").Node} AnyNode */
|
|
12
11
|
/** @typedef {import("../Dependency")} Dependency */
|
|
13
12
|
/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
|
|
14
13
|
/** @typedef {import("../Module")} Module */
|
|
15
14
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
16
|
-
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
|
17
|
-
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
18
15
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
|
19
16
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
20
17
|
|
|
21
|
-
/** @typedef {
|
|
18
|
+
/** @typedef {Set<string | TopLevelSymbol>} InnerGraphValueSet */
|
|
19
|
+
/** @typedef {InnerGraphValueSet | true} InnerGraphValue */
|
|
20
|
+
/** @typedef {TopLevelSymbol | null} InnerGraphKey */
|
|
21
|
+
/** @typedef {Map<InnerGraphKey, InnerGraphValue | undefined>} InnerGraph */
|
|
22
22
|
/** @typedef {(value: boolean | Set<string> | undefined) => void} UsageCallback */
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -28,7 +28,7 @@ const JavascriptParser = require("../javascript/JavascriptParser");
|
|
|
28
28
|
* @property {Map<TopLevelSymbol, Set<UsageCallback>>} usageCallbackMap
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
/** @typedef {false|StateObject} State */
|
|
31
|
+
/** @typedef {false | StateObject} State */
|
|
32
32
|
|
|
33
33
|
class TopLevelSymbol {
|
|
34
34
|
/**
|
|
@@ -56,7 +56,7 @@ function getState(parserState) {
|
|
|
56
56
|
/**
|
|
57
57
|
* @param {ParserState} state parser state
|
|
58
58
|
* @param {TopLevelSymbol | null} symbol the symbol, or null for all symbols
|
|
59
|
-
* @param {
|
|
59
|
+
* @param {Usage} usage usage data
|
|
60
60
|
* @returns {void}
|
|
61
61
|
*/
|
|
62
62
|
module.exports.addUsage = (state, symbol, usage) => {
|
|
@@ -75,10 +75,12 @@ module.exports.addUsage = (state, symbol, usage) => {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
+
/** @typedef {string | TopLevelSymbol | true} Usage */
|
|
79
|
+
|
|
78
80
|
/**
|
|
79
81
|
* @param {JavascriptParser} parser the parser
|
|
80
82
|
* @param {string} name name of variable
|
|
81
|
-
* @param {
|
|
83
|
+
* @param {Usage} usage usage data
|
|
82
84
|
* @returns {void}
|
|
83
85
|
*/
|
|
84
86
|
module.exports.addVariableUsage = (parser, name, usage) => {
|
|
@@ -115,9 +117,11 @@ module.exports.enable = (parserState) => {
|
|
|
115
117
|
});
|
|
116
118
|
};
|
|
117
119
|
|
|
120
|
+
/** @typedef {Set<string> | boolean} UsedByExports */
|
|
121
|
+
|
|
118
122
|
/**
|
|
119
123
|
* @param {Dependency} dependency the dependency
|
|
120
|
-
* @param {
|
|
124
|
+
* @param {UsedByExports | undefined} usedByExports usedByExports info
|
|
121
125
|
* @param {ModuleGraph} moduleGraph moduleGraph
|
|
122
126
|
* @returns {null | false | GetConditionFn} function to determine if the connection is active
|
|
123
127
|
*/
|
|
@@ -146,7 +150,7 @@ module.exports.getDependencyUsedByExportsCondition = (
|
|
|
146
150
|
|
|
147
151
|
/**
|
|
148
152
|
* @param {ParserState} state parser state
|
|
149
|
-
* @returns {TopLevelSymbol|void} usage data
|
|
153
|
+
* @returns {TopLevelSymbol | void} usage data
|
|
150
154
|
*/
|
|
151
155
|
module.exports.getTopLevelSymbol = (state) => {
|
|
152
156
|
const innerGraphState = getState(state);
|
|
@@ -168,17 +172,19 @@ module.exports.inferDependencyUsage = (state) => {
|
|
|
168
172
|
}
|
|
169
173
|
|
|
170
174
|
const { innerGraph, usageCallbackMap } = innerGraphState;
|
|
175
|
+
/** @type {Map<InnerGraphKey, InnerGraphValueSet | undefined>} */
|
|
171
176
|
const processed = new Map();
|
|
172
177
|
// flatten graph to terminal nodes (string, undefined or true)
|
|
173
178
|
const nonTerminal = new Set(innerGraph.keys());
|
|
174
179
|
while (nonTerminal.size > 0) {
|
|
175
180
|
for (const key of nonTerminal) {
|
|
176
|
-
/** @type {
|
|
181
|
+
/** @type {InnerGraphValue} */
|
|
177
182
|
let newSet = new Set();
|
|
178
183
|
let isTerminal = true;
|
|
179
184
|
const value = innerGraph.get(key);
|
|
180
185
|
let alreadyProcessed = processed.get(key);
|
|
181
186
|
if (alreadyProcessed === undefined) {
|
|
187
|
+
/** @type {InnerGraphValueSet} */
|
|
182
188
|
alreadyProcessed = new Set();
|
|
183
189
|
processed.set(key, alreadyProcessed);
|
|
184
190
|
}
|
|
@@ -254,7 +260,7 @@ module.exports.inferDependencyUsage = (state) => {
|
|
|
254
260
|
|
|
255
261
|
/**
|
|
256
262
|
* @param {Dependency} dependency the dependency
|
|
257
|
-
* @param {
|
|
263
|
+
* @param {UsedByExports | undefined} usedByExports usedByExports info
|
|
258
264
|
* @param {ModuleGraph} moduleGraph moduleGraph
|
|
259
265
|
* @param {RuntimeSpec} runtime runtime
|
|
260
266
|
* @returns {boolean} false, when unused. Otherwise true
|
|
@@ -21,12 +21,9 @@ const InnerGraph = require("./InnerGraph");
|
|
|
21
21
|
/** @typedef {import("estree").VariableDeclarator} VariableDeclarator */
|
|
22
22
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
23
23
|
/** @typedef {import("../Compiler")} Compiler */
|
|
24
|
-
/** @typedef {import("../Dependency")} Dependency */
|
|
25
24
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
|
26
|
-
/** @typedef {import("../dependencies/HarmonyImportSpecifierDependency")} HarmonyImportSpecifierDependency */
|
|
27
25
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|
28
26
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
29
|
-
/** @typedef {import("./InnerGraph").InnerGraph} InnerGraph */
|
|
30
27
|
/** @typedef {import("./InnerGraph").TopLevelSymbol} TopLevelSymbol */
|
|
31
28
|
|
|
32
29
|
const { topLevelSymbolTag } = InnerGraph;
|
|
@@ -390,7 +390,6 @@ class ModuleConcatenationPlugin {
|
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
// Create a new ConcatenatedModule
|
|
393
|
-
ConcatenatedModule.getCompilationHooks(compilation);
|
|
394
393
|
const newModule = ConcatenatedModule.create(
|
|
395
394
|
rootModule,
|
|
396
395
|
modules,
|
|
@@ -402,7 +401,7 @@ class ModuleConcatenationPlugin {
|
|
|
402
401
|
|
|
403
402
|
const build = () => {
|
|
404
403
|
newModule.build(
|
|
405
|
-
|
|
404
|
+
compilation.options,
|
|
406
405
|
compilation,
|
|
407
406
|
/** @type {EXPECTED_ANY} */
|
|
408
407
|
(null),
|
|
@@ -667,7 +666,7 @@ class ModuleConcatenationPlugin {
|
|
|
667
666
|
}
|
|
668
667
|
}
|
|
669
668
|
|
|
670
|
-
/** @type {Map<Module,
|
|
669
|
+
/** @type {Map<Module, ReadonlyArray<ModuleGraph.ModuleGraphConnection>>} */
|
|
671
670
|
const incomingConnectionsFromModules = new Map();
|
|
672
671
|
for (const [originModule, connections] of incomingConnections) {
|
|
673
672
|
if (originModule) {
|
|
@@ -725,7 +724,7 @@ class ModuleConcatenationPlugin {
|
|
|
725
724
|
return problem;
|
|
726
725
|
}
|
|
727
726
|
|
|
728
|
-
/** @type {Map<Module,
|
|
727
|
+
/** @type {Map<Module, ReadonlyArray<ModuleGraph.ModuleGraphConnection>>} */
|
|
729
728
|
const nonHarmonyConnections = new Map();
|
|
730
729
|
for (const [originModule, connections] of incomingConnectionsFromModules) {
|
|
731
730
|
const selected = connections.filter(
|