@module-federation/enhanced 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/dist/CHANGELOG.md +2357 -0
  2. package/dist/README.md +213 -0
  3. package/dist/rstestmigrate.md +140 -0
  4. package/dist/src/_virtual/_rolldown/runtime.js +47 -0
  5. package/dist/src/index.d.ts +22 -19
  6. package/dist/src/index.js +47 -43
  7. package/dist/src/index.js.map +1 -1
  8. package/dist/src/lib/Constants.d.ts +25 -29
  9. package/dist/src/lib/Constants.js +136 -116
  10. package/dist/src/lib/Constants.js.map +1 -1
  11. package/dist/src/lib/container/AsyncBoundaryPlugin.d.ts +20 -16
  12. package/dist/src/lib/container/AsyncBoundaryPlugin.js +137 -200
  13. package/dist/src/lib/container/AsyncBoundaryPlugin.js.map +1 -1
  14. package/dist/src/lib/container/ContainerEntryDependency.d.ts +28 -23
  15. package/dist/src/lib/container/ContainerEntryDependency.js +39 -39
  16. package/dist/src/lib/container/ContainerEntryDependency.js.map +1 -1
  17. package/dist/src/lib/container/ContainerEntryModule.d.ts +93 -84
  18. package/dist/src/lib/container/ContainerEntryModule.js +219 -234
  19. package/dist/src/lib/container/ContainerEntryModule.js.map +1 -1
  20. package/dist/src/lib/container/ContainerEntryModuleFactory.d.ts +15 -10
  21. package/dist/src/lib/container/ContainerEntryModuleFactory.js +21 -25
  22. package/dist/src/lib/container/ContainerEntryModuleFactory.js.map +1 -1
  23. package/dist/src/lib/container/ContainerExposedDependency.d.ts +29 -24
  24. package/dist/src/lib/container/ContainerExposedDependency.js +47 -47
  25. package/dist/src/lib/container/ContainerExposedDependency.js.map +1 -1
  26. package/dist/src/lib/container/ContainerPlugin.d.ts +12 -8
  27. package/dist/src/lib/container/ContainerPlugin.js +147 -211
  28. package/dist/src/lib/container/ContainerPlugin.js.map +1 -1
  29. package/dist/src/lib/container/ContainerReferencePlugin.d.ts +16 -12
  30. package/dist/src/lib/container/ContainerReferencePlugin.js +74 -102
  31. package/dist/src/lib/container/ContainerReferencePlugin.js.map +1 -1
  32. package/dist/src/lib/container/FallbackDependency.d.ts +24 -19
  33. package/dist/src/lib/container/FallbackDependency.js +46 -44
  34. package/dist/src/lib/container/FallbackDependency.js.map +1 -1
  35. package/dist/src/lib/container/FallbackItemDependency.d.ts +13 -8
  36. package/dist/src/lib/container/FallbackItemDependency.js +24 -24
  37. package/dist/src/lib/container/FallbackItemDependency.js.map +1 -1
  38. package/dist/src/lib/container/FallbackModule.d.ts +82 -71
  39. package/dist/src/lib/container/FallbackModule.js +133 -145
  40. package/dist/src/lib/container/FallbackModule.js.map +1 -1
  41. package/dist/src/lib/container/FallbackModuleFactory.d.ts +15 -10
  42. package/dist/src/lib/container/FallbackModuleFactory.js +20 -24
  43. package/dist/src/lib/container/FallbackModuleFactory.js.map +1 -1
  44. package/dist/src/lib/container/HoistContainerReferencesPlugin.d.ts +11 -7
  45. package/dist/src/lib/container/HoistContainerReferencesPlugin.js +125 -188
  46. package/dist/src/lib/container/HoistContainerReferencesPlugin.js.map +1 -1
  47. package/dist/src/lib/container/ModuleFederationPlugin.d.ts +20 -16
  48. package/dist/src/lib/container/ModuleFederationPlugin.js +143 -181
  49. package/dist/src/lib/container/ModuleFederationPlugin.js.map +1 -1
  50. package/dist/src/lib/container/RemoteModule.d.ts +79 -74
  51. package/dist/src/lib/container/RemoteModule.js +143 -153
  52. package/dist/src/lib/container/RemoteModule.js.map +1 -1
  53. package/dist/src/lib/container/RemoteRuntimeModule.d.ts +12 -7
  54. package/dist/src/lib/container/RemoteRuntimeModule.js +86 -132
  55. package/dist/src/lib/container/RemoteRuntimeModule.js.map +1 -1
  56. package/dist/src/lib/container/RemoteToExternalDependency.d.ts +13 -8
  57. package/dist/src/lib/container/RemoteToExternalDependency.js +25 -23
  58. package/dist/src/lib/container/RemoteToExternalDependency.js.map +1 -1
  59. package/dist/src/lib/container/constant.d.ts +3 -0
  60. package/dist/src/lib/container/constant.js +11 -14
  61. package/dist/src/lib/container/constant.js.map +1 -1
  62. package/dist/src/lib/container/options.d.ts +7 -3
  63. package/dist/src/lib/container/options.js +51 -69
  64. package/dist/src/lib/container/options.js.map +1 -1
  65. package/dist/src/lib/container/runtime/EmbedFederationRuntimeModule.d.ts +14 -9
  66. package/dist/src/lib/container/runtime/EmbedFederationRuntimeModule.js +56 -64
  67. package/dist/src/lib/container/runtime/EmbedFederationRuntimeModule.js.map +1 -1
  68. package/dist/src/lib/container/runtime/EmbedFederationRuntimePlugin.d.ts +23 -19
  69. package/dist/src/lib/container/runtime/EmbedFederationRuntimePlugin.js +71 -101
  70. package/dist/src/lib/container/runtime/EmbedFederationRuntimePlugin.js.map +1 -1
  71. package/dist/src/lib/container/runtime/FederationModulesPlugin.d.ts +20 -16
  72. package/dist/src/lib/container/runtime/FederationModulesPlugin.js +55 -47
  73. package/dist/src/lib/container/runtime/FederationModulesPlugin.js.map +1 -1
  74. package/dist/src/lib/container/runtime/FederationRuntimeDependency.d.ts +9 -4
  75. package/dist/src/lib/container/runtime/FederationRuntimeDependency.js +16 -12
  76. package/dist/src/lib/container/runtime/FederationRuntimeDependency.js.map +1 -1
  77. package/dist/src/lib/container/runtime/FederationRuntimeModule.d.ts +16 -11
  78. package/dist/src/lib/container/runtime/FederationRuntimeModule.js +39 -46
  79. package/dist/src/lib/container/runtime/FederationRuntimeModule.js.map +1 -1
  80. package/dist/src/lib/container/runtime/FederationRuntimePlugin.d.ts +31 -20
  81. package/dist/src/lib/container/runtime/FederationRuntimePlugin.js +265 -358
  82. package/dist/src/lib/container/runtime/FederationRuntimePlugin.js.map +1 -1
  83. package/dist/src/lib/container/runtime/getFederationGlobal.d.ts +9 -4
  84. package/dist/src/lib/container/runtime/getFederationGlobal.js +43 -41
  85. package/dist/src/lib/container/runtime/getFederationGlobal.js.map +1 -1
  86. package/dist/src/lib/container/runtime/utils.d.ts +24 -13
  87. package/dist/src/lib/container/runtime/utils.js +83 -101
  88. package/dist/src/lib/container/runtime/utils.js.map +1 -1
  89. package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.d.ts +15 -10
  90. package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.js +27 -25
  91. package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.js.map +1 -1
  92. package/dist/src/lib/sharing/ConsumeSharedModule.d.ts +77 -68
  93. package/dist/src/lib/sharing/ConsumeSharedModule.js +186 -214
  94. package/dist/src/lib/sharing/ConsumeSharedModule.js.map +1 -1
  95. package/dist/src/lib/sharing/ConsumeSharedPlugin.d.ts +13 -9
  96. package/dist/src/lib/sharing/ConsumeSharedPlugin.js +308 -475
  97. package/dist/src/lib/sharing/ConsumeSharedPlugin.js.map +1 -1
  98. package/dist/src/lib/sharing/ConsumeSharedRuntimeModule.d.ts +16 -11
  99. package/dist/src/lib/sharing/ConsumeSharedRuntimeModule.js +107 -137
  100. package/dist/src/lib/sharing/ConsumeSharedRuntimeModule.js.map +1 -1
  101. package/dist/src/lib/sharing/ProvideForSharedDependency.d.ts +14 -9
  102. package/dist/src/lib/sharing/ProvideForSharedDependency.js +25 -25
  103. package/dist/src/lib/sharing/ProvideForSharedDependency.js.map +1 -1
  104. package/dist/src/lib/sharing/ProvideSharedDependency.d.ts +44 -39
  105. package/dist/src/lib/sharing/ProvideSharedDependency.js +72 -76
  106. package/dist/src/lib/sharing/ProvideSharedDependency.js.map +1 -1
  107. package/dist/src/lib/sharing/ProvideSharedModule.d.ts +91 -82
  108. package/dist/src/lib/sharing/ProvideSharedModule.js +177 -184
  109. package/dist/src/lib/sharing/ProvideSharedModule.js.map +1 -1
  110. package/dist/src/lib/sharing/ProvideSharedModuleFactory.d.ts +14 -9
  111. package/dist/src/lib/sharing/ProvideSharedModuleFactory.js +19 -25
  112. package/dist/src/lib/sharing/ProvideSharedModuleFactory.js.map +1 -1
  113. package/dist/src/lib/sharing/ProvideSharedPlugin.d.ts +27 -21
  114. package/dist/src/lib/sharing/ProvideSharedPlugin.js +341 -550
  115. package/dist/src/lib/sharing/ProvideSharedPlugin.js.map +1 -1
  116. package/dist/src/lib/sharing/SharePlugin.d.ts +53 -49
  117. package/dist/src/lib/sharing/SharePlugin.js +86 -100
  118. package/dist/src/lib/sharing/SharePlugin.js.map +1 -1
  119. package/dist/src/lib/sharing/ShareRuntimeModule.d.ts +12 -7
  120. package/dist/src/lib/sharing/ShareRuntimeModule.js +81 -103
  121. package/dist/src/lib/sharing/ShareRuntimeModule.js.map +1 -1
  122. package/dist/src/lib/sharing/resolveMatchedConfigs.d.ts +11 -7
  123. package/dist/src/lib/sharing/resolveMatchedConfigs.js +58 -71
  124. package/dist/src/lib/sharing/resolveMatchedConfigs.js.map +1 -1
  125. package/dist/src/lib/sharing/tree-shaking/CollectSharedEntryPlugin.d.ts +18 -14
  126. package/dist/src/lib/sharing/tree-shaking/CollectSharedEntryPlugin.js +74 -128
  127. package/dist/src/lib/sharing/tree-shaking/CollectSharedEntryPlugin.js.map +1 -1
  128. package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.d.ts +39 -34
  129. package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.js +234 -328
  130. package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.js.map +1 -1
  131. package/dist/src/lib/sharing/tree-shaking/IndependentSharedRuntimeModule.d.ts +16 -11
  132. package/dist/src/lib/sharing/tree-shaking/IndependentSharedRuntimeModule.js +30 -28
  133. package/dist/src/lib/sharing/tree-shaking/IndependentSharedRuntimeModule.js.map +1 -1
  134. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedContainerPlugin.d.ts +28 -24
  135. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedContainerPlugin.js +91 -95
  136. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedContainerPlugin.js.map +1 -1
  137. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.d.ts +29 -24
  138. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.js +47 -43
  139. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.js.map +1 -1
  140. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.d.ts +20 -15
  141. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.js +33 -29
  142. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.js.map +1 -1
  143. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.d.ts +85 -77
  144. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.js +141 -153
  145. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.js.map +1 -1
  146. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModuleFactory.d.ts +15 -10
  147. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModuleFactory.js +20 -24
  148. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModuleFactory.js.map +1 -1
  149. package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerPlugin.d.ts +21 -16
  150. package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerPlugin.js +157 -231
  151. package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerPlugin.js.map +1 -1
  152. package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerRuntimeModule.d.ts +14 -9
  153. package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerRuntimeModule.js +26 -27
  154. package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerRuntimeModule.js.map +1 -1
  155. package/dist/src/lib/sharing/tree-shaking/TreeShakingSharedPlugin.d.ts +18 -13
  156. package/dist/src/lib/sharing/tree-shaking/TreeShakingSharedPlugin.js +41 -49
  157. package/dist/src/lib/sharing/tree-shaking/TreeShakingSharedPlugin.js.map +1 -1
  158. package/dist/src/lib/sharing/utils.d.ts +27 -24
  159. package/dist/src/lib/sharing/utils.js +224 -367
  160. package/dist/src/lib/sharing/utils.js.map +1 -1
  161. package/dist/src/lib/startup/MfStartupChunkDependenciesPlugin.d.ts +11 -7
  162. package/dist/src/lib/startup/MfStartupChunkDependenciesPlugin.js +56 -75
  163. package/dist/src/lib/startup/MfStartupChunkDependenciesPlugin.js.map +1 -1
  164. package/dist/src/lib/startup/StartupHelpers.d.ts +11 -6
  165. package/dist/src/lib/startup/StartupHelpers.js +128 -178
  166. package/dist/src/lib/startup/StartupHelpers.js.map +1 -1
  167. package/dist/src/prefetch.d.ts +3 -2
  168. package/dist/src/prefetch.js +17 -8
  169. package/dist/src/rspack.d.ts +3 -2
  170. package/dist/src/rspack.js +35 -11
  171. package/dist/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +8 -4
  172. package/dist/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js +19 -16
  173. package/dist/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -1
  174. package/dist/src/runtime.d.ts +1 -1
  175. package/dist/src/runtime.js +11 -18
  176. package/dist/src/schemas/container/ContainerPlugin.check.d.ts +13 -5
  177. package/dist/src/schemas/container/ContainerPlugin.check.js +958 -1218
  178. package/dist/src/schemas/container/ContainerPlugin.check.js.map +1 -1
  179. package/dist/src/schemas/container/ContainerPlugin.d.ts +271 -268
  180. package/dist/src/schemas/container/ContainerPlugin.js +273 -361
  181. package/dist/src/schemas/container/ContainerPlugin.js.map +1 -1
  182. package/dist/src/schemas/container/ContainerReferencePlugin.check.d.ts +13 -5
  183. package/dist/src/schemas/container/ContainerReferencePlugin.check.js +335 -443
  184. package/dist/src/schemas/container/ContainerReferencePlugin.check.js.map +1 -1
  185. package/dist/src/schemas/container/ContainerReferencePlugin.d.ts +102 -99
  186. package/dist/src/schemas/container/ContainerReferencePlugin.js +122 -162
  187. package/dist/src/schemas/container/ContainerReferencePlugin.js.map +1 -1
  188. package/dist/src/schemas/container/ExternalsType.check.d.ts +13 -5
  189. package/dist/src/schemas/container/ExternalsType.check.js +36 -62
  190. package/dist/src/schemas/container/ExternalsType.check.js.map +1 -1
  191. package/dist/src/schemas/container/ExternalsType.d.ts +5 -2
  192. package/dist/src/schemas/container/ExternalsType.js +8 -11
  193. package/dist/src/schemas/container/ExternalsType.js.map +1 -1
  194. package/dist/src/schemas/container/ModuleFederationPlugin.check.js +3001 -4812
  195. package/dist/src/schemas/container/ModuleFederationPlugin.check.js.map +1 -1
  196. package/dist/src/schemas/container/ModuleFederationPlugin.d.ts +819 -814
  197. package/dist/src/schemas/container/ModuleFederationPlugin.js +780 -1053
  198. package/dist/src/schemas/container/ModuleFederationPlugin.js.map +1 -1
  199. package/dist/src/schemas/sharing/ConsumeSharedPlugin.check.d.ts +13 -5
  200. package/dist/src/schemas/sharing/ConsumeSharedPlugin.check.js +568 -768
  201. package/dist/src/schemas/sharing/ConsumeSharedPlugin.check.js.map +1 -1
  202. package/dist/src/schemas/sharing/ConsumeSharedPlugin.d.ts +197 -194
  203. package/dist/src/schemas/sharing/ConsumeSharedPlugin.js +212 -238
  204. package/dist/src/schemas/sharing/ConsumeSharedPlugin.js.map +1 -1
  205. package/dist/src/schemas/sharing/ProvideSharedPlugin.check.d.ts +13 -5
  206. package/dist/src/schemas/sharing/ProvideSharedPlugin.check.js +598 -804
  207. package/dist/src/schemas/sharing/ProvideSharedPlugin.check.js.map +1 -1
  208. package/dist/src/schemas/sharing/ProvideSharedPlugin.d.ts +184 -181
  209. package/dist/src/schemas/sharing/ProvideSharedPlugin.js +196 -229
  210. package/dist/src/schemas/sharing/ProvideSharedPlugin.js.map +1 -1
  211. package/dist/src/schemas/sharing/ProviderSharedPlugin.check.d.ts +12 -4
  212. package/dist/src/schemas/sharing/ProviderSharedPlugin.check.js +285 -482
  213. package/dist/src/schemas/sharing/ProviderSharedPlugin.check.js.map +1 -1
  214. package/dist/src/schemas/sharing/ProviderSharedPlugin.d.ts +103 -100
  215. package/dist/src/schemas/sharing/ProviderSharedPlugin.js +104 -126
  216. package/dist/src/schemas/sharing/ProviderSharedPlugin.js.map +1 -1
  217. package/dist/src/schemas/sharing/SharePlugin.check.d.ts +13 -5
  218. package/dist/src/schemas/sharing/SharePlugin.check.js +749 -965
  219. package/dist/src/schemas/sharing/SharePlugin.check.js.map +1 -1
  220. package/dist/src/schemas/sharing/SharePlugin.d.ts +245 -242
  221. package/dist/src/schemas/sharing/SharePlugin.js +256 -293
  222. package/dist/src/schemas/sharing/SharePlugin.js.map +1 -1
  223. package/dist/src/utils.d.ts +3 -0
  224. package/dist/src/utils.js +35 -26
  225. package/dist/src/utils.js.map +1 -1
  226. package/dist/src/webpack.d.ts +2 -2
  227. package/dist/src/webpack.js +6 -40
  228. package/dist/src/wrapper/AsyncBoundaryPlugin.d.ts +9 -4
  229. package/dist/src/wrapper/AsyncBoundaryPlugin.js +12 -11
  230. package/dist/src/wrapper/AsyncBoundaryPlugin.js.map +1 -1
  231. package/dist/src/wrapper/BaseWrapperPlugin.d.ts +18 -13
  232. package/dist/src/wrapper/BaseWrapperPlugin.js +39 -39
  233. package/dist/src/wrapper/BaseWrapperPlugin.js.map +1 -1
  234. package/dist/src/wrapper/ConsumeSharedPlugin.d.ts +10 -4
  235. package/dist/src/wrapper/ConsumeSharedPlugin.js +12 -11
  236. package/dist/src/wrapper/ConsumeSharedPlugin.js.map +1 -1
  237. package/dist/src/wrapper/ContainerPlugin.d.ts +9 -4
  238. package/dist/src/wrapper/ContainerPlugin.js +12 -11
  239. package/dist/src/wrapper/ContainerPlugin.js.map +1 -1
  240. package/dist/src/wrapper/ContainerReferencePlugin.d.ts +9 -4
  241. package/dist/src/wrapper/ContainerReferencePlugin.js +12 -11
  242. package/dist/src/wrapper/ContainerReferencePlugin.js.map +1 -1
  243. package/dist/src/wrapper/FederationModulesPlugin.d.ts +18 -10
  244. package/dist/src/wrapper/FederationModulesPlugin.js +19 -19
  245. package/dist/src/wrapper/FederationModulesPlugin.js.map +1 -1
  246. package/dist/src/wrapper/FederationRuntimePlugin.d.ts +11 -6
  247. package/dist/src/wrapper/FederationRuntimePlugin.js +18 -17
  248. package/dist/src/wrapper/FederationRuntimePlugin.js.map +1 -1
  249. package/dist/src/wrapper/HoistContainerReferencesPlugin.d.ts +8 -3
  250. package/dist/src/wrapper/HoistContainerReferencesPlugin.js +12 -11
  251. package/dist/src/wrapper/HoistContainerReferencesPlugin.js.map +1 -1
  252. package/dist/src/wrapper/ModuleFederationPlugin.d.ts +12 -7
  253. package/dist/src/wrapper/ModuleFederationPlugin.js +73 -99
  254. package/dist/src/wrapper/ModuleFederationPlugin.js.map +1 -1
  255. package/dist/src/wrapper/ProvideSharedPlugin.d.ts +10 -4
  256. package/dist/src/wrapper/ProvideSharedPlugin.js +12 -11
  257. package/dist/src/wrapper/ProvideSharedPlugin.js.map +1 -1
  258. package/dist/src/wrapper/SharePlugin.d.ts +10 -4
  259. package/dist/src/wrapper/SharePlugin.js +12 -11
  260. package/dist/src/wrapper/SharePlugin.js.map +1 -1
  261. package/dist/src/wrapper/TreeShakingSharedPlugin.d.ts +9 -4
  262. package/dist/src/wrapper/TreeShakingSharedPlugin.js +12 -11
  263. package/dist/src/wrapper/TreeShakingSharedPlugin.js.map +1 -1
  264. package/package.json +20 -13
  265. package/dist/package.json +0 -110
  266. package/dist/src/declarations/plugins/container/AsyncDependenciesBlock.d.ts +0 -57
  267. package/dist/src/declarations/plugins/container/ModuleFactory.d.ts +0 -33
  268. package/dist/src/declarations/plugins/container/ObjectDeserializerContext.d.ts +0 -4
  269. package/dist/src/declarations/plugins/container/StaticExportsDependency.d.ts +0 -28
  270. package/dist/src/declarations/plugins/container/Template.d.ts +0 -198
  271. package/dist/src/declarations/plugins/container/WebpackError.d.ts +0 -33
  272. package/dist/src/declarations/plugins/sharing/ConsumeSharedModule.d.ts +0 -86
  273. package/dist/src/declarations/plugins/sharing/ConsumeSharedPlugin.d.ts +0 -100
  274. package/dist/src/declarations/plugins/sharing/ProvideSharedPlugin.d.ts +0 -102
  275. package/dist/src/declarations/plugins/sharing/SharePlugin.d.ts +0 -116
  276. package/dist/src/lib/container/runtime/ChildCompilationRuntimePlugin.d.ts +0 -20
  277. package/dist/src/lib/container/runtime/ChildCompilationRuntimePlugin.js +0 -222
  278. package/dist/src/lib/container/runtime/ChildCompilationRuntimePlugin.js.map +0 -1
  279. package/dist/src/prefetch.js.map +0 -1
  280. package/dist/src/rspack.js.map +0 -1
  281. package/dist/src/runtime.js.map +0 -1
  282. package/dist/src/types/runtime.d.ts +0 -10
  283. package/dist/src/types/runtime.js +0 -3
  284. package/dist/src/types/runtime.js.map +0 -1
  285. package/dist/src/webpack.js.map +0 -1
