@depup/webpack 5.105.4-depup.37

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.
Files changed (709) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +38 -0
  3. package/bin/webpack.js +196 -0
  4. package/hot/dev-server.js +90 -0
  5. package/hot/emitter-event-target.js +7 -0
  6. package/hot/emitter.js +2 -0
  7. package/hot/lazy-compilation-node.js +66 -0
  8. package/hot/lazy-compilation-universal.js +18 -0
  9. package/hot/lazy-compilation-web.js +93 -0
  10. package/hot/load-http.js +7 -0
  11. package/hot/log-apply-result.js +49 -0
  12. package/hot/log.js +78 -0
  13. package/hot/only-dev-server.js +118 -0
  14. package/hot/poll.js +41 -0
  15. package/hot/signal.js +66 -0
  16. package/lib/APIPlugin.js +392 -0
  17. package/lib/AbstractMethodError.js +56 -0
  18. package/lib/AsyncDependenciesBlock.js +128 -0
  19. package/lib/AsyncDependencyToInitialChunkError.js +34 -0
  20. package/lib/AutomaticPrefetchPlugin.js +66 -0
  21. package/lib/BannerPlugin.js +138 -0
  22. package/lib/Cache.js +168 -0
  23. package/lib/CacheFacade.js +349 -0
  24. package/lib/CaseSensitiveModulesWarning.js +72 -0
  25. package/lib/Chunk.js +899 -0
  26. package/lib/ChunkGraph.js +1968 -0
  27. package/lib/ChunkGroup.js +615 -0
  28. package/lib/ChunkRenderError.js +38 -0
  29. package/lib/ChunkTemplate.js +181 -0
  30. package/lib/CleanPlugin.js +495 -0
  31. package/lib/CodeGenerationError.js +35 -0
  32. package/lib/CodeGenerationResults.js +167 -0
  33. package/lib/CommentCompilationWarning.js +33 -0
  34. package/lib/CompatibilityPlugin.js +240 -0
  35. package/lib/Compilation.js +5876 -0
  36. package/lib/Compiler.js +1413 -0
  37. package/lib/ConcatenationScope.js +181 -0
  38. package/lib/ConcurrentCompilationError.js +18 -0
  39. package/lib/ConditionalInitFragment.js +120 -0
  40. package/lib/ConstPlugin.js +567 -0
  41. package/lib/ContextExclusionPlugin.js +33 -0
  42. package/lib/ContextModule.js +1411 -0
  43. package/lib/ContextModuleFactory.js +514 -0
  44. package/lib/ContextReplacementPlugin.js +227 -0
  45. package/lib/CssModule.js +179 -0
  46. package/lib/DefinePlugin.js +878 -0
  47. package/lib/DelegatedModule.js +279 -0
  48. package/lib/DelegatedModuleFactoryPlugin.js +116 -0
  49. package/lib/DelegatedPlugin.js +49 -0
  50. package/lib/DependenciesBlock.js +120 -0
  51. package/lib/Dependency.js +390 -0
  52. package/lib/DependencyTemplate.js +71 -0
  53. package/lib/DependencyTemplates.js +67 -0
  54. package/lib/DllEntryPlugin.js +76 -0
  55. package/lib/DllModule.js +175 -0
  56. package/lib/DllModuleFactory.js +38 -0
  57. package/lib/DllPlugin.js +73 -0
  58. package/lib/DllReferencePlugin.js +189 -0
  59. package/lib/DotenvPlugin.js +468 -0
  60. package/lib/DynamicEntryPlugin.js +93 -0
  61. package/lib/EntryOptionPlugin.js +98 -0
  62. package/lib/EntryPlugin.js +72 -0
  63. package/lib/Entrypoint.js +120 -0
  64. package/lib/EnvironmentNotSupportAsyncWarning.js +51 -0
  65. package/lib/EnvironmentPlugin.js +74 -0
  66. package/lib/ErrorHelpers.js +100 -0
  67. package/lib/EvalDevToolModulePlugin.js +135 -0
  68. package/lib/EvalSourceMapDevToolPlugin.js +252 -0
  69. package/lib/ExportsInfo.js +1663 -0
  70. package/lib/ExportsInfoApiPlugin.js +87 -0
  71. package/lib/ExternalModule.js +1169 -0
  72. package/lib/ExternalModuleFactoryPlugin.js +370 -0
  73. package/lib/ExternalsPlugin.js +93 -0
  74. package/lib/FalseIIFEUmdWarning.js +20 -0
  75. package/lib/FileSystemInfo.js +4131 -0
  76. package/lib/FlagAllModulesAsUsedPlugin.js +55 -0
  77. package/lib/FlagDependencyExportsPlugin.js +437 -0
  78. package/lib/FlagDependencyUsagePlugin.js +348 -0
  79. package/lib/FlagEntryExportAsUsedPlugin.js +56 -0
  80. package/lib/Generator.js +188 -0
  81. package/lib/GraphHelpers.js +46 -0
  82. package/lib/HarmonyLinkingError.js +17 -0
  83. package/lib/HookWebpackError.js +121 -0
  84. package/lib/HotModuleReplacementPlugin.js +930 -0
  85. package/lib/HotUpdateChunk.js +16 -0
  86. package/lib/IgnoreErrorModuleFactory.js +39 -0
  87. package/lib/IgnorePlugin.js +105 -0
  88. package/lib/IgnoreWarningsPlugin.js +41 -0
  89. package/lib/InitFragment.js +204 -0
  90. package/lib/InvalidDependenciesModuleWarning.js +44 -0
  91. package/lib/JavascriptMetaInfoPlugin.js +78 -0
  92. package/lib/LibManifestPlugin.js +144 -0
  93. package/lib/LibraryTemplatePlugin.js +48 -0
  94. package/lib/LoaderOptionsPlugin.js +81 -0
  95. package/lib/LoaderTargetPlugin.js +39 -0
  96. package/lib/MainTemplate.js +371 -0
  97. package/lib/ManifestPlugin.js +242 -0
  98. package/lib/Module.js +1319 -0
  99. package/lib/ModuleBuildError.js +83 -0
  100. package/lib/ModuleDependencyError.js +44 -0
  101. package/lib/ModuleDependencyWarning.js +49 -0
  102. package/lib/ModuleError.js +69 -0
  103. package/lib/ModuleFactory.js +57 -0
  104. package/lib/ModuleFilenameHelpers.js +388 -0
  105. package/lib/ModuleGraph.js +1024 -0
  106. package/lib/ModuleGraphConnection.js +199 -0
  107. package/lib/ModuleHashingError.js +31 -0
  108. package/lib/ModuleInfoHeaderPlugin.js +318 -0
  109. package/lib/ModuleNotFoundError.js +90 -0
  110. package/lib/ModuleParseError.js +125 -0
  111. package/lib/ModuleProfile.js +108 -0
  112. package/lib/ModuleRestoreError.js +46 -0
  113. package/lib/ModuleSourceTypeConstants.js +179 -0
  114. package/lib/ModuleStoreError.js +45 -0
  115. package/lib/ModuleTemplate.js +173 -0
  116. package/lib/ModuleTypeConstants.js +190 -0
  117. package/lib/ModuleWarning.js +68 -0
  118. package/lib/MultiCompiler.js +678 -0
  119. package/lib/MultiStats.js +213 -0
  120. package/lib/MultiWatching.js +77 -0
  121. package/lib/NoEmitOnErrorsPlugin.js +30 -0
  122. package/lib/NoModeWarning.js +23 -0
  123. package/lib/NodeStuffInWebError.js +35 -0
  124. package/lib/NodeStuffPlugin.js +587 -0
  125. package/lib/NormalModule.js +1798 -0
  126. package/lib/NormalModuleFactory.js +1455 -0
  127. package/lib/NormalModuleReplacementPlugin.js +75 -0
  128. package/lib/NullFactory.js +24 -0
  129. package/lib/OptimizationStages.js +10 -0
  130. package/lib/OptionsApply.js +24 -0
  131. package/lib/Parser.js +40 -0
  132. package/lib/PlatformPlugin.js +41 -0
  133. package/lib/PrefetchPlugin.js +56 -0
  134. package/lib/ProgressPlugin.js +712 -0
  135. package/lib/ProvidePlugin.js +121 -0
  136. package/lib/RawModule.js +180 -0
  137. package/lib/RecordIdsPlugin.js +216 -0
  138. package/lib/RequestShortener.js +36 -0
  139. package/lib/RequireJsStuffPlugin.js +84 -0
  140. package/lib/ResolverFactory.js +156 -0
  141. package/lib/RuntimeGlobals.js +450 -0
  142. package/lib/RuntimeModule.js +242 -0
  143. package/lib/RuntimePlugin.js +547 -0
  144. package/lib/RuntimeTemplate.js +1288 -0
  145. package/lib/SelfModuleFactory.js +33 -0
  146. package/lib/SingleEntryPlugin.js +8 -0
  147. package/lib/SizeFormatHelpers.js +25 -0
  148. package/lib/SourceMapDevToolModuleOptionsPlugin.js +52 -0
  149. package/lib/SourceMapDevToolPlugin.js +646 -0
  150. package/lib/Stats.js +89 -0
  151. package/lib/Template.js +427 -0
  152. package/lib/TemplatedPathPlugin.js +400 -0
  153. package/lib/UnhandledSchemeError.js +34 -0
  154. package/lib/UnsupportedFeatureWarning.js +35 -0
  155. package/lib/UseStrictPlugin.js +81 -0
  156. package/lib/WarnCaseSensitiveModulesPlugin.js +64 -0
  157. package/lib/WarnDeprecatedOptionPlugin.js +60 -0
  158. package/lib/WarnNoModeSetPlugin.js +27 -0
  159. package/lib/WatchIgnorePlugin.js +155 -0
  160. package/lib/Watching.js +531 -0
  161. package/lib/WebpackError.js +81 -0
  162. package/lib/WebpackIsIncludedPlugin.js +93 -0
  163. package/lib/WebpackOptionsApply.js +941 -0
  164. package/lib/WebpackOptionsDefaulter.js +26 -0
  165. package/lib/asset/AssetBytesGenerator.js +172 -0
  166. package/lib/asset/AssetBytesParser.js +37 -0
  167. package/lib/asset/AssetGenerator.js +816 -0
  168. package/lib/asset/AssetModulesPlugin.js +358 -0
  169. package/lib/asset/AssetParser.js +73 -0
  170. package/lib/asset/AssetSourceGenerator.js +171 -0
  171. package/lib/asset/AssetSourceParser.js +37 -0
  172. package/lib/asset/RawDataUrlModule.js +179 -0
  173. package/lib/async-modules/AsyncModuleHelpers.js +52 -0
  174. package/lib/async-modules/AwaitDependenciesInitFragment.js +90 -0
  175. package/lib/async-modules/InferAsyncModulesPlugin.js +54 -0
  176. package/lib/buildChunkGraph.js +1392 -0
  177. package/lib/cache/AddBuildDependenciesPlugin.js +32 -0
  178. package/lib/cache/AddManagedPathsPlugin.js +40 -0
  179. package/lib/cache/IdleFileCachePlugin.js +242 -0
  180. package/lib/cache/MemoryCachePlugin.js +57 -0
  181. package/lib/cache/MemoryWithGcCachePlugin.js +142 -0
  182. package/lib/cache/PackFileCacheStrategy.js +1600 -0
  183. package/lib/cache/ResolverCachePlugin.js +450 -0
  184. package/lib/cache/getLazyHashedEtag.js +91 -0
  185. package/lib/cache/mergeEtags.js +71 -0
  186. package/lib/cli.js +859 -0
  187. package/lib/config/browserslistTargetHandler.js +388 -0
  188. package/lib/config/defaults.js +2086 -0
  189. package/lib/config/normalization.js +681 -0
  190. package/lib/config/target.js +389 -0
  191. package/lib/container/ContainerEntryDependency.js +50 -0
  192. package/lib/container/ContainerEntryModule.js +303 -0
  193. package/lib/container/ContainerEntryModuleFactory.js +27 -0
  194. package/lib/container/ContainerExposedDependency.js +62 -0
  195. package/lib/container/ContainerPlugin.js +118 -0
  196. package/lib/container/ContainerReferencePlugin.js +139 -0
  197. package/lib/container/FallbackDependency.js +66 -0
  198. package/lib/container/FallbackItemDependency.js +34 -0
  199. package/lib/container/FallbackModule.js +193 -0
  200. package/lib/container/FallbackModuleFactory.js +27 -0
  201. package/lib/container/HoistContainerReferencesPlugin.js +256 -0
  202. package/lib/container/ModuleFederationPlugin.js +131 -0
  203. package/lib/container/RemoteModule.js +225 -0
  204. package/lib/container/RemoteRuntimeModule.js +144 -0
  205. package/lib/container/RemoteToExternalDependency.js +33 -0
  206. package/lib/container/options.js +105 -0
  207. package/lib/css/CssGenerator.js +587 -0
  208. package/lib/css/CssLoadingRuntimeModule.js +513 -0
  209. package/lib/css/CssMergeStyleSheetsRuntimeModule.js +56 -0
  210. package/lib/css/CssModulesPlugin.js +939 -0
  211. package/lib/css/CssParser.js +2621 -0
  212. package/lib/css/walkCssTokens.js +1740 -0
  213. package/lib/debug/ProfilingPlugin.js +589 -0
  214. package/lib/dependencies/AMDDefineDependency.js +267 -0
  215. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +504 -0
  216. package/lib/dependencies/AMDPlugin.js +243 -0
  217. package/lib/dependencies/AMDRequireArrayDependency.js +124 -0
  218. package/lib/dependencies/AMDRequireContextDependency.js +69 -0
  219. package/lib/dependencies/AMDRequireDependenciesBlock.js +28 -0
  220. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +425 -0
  221. package/lib/dependencies/AMDRequireDependency.js +189 -0
  222. package/lib/dependencies/AMDRequireItemDependency.js +41 -0
  223. package/lib/dependencies/AMDRuntimeModules.js +50 -0
  224. package/lib/dependencies/CachedConstDependency.js +135 -0
  225. package/lib/dependencies/CommonJsDependencyHelpers.js +65 -0
  226. package/lib/dependencies/CommonJsExportRequireDependency.js +416 -0
  227. package/lib/dependencies/CommonJsExportsDependency.js +184 -0
  228. package/lib/dependencies/CommonJsExportsParserPlugin.js +425 -0
  229. package/lib/dependencies/CommonJsFullRequireDependency.js +162 -0
  230. package/lib/dependencies/CommonJsImportsParserPlugin.js +611 -0
  231. package/lib/dependencies/CommonJsPlugin.js +316 -0
  232. package/lib/dependencies/CommonJsRequireContextDependency.js +73 -0
  233. package/lib/dependencies/CommonJsRequireDependency.js +42 -0
  234. package/lib/dependencies/CommonJsSelfReferenceDependency.js +156 -0
  235. package/lib/dependencies/ConstDependency.js +118 -0
  236. package/lib/dependencies/ContextDependency.js +183 -0
  237. package/lib/dependencies/ContextDependencyHelpers.js +277 -0
  238. package/lib/dependencies/ContextDependencyTemplateAsId.js +63 -0
  239. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +62 -0
  240. package/lib/dependencies/ContextElementDependency.js +147 -0
  241. package/lib/dependencies/CreateRequireParserPlugin.js +356 -0
  242. package/lib/dependencies/CreateScriptUrlDependency.js +75 -0
  243. package/lib/dependencies/CriticalDependencyWarning.js +29 -0
  244. package/lib/dependencies/CssIcssExportDependency.js +539 -0
  245. package/lib/dependencies/CssIcssImportDependency.js +183 -0
  246. package/lib/dependencies/CssIcssSymbolDependency.js +131 -0
  247. package/lib/dependencies/CssImportDependency.js +120 -0
  248. package/lib/dependencies/CssUrlDependency.js +189 -0
  249. package/lib/dependencies/DelegatedSourceDependency.js +33 -0
  250. package/lib/dependencies/DllEntryDependency.js +61 -0
  251. package/lib/dependencies/DynamicExports.js +73 -0
  252. package/lib/dependencies/EntryDependency.js +30 -0
  253. package/lib/dependencies/ExportsInfoDependency.js +161 -0
  254. package/lib/dependencies/ExternalModuleDependency.js +109 -0
  255. package/lib/dependencies/ExternalModuleInitFragment.js +137 -0
  256. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +87 -0
  257. package/lib/dependencies/HarmonyAcceptDependency.js +237 -0
  258. package/lib/dependencies/HarmonyAcceptImportDependency.js +37 -0
  259. package/lib/dependencies/HarmonyCompatibilityDependency.js +91 -0
  260. package/lib/dependencies/HarmonyDetectionParserPlugin.js +103 -0
  261. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +165 -0
  262. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +254 -0
  263. package/lib/dependencies/HarmonyExportExpressionDependency.js +211 -0
  264. package/lib/dependencies/HarmonyExportHeaderDependency.js +78 -0
  265. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +1494 -0
  266. package/lib/dependencies/HarmonyExportInitFragment.js +191 -0
  267. package/lib/dependencies/HarmonyExportSpecifierDependency.js +127 -0
  268. package/lib/dependencies/HarmonyExports.js +46 -0
  269. package/lib/dependencies/HarmonyImportDependency.js +459 -0
  270. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +576 -0
  271. package/lib/dependencies/HarmonyImportSideEffectDependency.js +91 -0
  272. package/lib/dependencies/HarmonyImportSpecifierDependency.js +514 -0
  273. package/lib/dependencies/HarmonyModulesPlugin.js +158 -0
  274. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +39 -0
  275. package/lib/dependencies/ImportContextDependency.js +81 -0
  276. package/lib/dependencies/ImportDependency.js +158 -0
  277. package/lib/dependencies/ImportEagerDependency.js +76 -0
  278. package/lib/dependencies/ImportMetaContextDependency.js +42 -0
  279. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +312 -0
  280. package/lib/dependencies/ImportMetaContextPlugin.js +72 -0
  281. package/lib/dependencies/ImportMetaHotAcceptDependency.js +41 -0
  282. package/lib/dependencies/ImportMetaHotDeclineDependency.js +42 -0
  283. package/lib/dependencies/ImportMetaPlugin.js +447 -0
  284. package/lib/dependencies/ImportParserPlugin.js +602 -0
  285. package/lib/dependencies/ImportPhase.js +125 -0
  286. package/lib/dependencies/ImportPlugin.js +98 -0
  287. package/lib/dependencies/ImportWeakDependency.js +74 -0
  288. package/lib/dependencies/JsonExportsDependency.js +137 -0
  289. package/lib/dependencies/LoaderDependency.js +38 -0
  290. package/lib/dependencies/LoaderImportDependency.js +39 -0
  291. package/lib/dependencies/LoaderPlugin.js +294 -0
  292. package/lib/dependencies/LocalModule.js +60 -0
  293. package/lib/dependencies/LocalModuleDependency.js +84 -0
  294. package/lib/dependencies/LocalModulesHelpers.js +68 -0
  295. package/lib/dependencies/ModuleDecoratorDependency.js +136 -0
  296. package/lib/dependencies/ModuleDependency.js +100 -0
  297. package/lib/dependencies/ModuleDependencyTemplateAsId.js +35 -0
  298. package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +39 -0
  299. package/lib/dependencies/ModuleHotAcceptDependency.js +41 -0
  300. package/lib/dependencies/ModuleHotDeclineDependency.js +42 -0
  301. package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
  302. package/lib/dependencies/NullDependency.js +42 -0
  303. package/lib/dependencies/PrefetchDependency.js +27 -0
  304. package/lib/dependencies/ProvidedDependency.js +156 -0
  305. package/lib/dependencies/PureExpressionDependency.js +161 -0
  306. package/lib/dependencies/RequireContextDependency.js +38 -0
  307. package/lib/dependencies/RequireContextDependencyParserPlugin.js +69 -0
  308. package/lib/dependencies/RequireContextPlugin.js +167 -0
  309. package/lib/dependencies/RequireEnsureDependenciesBlock.js +29 -0
  310. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +145 -0
  311. package/lib/dependencies/RequireEnsureDependency.js +115 -0
  312. package/lib/dependencies/RequireEnsureItemDependency.js +36 -0
  313. package/lib/dependencies/RequireEnsurePlugin.js +86 -0
  314. package/lib/dependencies/RequireHeaderDependency.js +70 -0
  315. package/lib/dependencies/RequireIncludeDependency.js +79 -0
  316. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +100 -0
  317. package/lib/dependencies/RequireIncludePlugin.js +63 -0
  318. package/lib/dependencies/RequireResolveContextDependency.js +67 -0
  319. package/lib/dependencies/RequireResolveDependency.js +58 -0
  320. package/lib/dependencies/RequireResolveHeaderDependency.js +81 -0
  321. package/lib/dependencies/RuntimeRequirementsDependency.js +85 -0
  322. package/lib/dependencies/StaticExportsDependency.js +72 -0
  323. package/lib/dependencies/SystemPlugin.js +168 -0
  324. package/lib/dependencies/SystemRuntimeModule.js +35 -0
  325. package/lib/dependencies/URLContextDependency.js +65 -0
  326. package/lib/dependencies/URLDependency.js +165 -0
  327. package/lib/dependencies/URLPlugin.js +67 -0
  328. package/lib/dependencies/UnsupportedDependency.js +82 -0
  329. package/lib/dependencies/WebAssemblyExportImportedDependency.js +93 -0
  330. package/lib/dependencies/WebAssemblyImportDependency.js +108 -0
  331. package/lib/dependencies/WebpackIsIncludedDependency.js +84 -0
  332. package/lib/dependencies/WorkerDependency.js +141 -0
  333. package/lib/dependencies/WorkerPlugin.js +565 -0
  334. package/lib/dependencies/getFunctionExpression.js +66 -0
  335. package/lib/dependencies/processExportInfo.js +67 -0
  336. package/lib/electron/ElectronTargetPlugin.js +71 -0
  337. package/lib/errors/BuildCycleError.js +30 -0
  338. package/lib/esm/ExportWebpackRequireRuntimeModule.js +30 -0
  339. package/lib/esm/ModuleChunkFormatPlugin.js +273 -0
  340. package/lib/esm/ModuleChunkLoadingPlugin.js +143 -0
  341. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +426 -0
  342. package/lib/formatLocation.js +67 -0
  343. package/lib/hmr/HotModuleReplacement.runtime.js +419 -0
  344. package/lib/hmr/HotModuleReplacementRuntimeModule.js +42 -0
  345. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +471 -0
  346. package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
  347. package/lib/hmr/LazyCompilationPlugin.js +473 -0
  348. package/lib/hmr/lazyCompilationBackend.js +167 -0
  349. package/lib/ids/ChunkModuleIdRangePlugin.js +94 -0
  350. package/lib/ids/DeterministicChunkIdsPlugin.js +73 -0
  351. package/lib/ids/DeterministicModuleIdsPlugin.js +98 -0
  352. package/lib/ids/HashedModuleIdsPlugin.js +85 -0
  353. package/lib/ids/IdHelpers.js +492 -0
  354. package/lib/ids/NamedChunkIdsPlugin.js +92 -0
  355. package/lib/ids/NamedModuleIdsPlugin.js +68 -0
  356. package/lib/ids/NaturalChunkIdsPlugin.js +35 -0
  357. package/lib/ids/NaturalModuleIdsPlugin.js +40 -0
  358. package/lib/ids/OccurrenceChunkIdsPlugin.js +86 -0
  359. package/lib/ids/OccurrenceModuleIdsPlugin.js +168 -0
  360. package/lib/ids/SyncModuleIdsPlugin.js +161 -0
  361. package/lib/index.js +681 -0
  362. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +153 -0
  363. package/lib/javascript/BasicEvaluatedExpression.js +603 -0
  364. package/lib/javascript/ChunkFormatHelpers.js +70 -0
  365. package/lib/javascript/ChunkHelpers.js +45 -0
  366. package/lib/javascript/CommonJsChunkFormatPlugin.js +148 -0
  367. package/lib/javascript/EnableChunkLoadingPlugin.js +127 -0
  368. package/lib/javascript/JavascriptGenerator.js +277 -0
  369. package/lib/javascript/JavascriptModulesPlugin.js +1905 -0
  370. package/lib/javascript/JavascriptParser.js +5476 -0
  371. package/lib/javascript/JavascriptParserHelpers.js +129 -0
  372. package/lib/javascript/StartupHelpers.js +178 -0
  373. package/lib/json/JsonData.js +74 -0
  374. package/lib/json/JsonGenerator.js +234 -0
  375. package/lib/json/JsonModulesPlugin.js +66 -0
  376. package/lib/json/JsonParser.js +93 -0
  377. package/lib/library/AbstractLibraryPlugin.js +339 -0
  378. package/lib/library/AmdLibraryPlugin.js +181 -0
  379. package/lib/library/AssignLibraryPlugin.js +445 -0
  380. package/lib/library/EnableLibraryPlugin.js +306 -0
  381. package/lib/library/ExportPropertyLibraryPlugin.js +116 -0
  382. package/lib/library/JsonpLibraryPlugin.js +92 -0
  383. package/lib/library/ModuleLibraryPlugin.js +438 -0
  384. package/lib/library/SystemLibraryPlugin.js +256 -0
  385. package/lib/library/UmdLibraryPlugin.js +355 -0
  386. package/lib/logging/Logger.js +223 -0
  387. package/lib/logging/createConsoleLogger.js +217 -0
  388. package/lib/logging/runtime.js +45 -0
  389. package/lib/logging/truncateArgs.js +83 -0
  390. package/lib/node/CommonJsChunkLoadingPlugin.js +120 -0
  391. package/lib/node/NodeEnvironmentPlugin.js +73 -0
  392. package/lib/node/NodeSourcePlugin.js +19 -0
  393. package/lib/node/NodeTargetPlugin.js +102 -0
  394. package/lib/node/NodeTemplatePlugin.js +42 -0
  395. package/lib/node/NodeWatchFileSystem.js +198 -0
  396. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +286 -0
  397. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +123 -0
  398. package/lib/node/ReadFileCompileWasmPlugin.js +127 -0
  399. package/lib/node/RequireChunkLoadingRuntimeModule.js +239 -0
  400. package/lib/node/nodeConsole.js +185 -0
  401. package/lib/optimize/AggressiveMergingPlugin.js +98 -0
  402. package/lib/optimize/AggressiveSplittingPlugin.js +352 -0
  403. package/lib/optimize/ConcatenatedModule.js +2290 -0
  404. package/lib/optimize/EnsureChunkConditionsPlugin.js +88 -0
  405. package/lib/optimize/FlagIncludedChunksPlugin.js +137 -0
  406. package/lib/optimize/InnerGraph.js +368 -0
  407. package/lib/optimize/InnerGraphPlugin.js +455 -0
  408. package/lib/optimize/LimitChunkCountPlugin.js +302 -0
  409. package/lib/optimize/MangleExportsPlugin.js +194 -0
  410. package/lib/optimize/MergeDuplicateChunksPlugin.js +138 -0
  411. package/lib/optimize/MinChunkSizePlugin.js +121 -0
  412. package/lib/optimize/MinMaxSizeWarning.js +35 -0
  413. package/lib/optimize/ModuleConcatenationPlugin.js +971 -0
  414. package/lib/optimize/RealContentHashPlugin.js +488 -0
  415. package/lib/optimize/RemoveEmptyChunksPlugin.js +60 -0
  416. package/lib/optimize/RemoveParentModulesPlugin.js +216 -0
  417. package/lib/optimize/RuntimeChunkPlugin.js +52 -0
  418. package/lib/optimize/SideEffectsFlagPlugin.js +417 -0
  419. package/lib/optimize/SplitChunksPlugin.js +1836 -0
  420. package/lib/performance/AssetsOverSizeLimitWarning.js +37 -0
  421. package/lib/performance/EntrypointsOverSizeLimitWarning.js +40 -0
  422. package/lib/performance/NoAsyncChunksWarning.js +21 -0
  423. package/lib/performance/SizeLimitsPlugin.js +183 -0
  424. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +46 -0
  425. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +95 -0
  426. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +56 -0
  427. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +52 -0
  428. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +46 -0
  429. package/lib/rules/BasicEffectRulePlugin.js +56 -0
  430. package/lib/rules/BasicMatcherRulePlugin.js +68 -0
  431. package/lib/rules/ObjectMatcherRulePlugin.js +79 -0
  432. package/lib/rules/RuleSetCompiler.js +447 -0
  433. package/lib/rules/UseEffectRulePlugin.js +236 -0
  434. package/lib/runtime/AsyncModuleRuntimeModule.js +199 -0
  435. package/lib/runtime/AutoPublicPathRuntimeModule.js +90 -0
  436. package/lib/runtime/BaseUriRuntimeModule.js +35 -0
  437. package/lib/runtime/ChunkNameRuntimeModule.js +28 -0
  438. package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +40 -0
  439. package/lib/runtime/CompatRuntimeModule.js +83 -0
  440. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +69 -0
  441. package/lib/runtime/CreateScriptRuntimeModule.js +38 -0
  442. package/lib/runtime/CreateScriptUrlRuntimeModule.js +38 -0
  443. package/lib/runtime/DefinePropertyGettersRuntimeModule.js +42 -0
  444. package/lib/runtime/EnsureChunkRuntimeModule.js +69 -0
  445. package/lib/runtime/GetChunkFilenameRuntimeModule.js +299 -0
  446. package/lib/runtime/GetFullHashRuntimeModule.js +31 -0
  447. package/lib/runtime/GetMainFilenameRuntimeModule.js +49 -0
  448. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +99 -0
  449. package/lib/runtime/GlobalRuntimeModule.js +47 -0
  450. package/lib/runtime/HasOwnPropertyRuntimeModule.js +35 -0
  451. package/lib/runtime/HelperRuntimeModule.js +18 -0
  452. package/lib/runtime/LoadScriptRuntimeModule.js +174 -0
  453. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +232 -0
  454. package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +39 -0
  455. package/lib/runtime/NonceRuntimeModule.js +24 -0
  456. package/lib/runtime/OnChunksLoadedRuntimeModule.js +78 -0
  457. package/lib/runtime/PublicPathRuntimeModule.js +38 -0
  458. package/lib/runtime/RelativeUrlRuntimeModule.js +44 -0
  459. package/lib/runtime/RuntimeIdRuntimeModule.js +33 -0
  460. package/lib/runtime/StartupChunkDependenciesPlugin.js +88 -0
  461. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +77 -0
  462. package/lib/runtime/StartupEntrypointRuntimeModule.js +54 -0
  463. package/lib/runtime/SystemContextRuntimeModule.js +23 -0
  464. package/lib/runtime/ToBinaryRuntimeModule.js +72 -0
  465. package/lib/schemes/DataUriPlugin.js +47 -0
  466. package/lib/schemes/FileUriPlugin.js +54 -0
  467. package/lib/schemes/HttpUriPlugin.js +1410 -0
  468. package/lib/schemes/VirtualUrlPlugin.js +248 -0
  469. package/lib/serialization/AggregateErrorSerializer.js +41 -0
  470. package/lib/serialization/ArraySerializer.js +38 -0
  471. package/lib/serialization/BinaryMiddleware.js +1164 -0
  472. package/lib/serialization/DateObjectSerializer.js +28 -0
  473. package/lib/serialization/ErrorObjectSerializer.js +49 -0
  474. package/lib/serialization/FileMiddleware.js +766 -0
  475. package/lib/serialization/MapObjectSerializer.js +48 -0
  476. package/lib/serialization/NullPrototypeObjectSerializer.js +53 -0
  477. package/lib/serialization/ObjectMiddleware.js +877 -0
  478. package/lib/serialization/PlainObjectSerializer.js +119 -0
  479. package/lib/serialization/RegExpObjectSerializer.js +29 -0
  480. package/lib/serialization/Serializer.js +82 -0
  481. package/lib/serialization/SerializerMiddleware.js +226 -0
  482. package/lib/serialization/SetObjectSerializer.js +40 -0
  483. package/lib/serialization/SingleItemMiddleware.js +36 -0
  484. package/lib/serialization/types.js +13 -0
  485. package/lib/sharing/ConsumeSharedFallbackDependency.js +33 -0
  486. package/lib/sharing/ConsumeSharedModule.js +344 -0
  487. package/lib/sharing/ConsumeSharedPlugin.js +380 -0
  488. package/lib/sharing/ConsumeSharedRuntimeModule.js +358 -0
  489. package/lib/sharing/ProvideForSharedDependency.js +33 -0
  490. package/lib/sharing/ProvideSharedDependency.js +80 -0
  491. package/lib/sharing/ProvideSharedModule.js +196 -0
  492. package/lib/sharing/ProvideSharedModuleFactory.js +37 -0
  493. package/lib/sharing/ProvideSharedPlugin.js +248 -0
  494. package/lib/sharing/SharePlugin.js +91 -0
  495. package/lib/sharing/ShareRuntimeModule.js +152 -0
  496. package/lib/sharing/resolveMatchedConfigs.js +106 -0
  497. package/lib/sharing/utils.js +421 -0
  498. package/lib/stats/DefaultStatsFactoryPlugin.js +2791 -0
  499. package/lib/stats/DefaultStatsPresetPlugin.js +417 -0
  500. package/lib/stats/DefaultStatsPrinterPlugin.js +1860 -0
  501. package/lib/stats/StatsFactory.js +406 -0
  502. package/lib/stats/StatsPrinter.js +300 -0
  503. package/lib/url/URLParserPlugin.js +266 -0
  504. package/lib/util/AppendOnlyStackedSet.js +78 -0
  505. package/lib/util/ArrayHelpers.js +46 -0
  506. package/lib/util/ArrayQueue.js +104 -0
  507. package/lib/util/AsyncQueue.js +411 -0
  508. package/lib/util/Hash.js +68 -0
  509. package/lib/util/IterableHelpers.js +46 -0
  510. package/lib/util/LazyBucketSortedSet.js +272 -0
  511. package/lib/util/LazySet.js +236 -0
  512. package/lib/util/MapHelpers.js +34 -0
  513. package/lib/util/ParallelismFactorCalculator.js +70 -0
  514. package/lib/util/Queue.js +52 -0
  515. package/lib/util/Semaphore.js +51 -0
  516. package/lib/util/SetHelpers.js +94 -0
  517. package/lib/util/SortableSet.js +176 -0
  518. package/lib/util/StackedCacheMap.js +140 -0
  519. package/lib/util/StackedMap.js +164 -0
  520. package/lib/util/StringXor.js +103 -0
  521. package/lib/util/TupleQueue.js +70 -0
  522. package/lib/util/TupleSet.js +185 -0
  523. package/lib/util/URLAbsoluteSpecifier.js +86 -0
  524. package/lib/util/WeakTupleMap.js +227 -0
  525. package/lib/util/binarySearchBounds.js +136 -0
  526. package/lib/util/chainedImports.js +99 -0
  527. package/lib/util/cleverMerge.js +676 -0
  528. package/lib/util/comparators.js +645 -0
  529. package/lib/util/compileBooleanMatcher.js +313 -0
  530. package/lib/util/concatenate.js +232 -0
  531. package/lib/util/conventions.js +126 -0
  532. package/lib/util/create-schema-validation.js +41 -0
  533. package/lib/util/createHash.js +91 -0
  534. package/lib/util/dataURL.js +39 -0
  535. package/lib/util/deprecation.js +350 -0
  536. package/lib/util/deterministicGrouping.js +561 -0
  537. package/lib/util/extractSourceMap.js +318 -0
  538. package/lib/util/extractUrlAndGlobal.js +18 -0
  539. package/lib/util/findGraphRoots.js +211 -0
  540. package/lib/util/fs.js +675 -0
  541. package/lib/util/generateDebugId.js +33 -0
  542. package/lib/util/hash/BatchedHash.js +115 -0
  543. package/lib/util/hash/BulkUpdateHash.js +145 -0
  544. package/lib/util/hash/DebugHash.js +75 -0
  545. package/lib/util/hash/hash-digest.js +217 -0
  546. package/lib/util/hash/md4.js +20 -0
  547. package/lib/util/hash/wasm-hash.js +232 -0
  548. package/lib/util/hash/xxhash64.js +20 -0
  549. package/lib/util/identifier.js +471 -0
  550. package/lib/util/internalSerializables.js +222 -0
  551. package/lib/util/magicComment.js +25 -0
  552. package/lib/util/makeSerializable.js +60 -0
  553. package/lib/util/memoize.js +36 -0
  554. package/lib/util/nonNumericOnlyHash.js +22 -0
  555. package/lib/util/numberHash.js +95 -0
  556. package/lib/util/objectToMap.js +15 -0
  557. package/lib/util/processAsyncTree.js +68 -0
  558. package/lib/util/propertyAccess.js +30 -0
  559. package/lib/util/propertyName.js +76 -0
  560. package/lib/util/registerExternalSerializer.js +334 -0
  561. package/lib/util/removeBOM.js +25 -0
  562. package/lib/util/runtime.js +717 -0
  563. package/lib/util/semver.js +604 -0
  564. package/lib/util/serialization.js +153 -0
  565. package/lib/util/smartGrouping.js +221 -0
  566. package/lib/util/source.js +62 -0
  567. package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
  568. package/lib/validateSchema.js +177 -0
  569. package/lib/wasm/EnableWasmLoadingPlugin.js +146 -0
  570. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +154 -0
  571. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +74 -0
  572. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +212 -0
  573. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +209 -0
  574. package/lib/wasm-async/AsyncWebAssemblyParser.js +80 -0
  575. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +107 -0
  576. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +20 -0
  577. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +422 -0
  578. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +91 -0
  579. package/lib/wasm-sync/WebAssemblyGenerator.js +535 -0
  580. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +111 -0
  581. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +236 -0
  582. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +151 -0
  583. package/lib/wasm-sync/WebAssemblyParser.js +201 -0
  584. package/lib/wasm-sync/WebAssemblyUtils.js +66 -0
  585. package/lib/web/FetchCompileAsyncWasmPlugin.js +70 -0
  586. package/lib/web/FetchCompileWasmPlugin.js +86 -0
  587. package/lib/web/JsonpChunkLoadingPlugin.js +101 -0
  588. package/lib/web/JsonpChunkLoadingRuntimeModule.js +455 -0
  589. package/lib/web/JsonpTemplatePlugin.js +37 -0
  590. package/lib/webpack.js +227 -0
  591. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +110 -0
  592. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +231 -0
  593. package/lib/webworker/WebWorkerTemplatePlugin.js +26 -0
  594. package/module.d.ts +238 -0
  595. package/package.json +258 -0
  596. package/schemas/WebpackOptions.check.d.ts +7 -0
  597. package/schemas/WebpackOptions.check.js +6 -0
  598. package/schemas/WebpackOptions.json +6179 -0
  599. package/schemas/_container.json +155 -0
  600. package/schemas/_sharing.json +118 -0
  601. package/schemas/plugins/BannerPlugin.check.d.ts +7 -0
  602. package/schemas/plugins/BannerPlugin.check.js +6 -0
  603. package/schemas/plugins/BannerPlugin.json +115 -0
  604. package/schemas/plugins/DllPlugin.check.d.ts +7 -0
  605. package/schemas/plugins/DllPlugin.check.js +6 -0
  606. package/schemas/plugins/DllPlugin.json +36 -0
  607. package/schemas/plugins/DllReferencePlugin.check.d.ts +7 -0
  608. package/schemas/plugins/DllReferencePlugin.check.js +6 -0
  609. package/schemas/plugins/DllReferencePlugin.json +206 -0
  610. package/schemas/plugins/IgnorePlugin.check.d.ts +7 -0
  611. package/schemas/plugins/IgnorePlugin.check.js +6 -0
  612. package/schemas/plugins/IgnorePlugin.json +34 -0
  613. package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +7 -0
  614. package/schemas/plugins/LoaderOptionsPlugin.check.js +6 -0
  615. package/schemas/plugins/LoaderOptionsPlugin.json +27 -0
  616. package/schemas/plugins/ManifestPlugin.check.d.ts +7 -0
  617. package/schemas/plugins/ManifestPlugin.check.js +6 -0
  618. package/schemas/plugins/ManifestPlugin.json +98 -0
  619. package/schemas/plugins/ProgressPlugin.check.d.ts +7 -0
  620. package/schemas/plugins/ProgressPlugin.check.js +6 -0
  621. package/schemas/plugins/ProgressPlugin.json +65 -0
  622. package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +7 -0
  623. package/schemas/plugins/SourceMapDevToolPlugin.check.js +6 -0
  624. package/schemas/plugins/SourceMapDevToolPlugin.json +168 -0
  625. package/schemas/plugins/WatchIgnorePlugin.check.d.ts +7 -0
  626. package/schemas/plugins/WatchIgnorePlugin.check.js +6 -0
  627. package/schemas/plugins/WatchIgnorePlugin.json +25 -0
  628. package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +7 -0
  629. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +6 -0
  630. package/schemas/plugins/asset/AssetGeneratorOptions.json +3 -0
  631. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +7 -0
  632. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +6 -0
  633. package/schemas/plugins/asset/AssetInlineGeneratorOptions.json +3 -0
  634. package/schemas/plugins/asset/AssetParserOptions.check.d.ts +7 -0
  635. package/schemas/plugins/asset/AssetParserOptions.check.js +6 -0
  636. package/schemas/plugins/asset/AssetParserOptions.json +3 -0
  637. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +7 -0
  638. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +6 -0
  639. package/schemas/plugins/asset/AssetResourceGeneratorOptions.json +3 -0
  640. package/schemas/plugins/container/ContainerPlugin.check.d.ts +7 -0
  641. package/schemas/plugins/container/ContainerPlugin.check.js +6 -0
  642. package/schemas/plugins/container/ContainerPlugin.json +294 -0
  643. package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +7 -0
  644. package/schemas/plugins/container/ContainerReferencePlugin.check.js +6 -0
  645. package/schemas/plugins/container/ContainerReferencePlugin.json +132 -0
  646. package/schemas/plugins/container/ExternalsType.check.d.ts +7 -0
  647. package/schemas/plugins/container/ExternalsType.check.js +6 -0
  648. package/schemas/plugins/container/ExternalsType.json +3 -0
  649. package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +7 -0
  650. package/schemas/plugins/container/ModuleFederationPlugin.check.js +6 -0
  651. package/schemas/plugins/container/ModuleFederationPlugin.json +525 -0
  652. package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
  653. package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
  654. package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
  655. package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +7 -0
  656. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +6 -0
  657. package/schemas/plugins/css/CssModuleGeneratorOptions.json +3 -0
  658. package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +7 -0
  659. package/schemas/plugins/css/CssModuleParserOptions.check.js +6 -0
  660. package/schemas/plugins/css/CssModuleParserOptions.json +3 -0
  661. package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
  662. package/schemas/plugins/css/CssParserOptions.check.js +6 -0
  663. package/schemas/plugins/css/CssParserOptions.json +3 -0
  664. package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +7 -0
  665. package/schemas/plugins/debug/ProfilingPlugin.check.js +6 -0
  666. package/schemas/plugins/debug/ProfilingPlugin.json +12 -0
  667. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
  668. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
  669. package/schemas/plugins/ids/HashedModuleIdsPlugin.json +57 -0
  670. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +7 -0
  671. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +6 -0
  672. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.json +11 -0
  673. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +7 -0
  674. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +6 -0
  675. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.json +11 -0
  676. package/schemas/plugins/json/JsonModulesPluginGenerator.check.d.ts +7 -0
  677. package/schemas/plugins/json/JsonModulesPluginGenerator.check.js +6 -0
  678. package/schemas/plugins/json/JsonModulesPluginGenerator.json +3 -0
  679. package/schemas/plugins/json/JsonModulesPluginParser.check.d.ts +7 -0
  680. package/schemas/plugins/json/JsonModulesPluginParser.check.js +6 -0
  681. package/schemas/plugins/json/JsonModulesPluginParser.json +3 -0
  682. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +7 -0
  683. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +6 -0
  684. package/schemas/plugins/optimize/AggressiveSplittingPlugin.json +23 -0
  685. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +7 -0
  686. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +6 -0
  687. package/schemas/plugins/optimize/LimitChunkCountPlugin.json +21 -0
  688. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +7 -0
  689. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +6 -0
  690. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.json +11 -0
  691. package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +7 -0
  692. package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +6 -0
  693. package/schemas/plugins/optimize/MinChunkSizePlugin.json +20 -0
  694. package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +7 -0
  695. package/schemas/plugins/schemes/HttpUriPlugin.check.js +6 -0
  696. package/schemas/plugins/schemes/HttpUriPlugin.json +74 -0
  697. package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
  698. package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
  699. package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
  700. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +7 -0
  701. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +6 -0
  702. package/schemas/plugins/sharing/ConsumeSharedPlugin.json +120 -0
  703. package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +7 -0
  704. package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +6 -0
  705. package/schemas/plugins/sharing/ProvideSharedPlugin.json +94 -0
  706. package/schemas/plugins/sharing/SharePlugin.check.d.ts +7 -0
  707. package/schemas/plugins/sharing/SharePlugin.check.js +6 -0
  708. package/schemas/plugins/sharing/SharePlugin.json +133 -0
  709. package/types.d.ts +20217 -0
