@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,214 +1,150 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
+ const require_lib_container_runtime_FederationModulesPlugin = require('./runtime/FederationModulesPlugin.js');
4
+ const require_lib_container_options = require('./options.js');
5
+ const require_lib_container_ContainerEntryDependency = require('./ContainerEntryDependency.js');
6
+ const require_lib_container_ContainerExposedDependency = require('./ContainerExposedDependency.js');
7
+ const require_lib_container_ContainerEntryModuleFactory = require('./ContainerEntryModuleFactory.js');
8
+ const require_lib_container_runtime_FederationRuntimeDependency = require('./runtime/FederationRuntimeDependency.js');
9
+ const require_lib_container_runtime_FederationRuntimePlugin = require('./runtime/FederationRuntimePlugin.js');
10
+ let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
11
+
12
+ //#region src/lib/container/ContainerPlugin.ts
13
+ require_lib_container_runtime_FederationModulesPlugin.init_FederationModulesPlugin();
14
+ const ModuleDependency = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/dependencies/ModuleDependency"));
15
+ const EntryDependency = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/dependencies/EntryDependency"));
16
+ require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/create-schema-validation"));
17
+ const PLUGIN_NAME = "ContainerPlugin";
18
+ var ContainerPlugin = class ContainerPlugin {
19
+ constructor(options) {
20
+ this.name = PLUGIN_NAME;
21
+ this._options = {
22
+ name: options.name,
23
+ shareScope: options.shareScope || "default",
24
+ library: options.library || {
25
+ type: "global",
26
+ name: options.name
27
+ },
28
+ runtime: options.runtime,
29
+ filename: options.filename || void 0,
30
+ exposes: require_lib_container_options.parseOptions(options.exposes, (item) => ({
31
+ import: Array.isArray(item) ? item : [item],
32
+ name: void 0
33
+ }), (item) => ({
34
+ import: Array.isArray(item.import) ? item.import : [item.import],
35
+ name: item.name || void 0
36
+ })),
37
+ runtimePlugins: options.runtimePlugins,
38
+ dataPrefetch: options.dataPrefetch
39
+ };
40
+ }
41
+ static patchChunkSplit(compiler, name) {
42
+ const { splitChunks } = compiler.options.optimization;
43
+ const patchChunkSplit = (cacheGroup) => {
44
+ switch (typeof cacheGroup) {
45
+ case "boolean":
46
+ case "string":
47
+ case "function": break;
48
+ case "object":
49
+ if (cacheGroup instanceof RegExp) break;
50
+ if (!cacheGroup.chunks) break;
51
+ if (typeof cacheGroup.chunks === "function") {
52
+ const prevChunks = cacheGroup.chunks;
53
+ cacheGroup.chunks = (chunk) => {
54
+ if (chunk.name && (chunk.name === name || chunk.name === name + "_partial")) return false;
55
+ return prevChunks(chunk);
56
+ };
57
+ break;
58
+ }
59
+ if (cacheGroup.chunks === "all") {
60
+ cacheGroup.chunks = (chunk) => {
61
+ if (chunk.name && (chunk.name === name || chunk.name === name + "_partial")) return false;
62
+ return true;
63
+ };
64
+ break;
65
+ }
66
+ if (cacheGroup.chunks === "initial") {
67
+ cacheGroup.chunks = (chunk) => {
68
+ if (chunk.name && (chunk.name === name || chunk.name === name + "_partial")) return false;
69
+ return chunk.isOnlyInitial();
70
+ };
71
+ break;
72
+ }
73
+ break;
74
+ }
75
+ };
76
+ if (!splitChunks) return;
77
+ patchChunkSplit(splitChunks);
78
+ const cacheGroups = splitChunks.cacheGroups;
79
+ if (!cacheGroups) return;
80
+ Object.keys(cacheGroups).forEach((cacheGroupKey) => {
81
+ patchChunkSplit(cacheGroups[cacheGroupKey]);
82
+ });
83
+ }
84
+ apply(compiler) {
85
+ if (!compiler.options.plugins.find((p) => {
86
+ if (typeof p !== "object" || !p) return false;
87
+ return p["name"] === "ModuleFederationPlugin";
88
+ })) ContainerPlugin.patchChunkSplit(compiler, this._options.name);
89
+ const federationRuntimePluginInstance = new require_lib_container_runtime_FederationRuntimePlugin.default();
90
+ federationRuntimePluginInstance.apply(compiler);
91
+ const { name, exposes, shareScope, filename, library, runtime } = this._options;
92
+ if (library && compiler.options.output && compiler.options.output.enabledLibraryTypes && !compiler.options.output.enabledLibraryTypes.includes(library.type)) compiler.options.output.enabledLibraryTypes.push(library.type);
93
+ compiler.hooks.make.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
94
+ const hooks = require_lib_container_runtime_FederationModulesPlugin.default.getCompilationHooks(compilation);
95
+ const federationRuntimeDependency = federationRuntimePluginInstance.getDependency(compiler);
96
+ const dep = new require_lib_container_ContainerEntryDependency.default(name, exposes, shareScope, federationRuntimePluginInstance.entryFilePath, this._options.dataPrefetch);
97
+ dep.loc = { name };
98
+ await new Promise((resolve, reject) => {
99
+ compilation.addEntry(compilation.options.context || "", dep, {
100
+ name,
101
+ filename,
102
+ runtime,
103
+ library
104
+ }, (error) => {
105
+ if (error) return reject(error);
106
+ hooks.addContainerEntryDependency.call(dep);
107
+ resolve(void 0);
108
+ });
109
+ }).catch(callback);
110
+ await new Promise((resolve, reject) => {
111
+ compilation.addInclude(compiler.context, federationRuntimeDependency, { name: void 0 }, (err, module) => {
112
+ if (err) return reject(err);
113
+ hooks.addFederationRuntimeDependency.call(federationRuntimeDependency);
114
+ resolve(void 0);
115
+ });
116
+ }).catch(callback);
117
+ callback();
118
+ });
119
+ compiler.hooks.finishMake.tapAsync(PLUGIN_NAME, (compilation, callback) => {
120
+ if (compilation.compiler.parentCompilation && compilation.compiler.parentCompilation !== compilation) return callback();
121
+ const hooks = require_lib_container_runtime_FederationModulesPlugin.default.getCompilationHooks(compilation);
122
+ const createdRuntimes = /* @__PURE__ */ new Set();
123
+ for (const entry of compilation.entries.values()) {
124
+ const runtime = entry.options.runtime;
125
+ if (runtime) createdRuntimes.add(runtime);
126
+ }
127
+ if (createdRuntimes.size === 0 && !compilation.options?.optimization?.runtimeChunk) return callback();
128
+ const dep = new require_lib_container_ContainerEntryDependency.default(name, exposes, shareScope, federationRuntimePluginInstance.entryFilePath, this._options.dataPrefetch);
129
+ dep.loc = { name };
130
+ compilation.addInclude(compilation.options.context || "", dep, { name: void 0 }, (error) => {
131
+ if (error) return callback(error);
132
+ hooks.addContainerEntryDependency.call(dep);
133
+ callback();
134
+ });
135
+ });
136
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation, { normalModuleFactory }) => {
137
+ compilation.dependencyFactories.set(require_lib_container_ContainerEntryDependency.default, new require_lib_container_ContainerEntryModuleFactory.default());
138
+ compilation.dependencyFactories.set(require_lib_container_ContainerExposedDependency.default, normalModuleFactory);
139
+ if (!compilation.dependencyFactories.has(EntryDependency)) compilation.dependencyFactories.set(EntryDependency, normalModuleFactory);
140
+ });
141
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation, { normalModuleFactory }) => {
142
+ compilation.dependencyFactories.set(require_lib_container_runtime_FederationRuntimeDependency.default, normalModuleFactory);
143
+ compilation.dependencyTemplates.set(require_lib_container_runtime_FederationRuntimeDependency.default, new ModuleDependency.Template());
144
+ });
145
+ }
4
146
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- /*
7
- MIT License http://www.opensource.org/licenses/mit-license.php
8
- Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr
9
- */
10
- const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
11
- const ContainerEntryDependency_1 = __importDefault(require("./ContainerEntryDependency"));
12
- const ContainerEntryModuleFactory_1 = __importDefault(require("./ContainerEntryModuleFactory"));
13
- const ContainerExposedDependency_1 = __importDefault(require("./ContainerExposedDependency"));
14
- const options_1 = require("./options");
15
- const FederationRuntimePlugin_1 = __importDefault(require("./runtime/FederationRuntimePlugin"));
16
- const FederationModulesPlugin_1 = __importDefault(require("./runtime/FederationModulesPlugin"));
17
- const FederationRuntimeDependency_1 = __importDefault(require("./runtime/FederationRuntimeDependency"));
18
- const ModuleDependency = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/dependencies/ModuleDependency'));
19
- const EntryDependency = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/dependencies/EntryDependency'));
20
- const createSchemaValidation = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/util/create-schema-validation'));
21
- // const validate = createSchemaValidation(checkOptions, () => schema, {
22
- // name: 'Container Plugin',
23
- // baseDataPath: 'options',
24
- // });
25
- const PLUGIN_NAME = 'ContainerPlugin';
26
- class ContainerPlugin {
27
- constructor(options) {
28
- // validate(options);
29
- this.name = PLUGIN_NAME;
30
- this._options = {
31
- name: options.name,
32
- shareScope: options.shareScope || 'default',
33
- library: options.library || {
34
- type: 'global',
35
- name: options.name,
36
- },
37
- runtime: options.runtime,
38
- filename: options.filename || undefined,
39
- //@ts-ignore
40
- exposes: (0, options_1.parseOptions)(options.exposes, (item) => ({
41
- import: Array.isArray(item) ? item : [item],
42
- name: undefined,
43
- }), (item) => ({
44
- import: Array.isArray(item.import) ? item.import : [item.import],
45
- name: item.name || undefined,
46
- })),
47
- runtimePlugins: options.runtimePlugins,
48
- dataPrefetch: options.dataPrefetch,
49
- };
50
- }
51
- // container should not be affected by splitChunks
52
- static patchChunkSplit(compiler, name) {
53
- const { splitChunks } = compiler.options.optimization;
54
- const patchChunkSplit = (cacheGroup) => {
55
- switch (typeof cacheGroup) {
56
- case 'boolean':
57
- case 'string':
58
- case 'function':
59
- break;
60
- // cacheGroup.chunks will inherit splitChunks.chunks, so you only need to modify the chunks that are set separately
61
- case 'object':
62
- {
63
- if (cacheGroup instanceof RegExp) {
64
- break;
65
- }
66
- if (!cacheGroup.chunks) {
67
- break;
68
- }
69
- if (typeof cacheGroup.chunks === 'function') {
70
- const prevChunks = cacheGroup.chunks;
71
- cacheGroup.chunks = (chunk) => {
72
- if (chunk.name &&
73
- (chunk.name === name || chunk.name === name + '_partial')) {
74
- return false;
75
- }
76
- return prevChunks(chunk);
77
- };
78
- break;
79
- }
80
- if (cacheGroup.chunks === 'all') {
81
- cacheGroup.chunks = (chunk) => {
82
- if (chunk.name &&
83
- (chunk.name === name || chunk.name === name + '_partial')) {
84
- return false;
85
- }
86
- return true;
87
- };
88
- break;
89
- }
90
- if (cacheGroup.chunks === 'initial') {
91
- cacheGroup.chunks = (chunk) => {
92
- if (chunk.name &&
93
- (chunk.name === name || chunk.name === name + '_partial')) {
94
- return false;
95
- }
96
- return chunk.isOnlyInitial();
97
- };
98
- break;
99
- }
100
- }
101
- break;
102
- }
103
- };
104
- if (!splitChunks) {
105
- return;
106
- }
107
- // patch splitChunk.chunks
108
- patchChunkSplit(splitChunks);
109
- const cacheGroups = splitChunks.cacheGroups;
110
- if (!cacheGroups) {
111
- return;
112
- }
113
- // patch splitChunk.cacheGroups[key].chunks
114
- Object.keys(cacheGroups).forEach((cacheGroupKey) => {
115
- patchChunkSplit(cacheGroups[cacheGroupKey]);
116
- });
117
- }
118
- apply(compiler) {
119
- const useModuleFederationPlugin = compiler.options.plugins.find((p) => {
120
- if (typeof p !== 'object' || !p) {
121
- return false;
122
- }
123
- return p['name'] === 'ModuleFederationPlugin';
124
- });
125
- if (!useModuleFederationPlugin) {
126
- ContainerPlugin.patchChunkSplit(compiler, this._options.name);
127
- }
128
- const federationRuntimePluginInstance = new FederationRuntimePlugin_1.default();
129
- federationRuntimePluginInstance.apply(compiler);
130
- const { name, exposes, shareScope, filename, library, runtime } = this._options;
131
- if (library &&
132
- compiler.options.output &&
133
- compiler.options.output.enabledLibraryTypes &&
134
- !compiler.options.output.enabledLibraryTypes.includes(library.type)) {
135
- compiler.options.output.enabledLibraryTypes.push(library.type);
136
- }
137
- compiler.hooks.make.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
138
- const hooks = FederationModulesPlugin_1.default.getCompilationHooks(compilation);
139
- const federationRuntimeDependency = federationRuntimePluginInstance.getDependency(compiler);
140
- const dep = new ContainerEntryDependency_1.default(name,
141
- //@ts-ignore
142
- exposes, shareScope, federationRuntimePluginInstance.entryFilePath, this._options.dataPrefetch);
143
- dep.loc = { name };
144
- await new Promise((resolve, reject) => {
145
- compilation.addEntry(compilation.options.context || '', dep, {
146
- name,
147
- filename,
148
- runtime,
149
- library,
150
- }, (error) => {
151
- if (error)
152
- return reject(error);
153
- hooks.addContainerEntryDependency.call(dep);
154
- resolve(undefined);
155
- });
156
- }).catch(callback);
157
- await new Promise((resolve, reject) => {
158
- compilation.addInclude(compiler.context, federationRuntimeDependency, { name: undefined }, (err, module) => {
159
- if (err) {
160
- return reject(err);
161
- }
162
- hooks.addFederationRuntimeDependency.call(federationRuntimeDependency);
163
- resolve(undefined);
164
- });
165
- }).catch(callback);
166
- callback();
167
- });
168
- // this will still be copied into child compiler, so it needs a check to avoid running hook on child
169
- // we have to use finishMake in order to check the entries created and see if there are multiple runtime chunks
170
- compiler.hooks.finishMake.tapAsync(PLUGIN_NAME, (compilation, callback) => {
171
- if (compilation.compiler.parentCompilation &&
172
- compilation.compiler.parentCompilation !== compilation) {
173
- return callback();
174
- }
175
- const hooks = FederationModulesPlugin_1.default.getCompilationHooks(compilation);
176
- const createdRuntimes = new Set();
177
- for (const entry of compilation.entries.values()) {
178
- const runtime = entry.options.runtime;
179
- if (runtime) {
180
- createdRuntimes.add(runtime);
181
- }
182
- }
183
- if (createdRuntimes.size === 0 &&
184
- !compilation.options?.optimization?.runtimeChunk) {
185
- return callback();
186
- }
187
- const dep = new ContainerEntryDependency_1.default(name,
188
- //@ts-ignore
189
- exposes, shareScope, federationRuntimePluginInstance.entryFilePath, this._options.dataPrefetch);
190
- dep.loc = { name };
191
- compilation.addInclude(compilation.options.context || '', dep, { name: undefined }, (error) => {
192
- if (error)
193
- return callback(error);
194
- hooks.addContainerEntryDependency.call(dep);
195
- callback();
196
- });
197
- });
198
- // add the container entry module
199
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation, { normalModuleFactory }) => {
200
- compilation.dependencyFactories.set(ContainerEntryDependency_1.default, new ContainerEntryModuleFactory_1.default());
201
- compilation.dependencyFactories.set(ContainerExposedDependency_1.default, normalModuleFactory);
202
- if (!compilation.dependencyFactories.has(EntryDependency)) {
203
- compilation.dependencyFactories.set(EntryDependency, normalModuleFactory);
204
- }
205
- });
206
- // add include of federation runtime
207
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation, { normalModuleFactory }) => {
208
- compilation.dependencyFactories.set(FederationRuntimeDependency_1.default, normalModuleFactory);
209
- compilation.dependencyTemplates.set(FederationRuntimeDependency_1.default, new ModuleDependency.Template());
210
- });
211
- }
212
- }
147
+
148
+ //#endregion
213
149
  exports.default = ContainerPlugin;