@@ -1,86 +1,95 @@
1
- import type { containerPlugin } from '@module-federation/sdk';
2
- import type { Compilation } from 'webpack';
3
- import type { InputFileSystem, LibIdentOptions, NeedBuildContext, ObjectDeserializerContext, ObjectSerializerContext, RequestShortener, ResolverWithOptions, WebpackOptions } from 'webpack/lib/Module';
4
- import type WebpackError from 'webpack/lib/WebpackError';
5
- declare const Module: typeof import("webpack").Module;
6
- export type ExposeOptions = {
7
- /**
8
- * requests to exposed modules (last one is exported)
9
- */
10
- import: string[];
11
- /**
12
- * custom chunk name for the exposed module
13
- */
14
- name: string;
1
+ import { containerPlugin } from "@module-federation/sdk";
2
+ import * as webpack$1 from "webpack";
3
+ import { Compilation } from "webpack";
4
+ import { InputFileSystem, LibIdentOptions, NeedBuildContext, ObjectDeserializerContext, ObjectSerializerContext, RequestShortener, ResolverWithOptions, WebpackOptions } from "webpack/lib/Module";
5
+ import WebpackError$1 from "webpack/lib/WebpackError";
6
+
7
+ //#region src/lib/container/ContainerEntryModule.d.ts
8
+ declare const Module$1: typeof webpack$1.Module;
9
+ type ExposeOptions = {
10
+ /**
11
+ * requests to exposed modules (last one is exported)
12
+ */
13
+ import: string[];
14
+ /**
15
+ * custom chunk name for the exposed module
16
+ */
17
+ name: string;
15
18
  };
16
- declare class ContainerEntryModule extends Module {
17
- private _name;
18
- private _exposes;
19
- private _shareScope;
20
- private _injectRuntimeEntry;
21
- private _dataPrefetch;
22
- /**
23
- * @param {string} name container entry name
24
- * @param {[string, ExposeOptions][]} exposes list of exposed modules
25
- * @param {string|string[]} shareScope name of the share scope
26
- * @param {string} injectRuntimeEntry the path of injectRuntime file.
27
- * @param {containerPlugin.ContainerPluginOptions['dataPrefetch']} dataPrefetch whether enable dataPrefetch
28
- */
29
- constructor(name: string, exposes: [string, ExposeOptions][], shareScope: string | string[], injectRuntimeEntry: string, dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch']);
30
- /**
31
- * @param {ObjectDeserializerContext} context context
32
- * @returns {ContainerEntryModule} deserialized container entry module
33
- */
34
- static deserialize(context: ObjectDeserializerContext): ContainerEntryModule;
35
- /**
36
- * @returns {Set<string>} types available (do not mutate)
37
- */
38
- getSourceTypes(): Set<string>;
39
- /**
40
- * @returns {string} a unique identifier of the module
41
- */
42
- identifier(): string;
43
- /**
44
- * @param {RequestShortener} requestShortener the request shortener
45
- * @returns {string} a user readable identifier of the module
46
- */
47
- readableIdentifier(requestShortener: RequestShortener): string;
48
- /**
49
- * @param {LibIdentOptions} options options
50
- * @returns {string | null} an identifier for library inclusion
51
- */
52
- libIdent(options: LibIdentOptions): string | null;
53
- /**
54
- * @param {NeedBuildContext} context context info
55
- * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
56
- * @returns {void}
57
- */
58
- needBuild(context: NeedBuildContext, callback: (arg0: (WebpackError | null) | undefined, arg1: boolean | undefined) => void): void;
59
- /**
60
- * @param {WebpackOptions} options webpack options
61
- * @param {Compilation} compilation the compilation
62
- * @param {ResolverWithOptions} resolver the resolver
63
- * @param {InputFileSystem} fs the file system
64
- * @param {function(WebpackError): void} callback callback function
65
- * @returns {void}
66
- */
67
- build(options: WebpackOptions, compilation: Compilation, resolver: ResolverWithOptions, fs: InputFileSystem, callback: (err?: WebpackError) => void): void;
68
- /**
69
- * @param {CodeGenerationContext} context context for code generation
70
- * @returns {CodeGenerationResult} result
71
- */
72
- codeGeneration({ moduleGraph, chunkGraph, runtimeTemplate }: any): {
73
- sources: Map<any, any>;
74
- runtimeRequirements: Set<"__webpack_require__.d" | "__webpack_require__.o" | "__webpack_exports__">;
75
- };
76
- /**
77
- * @param {string=} type the source type for which the size should be estimated
78
- * @returns {number} the estimated size of the module (must be non-zero)
79
- */
80
- size(type?: string): number;
81
- /**
82
- * @param {ObjectSerializerContext} context context
83
- */
84
- serialize(context: ObjectSerializerContext): void;
19
+ declare class ContainerEntryModule extends Module$1 {
20
+ private _name;
21
+ private _exposes;
22
+ private _shareScope;
23
+ private _injectRuntimeEntry;
24
+ private _dataPrefetch;
25
+ /**
26
+ * @param {string} name container entry name
27
+ * @param {[string, ExposeOptions][]} exposes list of exposed modules
28
+ * @param {string|string[]} shareScope name of the share scope
29
+ * @param {string} injectRuntimeEntry the path of injectRuntime file.
30
+ * @param {containerPlugin.ContainerPluginOptions['dataPrefetch']} dataPrefetch whether enable dataPrefetch
31
+ */
32
+ constructor(name: string, exposes: [string, ExposeOptions][], shareScope: string | string[], injectRuntimeEntry: string, dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch']);
33
+ /**
34
+ * @param {ObjectDeserializerContext} context context
35
+ * @returns {ContainerEntryModule} deserialized container entry module
36
+ */
37
+ static deserialize(context: ObjectDeserializerContext): ContainerEntryModule;
38
+ /**
39
+ * @returns {Set<string>} types available (do not mutate)
40
+ */
41
+ getSourceTypes(): Set<string>;
42
+ /**
43
+ * @returns {string} a unique identifier of the module
44
+ */
45
+ identifier(): string;
46
+ /**
47
+ * @param {RequestShortener} requestShortener the request shortener
48
+ * @returns {string} a user readable identifier of the module
49
+ */
50
+ readableIdentifier(requestShortener: RequestShortener): string;
51
+ /**
52
+ * @param {LibIdentOptions} options options
53
+ * @returns {string | null} an identifier for library inclusion
54
+ */
55
+ libIdent(options: LibIdentOptions): string | null;
56
+ /**
57
+ * @param {NeedBuildContext} context context info
58
+ * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
59
+ * @returns {void}
60
+ */
61
+ needBuild(context: NeedBuildContext, callback: (arg0: (WebpackError$1 | null) | undefined, arg1: boolean | undefined) => void): void;
62
+ /**
63
+ * @param {WebpackOptions} options webpack options
64
+ * @param {Compilation} compilation the compilation
65
+ * @param {ResolverWithOptions} resolver the resolver
66
+ * @param {InputFileSystem} fs the file system
67
+ * @param {function(WebpackError): void} callback callback function
68
+ * @returns {void}
69
+ */
70
+ build(options: WebpackOptions, compilation: Compilation, resolver: ResolverWithOptions, fs: InputFileSystem, callback: (err?: WebpackError$1) => void): void;
71
+ /**
72
+ * @param {CodeGenerationContext} context context for code generation
73
+ * @returns {CodeGenerationResult} result
74
+ */
75
+ codeGeneration({
76
+ moduleGraph,
77
+ chunkGraph,
78
+ runtimeTemplate
79
+ }: any): {
80
+ sources: Map<any, any>;
81
+ runtimeRequirements: Set<"__webpack_require__.d" | "__webpack_require__.o" | "__webpack_exports__">;
82
+ };
83
+ /**
84
+ * @param {string=} type the source type for which the size should be estimated
85
+ * @returns {number} the estimated size of the module (must be non-zero)
86
+ */
87
+ size(type?: string): number;
88
+ /**
89
+ * @param {ObjectSerializerContext} context context
90
+ */
91
+ serialize(context: ObjectSerializerContext): void;
85
92
  }
86
- export default ContainerEntryModule;
93
+ //#endregion
94
+ export { ExposeOptions, ContainerEntryModule as default };
95
+ //# sourceMappingURL=ContainerEntryModule.d.ts.map
@@ -1,238 +1,223 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr
4
- */
5
1
  'use strict';
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+
3
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
+ const require_runtime = require('../../_virtual/_rolldown/runtime.js');
5
+ const require_lib_Constants = require('../Constants.js');
6
+ const require_lib_container_ContainerExposedDependency = require('./ContainerExposedDependency.js');
7
+ const require_lib_container_runtime_utils = require('./runtime/utils.js');
8
+ let _module_federation_sdk = require("@module-federation/sdk");
9
+ let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
10
+ let _module_federation_error_codes = require("@module-federation/error-codes");
11
+ let _module_federation_error_codes_node = require("@module-federation/error-codes/node");
12
+ let _module_federation_data_prefetch_cli = require("@module-federation/data-prefetch/cli");
13
+
14
+ //#region src/lib/container/ContainerEntryModule.ts
15
+ const makeSerializable = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/makeSerializable"));
16
+ const { sources: webpackSources, AsyncDependenciesBlock, Template, Module, RuntimeGlobals } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
17
+ const StaticExportsDependency = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/dependencies/StaticExportsDependency"));
18
+ const EntryDependency = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/dependencies/EntryDependency"));
19
+ const SOURCE_TYPES = new Set(["javascript"]);
20
+ var ContainerEntryModule = class ContainerEntryModule extends Module {
21
+ /**
22
+ * @param {string} name container entry name
23
+ * @param {[string, ExposeOptions][]} exposes list of exposed modules
24
+ * @param {string|string[]} shareScope name of the share scope
25
+ * @param {string} injectRuntimeEntry the path of injectRuntime file.
26
+ * @param {containerPlugin.ContainerPluginOptions['dataPrefetch']} dataPrefetch whether enable dataPrefetch
27
+ */
28
+ constructor(name, exposes, shareScope, injectRuntimeEntry, dataPrefetch) {
29
+ super(require_lib_Constants.JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);
30
+ this._name = name;
31
+ this._exposes = exposes;
32
+ this._shareScope = shareScope;
33
+ this._injectRuntimeEntry = injectRuntimeEntry;
34
+ this._dataPrefetch = dataPrefetch;
35
+ }
36
+ /**
37
+ * @param {ObjectDeserializerContext} context context
38
+ * @returns {ContainerEntryModule} deserialized container entry module
39
+ */
40
+ static deserialize(context) {
41
+ const { read } = context;
42
+ const obj = new ContainerEntryModule(read(), read(), read(), read(), read());
43
+ obj.deserialize(context);
44
+ return obj;
45
+ }
46
+ /**
47
+ * @returns {Set<string>} types available (do not mutate)
48
+ */
49
+ getSourceTypes() {
50
+ return SOURCE_TYPES;
51
+ }
52
+ /**
53
+ * @returns {string} a unique identifier of the module
54
+ */
55
+ identifier() {
56
+ return `container entry (${Array.isArray(this._shareScope) ? this._shareScope.join("|") : this._shareScope}) ${JSON.stringify(this._exposes)} ${this._injectRuntimeEntry} ${JSON.stringify(this._dataPrefetch)}`;
57
+ }
58
+ /**
59
+ * @param {RequestShortener} requestShortener the request shortener
60
+ * @returns {string} a user readable identifier of the module
61
+ */
62
+ readableIdentifier(requestShortener) {
63
+ return "container entry";
64
+ }
65
+ /**
66
+ * @param {LibIdentOptions} options options
67
+ * @returns {string | null} an identifier for library inclusion
68
+ */
69
+ libIdent(options) {
70
+ return `${this.layer ? `(${this.layer})/` : ""}webpack/container/entry/${this._name}`;
71
+ }
72
+ /**
73
+ * @param {NeedBuildContext} context context info
74
+ * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
75
+ * @returns {void}
76
+ */
77
+ needBuild(context, callback) {
78
+ callback(null, !this.buildMeta);
79
+ }
80
+ /**
81
+ * @param {WebpackOptions} options webpack options
82
+ * @param {Compilation} compilation the compilation
83
+ * @param {ResolverWithOptions} resolver the resolver
84
+ * @param {InputFileSystem} fs the file system
85
+ * @param {function(WebpackError): void} callback callback function
86
+ * @returns {void}
87
+ */
88
+ build(options, compilation, resolver, fs, callback) {
89
+ this.buildMeta = {};
90
+ this.buildInfo = {
91
+ strict: true,
92
+ topLevelDeclarations: new Set([
93
+ "moduleMap",
94
+ "get",
95
+ "init"
96
+ ])
97
+ };
98
+ this.buildMeta.exportsType = "namespace";
99
+ this.clearDependenciesAndBlocks();
100
+ for (const [name, options] of this._exposes) {
101
+ const block = new AsyncDependenciesBlock({ name: options.name }, { name }, options.import[options.import.length - 1]);
102
+ let idx = 0;
103
+ for (const request of options.import) {
104
+ const dep = new require_lib_container_ContainerExposedDependency.default(name, request);
105
+ dep.loc = {
106
+ name,
107
+ index: idx++
108
+ };
109
+ block.addDependency(dep);
110
+ }
111
+ this.addBlock(block);
112
+ }
113
+ this.addDependency(new StaticExportsDependency(["get", "init"], false));
114
+ this.addDependency(new EntryDependency(this._injectRuntimeEntry));
115
+ callback();
116
+ }
117
+ /**
118
+ * @param {CodeGenerationContext} context context for code generation
119
+ * @returns {CodeGenerationResult} result
120
+ */
121
+ codeGeneration({ moduleGraph, chunkGraph, runtimeTemplate }) {
122
+ const sources = /* @__PURE__ */ new Map();
123
+ const runtimeRequirements = new Set([
124
+ RuntimeGlobals.definePropertyGetters,
125
+ RuntimeGlobals.hasOwnProperty,
126
+ RuntimeGlobals.exports
127
+ ]);
128
+ const getters = [];
129
+ for (const block of this.blocks) {
130
+ const { dependencies } = block;
131
+ const modules = dependencies.map((dependency) => {
132
+ const dep = dependency;
133
+ return {
134
+ name: dep.exposedName,
135
+ module: moduleGraph.getModule(dep),
136
+ request: dep.userRequest
137
+ };
138
+ });
139
+ let str;
140
+ if (modules.some((m) => !m.module)) {
141
+ (0, _module_federation_error_codes_node.logAndReport)(_module_federation_error_codes.BUILD_001, _module_federation_error_codes.buildDescMap, {
142
+ exposeModules: modules.filter((m) => !m.module),
143
+ FEDERATION_WEBPACK_PATH: process.env["FEDERATION_WEBPACK_PATH"]
144
+ }, _module_federation_sdk.infrastructureLogger.error.bind(_module_federation_sdk.infrastructureLogger), void 0, {
145
+ bundler: { name: "webpack" },
146
+ mfConfig: {
147
+ name: this._name,
148
+ exposes: Object.fromEntries(this._exposes.map(([key, opts]) => [key, opts.import[opts.import.length - 1]]))
149
+ }
150
+ });
151
+ process.exit(1);
152
+ } else str = `return ${runtimeTemplate.blockPromise({
153
+ block,
154
+ message: "",
155
+ chunkGraph,
156
+ runtimeRequirements
157
+ })}.then(${runtimeTemplate.returningFunction(runtimeTemplate.returningFunction(`(${modules.map(({ module, request }) => runtimeTemplate.moduleRaw({
158
+ module,
159
+ chunkGraph,
160
+ request,
161
+ weak: false,
162
+ runtimeRequirements
163
+ })).join(", ")})`))});`;
164
+ getters.push(`${JSON.stringify(modules[0].name)}: ${runtimeTemplate.basicFunction("", str)}`);
165
+ }
166
+ const federationGlobal = require_lib_container_runtime_utils.getFederationGlobalScope(RuntimeGlobals || {});
167
+ const source = Template.asString([
168
+ `var moduleMap = {`,
169
+ Template.indent(getters.join(",\n")),
170
+ "};",
171
+ `var get = ${runtimeTemplate.basicFunction("module, getScope", [
172
+ `${RuntimeGlobals.currentRemoteGetScope} = getScope;`,
173
+ "getScope = (",
174
+ Template.indent([`${RuntimeGlobals.hasOwnProperty}(moduleMap, module)`, Template.indent(["? moduleMap[module]()", `: Promise.resolve().then(${runtimeTemplate.basicFunction("", "throw new Error('Module \"' + module + '\" does not exist in container.');")})`])]),
175
+ ");",
176
+ `${RuntimeGlobals.currentRemoteGetScope} = undefined;`,
177
+ "return getScope;"
178
+ ])};`,
179
+ `var init = ${runtimeTemplate.basicFunction("shareScope, initScope, remoteEntryInitOptions", [`return ${federationGlobal}.bundlerRuntime.initContainerEntry({${Template.indent([
180
+ `webpackRequire: ${RuntimeGlobals.require},`,
181
+ `shareScope: shareScope,`,
182
+ `initScope: initScope,`,
183
+ `remoteEntryInitOptions: remoteEntryInitOptions,`,
184
+ `shareScopeKey: ${JSON.stringify(this._shareScope)}`
185
+ ])}`, "})"])};`,
186
+ this._dataPrefetch ? _module_federation_data_prefetch_cli.PrefetchPlugin.setRemoteIdentifier() : "",
187
+ this._dataPrefetch ? _module_federation_data_prefetch_cli.PrefetchPlugin.removeRemoteIdentifier() : "",
188
+ "// This exports getters to disallow modifications",
189
+ `${RuntimeGlobals.definePropertyGetters}(exports, {`,
190
+ Template.indent([`get: ${runtimeTemplate.returningFunction("get")},`, `init: ${runtimeTemplate.returningFunction("init")}`]),
191
+ "});"
192
+ ]);
193
+ sources.set("javascript", this.useSourceMap || this.useSimpleSourceMap ? new webpackSources.OriginalSource(source, "webpack/container-entry") : new webpackSources.RawSource(source));
194
+ return {
195
+ sources,
196
+ runtimeRequirements
197
+ };
198
+ }
199
+ /**
200
+ * @param {string=} type the source type for which the size should be estimated
201
+ * @returns {number} the estimated size of the module (must be non-zero)
202
+ */
203
+ size(type) {
204
+ return 42;
205
+ }
206
+ /**
207
+ * @param {ObjectSerializerContext} context context
208
+ */
209
+ serialize(context) {
210
+ const { write } = context;
211
+ write(this._name);
212
+ write(this._exposes);
213
+ write(this._shareScope);
214
+ write(this._injectRuntimeEntry);
215
+ write(this._dataPrefetch);
216
+ super.serialize(context);
217
+ }
8
218
  };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
11
- const sdk_1 = require("@module-federation/sdk");
12
- const error_codes_1 = require("@module-federation/error-codes");
13
- const cli_1 = require("@module-federation/data-prefetch/cli");
14
- const Constants_1 = require("../Constants");
15
- const ContainerExposedDependency_1 = __importDefault(require("./ContainerExposedDependency"));
16
- const utils_1 = require("./runtime/utils");
17
- const makeSerializable = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/util/makeSerializable'));
18
- const { sources: webpackSources, AsyncDependenciesBlock, Template, Module, RuntimeGlobals, } = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack'));
19
- const StaticExportsDependency = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/dependencies/StaticExportsDependency'));
20
- const EntryDependency = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/dependencies/EntryDependency'));
21
- const SOURCE_TYPES = new Set(['javascript']);
22
- class ContainerEntryModule extends Module {
23
- /**
24
- * @param {string} name container entry name
25
- * @param {[string, ExposeOptions][]} exposes list of exposed modules
26
- * @param {string|string[]} shareScope name of the share scope
27
- * @param {string} injectRuntimeEntry the path of injectRuntime file.
28
- * @param {containerPlugin.ContainerPluginOptions['dataPrefetch']} dataPrefetch whether enable dataPrefetch
29
- */
30
- constructor(name, exposes, shareScope, injectRuntimeEntry, dataPrefetch) {
31
- super(Constants_1.JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);
32
- this._name = name;
33
- this._exposes = exposes;
34
- this._shareScope = shareScope;
35
- this._injectRuntimeEntry = injectRuntimeEntry;
36
- this._dataPrefetch = dataPrefetch;
37
- }
38
- /**
39
- * @param {ObjectDeserializerContext} context context
40
- * @returns {ContainerEntryModule} deserialized container entry module
41
- */
42
- static deserialize(context) {
43
- const { read } = context;
44
- const obj = new ContainerEntryModule(read(), read(), read(), read(), read());
45
- obj.deserialize(context);
46
- return obj;
47
- }
48
- /**
49
- * @returns {Set<string>} types available (do not mutate)
50
- */
51
- getSourceTypes() {
52
- return SOURCE_TYPES;
53
- }
54
- /**
55
- * @returns {string} a unique identifier of the module
56
- */
57
- identifier() {
58
- const scopeStr = Array.isArray(this._shareScope)
59
- ? this._shareScope.join('|')
60
- : this._shareScope;
61
- return `container entry (${scopeStr}) ${JSON.stringify(this._exposes)} ${this._injectRuntimeEntry} ${JSON.stringify(this._dataPrefetch)}`;
62
- }
63
- /**
64
- * @param {RequestShortener} requestShortener the request shortener
65
- * @returns {string} a user readable identifier of the module
66
- */
67
- readableIdentifier(requestShortener) {
68
- return 'container entry';
69
- }
70
- /**
71
- * @param {LibIdentOptions} options options
72
- * @returns {string | null} an identifier for library inclusion
73
- */
74
- libIdent(options) {
75
- return `${this.layer ? `(${this.layer})/` : ''}webpack/container/entry/${this._name}`;
76
- }
77
- /**
78
- * @param {NeedBuildContext} context context info
79
- * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
80
- * @returns {void}
81
- */
82
- needBuild(context, callback) {
83
- callback(null, !this.buildMeta);
84
- }
85
- /**
86
- * @param {WebpackOptions} options webpack options
87
- * @param {Compilation} compilation the compilation
88
- * @param {ResolverWithOptions} resolver the resolver
89
- * @param {InputFileSystem} fs the file system
90
- * @param {function(WebpackError): void} callback callback function
91
- * @returns {void}
92
- */
93
- build(options, compilation, resolver, fs, callback) {
94
- this.buildMeta = {};
95
- this.buildInfo = {
96
- strict: true,
97
- topLevelDeclarations: new Set(['moduleMap', 'get', 'init']),
98
- };
99
- this.buildMeta.exportsType = 'namespace';
100
- this.clearDependenciesAndBlocks();
101
- for (const [name, options] of this._exposes) {
102
- const block = new AsyncDependenciesBlock({
103
- name: options.name,
104
- }, { name }, options.import[options.import.length - 1]);
105
- let idx = 0;
106
- for (const request of options.import) {
107
- const dep = new ContainerExposedDependency_1.default(name, request);
108
- dep.loc = {
109
- name,
110
- index: idx++,
111
- };
112
- block.addDependency(dep);
113
- }
114
- this.addBlock(block);
115
- }
116
- this.addDependency(new StaticExportsDependency(['get', 'init'], false));
117
- this.addDependency(new EntryDependency(this._injectRuntimeEntry));
118
- callback();
119
- }
120
- /**
121
- * @param {CodeGenerationContext} context context for code generation
122
- * @returns {CodeGenerationResult} result
123
- */
124
- codeGeneration({ moduleGraph, chunkGraph, runtimeTemplate }) {
125
- const sources = new Map();
126
- const runtimeRequirements = new Set([
127
- RuntimeGlobals.definePropertyGetters,
128
- RuntimeGlobals.hasOwnProperty,
129
- RuntimeGlobals.exports,
130
- ]);
131
- const getters = [];
132
- for (const block of this.blocks) {
133
- const { dependencies } = block;
134
- const modules = dependencies.map((dependency) => {
135
- const dep = dependency;
136
- return {
137
- name: dep.exposedName,
138
- module: moduleGraph.getModule(dep),
139
- request: dep.userRequest,
140
- };
141
- });
142
- let str;
143
- if (modules.some((m) => !m.module)) {
144
- sdk_1.infrastructureLogger.error((0, error_codes_1.getShortErrorMsg)(error_codes_1.BUILD_001, error_codes_1.buildDescMap, {
145
- exposeModules: modules.filter((m) => !m.module),
146
- FEDERATION_WEBPACK_PATH: process.env['FEDERATION_WEBPACK_PATH'],
147
- }));
148
- process.exit(1);
149
- }
150
- else {
151
- str = `return ${runtimeTemplate.blockPromise({
152
- block,
153
- message: '',
154
- chunkGraph,
155
- runtimeRequirements,
156
- })}.then(${runtimeTemplate.returningFunction(runtimeTemplate.returningFunction(`(${modules
157
- .map(({ module, request }) => runtimeTemplate.moduleRaw({
158
- module,
159
- chunkGraph,
160
- request,
161
- weak: false,
162
- runtimeRequirements,
163
- }))
164
- .join(', ')})`))});`;
165
- }
166
- getters.push(`${JSON.stringify(modules[0].name)}: ${runtimeTemplate.basicFunction('', str)}`);
167
- }
168
- const federationGlobal = (0, utils_1.getFederationGlobalScope)(RuntimeGlobals || {});
169
- const source = Template.asString([
170
- `var moduleMap = {`,
171
- Template.indent(getters.join(',\n')),
172
- '};',
173
- `var get = ${runtimeTemplate.basicFunction('module, getScope', [
174
- `${RuntimeGlobals.currentRemoteGetScope} = getScope;`,
175
- // reusing the getScope variable to avoid creating a new var (and module is also used later)
176
- 'getScope = (',
177
- Template.indent([
178
- `${RuntimeGlobals.hasOwnProperty}(moduleMap, module)`,
179
- Template.indent([
180
- '? moduleMap[module]()',
181
- `: Promise.resolve().then(${runtimeTemplate.basicFunction('', "throw new Error('Module \"' + module + '\" does not exist in container.');")})`,
182
- ]),
183
- ]),
184
- ');',
185
- `${RuntimeGlobals.currentRemoteGetScope} = undefined;`,
186
- 'return getScope;',
187
- ])};`,
188
- `var init = ${runtimeTemplate.basicFunction('shareScope, initScope, remoteEntryInitOptions', [
189
- `return ${federationGlobal}.bundlerRuntime.initContainerEntry({${Template.indent([
190
- `webpackRequire: ${RuntimeGlobals.require},`,
191
- `shareScope: shareScope,`,
192
- `initScope: initScope,`,
193
- `remoteEntryInitOptions: remoteEntryInitOptions,`,
194
- `shareScopeKey: ${JSON.stringify(this._shareScope)}`,
195
- ])}`,
196
- '})',
197
- ])};`,
198
- this._dataPrefetch ? cli_1.PrefetchPlugin.setRemoteIdentifier() : '',
199
- this._dataPrefetch ? cli_1.PrefetchPlugin.removeRemoteIdentifier() : '',
200
- '// This exports getters to disallow modifications',
201
- `${RuntimeGlobals.definePropertyGetters}(exports, {`,
202
- Template.indent([
203
- `get: ${runtimeTemplate.returningFunction('get')},`,
204
- `init: ${runtimeTemplate.returningFunction('init')}`,
205
- ]),
206
- '});',
207
- ]);
208
- sources.set('javascript', this.useSourceMap || this.useSimpleSourceMap
209
- ? new webpackSources.OriginalSource(source, 'webpack/container-entry')
210
- : new webpackSources.RawSource(source));
211
- return {
212
- sources,
213
- runtimeRequirements,
214
- };
215
- }
216
- /**
217
- * @param {string=} type the source type for which the size should be estimated
218
- * @returns {number} the estimated size of the module (must be non-zero)
219
- */
220
- size(type) {
221
- return 42;
222
- }
223
- /**
224
- * @param {ObjectSerializerContext} context context
225
- */
226
- serialize(context) {
227
- const { write } = context;
228
- write(this._name);
229
- write(this._exposes);
230
- write(this._shareScope);
231
- write(this._injectRuntimeEntry);
232
- write(this._dataPrefetch);
233
- super.serialize(context);
234
- }
235
- }
236
- makeSerializable(ContainerEntryModule, 'enhanced/lib/container/ContainerEntryModule');
219
+ makeSerializable(ContainerEntryModule, "enhanced/lib/container/ContainerEntryModule");
220
+
221
+ //#endregion
237
222
  exports.default = ContainerEntryModule;
238
223
  //# sourceMappingURL=ContainerEntryModule.js.map