@@ -0,0 +1,2290 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const eslintScope = require("eslint-scope");
9
+ const Referencer = require("eslint-scope/lib/referencer");
10
+ const { SyncBailHook } = require("tapable");
11
+ const {
12
+ CachedSource,
13
+ ConcatSource,
14
+ ReplaceSource
15
+ } = require("webpack-sources");
16
+ const ConcatenationScope = require("../ConcatenationScope");
17
+ const { UsageState } = require("../ExportsInfo");
18
+ const Module = require("../Module");
19
+ const {
20
+ JAVASCRIPT_TYPE,
21
+ JAVASCRIPT_TYPES
22
+ } = require("../ModuleSourceTypeConstants");
23
+ const { JAVASCRIPT_MODULE_TYPE_ESM } = require("../ModuleTypeConstants");
24
+ const RuntimeGlobals = require("../RuntimeGlobals");
25
+ const Template = require("../Template");
26
+ const { DEFAULTS } = require("../config/defaults");
27
+ const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
28
+ const { ImportPhaseUtils } = require("../dependencies/ImportPhase");
29
+ const JavascriptParser = require("../javascript/JavascriptParser");
30
+ const {
31
+ getMakeDeferredNamespaceModeFromExportsType,
32
+ getOptimizedDeferredModule
33
+ } = require("../runtime/MakeDeferredNamespaceObjectRuntime");
34
+ const { equals } = require("../util/ArrayHelpers");
35
+ const LazySet = require("../util/LazySet");
36
+ const { concatComparators } = require("../util/comparators");
37
+ const {
38
+ RESERVED_NAMES,
39
+ addScopeSymbols,
40
+ findNewName,
41
+ getAllReferences,
42
+ getPathInAst,
43
+ getUsedNamesInScopeInfo
44
+ } = require("../util/concatenate");
45
+ const createHash = require("../util/createHash");
46
+ const { makePathsRelative } = require("../util/identifier");
47
+ const makeSerializable = require("../util/makeSerializable");
48
+ const propertyAccess = require("../util/propertyAccess");
49
+ const { propertyName } = require("../util/propertyName");
50
+ const {
51
+ filterRuntime,
52
+ intersectRuntime,
53
+ mergeRuntimeCondition,
54
+ mergeRuntimeConditionNonFalse,
55
+ runtimeConditionToString,
56
+ subtractRuntimeCondition
57
+ } = require("../util/runtime");
58
+
59
+ /** @typedef {import("eslint-scope").Reference} Reference */
60
+ /** @typedef {import("eslint-scope").Scope} Scope */
61
+ /** @typedef {import("eslint-scope").Variable} Variable */
62
+ /** @typedef {import("webpack-sources").Source} Source */
63
+ /** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
64
+ /** @typedef {import("../ChunkGraph")} ChunkGraph */
65
+ /** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
66
+ /** @typedef {import("../Compilation")} Compilation */
67
+ /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
68
+ /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
69
+ /** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
70
+ /** @typedef {import("../Module").BuildCallback} BuildCallback */
71
+ /** @typedef {import("../Module").BuildInfo} BuildInfo */
72
+ /** @typedef {import("../Module").FileSystemDependencies} FileSystemDependencies */
73
+ /** @typedef {import("../Module").BuildMeta} BuildMeta */
74
+ /** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
75
+ /** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
76
+ /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
77
+ /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
78
+ /** @typedef {import("../Module").LibIdent} LibIdent */
79
+ /** @typedef {import("../Module").NameForCondition} NameForCondition */
80
+ /** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
81
+ /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
82
+ /** @typedef {import("../Module").SourceTypes} SourceTypes */
83
+ /** @typedef {import("../ModuleGraph")} ModuleGraph */
84
+ /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
85
+ /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
86
+ /** @typedef {import("../RequestShortener")} RequestShortener */
87
+ /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
88
+ /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
89
+ /** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
90
+ /** @typedef {import("../javascript/JavascriptParser").Program} Program */
91
+ /** @typedef {import("../javascript/JavascriptParser").Range} Range */
92
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
93
+ /** @typedef {import("../util/Hash")} Hash */
94
+ /** @typedef {import("../util/Hash").HashFunction} HashFunction */
95
+ /** @typedef {import("../util/concatenate").UsedNames} UsedNames */
96
+ /** @typedef {import("../util/concatenate").ScopeInfo} ScopeInfo */
97
+ /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
98
+ /** @typedef {import("../util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
99
+ /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
100
+ /**
101
+ * @template T
102
+ * @typedef {import("../InitFragment")<T>} InitFragment
103
+ */
104
+
105
+ /**
106
+ * @template T
107
+ * @typedef {import("../util/comparators").Comparator<T>} Comparator
108
+ */
109
+
110
+ // fix eslint-scope to support class properties correctly
111
+ // cspell:word Referencer
112
+ const ReferencerClass = Referencer;
113
+ if (!ReferencerClass.prototype.PropertyDefinition) {
114
+ ReferencerClass.prototype.PropertyDefinition =
115
+ ReferencerClass.prototype.Property;
116
+ }
117
+
118
+ /** @typedef {RawBinding | SymbolBinding} Binding */
119
+
120
+ /** @typedef {string[]} ExportName */
121
+
122
+ /**
123
+ * @typedef {object} RawBinding
124
+ * @property {ModuleInfo} info
125
+ * @property {string} rawName
126
+ * @property {string=} comment
127
+ * @property {ExportName} ids
128
+ * @property {ExportName} exportName
129
+ */
130
+
131
+ /**
132
+ * @typedef {object} SymbolBinding
133
+ * @property {ConcatenatedModuleInfo} info
134
+ * @property {string} name
135
+ * @property {string=} comment
136
+ * @property {ExportName} ids
137
+ * @property {ExportName} exportName
138
+ */
139
+
140
+ /** @typedef {ConcatenatedModuleInfo | ExternalModuleInfo} ModuleInfo */
141
+ /** @typedef {ConcatenatedModuleInfo | ExternalModuleInfo | ReferenceToModuleInfo} ModuleInfoOrReference */
142
+
143
+ /** @typedef {Map<string, string>} ExportMap */
144
+
145
+ /**
146
+ * @typedef {object} ConcatenatedModuleInfo
147
+ * @property {"concatenated"} type
148
+ * @property {Module} module
149
+ * @property {number} index
150
+ * @property {Program | undefined} ast
151
+ * @property {Source | undefined} internalSource
152
+ * @property {ReplaceSource | undefined} source
153
+ * @property {InitFragment<ChunkRenderContext>[]=} chunkInitFragments
154
+ * @property {ReadOnlyRuntimeRequirements | undefined} runtimeRequirements
155
+ * @property {Scope | undefined} globalScope
156
+ * @property {Scope | undefined} moduleScope
157
+ * @property {Map<string, string>} internalNames
158
+ * @property {ExportMap | undefined} exportMap
159
+ * @property {ExportMap | undefined} rawExportMap
160
+ * @property {string=} namespaceExportSymbol
161
+ * @property {string | undefined} namespaceObjectName
162
+ * @property {ConcatenationScope | undefined} concatenationScope
163
+ * @property {boolean} interopNamespaceObjectUsed "default-with-named" namespace
164
+ * @property {string | undefined} interopNamespaceObjectName "default-with-named" namespace
165
+ * @property {boolean} interopNamespaceObject2Used "default-only" namespace
166
+ * @property {string | undefined} interopNamespaceObject2Name "default-only" namespace
167
+ * @property {boolean} interopDefaultAccessUsed runtime namespace object that detects "__esModule"
168
+ * @property {string | undefined} interopDefaultAccessName runtime namespace object that detects "__esModule"
169
+ */
170
+
171
+ /**
172
+ * @typedef {object} ExternalModuleInfo
173
+ * @property {"external"} type
174
+ * @property {Module} module
175
+ * @property {RuntimeSpec | boolean} runtimeCondition
176
+ * @property {NonDeferAccess} nonDeferAccess
177
+ * @property {number} index
178
+ * @property {string | undefined} name module.exports / harmony namespace object
179
+ * @property {string | undefined} deferredName deferred module.exports / harmony namespace object
180
+ * @property {boolean} deferred the module is deferred at least once
181
+ * @property {boolean} deferredNamespaceObjectUsed deferred namespace object that being used in a not-analyzable way so it must be materialized
182
+ * @property {string | undefined} deferredNamespaceObjectName deferred namespace object that being used in a not-analyzable way so it must be materialized
183
+ * @property {boolean} interopNamespaceObjectUsed "default-with-named" namespace
184
+ * @property {string | undefined} interopNamespaceObjectName "default-with-named" namespace
185
+ * @property {boolean} interopNamespaceObject2Used "default-only" namespace
186
+ * @property {string | undefined} interopNamespaceObject2Name "default-only" namespace
187
+ * @property {boolean} interopDefaultAccessUsed runtime namespace object that detects "__esModule"
188
+ * @property {string | undefined} interopDefaultAccessName runtime namespace object that detects "__esModule"
189
+ */
190
+
191
+ /**
192
+ * @typedef {object} ReferenceToModuleInfo
193
+ * @property {"reference"} type
194
+ * @property {RuntimeSpec | boolean} runtimeCondition
195
+ * @property {NonDeferAccess} nonDeferAccess
196
+ * @property {ModuleInfo} target
197
+ */
198
+
199
+ /**
200
+ * @template T
201
+ * @param {string} property property
202
+ * @param {(a: T[keyof T], b: T[keyof T]) => 0 | 1 | -1} comparator comparator
203
+ * @returns {Comparator<T>} comparator
204
+ */
205
+
206
+ const createComparator = (property, comparator) => (a, b) =>
207
+ comparator(
208
+ a[/** @type {keyof T} */ (property)],
209
+ b[/** @type {keyof T} */ (property)]
210
+ );
211
+
212
+ /**
213
+ * @param {number} a a
214
+ * @param {number} b b
215
+ * @returns {0 | 1 | -1} result
216
+ */
217
+ const compareNumbers = (a, b) => {
218
+ if (Number.isNaN(a)) {
219
+ if (!Number.isNaN(b)) {
220
+ return 1;
221
+ }
222
+ } else {
223
+ if (Number.isNaN(b)) {
224
+ return -1;
225
+ }
226
+ if (a !== b) {
227
+ return a < b ? -1 : 1;
228
+ }
229
+ }
230
+ return 0;
231
+ };
232
+
233
+ const bySourceOrder = createComparator("sourceOrder", compareNumbers);
234
+ const byRangeStart = createComparator("rangeStart", compareNumbers);
235
+
236
+ /**
237
+ * @param {Iterable<string>} iterable iterable object
238
+ * @returns {string} joined iterable object
239
+ */
240
+ const joinIterableWithComma = (iterable) => {
241
+ // This is more performant than Array.from().join(", ")
242
+ // as it doesn't create an array
243
+ let str = "";
244
+ let first = true;
245
+ for (const item of iterable) {
246
+ if (first) {
247
+ first = false;
248
+ } else {
249
+ str += ", ";
250
+ }
251
+ str += item;
252
+ }
253
+ return str;
254
+ };
255
+
256
+ /** @typedef {boolean} NonDeferAccess */
257
+
258
+ /**
259
+ * @param {NonDeferAccess} a a
260
+ * @param {NonDeferAccess} b b
261
+ * @returns {NonDeferAccess} merged
262
+ */
263
+ const mergeNonDeferAccess = (a, b) => a || b;
264
+
265
+ /**
266
+ * @param {NonDeferAccess} a first
267
+ * @param {NonDeferAccess} b second
268
+ * @returns {NonDeferAccess} first - second
269
+ */
270
+ const subtractNonDeferAccess = (a, b) => a && !b;
271
+
272
+ /**
273
+ * @typedef {object} ConcatenationEntry
274
+ * @property {"concatenated" | "external"} type
275
+ * @property {Module} module
276
+ * @property {RuntimeSpec | boolean} runtimeCondition
277
+ * @property {NonDeferAccess} nonDeferAccess
278
+ */
279
+
280
+ /** @typedef {Set<ConcatenatedModuleInfo>} NeededNamespaceObjects */
281
+
282
+ /** @typedef {Map<Module, ModuleInfo>} ModuleToInfoMap */
283
+
284
+ /**
285
+ * @param {ModuleGraph} moduleGraph the module graph
286
+ * @param {ModuleInfo} info module info
287
+ * @param {ExportName} exportName exportName
288
+ * @param {ModuleToInfoMap} moduleToInfoMap moduleToInfoMap
289
+ * @param {RuntimeSpec} runtime for which runtime
290
+ * @param {RequestShortener} requestShortener the request shortener
291
+ * @param {RuntimeTemplate} runtimeTemplate the runtime template
292
+ * @param {NeededNamespaceObjects} neededNamespaceObjects modules for which a namespace object should be generated
293
+ * @param {boolean} asCall asCall
294
+ * @param {boolean} depDeferred the dependency is deferred
295
+ * @param {boolean | undefined} strictHarmonyModule strictHarmonyModule
296
+ * @param {boolean | undefined} asiSafe asiSafe
297
+ * @param {Set<ExportInfo>} alreadyVisited alreadyVisited
298
+ * @returns {Binding} the final variable
299
+ */
300
+ const getFinalBinding = (
301
+ moduleGraph,
302
+ info,
303
+ exportName,
304
+ moduleToInfoMap,
305
+ runtime,
306
+ requestShortener,
307
+ runtimeTemplate,
308
+ neededNamespaceObjects,
309
+ asCall,
310
+ depDeferred,
311
+ strictHarmonyModule,
312
+ asiSafe,
313
+ alreadyVisited = new Set()
314
+ ) => {
315
+ const exportsType = info.module.getExportsType(
316
+ moduleGraph,
317
+ strictHarmonyModule
318
+ );
319
+ const moduleDeferred =
320
+ info.type === "external" &&
321
+ info.deferred &&
322
+ !(/** @type {BuildMeta} */ (info.module.buildMeta).async);
323
+ const deferred = depDeferred && moduleDeferred;
324
+ if (exportName.length === 0) {
325
+ switch (exportsType) {
326
+ case "default-only":
327
+ if (deferred) info.deferredNamespaceObjectUsed = true;
328
+ else info.interopNamespaceObject2Used = true;
329
+ return {
330
+ info,
331
+ rawName: /** @type {string} */ (
332
+ deferred
333
+ ? info.deferredNamespaceObjectName
334
+ : info.interopNamespaceObject2Name
335
+ ),
336
+ ids: exportName,
337
+ exportName
338
+ };
339
+ case "default-with-named":
340
+ if (deferred) info.deferredNamespaceObjectUsed = true;
341
+ else info.interopNamespaceObjectUsed = true;
342
+ return {
343
+ info,
344
+ rawName: /** @type {string} */ (
345
+ deferred
346
+ ? info.deferredNamespaceObjectName
347
+ : info.interopNamespaceObjectName
348
+ ),
349
+ ids: exportName,
350
+ exportName
351
+ };
352
+ case "namespace":
353
+ case "dynamic":
354
+ break;
355
+ default:
356
+ throw new Error(`Unexpected exportsType ${exportsType}`);
357
+ }
358
+ } else {
359
+ switch (exportsType) {
360
+ case "namespace":
361
+ break;
362
+ case "default-with-named":
363
+ switch (exportName[0]) {
364
+ case "default":
365
+ exportName = exportName.slice(1);
366
+ break;
367
+ case "__esModule":
368
+ return {
369
+ info,
370
+ rawName: "/* __esModule */true",
371
+ ids: exportName.slice(1),
372
+ exportName
373
+ };
374
+ }
375
+ break;
376
+ case "default-only": {
377
+ const exportId = exportName[0];
378
+ if (exportId === "__esModule") {
379
+ return {
380
+ info,
381
+ rawName: "/* __esModule */true",
382
+ ids: exportName.slice(1),
383
+ exportName
384
+ };
385
+ }
386
+ exportName = exportName.slice(1);
387
+ if (exportId !== "default") {
388
+ return {
389
+ info,
390
+ rawName:
391
+ "/* non-default import from default-exporting module */undefined",
392
+ ids: exportName,
393
+ exportName
394
+ };
395
+ }
396
+ break;
397
+ }
398
+ case "dynamic":
399
+ switch (exportName[0]) {
400
+ case "default": {
401
+ exportName = exportName.slice(1);
402
+ if (deferred) {
403
+ return {
404
+ info,
405
+ rawName: `${info.deferredName}.a`,
406
+ ids: exportName,
407
+ exportName
408
+ };
409
+ }
410
+ if (moduleDeferred) {
411
+ return {
412
+ info,
413
+ rawName: /** @type {string} */ (info.name),
414
+ ids: exportName,
415
+ exportName
416
+ };
417
+ }
418
+ info.interopDefaultAccessUsed = true;
419
+ const defaultExport = asCall
420
+ ? `${info.interopDefaultAccessName}()`
421
+ : asiSafe
422
+ ? `(${info.interopDefaultAccessName}())`
423
+ : asiSafe === false
424
+ ? `;(${info.interopDefaultAccessName}())`
425
+ : `${info.interopDefaultAccessName}.a`;
426
+ return {
427
+ info,
428
+ rawName: defaultExport,
429
+ ids: exportName,
430
+ exportName
431
+ };
432
+ }
433
+ case "__esModule":
434
+ return {
435
+ info,
436
+ rawName: "/* __esModule */true",
437
+ ids: exportName.slice(1),
438
+ exportName
439
+ };
440
+ }
441
+ break;
442
+ default:
443
+ throw new Error(`Unexpected exportsType ${exportsType}`);
444
+ }
445
+ }
446
+ if (exportName.length === 0) {
447
+ switch (info.type) {
448
+ case "concatenated":
449
+ neededNamespaceObjects.add(info);
450
+ return {
451
+ info,
452
+ rawName:
453
+ /** @type {NonNullable<ConcatenatedModuleInfo["namespaceObjectName"]>} */
454
+ (info.namespaceObjectName),
455
+ ids: exportName,
456
+ exportName
457
+ };
458
+ case "external":
459
+ if (deferred) {
460
+ info.deferredNamespaceObjectUsed = true;
461
+ return {
462
+ info,
463
+ rawName: /** @type {string} */ (info.deferredNamespaceObjectName),
464
+ ids: exportName,
465
+ exportName
466
+ };
467
+ }
468
+ return {
469
+ info,
470
+ rawName:
471
+ /** @type {NonNullable<ExternalModuleInfo["name"]>} */
472
+ (info.name),
473
+ ids: exportName,
474
+ exportName
475
+ };
476
+ }
477
+ }
478
+ const exportsInfo = moduleGraph.getExportsInfo(info.module);
479
+ const exportInfo = exportsInfo.getExportInfo(exportName[0]);
480
+ if (alreadyVisited.has(exportInfo)) {
481
+ return {
482
+ info,
483
+ rawName: "/* circular reexport */ Object(function x() { x() }())",
484
+ ids: [],
485
+ exportName
486
+ };
487
+ }
488
+ alreadyVisited.add(exportInfo);
489
+ switch (info.type) {
490
+ case "concatenated": {
491
+ const exportId = exportName[0];
492
+ if (exportInfo.provided === false) {
493
+ // It's not provided, but it could be on the prototype
494
+ neededNamespaceObjects.add(info);
495
+ return {
496
+ info,
497
+ rawName: /** @type {string} */ (info.namespaceObjectName),
498
+ ids: exportName,
499
+ exportName
500
+ };
501
+ }
502
+ const directExport = info.exportMap && info.exportMap.get(exportId);
503
+ if (directExport) {
504
+ const usedName = /** @type {ExportName} */ (
505
+ exportsInfo.getUsedName(exportName, runtime)
506
+ );
507
+ if (!usedName) {
508
+ return {
509
+ info,
510
+ rawName: "/* unused export */ undefined",
511
+ ids: exportName.slice(1),
512
+ exportName
513
+ };
514
+ }
515
+ return {
516
+ info,
517
+ name: directExport,
518
+ ids: usedName.slice(1),
519
+ exportName
520
+ };
521
+ }
522
+ const rawExport = info.rawExportMap && info.rawExportMap.get(exportId);
523
+ if (rawExport) {
524
+ return {
525
+ info,
526
+ rawName: rawExport,
527
+ ids: exportName.slice(1),
528
+ exportName
529
+ };
530
+ }
531
+ const reexport = exportInfo.findTarget(moduleGraph, (module) =>
532
+ moduleToInfoMap.has(module)
533
+ );
534
+ if (reexport === false) {
535
+ throw new Error(
536
+ `Target module of reexport from '${info.module.readableIdentifier(
537
+ requestShortener
538
+ )}' is not part of the concatenation (export '${exportId}')\nModules in the concatenation:\n${Array.from(
539
+ moduleToInfoMap,
540
+ ([m, info]) =>
541
+ ` * ${info.type} ${m.readableIdentifier(requestShortener)}`
542
+ ).join("\n")}`
543
+ );
544
+ }
545
+ if (reexport) {
546
+ const refInfo = moduleToInfoMap.get(reexport.module);
547
+ return getFinalBinding(
548
+ moduleGraph,
549
+ /** @type {ModuleInfo} */ (refInfo),
550
+ reexport.export
551
+ ? [...reexport.export, ...exportName.slice(1)]
552
+ : exportName.slice(1),
553
+ moduleToInfoMap,
554
+ runtime,
555
+ requestShortener,
556
+ runtimeTemplate,
557
+ neededNamespaceObjects,
558
+ asCall,
559
+ reexport.deferred,
560
+ /** @type {BuildMeta} */
561
+ (info.module.buildMeta).strictHarmonyModule,
562
+ asiSafe,
563
+ alreadyVisited
564
+ );
565
+ }
566
+ if (info.namespaceExportSymbol) {
567
+ const usedName = /** @type {ExportName} */ (
568
+ exportsInfo.getUsedName(exportName, runtime)
569
+ );
570
+ return {
571
+ info,
572
+ rawName: /** @type {string} */ (info.namespaceObjectName),
573
+ ids: usedName,
574
+ exportName
575
+ };
576
+ }
577
+ throw new Error(
578
+ `Cannot get final name for export '${exportName.join(
579
+ "."
580
+ )}' of ${info.module.readableIdentifier(requestShortener)}`
581
+ );
582
+ }
583
+
584
+ case "external": {
585
+ const used = /** @type {ExportName} */ (
586
+ exportsInfo.getUsedName(exportName, runtime)
587
+ );
588
+ if (!used) {
589
+ return {
590
+ info,
591
+ rawName: "/* unused export */ undefined",
592
+ ids: exportName.slice(1),
593
+ exportName
594
+ };
595
+ }
596
+ const comment = equals(used, exportName)
597
+ ? ""
598
+ : Template.toNormalComment(`${exportName.join(".")}`);
599
+ return {
600
+ info,
601
+ rawName:
602
+ (deferred ? info.deferredName : info.name) +
603
+ (deferred ? ".a" : "") +
604
+ comment,
605
+ ids: used,
606
+ exportName
607
+ };
608
+ }
609
+ }
610
+ };
611
+
612
+ /**
613
+ * @param {ModuleGraph} moduleGraph the module graph
614
+ * @param {ModuleInfo} info module info
615
+ * @param {ExportName} exportName exportName
616
+ * @param {ModuleToInfoMap} moduleToInfoMap moduleToInfoMap
617
+ * @param {RuntimeSpec} runtime for which runtime
618
+ * @param {RequestShortener} requestShortener the request shortener
619
+ * @param {RuntimeTemplate} runtimeTemplate the runtime template
620
+ * @param {NeededNamespaceObjects} neededNamespaceObjects modules for which a namespace object should be generated
621
+ * @param {boolean} asCall asCall
622
+ * @param {boolean} depDeferred the dependency is deferred
623
+ * @param {boolean | undefined} callContext callContext
624
+ * @param {boolean | undefined} strictHarmonyModule strictHarmonyModule
625
+ * @param {boolean | undefined} asiSafe asiSafe
626
+ * @returns {string} the final name
627
+ */
628
+ const getFinalName = (
629
+ moduleGraph,
630
+ info,
631
+ exportName,
632
+ moduleToInfoMap,
633
+ runtime,
634
+ requestShortener,
635
+ runtimeTemplate,
636
+ neededNamespaceObjects,
637
+ asCall,
638
+ depDeferred,
639
+ callContext,
640
+ strictHarmonyModule,
641
+ asiSafe
642
+ ) => {
643
+ const binding = getFinalBinding(
644
+ moduleGraph,
645
+ info,
646
+ exportName,
647
+ moduleToInfoMap,
648
+ runtime,
649
+ requestShortener,
650
+ runtimeTemplate,
651
+ neededNamespaceObjects,
652
+ asCall,
653
+ depDeferred,
654
+ strictHarmonyModule,
655
+ asiSafe
656
+ );
657
+ {
658
+ const { ids, comment } = binding;
659
+ /** @type {string} */
660
+ let reference;
661
+ /** @type {boolean} */
662
+ let isPropertyAccess;
663
+ if ("rawName" in binding) {
664
+ reference = `${binding.rawName}${comment || ""}${propertyAccess(ids)}`;
665
+ isPropertyAccess = ids.length > 0;
666
+ } else {
667
+ const { info, name: exportId } = binding;
668
+ const name = info.internalNames.get(exportId);
669
+ if (!name) {
670
+ throw new Error(
671
+ `The export "${exportId}" in "${info.module.readableIdentifier(
672
+ requestShortener
673
+ )}" has no internal name (existing names: ${
674
+ Array.from(
675
+ info.internalNames,
676
+ ([name, symbol]) => `${name}: ${symbol}`
677
+ ).join(", ") || "none"
678
+ })`
679
+ );
680
+ }
681
+ reference = `${name}${comment || ""}${propertyAccess(ids)}`;
682
+ isPropertyAccess = ids.length > 1;
683
+ }
684
+ if (isPropertyAccess && asCall && callContext === false) {
685
+ return asiSafe
686
+ ? `(0,${reference})`
687
+ : asiSafe === false
688
+ ? `;(0,${reference})`
689
+ : `/*#__PURE__*/Object(${reference})`;
690
+ }
691
+ return reference;
692
+ }
693
+ };
694
+
695
+ /**
696
+ * @typedef {object} ConcatenateModuleHooks
697
+ * @property {SyncBailHook<[ConcatenatedModule, RuntimeSpec[], string, Record<string, string>], boolean>} onDemandExportsGeneration
698
+ * @property {SyncBailHook<[Partial<ConcatenatedModuleInfo>, ConcatenatedModuleInfo], boolean | void>} concatenatedModuleInfo
699
+ */
700
+
701
+ /** @typedef {BuildInfo["topLevelDeclarations"]} TopLevelDeclarations */
702
+
703
+ /** @type {WeakMap<Compilation, ConcatenateModuleHooks>} */
704
+ const compilationHooksMap = new WeakMap();
705
+
706
+ class ConcatenatedModule extends Module {
707
+ /**
708
+ * @param {Module} rootModule the root module of the concatenation
709
+ * @param {Set<Module>} modules all modules in the concatenation (including the root module)
710
+ * @param {RuntimeSpec} runtime the runtime
711
+ * @param {Compilation} compilation the compilation
712
+ * @param {AssociatedObjectForCache=} associatedObjectForCache object for caching
713
+ * @param {HashFunction=} hashFunction hash function to use
714
+ * @returns {ConcatenatedModule} the module
715
+ */
716
+ static create(
717
+ rootModule,
718
+ modules,
719
+ runtime,
720
+ compilation,
721
+ associatedObjectForCache,
722
+ hashFunction = DEFAULTS.HASH_FUNCTION
723
+ ) {
724
+ const identifier = ConcatenatedModule._createIdentifier(
725
+ rootModule,
726
+ modules,
727
+ associatedObjectForCache,
728
+ hashFunction
729
+ );
730
+ return new ConcatenatedModule({
731
+ identifier,
732
+ rootModule,
733
+ modules,
734
+ runtime,
735
+ compilation
736
+ });
737
+ }
738
+
739
+ /**
740
+ * @param {Compilation} compilation the compilation
741
+ * @returns {ConcatenateModuleHooks} the attached hooks
742
+ */
743
+ static getCompilationHooks(compilation) {
744
+ let hooks = compilationHooksMap.get(compilation);
745
+ if (hooks === undefined) {
746
+ hooks = {
747
+ onDemandExportsGeneration: new SyncBailHook([
748
+ "module",
749
+ "runtimes",
750
+ "exportsFinalName",
751
+ "exportsSource"
752
+ ]),
753
+ concatenatedModuleInfo: new SyncBailHook([
754
+ "updatedInfo",
755
+ "concatenatedModuleInfo"
756
+ ])
757
+ };
758
+ compilationHooksMap.set(compilation, hooks);
759
+ }
760
+ return hooks;
761
+ }
762
+
763
+ /**
764
+ * @param {object} options options
765
+ * @param {string} options.identifier the identifier of the module
766
+ * @param {Module} options.rootModule the root module of the concatenation
767
+ * @param {RuntimeSpec} options.runtime the selected runtime
768
+ * @param {Set<Module>} options.modules all concatenated modules
769
+ * @param {Compilation} options.compilation the compilation
770
+ */
771
+ constructor({ identifier, rootModule, modules, runtime, compilation }) {
772
+ super(JAVASCRIPT_MODULE_TYPE_ESM, null, rootModule && rootModule.layer);
773
+
774
+ // Info from Factory
775
+ /** @type {string} */
776
+ this._identifier = identifier;
777
+ /** @type {Module} */
778
+ this.rootModule = rootModule;
779
+ /** @type {Set<Module>} */
780
+ this._modules = modules;
781
+ this._runtime = runtime;
782
+ this.factoryMeta = rootModule && rootModule.factoryMeta;
783
+ /** @type {Compilation} */
784
+ this.compilation = compilation;
785
+ }
786
+
787
+ /**
788
+ * Assuming this module is in the cache. Update the (cached) module with
789
+ * the fresh module from the factory. Usually updates internal references
790
+ * and properties.
791
+ * @param {Module} module fresh module
792
+ * @returns {void}
793
+ */
794
+ updateCacheModule(module) {
795
+ throw new Error("Must not be called");
796
+ }
797
+
798
+ /**
799
+ * @returns {SourceTypes} types available (do not mutate)
800
+ */
801
+ getSourceTypes() {
802
+ return JAVASCRIPT_TYPES;
803
+ }
804
+
805
+ get modules() {
806
+ return [...this._modules];
807
+ }
808
+
809
+ /**
810
+ * @returns {string} a unique identifier of the module
811
+ */
812
+ identifier() {
813
+ return this._identifier;
814
+ }
815
+
816
+ /**
817
+ * @param {RequestShortener} requestShortener the request shortener
818
+ * @returns {string} a user readable identifier of the module
819
+ */
820
+ readableIdentifier(requestShortener) {
821
+ return `${this.rootModule.readableIdentifier(
822
+ requestShortener
823
+ )} + ${this._modules.size - 1} modules`;
824
+ }
825
+
826
+ /**
827
+ * @param {LibIdentOptions} options options
828
+ * @returns {LibIdent | null} an identifier for library inclusion
829
+ */
830
+ libIdent(options) {
831
+ return this.rootModule.libIdent(options);
832
+ }
833
+
834
+ /**
835
+ * @returns {NameForCondition | null} absolute path which should be used for condition matching (usually the resource path)
836
+ */
837
+ nameForCondition() {
838
+ return this.rootModule.nameForCondition();
839
+ }
840
+
841
+ /**
842
+ * @param {ModuleGraph} moduleGraph the module graph
843
+ * @returns {ConnectionState} how this module should be connected to referencing modules when consumed for side-effects only
844
+ */
845
+ getSideEffectsConnectionState(moduleGraph) {
846
+ return this.rootModule.getSideEffectsConnectionState(moduleGraph);
847
+ }
848
+
849
+ /**
850
+ * @param {WebpackOptions} options webpack options
851
+ * @param {Compilation} compilation the compilation
852
+ * @param {ResolverWithOptions} resolver the resolver
853
+ * @param {InputFileSystem} fs the file system
854
+ * @param {BuildCallback} callback callback function
855
+ * @returns {void}
856
+ */
857
+ build(options, compilation, resolver, fs, callback) {
858
+ const { rootModule } = this;
859
+ const { moduleArgument, exportsArgument } =
860
+ /** @type {BuildInfo} */
861
+ (rootModule.buildInfo);
862
+ /** @type {BuildInfo} */
863
+ this.buildInfo = {
864
+ strict: true,
865
+ cacheable: true,
866
+ moduleArgument,
867
+ exportsArgument,
868
+ fileDependencies: new LazySet(),
869
+ contextDependencies: new LazySet(),
870
+ missingDependencies: new LazySet(),
871
+ topLevelDeclarations: new Set(),
872
+ assets: undefined
873
+ };
874
+ this.buildMeta = rootModule.buildMeta;
875
+ this.clearDependenciesAndBlocks();
876
+ this.clearWarningsAndErrors();
877
+
878
+ for (const m of this._modules) {
879
+ // populate cacheable
880
+ if (!(/** @type {BuildInfo} */ (m.buildInfo).cacheable)) {
881
+ this.buildInfo.cacheable = false;
882
+ }
883
+
884
+ // populate dependencies
885
+ for (const d of m.dependencies.filter(
886
+ (dep) =>
887
+ !(dep instanceof HarmonyImportDependency) ||
888
+ !this._modules.has(
889
+ /** @type {Module} */
890
+ (compilation.moduleGraph.getModule(dep))
891
+ )
892
+ )) {
893
+ this.dependencies.push(d);
894
+ }
895
+ // populate blocks
896
+ for (const d of m.blocks) {
897
+ this.blocks.push(d);
898
+ }
899
+
900
+ // populate warnings
901
+ const warnings = m.getWarnings();
902
+ if (warnings !== undefined) {
903
+ for (const warning of warnings) {
904
+ this.addWarning(warning);
905
+ }
906
+ }
907
+
908
+ // populate errors
909
+ const errors = m.getErrors();
910
+ if (errors !== undefined) {
911
+ for (const error of errors) {
912
+ this.addError(error);
913
+ }
914
+ }
915
+
916
+ const { assets, assetsInfo, topLevelDeclarations, needCreateRequire } =
917
+ /** @type {BuildInfo} */ (m.buildInfo);
918
+
919
+ const buildInfo = this.buildInfo;
920
+
921
+ // populate topLevelDeclarations
922
+ if (topLevelDeclarations) {
923
+ const topLevelDeclarations = buildInfo.topLevelDeclarations;
924
+ if (topLevelDeclarations !== undefined) {
925
+ for (const decl of topLevelDeclarations) {
926
+ topLevelDeclarations.add(decl);
927
+ }
928
+ }
929
+ } else {
930
+ buildInfo.topLevelDeclarations = undefined;
931
+ }
932
+
933
+ // populate needCreateRequire
934
+ if (needCreateRequire) {
935
+ this.buildInfo.needCreateRequire = true;
936
+ }
937
+
938
+ // populate assets
939
+ if (assets) {
940
+ if (buildInfo.assets === undefined) {
941
+ buildInfo.assets = Object.create(null);
942
+ }
943
+ Object.assign(
944
+ /** @type {NonNullable<BuildInfo["assets"]>} */
945
+ (buildInfo.assets),
946
+ assets
947
+ );
948
+ }
949
+ if (assetsInfo) {
950
+ if (buildInfo.assetsInfo === undefined) {
951
+ buildInfo.assetsInfo = new Map();
952
+ }
953
+ for (const [key, value] of assetsInfo) {
954
+ buildInfo.assetsInfo.set(key, value);
955
+ }
956
+ }
957
+ }
958
+ callback();
959
+ }
960
+
961
+ /**
962
+ * @param {string=} type the source type for which the size should be estimated
963
+ * @returns {number} the estimated size of the module (must be non-zero)
964
+ */
965
+ size(type) {
966
+ // Guess size from embedded modules
967
+ let size = 0;
968
+ for (const module of this._modules) {
969
+ size += module.size(type);
970
+ }
971
+ return size;
972
+ }
973
+
974
+ /**
975
+ * @private
976
+ * @param {Module} rootModule the root of the concatenation
977
+ * @param {Set<Module>} modulesSet a set of modules which should be concatenated
978
+ * @param {RuntimeSpec} runtime for this runtime
979
+ * @param {ModuleGraph} moduleGraph the module graph
980
+ * @returns {ConcatenationEntry[]} concatenation list
981
+ */
982
+ _createConcatenationList(rootModule, modulesSet, runtime, moduleGraph) {
983
+ /** @type {ConcatenationEntry[]} */
984
+ const list = [];
985
+ /** @type {Map<Module, { runtimeCondition: RuntimeSpec | true, nonDeferAccess: NonDeferAccess }>} */
986
+ const existingEntries = new Map();
987
+
988
+ /**
989
+ * @param {Module} module a module
990
+ * @returns {Iterable<{ connection: ModuleGraphConnection, runtimeCondition: RuntimeSpec | true, nonDeferAccess: NonDeferAccess }>} imported modules in order
991
+ */
992
+ const getConcatenatedImports = (module) => {
993
+ const connections = [...moduleGraph.getOutgoingConnections(module)];
994
+ if (module === rootModule) {
995
+ for (const c of moduleGraph.getOutgoingConnections(this)) {
996
+ connections.push(c);
997
+ }
998
+ }
999
+ /**
1000
+ * @type {{ connection: ModuleGraphConnection, sourceOrder: number, rangeStart: number | undefined, defer?: boolean }[]}
1001
+ */
1002
+ const references = connections
1003
+ .filter((connection) => {
1004
+ if (!(connection.dependency instanceof HarmonyImportDependency)) {
1005
+ return false;
1006
+ }
1007
+ if (!connection.module.getSourceBasicTypes().has(JAVASCRIPT_TYPE)) {
1008
+ return false;
1009
+ }
1010
+ return (
1011
+ connection &&
1012
+ connection.resolvedOriginModule === module &&
1013
+ connection.module &&
1014
+ connection.isTargetActive(runtime)
1015
+ );
1016
+ })
1017
+ .map((connection) => {
1018
+ const dep =
1019
+ /** @type {HarmonyImportDependency} */
1020
+ (connection.dependency);
1021
+ return {
1022
+ connection,
1023
+ sourceOrder: /** @type {number} */ (dep.sourceOrder),
1024
+ rangeStart: dep.range && dep.range[0],
1025
+ defer: ImportPhaseUtils.isDefer(dep.phase)
1026
+ };
1027
+ });
1028
+ /**
1029
+ * bySourceOrder
1030
+ * @example
1031
+ * import a from "a"; // sourceOrder=1
1032
+ * import b from "b"; // sourceOrder=2
1033
+ *
1034
+ * byRangeStart
1035
+ * @example
1036
+ * import {a, b} from "a"; // sourceOrder=1
1037
+ * a.a(); // first range
1038
+ * b.b(); // second range
1039
+ *
1040
+ * If there is no reexport, we have the same source.
1041
+ * If there is reexport, but module has side effects, this will lead to reexport module only.
1042
+ * If there is side-effects-free reexport, we can get simple deterministic result with range start comparison.
1043
+ */
1044
+ references.sort(concatComparators(bySourceOrder, byRangeStart));
1045
+ /** @type {Map<Module, { connection: ModuleGraphConnection, runtimeCondition: RuntimeSpec | true, nonDeferAccess: NonDeferAccess }>} */
1046
+ const referencesMap = new Map();
1047
+ for (const { connection, defer } of references) {
1048
+ const runtimeCondition = filterRuntime(runtime, (r) =>
1049
+ connection.isTargetActive(r)
1050
+ );
1051
+ if (runtimeCondition === false) continue;
1052
+ const nonDeferAccess = !defer;
1053
+ const module = connection.module;
1054
+ const entry = referencesMap.get(module);
1055
+ if (entry === undefined) {
1056
+ referencesMap.set(module, {
1057
+ connection,
1058
+ runtimeCondition,
1059
+ nonDeferAccess
1060
+ });
1061
+ continue;
1062
+ }
1063
+ entry.runtimeCondition = mergeRuntimeConditionNonFalse(
1064
+ entry.runtimeCondition,
1065
+ runtimeCondition,
1066
+ runtime
1067
+ );
1068
+ entry.nonDeferAccess = mergeNonDeferAccess(
1069
+ entry.nonDeferAccess,
1070
+ nonDeferAccess
1071
+ );
1072
+ }
1073
+ return referencesMap.values();
1074
+ };
1075
+
1076
+ /**
1077
+ * @param {ModuleGraphConnection} connection graph connection
1078
+ * @param {RuntimeSpec | true} runtimeCondition runtime condition
1079
+ * @param {NonDeferAccess} nonDeferAccess non-defer access
1080
+ * @returns {void}
1081
+ */
1082
+ const enterModule = (connection, runtimeCondition, nonDeferAccess) => {
1083
+ const module = connection.module;
1084
+ if (!module) return;
1085
+ const existingEntry = existingEntries.get(module);
1086
+ if (
1087
+ existingEntry &&
1088
+ existingEntry.runtimeCondition === true &&
1089
+ existingEntry.nonDeferAccess === true
1090
+ ) {
1091
+ return;
1092
+ }
1093
+ if (modulesSet.has(module)) {
1094
+ existingEntries.set(module, {
1095
+ runtimeCondition: true,
1096
+ nonDeferAccess: true
1097
+ });
1098
+ if (runtimeCondition !== true) {
1099
+ throw new Error(
1100
+ `Cannot runtime-conditional concatenate a module (${module.identifier()} in ${this.rootModule.identifier()}, ${runtimeConditionToString(
1101
+ runtimeCondition
1102
+ )}). This should not happen.`
1103
+ );
1104
+ }
1105
+ if (nonDeferAccess !== true) {
1106
+ throw new Error(
1107
+ `Cannot deferred concatenate a module (${module.identifier()} in ${this.rootModule.identifier()}. This should not happen.`
1108
+ );
1109
+ }
1110
+ const imports = getConcatenatedImports(module);
1111
+ for (const {
1112
+ connection,
1113
+ runtimeCondition,
1114
+ nonDeferAccess
1115
+ } of imports) {
1116
+ enterModule(connection, runtimeCondition, nonDeferAccess);
1117
+ }
1118
+ list.push({
1119
+ type: "concatenated",
1120
+ module: connection.module,
1121
+ runtimeCondition,
1122
+ nonDeferAccess
1123
+ });
1124
+ } else {
1125
+ /** @type {RuntimeSpec | boolean} */
1126
+ let reducedRuntimeCondition;
1127
+ /** @type {NonDeferAccess} */
1128
+ let reducedNonDeferAccess;
1129
+ if (existingEntry !== undefined) {
1130
+ reducedRuntimeCondition = subtractRuntimeCondition(
1131
+ runtimeCondition,
1132
+ existingEntry.runtimeCondition,
1133
+ runtime
1134
+ );
1135
+ reducedNonDeferAccess = subtractNonDeferAccess(
1136
+ nonDeferAccess,
1137
+ existingEntry.nonDeferAccess
1138
+ );
1139
+ if (
1140
+ reducedRuntimeCondition === false &&
1141
+ reducedNonDeferAccess === false
1142
+ ) {
1143
+ return;
1144
+ }
1145
+ if (reducedRuntimeCondition !== false) {
1146
+ existingEntry.runtimeCondition = mergeRuntimeConditionNonFalse(
1147
+ existingEntry.runtimeCondition,
1148
+ reducedRuntimeCondition,
1149
+ runtime
1150
+ );
1151
+ }
1152
+ if (reducedNonDeferAccess !== false) {
1153
+ existingEntry.nonDeferAccess = mergeNonDeferAccess(
1154
+ existingEntry.nonDeferAccess,
1155
+ reducedNonDeferAccess
1156
+ );
1157
+ }
1158
+ } else {
1159
+ reducedRuntimeCondition = runtimeCondition;
1160
+ reducedNonDeferAccess = nonDeferAccess;
1161
+ existingEntries.set(connection.module, {
1162
+ runtimeCondition,
1163
+ nonDeferAccess
1164
+ });
1165
+ }
1166
+ if (list.length > 0) {
1167
+ const lastItem = list[list.length - 1];
1168
+ if (
1169
+ lastItem.type === "external" &&
1170
+ lastItem.module === connection.module
1171
+ ) {
1172
+ lastItem.runtimeCondition = mergeRuntimeCondition(
1173
+ lastItem.runtimeCondition,
1174
+ reducedRuntimeCondition,
1175
+ runtime
1176
+ );
1177
+ lastItem.nonDeferAccess = mergeNonDeferAccess(
1178
+ lastItem.nonDeferAccess,
1179
+ reducedNonDeferAccess
1180
+ );
1181
+ return;
1182
+ }
1183
+ }
1184
+ list.push({
1185
+ type: "external",
1186
+ get module() {
1187
+ // We need to use a getter here, because the module in the dependency
1188
+ // could be replaced by some other process (i. e. also replaced with a
1189
+ // concatenated module)
1190
+ return connection.module;
1191
+ },
1192
+ runtimeCondition: reducedRuntimeCondition,
1193
+ nonDeferAccess: reducedNonDeferAccess
1194
+ });
1195
+ }
1196
+ };
1197
+
1198
+ existingEntries.set(rootModule, {
1199
+ runtimeCondition: true,
1200
+ nonDeferAccess: true
1201
+ });
1202
+ const imports = getConcatenatedImports(rootModule);
1203
+ for (const { connection, runtimeCondition, nonDeferAccess } of imports) {
1204
+ enterModule(connection, runtimeCondition, nonDeferAccess);
1205
+ }
1206
+ list.push({
1207
+ type: "concatenated",
1208
+ module: rootModule,
1209
+ runtimeCondition: true,
1210
+ nonDeferAccess: true
1211
+ });
1212
+
1213
+ return list;
1214
+ }
1215
+
1216
+ /**
1217
+ * @param {Module} rootModule the root module of the concatenation
1218
+ * @param {Set<Module>} modules all modules in the concatenation (including the root module)
1219
+ * @param {AssociatedObjectForCache=} associatedObjectForCache object for caching
1220
+ * @param {HashFunction=} hashFunction hash function to use
1221
+ * @returns {string} the identifier
1222
+ */
1223
+ static _createIdentifier(
1224
+ rootModule,
1225
+ modules,
1226
+ associatedObjectForCache,
1227
+ hashFunction = DEFAULTS.HASH_FUNCTION
1228
+ ) {
1229
+ const cachedMakePathsRelative = makePathsRelative.bindContextCache(
1230
+ /** @type {string} */ (rootModule.context),
1231
+ associatedObjectForCache
1232
+ );
1233
+ /** @type {string[]} */
1234
+ const identifiers = [];
1235
+ for (const module of modules) {
1236
+ identifiers.push(cachedMakePathsRelative(module.identifier()));
1237
+ }
1238
+ identifiers.sort();
1239
+ const hash = createHash(hashFunction);
1240
+ hash.update(identifiers.join(" "));
1241
+ return `${rootModule.identifier()}|${hash.digest("hex")}`;
1242
+ }
1243
+
1244
+ /**
1245
+ * @param {FileSystemDependencies} fileDependencies set where file dependencies are added to
1246
+ * @param {FileSystemDependencies} contextDependencies set where context dependencies are added to
1247
+ * @param {FileSystemDependencies} missingDependencies set where missing dependencies are added to
1248
+ * @param {FileSystemDependencies} buildDependencies set where build dependencies are added to
1249
+ */
1250
+ addCacheDependencies(
1251
+ fileDependencies,
1252
+ contextDependencies,
1253
+ missingDependencies,
1254
+ buildDependencies
1255
+ ) {
1256
+ for (const module of this._modules) {
1257
+ module.addCacheDependencies(
1258
+ fileDependencies,
1259
+ contextDependencies,
1260
+ missingDependencies,
1261
+ buildDependencies
1262
+ );
1263
+ }
1264
+ }
1265
+
1266
+ /**
1267
+ * @param {CodeGenerationContext} context context for code generation
1268
+ * @returns {CodeGenerationResult} result
1269
+ */
1270
+ codeGeneration({
1271
+ dependencyTemplates,
1272
+ runtimeTemplate,
1273
+ moduleGraph,
1274
+ chunkGraph,
1275
+ runtime: generationRuntime,
1276
+ runtimes,
1277
+ codeGenerationResults
1278
+ }) {
1279
+ const { concatenatedModuleInfo } = ConcatenatedModule.getCompilationHooks(
1280
+ this.compilation
1281
+ );
1282
+
1283
+ /** @type {RuntimeRequirements} */
1284
+ const runtimeRequirements = new Set();
1285
+ const runtime = intersectRuntime(generationRuntime, this._runtime);
1286
+
1287
+ const requestShortener = runtimeTemplate.requestShortener;
1288
+ // Meta info for each module
1289
+ const [modulesWithInfo, moduleToInfoMap] = this._getModulesWithInfo(
1290
+ moduleGraph,
1291
+ runtime
1292
+ );
1293
+
1294
+ // Set with modules that need a generated namespace object
1295
+ /** @type {NeededNamespaceObjects} */
1296
+ const neededNamespaceObjects = new Set();
1297
+
1298
+ // List of all used names to avoid conflicts
1299
+ const allUsedNames = new Set(RESERVED_NAMES);
1300
+
1301
+ // Generate source code and analyse scopes
1302
+ // Prepare a ReplaceSource for the final source
1303
+ for (const info of moduleToInfoMap.values()) {
1304
+ this._analyseModule(
1305
+ moduleToInfoMap,
1306
+ info,
1307
+ dependencyTemplates,
1308
+ runtimeTemplate,
1309
+ moduleGraph,
1310
+ chunkGraph,
1311
+ runtime,
1312
+ runtimes,
1313
+ /** @type {CodeGenerationResults} */
1314
+ (codeGenerationResults),
1315
+ allUsedNames
1316
+ );
1317
+ }
1318
+
1319
+ // Updated Top level declarations are created by renaming
1320
+ /** @type {TopLevelDeclarations} */
1321
+ const topLevelDeclarations = new Set();
1322
+
1323
+ // List of additional names in scope for module references
1324
+ /** @type {Map<string, ScopeInfo>} */
1325
+ const usedNamesInScopeInfo = new Map();
1326
+
1327
+ // Set of already checked scopes
1328
+ /** @type {Set<Scope>} */
1329
+ const ignoredScopes = new Set();
1330
+
1331
+ // get all global names
1332
+ for (const info of modulesWithInfo) {
1333
+ if (info.type === "concatenated") {
1334
+ // ignore symbols from moduleScope
1335
+ if (info.moduleScope) {
1336
+ ignoredScopes.add(info.moduleScope);
1337
+ }
1338
+
1339
+ // The super class expression in class scopes behaves weird
1340
+ // We get ranges of all super class expressions to make
1341
+ // renaming to work correctly
1342
+ /** @typedef {{ range: Range, variables: Variable[] }} ClassInfo */
1343
+ /** @type {WeakMap<Scope, ClassInfo[]>} */
1344
+ const superClassCache = new WeakMap();
1345
+ /**
1346
+ * @param {Scope} scope scope
1347
+ * @returns {ClassInfo[]} result
1348
+ */
1349
+ const getSuperClassExpressions = (scope) => {
1350
+ const cacheEntry = superClassCache.get(scope);
1351
+ if (cacheEntry !== undefined) return cacheEntry;
1352
+ /** @type {ClassInfo[]} */
1353
+ const superClassExpressions = [];
1354
+ for (const childScope of scope.childScopes) {
1355
+ if (childScope.type !== "class") continue;
1356
+ const block = childScope.block;
1357
+ if (
1358
+ (block.type === "ClassDeclaration" ||
1359
+ block.type === "ClassExpression") &&
1360
+ block.superClass
1361
+ ) {
1362
+ superClassExpressions.push({
1363
+ range: /** @type {Range} */ (block.superClass.range),
1364
+ variables: childScope.variables
1365
+ });
1366
+ }
1367
+ }
1368
+ superClassCache.set(scope, superClassExpressions);
1369
+ return superClassExpressions;
1370
+ };
1371
+
1372
+ // add global symbols
1373
+ if (info.globalScope) {
1374
+ for (const reference of info.globalScope.through) {
1375
+ const name = reference.identifier.name;
1376
+ if (ConcatenationScope.isModuleReference(name)) {
1377
+ const match = ConcatenationScope.matchModuleReference(name);
1378
+ if (!match) continue;
1379
+ const referencedInfo = modulesWithInfo[match.index];
1380
+ if (referencedInfo.type === "reference") {
1381
+ throw new Error("Module reference can't point to a reference");
1382
+ }
1383
+ const binding = getFinalBinding(
1384
+ moduleGraph,
1385
+ referencedInfo,
1386
+ match.ids,
1387
+ moduleToInfoMap,
1388
+ runtime,
1389
+ requestShortener,
1390
+ runtimeTemplate,
1391
+ neededNamespaceObjects,
1392
+ false,
1393
+ match.deferredImport,
1394
+ /** @type {BuildMeta} */
1395
+ (info.module.buildMeta).strictHarmonyModule,
1396
+ true
1397
+ );
1398
+ if (!binding.ids) continue;
1399
+ const { usedNames, alreadyCheckedScopes } =
1400
+ getUsedNamesInScopeInfo(
1401
+ usedNamesInScopeInfo,
1402
+ binding.info.module.identifier(),
1403
+ "name" in binding ? binding.name : ""
1404
+ );
1405
+ for (const expr of getSuperClassExpressions(reference.from)) {
1406
+ if (
1407
+ expr.range[0] <=
1408
+ /** @type {Range} */ (reference.identifier.range)[0] &&
1409
+ expr.range[1] >=
1410
+ /** @type {Range} */ (reference.identifier.range)[1]
1411
+ ) {
1412
+ for (const variable of expr.variables) {
1413
+ usedNames.add(variable.name);
1414
+ }
1415
+ }
1416
+ }
1417
+ addScopeSymbols(
1418
+ reference.from,
1419
+ usedNames,
1420
+ alreadyCheckedScopes,
1421
+ ignoredScopes
1422
+ );
1423
+ } else {
1424
+ allUsedNames.add(name);
1425
+ }
1426
+ }
1427
+ }
1428
+ }
1429
+ }
1430
+
1431
+ /**
1432
+ * @param {string} name the name to find a new name for
1433
+ * @param {ConcatenatedModuleInfo} info the info of the module
1434
+ * @param {Reference[]} references the references to the name
1435
+ * @returns {string | undefined} the new name or undefined if the name is not found
1436
+ */
1437
+ const _findNewName = (name, info, references) => {
1438
+ const { usedNames, alreadyCheckedScopes } = getUsedNamesInScopeInfo(
1439
+ usedNamesInScopeInfo,
1440
+ info.module.identifier(),
1441
+ name
1442
+ );
1443
+ if (allUsedNames.has(name) || usedNames.has(name)) {
1444
+ for (const ref of references) {
1445
+ addScopeSymbols(
1446
+ ref.from,
1447
+ usedNames,
1448
+ alreadyCheckedScopes,
1449
+ ignoredScopes
1450
+ );
1451
+ }
1452
+ const newName = findNewName(
1453
+ name,
1454
+ allUsedNames,
1455
+ usedNames,
1456
+ info.module.readableIdentifier(requestShortener)
1457
+ );
1458
+ allUsedNames.add(newName);
1459
+ info.internalNames.set(name, newName);
1460
+ topLevelDeclarations.add(newName);
1461
+ return newName;
1462
+ }
1463
+ };
1464
+
1465
+ /**
1466
+ * @param {string} name the name to find a new name for
1467
+ * @param {ConcatenatedModuleInfo} info the info of the module
1468
+ * @param {Reference[]} references the references to the name
1469
+ * @returns {string | undefined} the new name or undefined if the name is not found
1470
+ */
1471
+ const _findNewNameForSpecifier = (name, info, references) => {
1472
+ const { usedNames: moduleUsedNames, alreadyCheckedScopes } =
1473
+ getUsedNamesInScopeInfo(
1474
+ usedNamesInScopeInfo,
1475
+ info.module.identifier(),
1476
+ name
1477
+ );
1478
+ /** @type {UsedNames} */
1479
+ const referencesUsedNames = new Set();
1480
+ for (const ref of references) {
1481
+ addScopeSymbols(
1482
+ ref.from,
1483
+ referencesUsedNames,
1484
+ alreadyCheckedScopes,
1485
+ ignoredScopes
1486
+ );
1487
+ }
1488
+ if (moduleUsedNames.has(name) || referencesUsedNames.has(name)) {
1489
+ const newName = findNewName(
1490
+ name,
1491
+ allUsedNames,
1492
+ new Set([...moduleUsedNames, ...referencesUsedNames]),
1493
+ info.module.readableIdentifier(requestShortener)
1494
+ );
1495
+ allUsedNames.add(newName);
1496
+ topLevelDeclarations.add(newName);
1497
+ return newName;
1498
+ }
1499
+ };
1500
+
1501
+ // generate names for symbols
1502
+ for (const info of moduleToInfoMap.values()) {
1503
+ const { usedNames: namespaceObjectUsedNames } = getUsedNamesInScopeInfo(
1504
+ usedNamesInScopeInfo,
1505
+ info.module.identifier(),
1506
+ ""
1507
+ );
1508
+ switch (info.type) {
1509
+ case "concatenated": {
1510
+ const variables = /** @type {Scope} */ (info.moduleScope).variables;
1511
+ for (const variable of variables) {
1512
+ const name = variable.name;
1513
+ const references = getAllReferences(variable);
1514
+ const newName = _findNewName(name, info, references);
1515
+ if (newName) {
1516
+ const source = /** @type {ReplaceSource} */ (info.source);
1517
+ const allIdentifiers = new Set([
1518
+ ...references.map((r) => r.identifier),
1519
+ ...variable.identifiers
1520
+ ]);
1521
+ for (const identifier of allIdentifiers) {
1522
+ const r = /** @type {Range} */ (identifier.range);
1523
+ const path = getPathInAst(
1524
+ /** @type {NonNullable<ConcatenatedModuleInfo["ast"]>} */
1525
+ (info.ast),
1526
+ identifier
1527
+ );
1528
+ if (path && path.length > 1) {
1529
+ const maybeProperty =
1530
+ path[1].type === "AssignmentPattern" &&
1531
+ path[1].left === path[0]
1532
+ ? path[2]
1533
+ : path[1];
1534
+ if (
1535
+ maybeProperty.type === "Property" &&
1536
+ maybeProperty.shorthand
1537
+ ) {
1538
+ source.insert(r[1], `: ${newName}`);
1539
+ continue;
1540
+ }
1541
+ }
1542
+ source.replace(r[0], r[1] - 1, newName);
1543
+ }
1544
+ } else {
1545
+ allUsedNames.add(name);
1546
+ info.internalNames.set(name, name);
1547
+ topLevelDeclarations.add(name);
1548
+ }
1549
+ }
1550
+ /** @type {string} */
1551
+ let namespaceObjectName;
1552
+ if (info.namespaceExportSymbol) {
1553
+ namespaceObjectName =
1554
+ /** @type {string} */
1555
+ (info.internalNames.get(info.namespaceExportSymbol));
1556
+ } else {
1557
+ namespaceObjectName = findNewName(
1558
+ "namespaceObject",
1559
+ allUsedNames,
1560
+ namespaceObjectUsedNames,
1561
+ info.module.readableIdentifier(requestShortener)
1562
+ );
1563
+ allUsedNames.add(namespaceObjectName);
1564
+ }
1565
+ info.namespaceObjectName = namespaceObjectName;
1566
+ topLevelDeclarations.add(namespaceObjectName);
1567
+ break;
1568
+ }
1569
+ case "external": {
1570
+ const externalName = findNewName(
1571
+ "",
1572
+ allUsedNames,
1573
+ namespaceObjectUsedNames,
1574
+ info.module.readableIdentifier(requestShortener)
1575
+ );
1576
+ allUsedNames.add(externalName);
1577
+ info.name = externalName;
1578
+ topLevelDeclarations.add(externalName);
1579
+
1580
+ if (info.deferred) {
1581
+ const externalName = findNewName(
1582
+ "deferred",
1583
+ allUsedNames,
1584
+ namespaceObjectUsedNames,
1585
+ info.module.readableIdentifier(requestShortener)
1586
+ );
1587
+ allUsedNames.add(externalName);
1588
+ info.deferredName = externalName;
1589
+ topLevelDeclarations.add(externalName);
1590
+
1591
+ const externalNameInterop = findNewName(
1592
+ "deferredNamespaceObject",
1593
+ allUsedNames,
1594
+ namespaceObjectUsedNames,
1595
+ info.module.readableIdentifier(requestShortener)
1596
+ );
1597
+ allUsedNames.add(externalNameInterop);
1598
+ info.deferredNamespaceObjectName = externalNameInterop;
1599
+ topLevelDeclarations.add(externalNameInterop);
1600
+ }
1601
+ break;
1602
+ }
1603
+ }
1604
+ const buildMeta = /** @type {BuildMeta} */ (info.module.buildMeta);
1605
+ if (buildMeta.exportsType !== "namespace") {
1606
+ const externalNameInterop = findNewName(
1607
+ "namespaceObject",
1608
+ allUsedNames,
1609
+ namespaceObjectUsedNames,
1610
+ info.module.readableIdentifier(requestShortener)
1611
+ );
1612
+ allUsedNames.add(externalNameInterop);
1613
+ info.interopNamespaceObjectName = externalNameInterop;
1614
+ topLevelDeclarations.add(externalNameInterop);
1615
+ }
1616
+ if (
1617
+ buildMeta.exportsType === "default" &&
1618
+ buildMeta.defaultObject !== "redirect" &&
1619
+ info.interopNamespaceObject2Used
1620
+ ) {
1621
+ const externalNameInterop = findNewName(
1622
+ "namespaceObject2",
1623
+ allUsedNames,
1624
+ namespaceObjectUsedNames,
1625
+ info.module.readableIdentifier(requestShortener)
1626
+ );
1627
+ allUsedNames.add(externalNameInterop);
1628
+ info.interopNamespaceObject2Name = externalNameInterop;
1629
+ topLevelDeclarations.add(externalNameInterop);
1630
+ }
1631
+ if (buildMeta.exportsType === "dynamic" || !buildMeta.exportsType) {
1632
+ const externalNameInterop = findNewName(
1633
+ "default",
1634
+ allUsedNames,
1635
+ namespaceObjectUsedNames,
1636
+ info.module.readableIdentifier(requestShortener)
1637
+ );
1638
+ allUsedNames.add(externalNameInterop);
1639
+ info.interopDefaultAccessName = externalNameInterop;
1640
+ topLevelDeclarations.add(externalNameInterop);
1641
+ }
1642
+ }
1643
+
1644
+ // Find and replace references to modules
1645
+ for (const info of moduleToInfoMap.values()) {
1646
+ if (info.type === "concatenated") {
1647
+ const globalScope = /** @type {Scope} */ (info.globalScope);
1648
+ // group references by name
1649
+ /** @type {Map<string, Reference[]>} */
1650
+ const referencesByName = new Map();
1651
+ for (const reference of globalScope.through) {
1652
+ const name = reference.identifier.name;
1653
+ if (!referencesByName.has(name)) {
1654
+ referencesByName.set(name, []);
1655
+ }
1656
+ /** @type {Reference[]} */
1657
+ (referencesByName.get(name)).push(reference);
1658
+ }
1659
+ for (const [name, references] of referencesByName) {
1660
+ const match = ConcatenationScope.matchModuleReference(name);
1661
+ if (match) {
1662
+ const referencedInfo = modulesWithInfo[match.index];
1663
+ if (referencedInfo.type === "reference") {
1664
+ throw new Error("Module reference can't point to a reference");
1665
+ }
1666
+ const concatenationScope = /** @type {ConcatenatedModuleInfo} */ (
1667
+ referencedInfo
1668
+ ).concatenationScope;
1669
+ const exportId = match.ids[0];
1670
+ const specifier =
1671
+ concatenationScope && concatenationScope.getRawExport(exportId);
1672
+ if (specifier) {
1673
+ const newName = _findNewNameForSpecifier(
1674
+ specifier,
1675
+ info,
1676
+ references
1677
+ );
1678
+ const initFragmentChanged =
1679
+ newName &&
1680
+ concatenatedModuleInfo.call(
1681
+ {
1682
+ rawExportMap: new Map([
1683
+ [exportId, /** @type {string} */ (newName)]
1684
+ ])
1685
+ },
1686
+ /** @type {ConcatenatedModuleInfo} */ (referencedInfo)
1687
+ );
1688
+ if (initFragmentChanged) {
1689
+ concatenationScope.setRawExportMap(exportId, newName);
1690
+ }
1691
+ }
1692
+ const finalName = getFinalName(
1693
+ moduleGraph,
1694
+ referencedInfo,
1695
+ match.ids,
1696
+ moduleToInfoMap,
1697
+ runtime,
1698
+ requestShortener,
1699
+ runtimeTemplate,
1700
+ neededNamespaceObjects,
1701
+ match.call,
1702
+ match.deferredImport,
1703
+ !match.directImport,
1704
+ /** @type {BuildMeta} */
1705
+ (info.module.buildMeta).strictHarmonyModule,
1706
+ match.asiSafe
1707
+ );
1708
+
1709
+ for (const reference of references) {
1710
+ const r = /** @type {Range} */ (reference.identifier.range);
1711
+ const source = /** @type {ReplaceSource} */ (info.source);
1712
+ // range is extended by 2 chars to cover the appended "._"
1713
+ source.replace(r[0], r[1] + 1, finalName);
1714
+ }
1715
+ }
1716
+ }
1717
+ }
1718
+ }
1719
+
1720
+ // Map with all root exposed used exports
1721
+ /** @type {Map<string, (requestShortener: RequestShortener) => string>} */
1722
+ const exportsMap = new Map();
1723
+
1724
+ // Set with all root exposed unused exports
1725
+ /** @type {Set<string>} */
1726
+ const unusedExports = new Set();
1727
+
1728
+ const rootInfo =
1729
+ /** @type {ConcatenatedModuleInfo} */
1730
+ (moduleToInfoMap.get(this.rootModule));
1731
+ const strictHarmonyModule =
1732
+ /** @type {BuildMeta} */
1733
+ (rootInfo.module.buildMeta).strictHarmonyModule;
1734
+ const exportsInfo = moduleGraph.getExportsInfo(rootInfo.module);
1735
+ /** @type {Record<string, string>} */
1736
+ const exportsFinalName = {};
1737
+ for (const exportInfo of exportsInfo.orderedExports) {
1738
+ const name = exportInfo.name;
1739
+ if (exportInfo.provided === false) continue;
1740
+ const used = exportInfo.getUsedName(undefined, runtime);
1741
+ if (!used) {
1742
+ unusedExports.add(name);
1743
+ continue;
1744
+ }
1745
+ exportsMap.set(used, (requestShortener) => {
1746
+ try {
1747
+ const finalName = getFinalName(
1748
+ moduleGraph,
1749
+ rootInfo,
1750
+ [name],
1751
+ moduleToInfoMap,
1752
+ runtime,
1753
+ requestShortener,
1754
+ runtimeTemplate,
1755
+ neededNamespaceObjects,
1756
+ false,
1757
+ false,
1758
+ false,
1759
+ strictHarmonyModule,
1760
+ true
1761
+ );
1762
+ exportsFinalName[used] = finalName;
1763
+ return `/* ${
1764
+ exportInfo.isReexport() ? "reexport" : "binding"
1765
+ } */ ${finalName}`;
1766
+ } catch (err) {
1767
+ /** @type {Error} */
1768
+ (err).message +=
1769
+ `\nwhile generating the root export '${name}' (used name: '${used}')`;
1770
+ throw err;
1771
+ }
1772
+ });
1773
+ }
1774
+
1775
+ const result = new ConcatSource();
1776
+
1777
+ // add harmony compatibility flag (must be first because of possible circular dependencies)
1778
+ let shouldAddHarmonyFlag = false;
1779
+ const rootExportsInfo = moduleGraph.getExportsInfo(this);
1780
+ if (
1781
+ rootExportsInfo.otherExportsInfo.getUsed(runtime) !== UsageState.Unused ||
1782
+ rootExportsInfo.getReadOnlyExportInfo("__esModule").getUsed(runtime) !==
1783
+ UsageState.Unused
1784
+ ) {
1785
+ shouldAddHarmonyFlag = true;
1786
+ }
1787
+
1788
+ // define exports
1789
+ if (exportsMap.size > 0) {
1790
+ /** @type {string[]} */
1791
+ const definitions = [];
1792
+ for (const [key, value] of exportsMap) {
1793
+ definitions.push(
1794
+ `\n ${propertyName(key)}: ${runtimeTemplate.returningFunction(
1795
+ value(requestShortener)
1796
+ )}`
1797
+ );
1798
+ }
1799
+
1800
+ runtimeRequirements.add(RuntimeGlobals.exports);
1801
+ runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
1802
+
1803
+ if (shouldAddHarmonyFlag) {
1804
+ result.add("// ESM COMPAT FLAG\n");
1805
+ result.add(
1806
+ runtimeTemplate.defineEsModuleFlagStatement({
1807
+ exportsArgument: this.exportsArgument,
1808
+ runtimeRequirements
1809
+ })
1810
+ );
1811
+ }
1812
+
1813
+ const exportsSource =
1814
+ "\n// EXPORTS\n" +
1815
+ `${RuntimeGlobals.definePropertyGetters}(${this.exportsArgument}, {${definitions.join(
1816
+ ","
1817
+ )}\n});\n`;
1818
+
1819
+ const { onDemandExportsGeneration } =
1820
+ ConcatenatedModule.getCompilationHooks(this.compilation);
1821
+
1822
+ if (
1823
+ !onDemandExportsGeneration.call(
1824
+ this,
1825
+ runtimes,
1826
+ exportsSource,
1827
+ exportsFinalName
1828
+ )
1829
+ ) {
1830
+ result.add(exportsSource);
1831
+ }
1832
+ }
1833
+
1834
+ // list unused exports
1835
+ if (unusedExports.size > 0) {
1836
+ result.add(
1837
+ `\n// UNUSED EXPORTS: ${joinIterableWithComma(unusedExports)}\n`
1838
+ );
1839
+ }
1840
+
1841
+ // generate namespace objects
1842
+ /** @type {Map<ConcatenatedModuleInfo, string>} */
1843
+ const namespaceObjectSources = new Map();
1844
+ for (const info of neededNamespaceObjects) {
1845
+ if (info.namespaceExportSymbol) continue;
1846
+ /** @type {string[]} */
1847
+ const nsObj = [];
1848
+ const exportsInfo = moduleGraph.getExportsInfo(info.module);
1849
+ for (const exportInfo of exportsInfo.orderedExports) {
1850
+ if (exportInfo.provided === false) continue;
1851
+ const usedName = exportInfo.getUsedName(undefined, runtime);
1852
+ if (usedName) {
1853
+ const finalName = getFinalName(
1854
+ moduleGraph,
1855
+ info,
1856
+ [exportInfo.name],
1857
+ moduleToInfoMap,
1858
+ runtime,
1859
+ requestShortener,
1860
+ runtimeTemplate,
1861
+ neededNamespaceObjects,
1862
+ false,
1863
+ false,
1864
+ undefined,
1865
+ /** @type {BuildMeta} */
1866
+ (info.module.buildMeta).strictHarmonyModule,
1867
+ true
1868
+ );
1869
+ nsObj.push(
1870
+ `\n ${propertyName(usedName)}: ${runtimeTemplate.returningFunction(
1871
+ finalName
1872
+ )}`
1873
+ );
1874
+ }
1875
+ }
1876
+ const name = info.namespaceObjectName;
1877
+ const defineGetters =
1878
+ nsObj.length > 0
1879
+ ? `${RuntimeGlobals.definePropertyGetters}(${name}, {${nsObj.join(
1880
+ ","
1881
+ )}\n});\n`
1882
+ : "";
1883
+ if (nsObj.length > 0) {
1884
+ runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
1885
+ }
1886
+ namespaceObjectSources.set(
1887
+ info,
1888
+ `
1889
+ // NAMESPACE OBJECT: ${info.module.readableIdentifier(requestShortener)}
1890
+ var ${name} = {};
1891
+ ${RuntimeGlobals.makeNamespaceObject}(${name});
1892
+ ${defineGetters}`
1893
+ );
1894
+ runtimeRequirements.add(RuntimeGlobals.makeNamespaceObject);
1895
+ }
1896
+
1897
+ // define required namespace objects (must be before evaluation modules)
1898
+ for (const info of modulesWithInfo) {
1899
+ if (info.type === "concatenated") {
1900
+ const source = namespaceObjectSources.get(info);
1901
+ if (!source) continue;
1902
+ result.add(source);
1903
+ }
1904
+
1905
+ if (info.type === "external" && info.deferred) {
1906
+ const moduleId = JSON.stringify(chunkGraph.getModuleId(info.module));
1907
+ const loader = getOptimizedDeferredModule(
1908
+ moduleId,
1909
+ info.module.getExportsType(
1910
+ moduleGraph,
1911
+ /** @type {BuildMeta} */
1912
+ (this.rootModule.buildMeta).strictHarmonyModule
1913
+ ),
1914
+ // an async module will opt-out of the concat module optimization.
1915
+ [],
1916
+ runtimeRequirements
1917
+ );
1918
+ runtimeRequirements.add(RuntimeGlobals.require);
1919
+ result.add(
1920
+ `\n// DEFERRED EXTERNAL MODULE: ${info.module.readableIdentifier(requestShortener)}\nvar ${info.deferredName} = ${loader};`
1921
+ );
1922
+ if (info.deferredNamespaceObjectUsed) {
1923
+ runtimeRequirements.add(RuntimeGlobals.makeDeferredNamespaceObject);
1924
+ result.add(
1925
+ `\nvar ${info.deferredNamespaceObjectName} = /*#__PURE__*/${
1926
+ RuntimeGlobals.makeDeferredNamespaceObject
1927
+ }(${JSON.stringify(
1928
+ chunkGraph.getModuleId(info.module)
1929
+ )}, ${getMakeDeferredNamespaceModeFromExportsType(
1930
+ info.module.getExportsType(moduleGraph, strictHarmonyModule)
1931
+ )});`
1932
+ );
1933
+ }
1934
+ }
1935
+ }
1936
+
1937
+ /** @type {InitFragment<ChunkRenderContext>[]} */
1938
+ const chunkInitFragments = [];
1939
+
1940
+ // evaluate modules in order
1941
+ for (const rawInfo of modulesWithInfo) {
1942
+ /** @type {undefined | string} */
1943
+ let name;
1944
+ let isConditional = false;
1945
+ const info = rawInfo.type === "reference" ? rawInfo.target : rawInfo;
1946
+ switch (info.type) {
1947
+ case "concatenated": {
1948
+ result.add(
1949
+ `\n;// ${info.module.readableIdentifier(requestShortener)}\n`
1950
+ );
1951
+ result.add(/** @type {ReplaceSource} */ (info.source));
1952
+ if (info.chunkInitFragments) {
1953
+ for (const f of info.chunkInitFragments) chunkInitFragments.push(f);
1954
+ }
1955
+ if (info.runtimeRequirements) {
1956
+ for (const r of info.runtimeRequirements) {
1957
+ runtimeRequirements.add(r);
1958
+ }
1959
+ }
1960
+ name = info.namespaceObjectName;
1961
+ break;
1962
+ }
1963
+ case "external": {
1964
+ // deferred case is handled in the "const info of modulesWithInfo" loop above
1965
+ if (!info.deferred) {
1966
+ result.add(
1967
+ `\n// EXTERNAL MODULE: ${info.module.readableIdentifier(
1968
+ requestShortener
1969
+ )}\n`
1970
+ );
1971
+ runtimeRequirements.add(RuntimeGlobals.require);
1972
+ const { runtimeCondition } =
1973
+ /** @type {ExternalModuleInfo | ReferenceToModuleInfo} */
1974
+ (rawInfo);
1975
+ const condition = runtimeTemplate.runtimeConditionExpression({
1976
+ chunkGraph,
1977
+ runtimeCondition,
1978
+ runtime,
1979
+ runtimeRequirements
1980
+ });
1981
+ if (condition !== "true") {
1982
+ isConditional = true;
1983
+ result.add(`if (${condition}) {\n`);
1984
+ }
1985
+ const moduleId = JSON.stringify(
1986
+ chunkGraph.getModuleId(info.module)
1987
+ );
1988
+ result.add(`var ${info.name} = __webpack_require__(${moduleId});`);
1989
+ name = info.name;
1990
+ }
1991
+ // If a module is deferred in other places, but used as non-deferred here,
1992
+ // the module itself will be emitted as mod_deferred (in the case "external"),
1993
+ // we need to emit an extra import declaration to evaluate it in order.
1994
+ const { nonDeferAccess } =
1995
+ /** @type {ExternalModuleInfo | ReferenceToModuleInfo} */
1996
+ (rawInfo);
1997
+ if (info.deferred && nonDeferAccess) {
1998
+ result.add(
1999
+ `\n// non-deferred import to a deferred module (${info.module.readableIdentifier(requestShortener)})\nvar ${info.name} = ${info.deferredName}.a;`
2000
+ );
2001
+ }
2002
+ break;
2003
+ }
2004
+ default:
2005
+ // @ts-expect-error never is expected here
2006
+ throw new Error(`Unsupported concatenation entry type ${info.type}`);
2007
+ }
2008
+ if (info.interopNamespaceObjectUsed) {
2009
+ runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
2010
+ result.add(
2011
+ `\nvar ${info.interopNamespaceObjectName} = /*#__PURE__*/${RuntimeGlobals.createFakeNamespaceObject}(${name}, 2);`
2012
+ );
2013
+ }
2014
+ if (info.interopNamespaceObject2Used) {
2015
+ runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
2016
+ result.add(
2017
+ `\nvar ${info.interopNamespaceObject2Name} = /*#__PURE__*/${RuntimeGlobals.createFakeNamespaceObject}(${name});`
2018
+ );
2019
+ }
2020
+ if (info.interopDefaultAccessUsed) {
2021
+ runtimeRequirements.add(RuntimeGlobals.compatGetDefaultExport);
2022
+ result.add(
2023
+ `\nvar ${info.interopDefaultAccessName} = /*#__PURE__*/${RuntimeGlobals.compatGetDefaultExport}(${name});`
2024
+ );
2025
+ }
2026
+ if (isConditional) {
2027
+ result.add("\n}");
2028
+ }
2029
+ }
2030
+
2031
+ /** @type {CodeGenerationResultData} */
2032
+ const data = new Map();
2033
+ if (chunkInitFragments.length > 0) {
2034
+ data.set("chunkInitFragments", chunkInitFragments);
2035
+ }
2036
+ data.set("topLevelDeclarations", topLevelDeclarations);
2037
+
2038
+ /** @type {CodeGenerationResult} */
2039
+ const resultEntry = {
2040
+ sources: new Map([[JAVASCRIPT_TYPE, new CachedSource(result)]]),
2041
+ data,
2042
+ runtimeRequirements
2043
+ };
2044
+
2045
+ return resultEntry;
2046
+ }
2047
+
2048
+ /**
2049
+ * @param {ModuleToInfoMap} modulesMap modulesMap
2050
+ * @param {ModuleInfo} info info
2051
+ * @param {DependencyTemplates} dependencyTemplates dependencyTemplates
2052
+ * @param {RuntimeTemplate} runtimeTemplate runtimeTemplate
2053
+ * @param {ModuleGraph} moduleGraph moduleGraph
2054
+ * @param {ChunkGraph} chunkGraph chunkGraph
2055
+ * @param {RuntimeSpec} runtime runtime
2056
+ * @param {RuntimeSpec[]} runtimes runtimes
2057
+ * @param {CodeGenerationResults} codeGenerationResults codeGenerationResults
2058
+ * @param {UsedNames} usedNames used names
2059
+ */
2060
+ _analyseModule(
2061
+ modulesMap,
2062
+ info,
2063
+ dependencyTemplates,
2064
+ runtimeTemplate,
2065
+ moduleGraph,
2066
+ chunkGraph,
2067
+ runtime,
2068
+ runtimes,
2069
+ codeGenerationResults,
2070
+ usedNames
2071
+ ) {
2072
+ if (info.type === "concatenated") {
2073
+ const m = info.module;
2074
+ try {
2075
+ // Create a concatenation scope to track and capture information
2076
+ const concatenationScope = new ConcatenationScope(
2077
+ modulesMap,
2078
+ info,
2079
+ usedNames
2080
+ );
2081
+
2082
+ // TODO cache codeGeneration results
2083
+ const codeGenResult = m.codeGeneration({
2084
+ dependencyTemplates,
2085
+ runtimeTemplate,
2086
+ moduleGraph,
2087
+ chunkGraph,
2088
+ runtime,
2089
+ runtimes,
2090
+ concatenationScope,
2091
+ codeGenerationResults,
2092
+ sourceTypes: JAVASCRIPT_TYPES
2093
+ });
2094
+ const source =
2095
+ /** @type {Source} */
2096
+ (codeGenResult.sources.get(JAVASCRIPT_TYPE));
2097
+ const data = codeGenResult.data;
2098
+ const chunkInitFragments = data && data.get("chunkInitFragments");
2099
+ const code = source.source().toString();
2100
+
2101
+ /** @type {Program} */
2102
+ let ast;
2103
+
2104
+ try {
2105
+ ({ ast } = JavascriptParser._parse(
2106
+ code,
2107
+ {
2108
+ sourceType: "module",
2109
+ ranges: true
2110
+ },
2111
+ JavascriptParser._getModuleParseFunction(this.compilation, m)
2112
+ ));
2113
+ } catch (_err) {
2114
+ const err =
2115
+ /** @type {Error & { loc?: { line: number, column: number } }} */
2116
+ (_err);
2117
+ if (
2118
+ err.loc &&
2119
+ typeof err.loc === "object" &&
2120
+ typeof err.loc.line === "number"
2121
+ ) {
2122
+ const lineNumber = err.loc.line;
2123
+ const lines = code.split("\n");
2124
+ err.message += `\n| ${lines
2125
+ .slice(Math.max(0, lineNumber - 3), lineNumber + 2)
2126
+ .join("\n| ")}`;
2127
+ }
2128
+ throw err;
2129
+ }
2130
+ const scopeManager = eslintScope.analyze(ast, {
2131
+ ecmaVersion: 6,
2132
+ sourceType: "module",
2133
+ optimistic: true,
2134
+ ignoreEval: true,
2135
+ impliedStrict: true
2136
+ });
2137
+ const globalScope = /** @type {Scope} */ (scopeManager.acquire(ast));
2138
+ const moduleScope = globalScope.childScopes[0];
2139
+ const resultSource = new ReplaceSource(source);
2140
+ info.runtimeRequirements =
2141
+ /** @type {ReadOnlyRuntimeRequirements} */
2142
+ (codeGenResult.runtimeRequirements);
2143
+ info.ast = ast;
2144
+ info.internalSource = source;
2145
+ info.source = resultSource;
2146
+ info.chunkInitFragments = chunkInitFragments;
2147
+ info.globalScope = globalScope;
2148
+ info.moduleScope = moduleScope;
2149
+ info.concatenationScope = concatenationScope;
2150
+ } catch (err) {
2151
+ /** @type {Error} */
2152
+ (err).message +=
2153
+ `\nwhile analyzing module ${m.identifier()} for concatenation`;
2154
+ throw err;
2155
+ }
2156
+ }
2157
+ }
2158
+
2159
+ /**
2160
+ * @param {ModuleGraph} moduleGraph the module graph
2161
+ * @param {RuntimeSpec} runtime the runtime
2162
+ * @returns {[ModuleInfoOrReference[], ModuleToInfoMap]} module info items
2163
+ */
2164
+ _getModulesWithInfo(moduleGraph, runtime) {
2165
+ const orderedConcatenationList = this._createConcatenationList(
2166
+ this.rootModule,
2167
+ this._modules,
2168
+ runtime,
2169
+ moduleGraph
2170
+ );
2171
+ /** @type {ModuleToInfoMap} */
2172
+ const map = new Map();
2173
+ const list = orderedConcatenationList.map((info, index) => {
2174
+ let item = map.get(info.module);
2175
+ if (item === undefined) {
2176
+ switch (info.type) {
2177
+ case "concatenated":
2178
+ item = {
2179
+ type: "concatenated",
2180
+ module: info.module,
2181
+ index,
2182
+ ast: undefined,
2183
+ internalSource: undefined,
2184
+ runtimeRequirements: undefined,
2185
+ source: undefined,
2186
+ globalScope: undefined,
2187
+ moduleScope: undefined,
2188
+ internalNames: new Map(),
2189
+ exportMap: undefined,
2190
+ rawExportMap: undefined,
2191
+ namespaceExportSymbol: undefined,
2192
+ namespaceObjectName: undefined,
2193
+ interopNamespaceObjectUsed: false,
2194
+ interopNamespaceObjectName: undefined,
2195
+ interopNamespaceObject2Used: false,
2196
+ interopNamespaceObject2Name: undefined,
2197
+ interopDefaultAccessUsed: false,
2198
+ interopDefaultAccessName: undefined,
2199
+ concatenationScope: undefined
2200
+ };
2201
+ break;
2202
+ case "external":
2203
+ item = {
2204
+ type: "external",
2205
+ module: info.module,
2206
+ runtimeCondition: info.runtimeCondition,
2207
+ nonDeferAccess: info.nonDeferAccess,
2208
+ index,
2209
+ name: undefined,
2210
+ deferredName: undefined,
2211
+ interopNamespaceObjectUsed: false,
2212
+ interopNamespaceObjectName: undefined,
2213
+ interopNamespaceObject2Used: false,
2214
+ interopNamespaceObject2Name: undefined,
2215
+ interopDefaultAccessUsed: false,
2216
+ interopDefaultAccessName: undefined,
2217
+ deferred: moduleGraph.isDeferred(info.module),
2218
+ deferredNamespaceObjectName: undefined,
2219
+ deferredNamespaceObjectUsed: false
2220
+ };
2221
+ break;
2222
+ default:
2223
+ throw new Error(
2224
+ `Unsupported concatenation entry type ${info.type}`
2225
+ );
2226
+ }
2227
+ map.set(
2228
+ /** @type {ModuleInfo} */ (item).module,
2229
+ /** @type {ModuleInfo} */ (item)
2230
+ );
2231
+ return /** @type {ModuleInfo} */ (item);
2232
+ }
2233
+ /** @type {ReferenceToModuleInfo} */
2234
+ const ref = {
2235
+ type: "reference",
2236
+ runtimeCondition: info.runtimeCondition,
2237
+ nonDeferAccess: info.nonDeferAccess,
2238
+ target: item
2239
+ };
2240
+ return ref;
2241
+ });
2242
+ return [list, map];
2243
+ }
2244
+
2245
+ /**
2246
+ * @param {Hash} hash the hash used to track dependencies
2247
+ * @param {UpdateHashContext} context context
2248
+ * @returns {void}
2249
+ */
2250
+ updateHash(hash, context) {
2251
+ const { chunkGraph, runtime } = context;
2252
+ for (const info of this._createConcatenationList(
2253
+ this.rootModule,
2254
+ this._modules,
2255
+ intersectRuntime(runtime, this._runtime),
2256
+ chunkGraph.moduleGraph
2257
+ )) {
2258
+ switch (info.type) {
2259
+ case "concatenated":
2260
+ info.module.updateHash(hash, context);
2261
+ break;
2262
+ case "external":
2263
+ hash.update(`${chunkGraph.getModuleId(info.module)}`);
2264
+ // TODO runtimeCondition
2265
+ break;
2266
+ }
2267
+ }
2268
+ super.updateHash(hash, context);
2269
+ }
2270
+
2271
+ /**
2272
+ * @param {ObjectDeserializerContext} context context
2273
+ * @returns {ConcatenatedModule} ConcatenatedModule
2274
+ */
2275
+ static deserialize(context) {
2276
+ const obj = new ConcatenatedModule({
2277
+ identifier: /** @type {EXPECTED_ANY} */ (undefined),
2278
+ rootModule: /** @type {EXPECTED_ANY} */ (undefined),
2279
+ modules: /** @type {EXPECTED_ANY} */ (undefined),
2280
+ runtime: undefined,
2281
+ compilation: /** @type {EXPECTED_ANY} */ (undefined)
2282
+ });
2283
+ obj.deserialize(context);
2284
+ return obj;
2285
+ }
2286
+ }
2287
+
2288
+ makeSerializable(ConcatenatedModule, "webpack/lib/optimize/ConcatenatedModule");
2289
+
2290
+ module.exports = ConcatenatedModule;