214
150
  //# sourceMappingURL=ContainerPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContainerPlugin.js","sourceRoot":"","sources":["../../../../src/lib/container/ContainerPlugin.ts"],"names":[],"mappings":";;;;;AAAA;;;EAGE;AACF,0FAAqF;AACrF,0FAAkE;AAClE,gGAAwE;AACxE,8FAAsE;AACtE,uCAAyC;AASzC,gGAAwE;AACxE,gGAAwE;AAGxE,wGAAgF;AAIhF,MAAM,gBAAgB,GAAG,OAAO,CAC9B,IAAA,6CAAoB,EAAC,2CAA2C,CAAC,CACJ,CAAC;AAEhE,MAAM,eAAe,GAAG,OAAO,CAC7B,IAAA,6CAAoB,EAAC,0CAA0C,CAAC,CACJ,CAAC;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,CAAC;YAEF,WAAW,CAAC,mBAAmB,CAAC,GAAG,CACjC,oCAA0B,EAC1B,mBAAmB,CACpB,CAAC;YAEF,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC;gBAC1D,WAAW,CAAC,mBAAmB,CAAC,GAAG,CACjC,eAAe,EACf,mBAAmB,CACpB,CAAC;YACJ,CAAC;QACH,CAAC,CACF,CAAC;QAEF,oCAAoC;QACpC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAChC,WAAW,EACX,CAAC,WAAwB,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE;YACpD,WAAW,CAAC,mBAAmB,CAAC,GAAG,CACjC,qCAA2B,EAC3B,mBAAmB,CACpB,CAAC;YACF,WAAW,CAAC,mBAAmB,CAAC,GAAG,CACjC,qCAA2B,EAC3B,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAChC,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAED,kBAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"ContainerPlugin.js","names":["parseOptions","FederationRuntimePlugin","FederationModulesPlugin","ContainerEntryDependency","ContainerEntryModuleFactory","ContainerExposedDependency","FederationRuntimeDependency"],"sources":["../../../../src/lib/container/ContainerPlugin.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport ContainerEntryDependency from './ContainerEntryDependency';\nimport ContainerEntryModuleFactory from './ContainerEntryModuleFactory';\nimport ContainerExposedDependency from './ContainerExposedDependency';\nimport { parseOptions } from './options';\nimport type {\n Compiler,\n Compilation,\n WebpackError,\n WebpackPluginInstance,\n WebpackPluginFunction,\n} from 'webpack';\nimport type { containerPlugin } from '@module-federation/sdk';\nimport FederationRuntimePlugin from './runtime/FederationRuntimePlugin';\nimport FederationModulesPlugin from './runtime/FederationModulesPlugin';\nimport checkOptions from '../../schemas/container/ContainerPlugin.check';\nimport schema from '../../schemas/container/ContainerPlugin';\nimport FederationRuntimeDependency from './runtime/FederationRuntimeDependency';\nimport type { OptimizationSplitChunksCacheGroup } from 'webpack/lib/optimize/SplitChunksPlugin';\nimport type { Falsy } from 'webpack/declarations/WebpackOptions';\n\nconst ModuleDependency = require(\n normalizeWebpackPath('webpack/lib/dependencies/ModuleDependency'),\n) as typeof import('webpack/lib/dependencies/ModuleDependency');\n\nconst EntryDependency = require(\n normalizeWebpackPath('webpack/lib/dependencies/EntryDependency'),\n) as typeof import('webpack/lib/dependencies/EntryDependency');\n\nconst createSchemaValidation = require(\n normalizeWebpackPath('webpack/lib/util/create-schema-validation'),\n) as typeof import('webpack/lib/util/create-schema-validation');\n\n// const validate = createSchemaValidation(checkOptions, () => schema, {\n// name: 'Container Plugin',\n// baseDataPath: 'options',\n// });\n\nconst PLUGIN_NAME = 'ContainerPlugin';\n\nclass ContainerPlugin {\n _options: containerPlugin.ContainerPluginOptions;\n name: string;\n\n constructor(options: containerPlugin.ContainerPluginOptions) {\n // validate(options);\n this.name = PLUGIN_NAME;\n\n this._options = {\n name: options.name,\n shareScope: options.shareScope || 'default',\n library: options.library || {\n type: 'global',\n name: options.name,\n },\n runtime: options.runtime,\n filename: options.filename || undefined,\n //@ts-ignore\n exposes: parseOptions(\n options.exposes,\n (item) => ({\n import: Array.isArray(item) ? item : [item],\n name: undefined,\n }),\n (item) => ({\n import: Array.isArray(item.import) ? item.import : [item.import],\n name: item.name || undefined,\n }),\n ),\n runtimePlugins: options.runtimePlugins,\n dataPrefetch: options.dataPrefetch,\n };\n }\n\n // container should not be affected by splitChunks\n static patchChunkSplit(compiler: Compiler, name: string): void {\n const { splitChunks } = compiler.options.optimization;\n const patchChunkSplit = (\n cacheGroup:\n | string\n | false\n | ((...args: any[]) => any)\n | RegExp\n | OptimizationSplitChunksCacheGroup,\n ) => {\n switch (typeof cacheGroup) {\n case 'boolean':\n case 'string':\n case 'function':\n break;\n // cacheGroup.chunks will inherit splitChunks.chunks, so you only need to modify the chunks that are set separately\n case 'object':\n {\n if (cacheGroup instanceof RegExp) {\n break;\n }\n if (!cacheGroup.chunks) {\n break;\n }\n if (typeof cacheGroup.chunks === 'function') {\n const prevChunks = cacheGroup.chunks;\n cacheGroup.chunks = (chunk) => {\n if (\n chunk.name &&\n (chunk.name === name || chunk.name === name + '_partial')\n ) {\n return false;\n }\n return prevChunks(chunk);\n };\n break;\n }\n\n if (cacheGroup.chunks === 'all') {\n cacheGroup.chunks = (chunk) => {\n if (\n chunk.name &&\n (chunk.name === name || chunk.name === name + '_partial')\n ) {\n return false;\n }\n return true;\n };\n break;\n }\n if (cacheGroup.chunks === 'initial') {\n cacheGroup.chunks = (chunk) => {\n if (\n chunk.name &&\n (chunk.name === name || chunk.name === name + '_partial')\n ) {\n return false;\n }\n return chunk.isOnlyInitial();\n };\n break;\n }\n }\n break;\n }\n };\n\n if (!splitChunks) {\n return;\n }\n // patch splitChunk.chunks\n patchChunkSplit(splitChunks);\n\n const cacheGroups = splitChunks.cacheGroups;\n if (!cacheGroups) {\n return;\n }\n\n // patch splitChunk.cacheGroups[key].chunks\n Object.keys(cacheGroups).forEach((cacheGroupKey) => {\n patchChunkSplit(cacheGroups[cacheGroupKey]);\n });\n }\n\n apply(compiler: Compiler): void {\n const useModuleFederationPlugin = compiler.options.plugins.find(\n (p: Falsy | WebpackPluginInstance | WebpackPluginFunction) => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n\n return p['name'] === 'ModuleFederationPlugin';\n },\n );\n\n if (!useModuleFederationPlugin) {\n ContainerPlugin.patchChunkSplit(compiler, this._options.name);\n }\n\n const federationRuntimePluginInstance = new FederationRuntimePlugin();\n federationRuntimePluginInstance.apply(compiler);\n\n const { name, exposes, shareScope, filename, library, runtime } =\n this._options;\n\n if (\n library &&\n compiler.options.output &&\n compiler.options.output.enabledLibraryTypes &&\n !compiler.options.output.enabledLibraryTypes.includes(library.type)\n ) {\n compiler.options.output.enabledLibraryTypes.push(library.type);\n }\n\n compiler.hooks.make.tapAsync(\n PLUGIN_NAME,\n async (\n compilation: Compilation,\n callback: (error?: WebpackError | null | undefined) => void,\n ) => {\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n const federationRuntimeDependency =\n federationRuntimePluginInstance.getDependency(compiler);\n const dep = new ContainerEntryDependency(\n name,\n //@ts-ignore\n exposes,\n shareScope,\n federationRuntimePluginInstance.entryFilePath,\n this._options.dataPrefetch,\n );\n dep.loc = { name };\n\n await new Promise((resolve, reject) => {\n compilation.addEntry(\n compilation.options.context || '',\n dep,\n {\n name,\n filename,\n runtime,\n library,\n },\n (error: WebpackError | null | undefined) => {\n if (error) return reject(error);\n hooks.addContainerEntryDependency.call(dep);\n resolve(undefined);\n },\n );\n }).catch(callback);\n\n await new Promise((resolve, reject) => {\n compilation.addInclude(\n compiler.context,\n federationRuntimeDependency,\n { name: undefined },\n (err, module) => {\n if (err) {\n return reject(err);\n }\n hooks.addFederationRuntimeDependency.call(\n federationRuntimeDependency,\n );\n resolve(undefined);\n },\n );\n }).catch(callback);\n\n callback();\n },\n );\n\n // this will still be copied into child compiler, so it needs a check to avoid running hook on child\n // we have to use finishMake in order to check the entries created and see if there are multiple runtime chunks\n compiler.hooks.finishMake.tapAsync(\n PLUGIN_NAME,\n (compilation: Compilation, callback) => {\n if (\n compilation.compiler.parentCompilation &&\n compilation.compiler.parentCompilation !== compilation\n ) {\n return callback();\n }\n\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n const createdRuntimes = new Set<string>();\n\n for (const entry of compilation.entries.values()) {\n const runtime = entry.options.runtime;\n if (runtime) {\n createdRuntimes.add(runtime);\n }\n }\n\n if (\n createdRuntimes.size === 0 &&\n !compilation.options?.optimization?.runtimeChunk\n ) {\n return callback();\n }\n\n const dep = new ContainerEntryDependency(\n name,\n //@ts-ignore\n exposes,\n shareScope,\n federationRuntimePluginInstance.entryFilePath,\n this._options.dataPrefetch,\n );\n\n dep.loc = { name };\n\n compilation.addInclude(\n compilation.options.context || '',\n dep,\n { name: undefined },\n (error: WebpackError | null | undefined) => {\n if (error) return callback(error);\n hooks.addContainerEntryDependency.call(dep);\n callback();\n },\n );\n },\n );\n\n // add the container entry module\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (compilation: Compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n ContainerEntryDependency,\n new ContainerEntryModuleFactory(),\n );\n\n compilation.dependencyFactories.set(\n ContainerExposedDependency,\n normalModuleFactory,\n );\n\n if (!compilation.dependencyFactories.has(EntryDependency)) {\n compilation.dependencyFactories.set(\n EntryDependency,\n normalModuleFactory,\n );\n }\n },\n );\n\n // add include of federation runtime\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (compilation: Compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n FederationRuntimeDependency,\n normalModuleFactory,\n );\n compilation.dependencyTemplates.set(\n FederationRuntimeDependency,\n new ModuleDependency.Template(),\n );\n },\n );\n }\n}\n\nexport default ContainerPlugin;\n"],"mappings":";;;;;;;;;;;;oFAkBwE;AAOxE,MAAM,mBAAmB,gFACF,4CAA4C,CAClE;AAED,MAAM,kBAAkB,gFACD,2CAA2C,CACjE;AAE8B,gFACR,4CAA4C,CAClE;AAOD,MAAM,cAAc;AAEpB,IAAM,kBAAN,MAAM,gBAAgB;CAIpB,YAAY,SAAiD;AAE3D,OAAK,OAAO;AAEZ,OAAK,WAAW;GACd,MAAM,QAAQ;GACd,YAAY,QAAQ,cAAc;GAClC,SAAS,QAAQ,WAAW;IAC1B,MAAM;IACN,MAAM,QAAQ;IACf;GACD,SAAS,QAAQ;GACjB,UAAU,QAAQ,YAAY;GAE9B,SAASA,2CACP,QAAQ,UACP,UAAU;IACT,QAAQ,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC,KAAK;IAC3C,MAAM;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,MAAM,kCAAkB,IAAI,KAAa;AAEzC,QAAK,MAAM,SAAS,YAAY,QAAQ,QAAQ,EAAE;IAChD,MAAM,UAAU,MAAM,QAAQ;AAC9B,QAAI,QACF,iBAAgB,IAAI,QAAQ;;AAIhC,OACE,gBAAgB,SAAS,KACzB,CAAC,YAAY,SAAS,cAAc,aAEpC,QAAO,UAAU;GAGnB,MAAM,MAAM,IAAIC,uDACd,MAEA,SACA,YACA,gCAAgC,eAChC,KAAK,SAAS,aACf;AAED,OAAI,MAAM,EAAE,MAAM;AAElB,eAAY,WACV,YAAY,QAAQ,WAAW,IAC/B,KACA,EAAE,MAAM,QAAW,GAClB,UAA2C;AAC1C,QAAI,MAAO,QAAO,SAAS,MAAM;AACjC,UAAM,4BAA4B,KAAK,IAAI;AAC3C,cAAU;KAEb;IAEJ;AAGD,WAAS,MAAM,gBAAgB,IAC7B,cACC,aAA0B,EAAE,0BAA0B;AACrD,eAAY,oBAAoB,IAC9BA,wDACA,IAAIC,2DAA6B,CAClC;AAED,eAAY,oBAAoB,IAC9BC,0DACA,oBACD;AAED,OAAI,CAAC,YAAY,oBAAoB,IAAI,gBAAgB,CACvD,aAAY,oBAAoB,IAC9B,iBACA,oBACD;IAGN;AAGD,WAAS,MAAM,gBAAgB,IAC7B,cACC,aAA0B,EAAE,0BAA0B;AACrD,eAAY,oBAAoB,IAC9BC,mEACA,oBACD;AACD,eAAY,oBAAoB,IAC9BA,mEACA,IAAI,iBAAiB,UAAU,CAChC;IAEJ"}
@@ -1,14 +1,18 @@
1
- import type { Compiler } from 'webpack';
2
- import type { containerReferencePlugin } from '@module-federation/sdk';
1
+ import { containerReferencePlugin } from "@module-federation/sdk";
2
+ import { Compiler } from "webpack";
3
+
4
+ //#region src/lib/container/ContainerReferencePlugin.d.ts
3
5
  declare class ContainerReferencePlugin {
4
- private _remoteType;
5
- private _remotes;
6
- constructor(options: containerReferencePlugin.ContainerReferencePluginOptions);
7
- /**
8
- * Apply the plugin
9
- * @param {Compiler} compiler the compiler instance
10
- * @returns {void}
11
- */
12
- apply(compiler: Compiler): void;
6
+ private _remoteType;
7
+ private _remotes;
8
+ constructor(options: containerReferencePlugin.ContainerReferencePluginOptions);
9
+ /**
10
+ * Apply the plugin
11
+ * @param {Compiler} compiler the compiler instance
12
+ * @returns {void}
13
+ */
14
+ apply(compiler: Compiler): void;
13
15
  }
14
- export default ContainerReferencePlugin;
16
+ //#endregion
17
+ export { ContainerReferencePlugin as default };
18
+ //# sourceMappingURL=ContainerReferencePlugin.d.ts.map
@@ -1,105 +1,77 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
+ const require_lib_container_runtime_FederationModulesPlugin = require('./runtime/FederationModulesPlugin.js');
4
+ const require_lib_container_options = require('./options.js');
5
+ const require_lib_container_runtime_FederationRuntimePlugin = require('./runtime/FederationRuntimePlugin.js');
6
+ const require_lib_container_FallbackDependency = require('./FallbackDependency.js');
7
+ const require_lib_container_FallbackItemDependency = require('./FallbackItemDependency.js');
8
+ const require_lib_container_FallbackModuleFactory = require('./FallbackModuleFactory.js');
9
+ const require_lib_container_RemoteToExternalDependency = require('./RemoteToExternalDependency.js');
10
+ const require_lib_container_RemoteModule = require('./RemoteModule.js');
11
+ const require_lib_container_RemoteRuntimeModule = require('./RemoteRuntimeModule.js');
12
+ let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
13
+
14
+ //#region src/lib/container/ContainerReferencePlugin.ts
15
+ require_lib_container_runtime_FederationModulesPlugin.init_FederationModulesPlugin();
16
+ const { ExternalsPlugin } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
17
+ require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/create-schema-validation"));
18
+ const slashCode = "/".charCodeAt(0);
19
+ var ContainerReferencePlugin = class {
20
+ constructor(options) {
21
+ this._remoteType = options.remoteType;
22
+ this._remotes = require_lib_container_options.parseOptions(options.remotes, (item) => ({
23
+ external: Array.isArray(item) ? item : [item],
24
+ shareScope: options.shareScope || "default"
25
+ }), (item) => ({
26
+ external: Array.isArray(item.external) ? item.external : [item.external],
27
+ shareScope: item.shareScope || options.shareScope || "default"
28
+ }));
29
+ }
30
+ /**
31
+ * Apply the plugin
32
+ * @param {Compiler} compiler the compiler instance
33
+ * @returns {void}
34
+ */
35
+ apply(compiler) {
36
+ const { _remotes: remotes, _remoteType: remoteType } = this;
37
+ new require_lib_container_runtime_FederationRuntimePlugin.default().apply(compiler);
38
+ /** @type {Record<string, string>} */
39
+ const remoteExternals = {};
40
+ for (const [key, config] of remotes) {
41
+ let i = 0;
42
+ for (const external of config.external) {
43
+ if (typeof external === "string" && external.startsWith("internal ")) continue;
44
+ remoteExternals[`webpack/container/reference/${key}${i ? `/fallback-${i}` : ""}`] = external;
45
+ i++;
46
+ }
47
+ }
48
+ new (compiler.webpack.ExternalsPlugin || ExternalsPlugin)(remoteType, remoteExternals).apply(compiler);
49
+ compiler.hooks.compilation.tap("ContainerReferencePlugin", (compilation, { normalModuleFactory }) => {
50
+ compilation.dependencyFactories.set(require_lib_container_RemoteToExternalDependency.default, normalModuleFactory);
51
+ compilation.dependencyFactories.set(require_lib_container_FallbackItemDependency.default, normalModuleFactory);
52
+ compilation.dependencyFactories.set(require_lib_container_FallbackDependency.default, new require_lib_container_FallbackModuleFactory.default());
53
+ const hooks = require_lib_container_runtime_FederationModulesPlugin.default.getCompilationHooks(compilation);
54
+ normalModuleFactory.hooks.factorize.tap("ContainerReferencePlugin", (data) => {
55
+ if (!data.request.includes("!")) {
56
+ for (const [key, config] of remotes) if (data.request.startsWith(`${key}`) && (data.request.length === key.length || data.request.charCodeAt(key.length) === slashCode)) {
57
+ const remoteModule = new require_lib_container_RemoteModule.default(data.request, config.external.map((external, i) => external.startsWith("internal ") ? external.slice(9) : `webpack/container/reference/${key}${i ? `/fallback-${i}` : ""}`), `.${data.request.slice(key.length)}`, config.shareScope);
58
+ hooks.addRemoteDependency.call(remoteModule);
59
+ return remoteModule;
60
+ }
61
+ }
62
+ });
63
+ compilation.hooks.runtimeRequirementInTree.for(compiler.webpack.RuntimeGlobals.ensureChunkHandlers).tap("ContainerReferencePlugin", (chunk, set) => {
64
+ set.add(compiler.webpack.RuntimeGlobals.module);
65
+ set.add(compiler.webpack.RuntimeGlobals.moduleFactoriesAddOnly);
66
+ set.add(compiler.webpack.RuntimeGlobals.hasOwnProperty);
67
+ set.add(compiler.webpack.RuntimeGlobals.initializeSharing);
68
+ set.add(compiler.webpack.RuntimeGlobals.shareScopeMap);
69
+ compilation.addRuntimeModule(chunk, new require_lib_container_RemoteRuntimeModule.default());
70
+ });
71
+ });
72
+ }
4
73
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
7
- // import * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';
8
- const FallbackDependency_1 = __importDefault(require("./FallbackDependency"));
9
- const FallbackItemDependency_1 = __importDefault(require("./FallbackItemDependency"));
10
- const FallbackModuleFactory_1 = __importDefault(require("./FallbackModuleFactory"));
11
- const RemoteModule_1 = __importDefault(require("./RemoteModule"));
12
- const RemoteRuntimeModule_1 = __importDefault(require("./RemoteRuntimeModule"));
13
- const RemoteToExternalDependency_1 = __importDefault(require("./RemoteToExternalDependency"));
14
- const options_1 = require("./options");
15
- const FederationRuntimePlugin_1 = __importDefault(require("./runtime/FederationRuntimePlugin"));
16
- const FederationModulesPlugin_1 = __importDefault(require("./runtime/FederationModulesPlugin"));
17
- const { ExternalsPlugin } = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack'));
18
- const createSchemaValidation = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/util/create-schema-validation'));
19
- // const validate = createSchemaValidation(
20
- // //eslint-disable-next-line
21
- // checkOptions,
22
- // () => schema,
23
- // {
24
- // name: 'Container Reference Plugin',
25
- // baseDataPath: 'options',
26
- // },
27
- // );
28
- const slashCode = '/'.charCodeAt(0);
29
- class ContainerReferencePlugin {
30
- constructor(options) {
31
- // validate(options);
32
- this._remoteType = options.remoteType;
33
- this._remotes = (0, options_1.parseOptions)(options.remotes, (item) => ({
34
- external: Array.isArray(item) ? item : [item],
35
- shareScope: options.shareScope || 'default',
36
- }), (item) => ({
37
- external: Array.isArray(item.external)
38
- ? item.external
39
- : [item.external],
40
- shareScope: item.shareScope || options.shareScope || 'default',
41
- }));
42
- }
43
- /**
44
- * Apply the plugin
45
- * @param {Compiler} compiler the compiler instance
46
- * @returns {void}
47
- */
48
- apply(compiler) {
49
- const { _remotes: remotes, _remoteType: remoteType } = this;
50
- new FederationRuntimePlugin_1.default().apply(compiler);
51
- /** @type {Record<string, string>} */
52
- const remoteExternals = {};
53
- for (const [key, config] of remotes) {
54
- let i = 0;
55
- for (const external of config.external) {
56
- if (typeof external === 'string' && external.startsWith('internal ')) {
57
- continue;
58
- }
59
- remoteExternals[`webpack/container/reference/${key}${i ? `/fallback-${i}` : ''}`] = external;
60
- i++;
61
- }
62
- }
63
- const Externals = compiler.webpack.ExternalsPlugin || ExternalsPlugin;
64
- new Externals(remoteType, remoteExternals).apply(compiler);
65
- compiler.hooks.compilation.tap('ContainerReferencePlugin', (compilation, { normalModuleFactory }) => {
66
- compilation.dependencyFactories.set(RemoteToExternalDependency_1.default, normalModuleFactory);
67
- compilation.dependencyFactories.set(FallbackItemDependency_1.default, normalModuleFactory);
68
- compilation.dependencyFactories.set(FallbackDependency_1.default, new FallbackModuleFactory_1.default());
69
- const hooks = FederationModulesPlugin_1.default.getCompilationHooks(compilation);
70
- normalModuleFactory.hooks.factorize.tap('ContainerReferencePlugin',
71
- //@ts-ignore
72
- (data) => {
73
- if (!data.request.includes('!')) {
74
- for (const [key, config] of remotes) {
75
- if (data.request.startsWith(`${key}`) &&
76
- (data.request.length === key.length ||
77
- data.request.charCodeAt(key.length) === slashCode)) {
78
- const remoteModule = new RemoteModule_1.default(data.request,
79
- //@ts-ignore
80
- config.external.map((external, i) => external.startsWith('internal ')
81
- ? external.slice(9)
82
- : `webpack/container/reference/${key}${i ? `/fallback-${i}` : ''}`), `.${data.request.slice(key.length)}`,
83
- //@ts-ignore
84
- config.shareScope);
85
- hooks.addRemoteDependency.call(remoteModule);
86
- return remoteModule;
87
- }
88
- }
89
- }
90
- });
91
- compilation.hooks.runtimeRequirementInTree
92
- .for(compiler.webpack.RuntimeGlobals.ensureChunkHandlers)
93
- .tap('ContainerReferencePlugin', (chunk, set) => {
94
- set.add(compiler.webpack.RuntimeGlobals.module);
95
- set.add(compiler.webpack.RuntimeGlobals.moduleFactoriesAddOnly);
96
- set.add(compiler.webpack.RuntimeGlobals.hasOwnProperty);
97
- set.add(compiler.webpack.RuntimeGlobals.initializeSharing);
98
- set.add(compiler.webpack.RuntimeGlobals.shareScopeMap);
99
- compilation.addRuntimeModule(chunk, new RemoteRuntimeModule_1.default());
100
- });
101
- });
102
- }
103
- }
74
+
75
+ //#endregion
104
76
  exports.default = ContainerReferencePlugin;
105
77
  //# sourceMappingURL=ContainerReferencePlugin.js.map