@module-federation/enhanced 0.0.0-perf-devtools-20260107043700 → 0.0.0-perf-website-code-usage-20260914033703

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 (289) hide show
  1. package/README.md +1 -1
  2. package/dist/CHANGELOG.md +2678 -0
  3. package/dist/README.md +213 -0
  4. package/dist/rstestmigrate.md +140 -0
  5. package/dist/src/_virtual/_rolldown/runtime.js +47 -0
  6. package/dist/src/index.d.ts +22 -18
  7. package/dist/src/index.js +47 -41
  8. package/dist/src/index.js.map +1 -1
  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 -196
  13. package/dist/src/lib/container/AsyncBoundaryPlugin.js.map +1 -1
  14. package/dist/src/lib/container/ContainerEntryDependency.d.ts +25 -23
  15. package/dist/src/lib/container/ContainerEntryDependency.js +37 -39
  16. package/dist/src/lib/container/ContainerEntryDependency.js.map +1 -1
  17. package/dist/src/lib/container/ContainerEntryModule.d.ts +104 -79
  18. package/dist/src/lib/container/ContainerEntryModule.js +213 -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 +26 -23
  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 +144 -213
  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 +72 -101
  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 +124 -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 +151 -170
  49. package/dist/src/lib/container/ModuleFederationPlugin.js.map +1 -1
  50. package/dist/src/lib/container/RemoteModule.d.ts +83 -74
  51. package/dist/src/lib/container/RemoteModule.js +149 -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 -120
  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 +12 -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 +70 -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 +38 -46
  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 -18
  81. package/dist/src/lib/container/runtime/FederationRuntimePlugin.js +263 -293
  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/normalizeToPosixPath.d.ts +5 -0
  87. package/dist/src/lib/container/runtime/normalizeToPosixPath.js +20 -0
  88. package/dist/src/lib/container/runtime/normalizeToPosixPath.js.map +1 -0
  89. package/dist/src/lib/container/runtime/utils.d.ts +22 -7
  90. package/dist/src/lib/container/runtime/utils.js +80 -102
  91. package/dist/src/lib/container/runtime/utils.js.map +1 -1
  92. package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.d.ts +15 -10
  93. package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.js +27 -25
  94. package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.js.map +1 -1
  95. package/dist/src/lib/sharing/ConsumeSharedModule.d.ts +77 -67
  96. package/dist/src/lib/sharing/ConsumeSharedModule.js +190 -214
  97. package/dist/src/lib/sharing/ConsumeSharedModule.js.map +1 -1
  98. package/dist/src/lib/sharing/ConsumeSharedPlugin.d.ts +13 -9
  99. package/dist/src/lib/sharing/ConsumeSharedPlugin.js +308 -472
  100. package/dist/src/lib/sharing/ConsumeSharedPlugin.js.map +1 -1
  101. package/dist/src/lib/sharing/ConsumeSharedRuntimeModule.d.ts +16 -11
  102. package/dist/src/lib/sharing/ConsumeSharedRuntimeModule.js +108 -123
  103. package/dist/src/lib/sharing/ConsumeSharedRuntimeModule.js.map +1 -1
  104. package/dist/src/lib/sharing/ProvideForSharedDependency.d.ts +14 -9
  105. package/dist/src/lib/sharing/ProvideForSharedDependency.js +25 -25
  106. package/dist/src/lib/sharing/ProvideForSharedDependency.js.map +1 -1
  107. package/dist/src/lib/sharing/ProvideSharedDependency.d.ts +44 -38
  108. package/dist/src/lib/sharing/ProvideSharedDependency.js +72 -74
  109. package/dist/src/lib/sharing/ProvideSharedDependency.js.map +1 -1
  110. package/dist/src/lib/sharing/ProvideSharedModule.d.ts +91 -81
  111. package/dist/src/lib/sharing/ProvideSharedModule.js +177 -181
  112. package/dist/src/lib/sharing/ProvideSharedModule.js.map +1 -1
  113. package/dist/src/lib/sharing/ProvideSharedModuleFactory.d.ts +14 -9
  114. package/dist/src/lib/sharing/ProvideSharedModuleFactory.js +19 -25
  115. package/dist/src/lib/sharing/ProvideSharedModuleFactory.js.map +1 -1
  116. package/dist/src/lib/sharing/ProvideSharedPlugin.d.ts +27 -21
  117. package/dist/src/lib/sharing/ProvideSharedPlugin.js +341 -548
  118. package/dist/src/lib/sharing/ProvideSharedPlugin.js.map +1 -1
  119. package/dist/src/lib/sharing/SharePlugin.d.ts +55 -12
  120. package/dist/src/lib/sharing/SharePlugin.js +91 -91
  121. package/dist/src/lib/sharing/SharePlugin.js.map +1 -1
  122. package/dist/src/lib/sharing/ShareRuntimeModule.d.ts +12 -7
  123. package/dist/src/lib/sharing/ShareRuntimeModule.js +81 -99
  124. package/dist/src/lib/sharing/ShareRuntimeModule.js.map +1 -1
  125. package/dist/src/lib/sharing/resolveMatchedConfigs.d.ts +11 -7
  126. package/dist/src/lib/sharing/resolveMatchedConfigs.js +58 -71
  127. package/dist/src/lib/sharing/resolveMatchedConfigs.js.map +1 -1
  128. package/dist/src/lib/sharing/tree-shaking/CollectSharedEntryPlugin.d.ts +25 -0
  129. package/dist/src/lib/sharing/tree-shaking/CollectSharedEntryPlugin.js +85 -0
  130. package/dist/src/lib/sharing/tree-shaking/CollectSharedEntryPlugin.js.map +1 -0
  131. package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.d.ts +41 -0
  132. package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.js +227 -0
  133. package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.js.map +1 -0
  134. package/dist/src/lib/sharing/tree-shaking/IndependentSharedRuntimeModule.d.ts +26 -0
  135. package/dist/src/lib/sharing/tree-shaking/IndependentSharedRuntimeModule.js +32 -0
  136. package/dist/src/lib/sharing/tree-shaking/IndependentSharedRuntimeModule.js.map +1 -0
  137. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedContainerPlugin.d.ts +32 -0
  138. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedContainerPlugin.js +94 -0
  139. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedContainerPlugin.js.map +1 -0
  140. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.d.ts +31 -0
  141. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.js +49 -0
  142. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.js.map +1 -0
  143. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.d.ts +22 -0
  144. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.js +35 -0
  145. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.js.map +1 -0
  146. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.d.ts +87 -0
  147. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.js +144 -0
  148. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.js.map +1 -0
  149. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModuleFactory.d.ts +16 -0
  150. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModuleFactory.js +23 -0
  151. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModuleFactory.js.map +1 -0
  152. package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerPlugin.d.ts +23 -0
  153. package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerPlugin.js +163 -0
  154. package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerPlugin.js.map +1 -0
  155. package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerRuntimeModule.d.ts +22 -0
  156. package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerRuntimeModule.js +28 -0
  157. package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerRuntimeModule.js.map +1 -0
  158. package/dist/src/lib/sharing/tree-shaking/TreeShakingSharedPlugin.d.ts +20 -0
  159. package/dist/src/lib/sharing/tree-shaking/TreeShakingSharedPlugin.js +44 -0
  160. package/dist/src/lib/sharing/tree-shaking/TreeShakingSharedPlugin.js.map +1 -0
  161. package/dist/src/lib/sharing/utils.d.ts +27 -23
  162. package/dist/src/lib/sharing/utils.js +224 -366
  163. package/dist/src/lib/sharing/utils.js.map +1 -1
  164. package/dist/src/lib/startup/MfStartupChunkDependenciesPlugin.d.ts +11 -7
  165. package/dist/src/lib/startup/MfStartupChunkDependenciesPlugin.js +56 -75
  166. package/dist/src/lib/startup/MfStartupChunkDependenciesPlugin.js.map +1 -1
  167. package/dist/src/lib/startup/StartupHelpers.d.ts +11 -6
  168. package/dist/src/lib/startup/StartupHelpers.js +128 -178
  169. package/dist/src/lib/startup/StartupHelpers.js.map +1 -1
  170. package/dist/src/rspack.d.ts +3 -2
  171. package/dist/src/rspack.js +35 -10
  172. package/dist/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +8 -4
  173. package/dist/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js +19 -16
  174. package/dist/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -1
  175. package/dist/src/runtime.d.ts +1 -1
  176. package/dist/src/runtime.js +11 -18
  177. package/dist/src/runtime.mjs +3 -0
  178. package/dist/src/schemas/container/ContainerPlugin.check.d.ts +13 -5
  179. package/dist/src/schemas/container/ContainerPlugin.check.js +767 -1220
  180. package/dist/src/schemas/container/ContainerPlugin.check.js.map +1 -1
  181. package/dist/src/schemas/container/ContainerPlugin.d.ts +267 -268
  182. package/dist/src/schemas/container/ContainerPlugin.js +269 -361
  183. package/dist/src/schemas/container/ContainerPlugin.js.map +1 -1
  184. package/dist/src/schemas/container/ContainerReferencePlugin.check.d.ts +13 -5
  185. package/dist/src/schemas/container/ContainerReferencePlugin.check.js +335 -443
  186. package/dist/src/schemas/container/ContainerReferencePlugin.check.js.map +1 -1
  187. package/dist/src/schemas/container/ContainerReferencePlugin.d.ts +102 -99
  188. package/dist/src/schemas/container/ContainerReferencePlugin.js +122 -162
  189. package/dist/src/schemas/container/ContainerReferencePlugin.js.map +1 -1
  190. package/dist/src/schemas/container/ExternalsType.check.d.ts +13 -5
  191. package/dist/src/schemas/container/ExternalsType.check.js +36 -62
  192. package/dist/src/schemas/container/ExternalsType.check.js.map +1 -1
  193. package/dist/src/schemas/container/ExternalsType.d.ts +5 -2
  194. package/dist/src/schemas/container/ExternalsType.js +8 -11
  195. package/dist/src/schemas/container/ExternalsType.js.map +1 -1
  196. package/dist/src/schemas/container/ModuleFederationPlugin.check.js +3020 -4301
  197. package/dist/src/schemas/container/ModuleFederationPlugin.check.js.map +1 -1
  198. package/dist/src/schemas/container/ModuleFederationPlugin.d.ts +828 -758
  199. package/dist/src/schemas/container/ModuleFederationPlugin.js +788 -993
  200. package/dist/src/schemas/container/ModuleFederationPlugin.js.map +1 -1
  201. package/dist/src/schemas/sharing/ConsumeSharedPlugin.check.d.ts +13 -5
  202. package/dist/src/schemas/sharing/ConsumeSharedPlugin.check.js +568 -739
  203. package/dist/src/schemas/sharing/ConsumeSharedPlugin.check.js.map +1 -1
  204. package/dist/src/schemas/sharing/ConsumeSharedPlugin.d.ts +197 -189
  205. package/dist/src/schemas/sharing/ConsumeSharedPlugin.js +212 -233
  206. package/dist/src/schemas/sharing/ConsumeSharedPlugin.js.map +1 -1
  207. package/dist/src/schemas/sharing/ProvideSharedPlugin.check.d.ts +13 -5
  208. package/dist/src/schemas/sharing/ProvideSharedPlugin.check.js +598 -775
  209. package/dist/src/schemas/sharing/ProvideSharedPlugin.check.js.map +1 -1
  210. package/dist/src/schemas/sharing/ProvideSharedPlugin.d.ts +184 -176
  211. package/dist/src/schemas/sharing/ProvideSharedPlugin.js +196 -224
  212. package/dist/src/schemas/sharing/ProvideSharedPlugin.js.map +1 -1
  213. package/dist/src/schemas/sharing/ProviderSharedPlugin.check.d.ts +12 -4
  214. package/dist/src/schemas/sharing/ProviderSharedPlugin.check.js +285 -482
  215. package/dist/src/schemas/sharing/ProviderSharedPlugin.check.js.map +1 -1
  216. package/dist/src/schemas/sharing/ProviderSharedPlugin.d.ts +103 -100
  217. package/dist/src/schemas/sharing/ProviderSharedPlugin.js +104 -126
  218. package/dist/src/schemas/sharing/ProviderSharedPlugin.js.map +1 -1
  219. package/dist/src/schemas/sharing/SharePlugin.check.d.ts +13 -5
  220. package/dist/src/schemas/sharing/SharePlugin.check.js +749 -794
  221. package/dist/src/schemas/sharing/SharePlugin.check.js.map +1 -1
  222. package/dist/src/schemas/sharing/SharePlugin.d.ts +245 -205
  223. package/dist/src/schemas/sharing/SharePlugin.js +256 -253
  224. package/dist/src/schemas/sharing/SharePlugin.js.map +1 -1
  225. package/dist/src/utils.d.ts +3 -0
  226. package/dist/src/utils.js +35 -26
  227. package/dist/src/utils.js.map +1 -1
  228. package/dist/src/webpack.d.ts +2 -2
  229. package/dist/src/webpack.js +6 -40
  230. package/dist/src/wrapper/AsyncBoundaryPlugin.d.ts +9 -7
  231. package/dist/src/wrapper/AsyncBoundaryPlugin.js +13 -17
  232. package/dist/src/wrapper/AsyncBoundaryPlugin.js.map +1 -1
  233. package/dist/src/wrapper/BaseWrapperPlugin.d.ts +32 -0
  234. package/dist/src/wrapper/BaseWrapperPlugin.js +43 -0
  235. package/dist/src/wrapper/BaseWrapperPlugin.js.map +1 -0
  236. package/dist/src/wrapper/ConsumeSharedPlugin.d.ts +10 -7
  237. package/dist/src/wrapper/ConsumeSharedPlugin.js +13 -17
  238. package/dist/src/wrapper/ConsumeSharedPlugin.js.map +1 -1
  239. package/dist/src/wrapper/ContainerPlugin.d.ts +9 -7
  240. package/dist/src/wrapper/ContainerPlugin.js +13 -17
  241. package/dist/src/wrapper/ContainerPlugin.js.map +1 -1
  242. package/dist/src/wrapper/ContainerReferencePlugin.d.ts +9 -7
  243. package/dist/src/wrapper/ContainerReferencePlugin.js +13 -17
  244. package/dist/src/wrapper/ContainerReferencePlugin.js.map +1 -1
  245. package/dist/src/wrapper/FederationModulesPlugin.d.ts +18 -10
  246. package/dist/src/wrapper/FederationModulesPlugin.js +20 -21
  247. package/dist/src/wrapper/FederationModulesPlugin.js.map +1 -1
  248. package/dist/src/wrapper/FederationRuntimePlugin.d.ts +11 -8
  249. package/dist/src/wrapper/FederationRuntimePlugin.js +19 -20
  250. package/dist/src/wrapper/FederationRuntimePlugin.js.map +1 -1
  251. package/dist/src/wrapper/HoistContainerReferencesPlugin.d.ts +8 -5
  252. package/dist/src/wrapper/HoistContainerReferencesPlugin.js +13 -16
  253. package/dist/src/wrapper/HoistContainerReferencesPlugin.js.map +1 -1
  254. package/dist/src/wrapper/ModuleFederationPlugin.d.ts +12 -9
  255. package/dist/src/wrapper/ModuleFederationPlugin.js +71 -104
  256. package/dist/src/wrapper/ModuleFederationPlugin.js.map +1 -1
  257. package/dist/src/wrapper/ProvideSharedPlugin.d.ts +10 -7
  258. package/dist/src/wrapper/ProvideSharedPlugin.js +13 -17
  259. package/dist/src/wrapper/ProvideSharedPlugin.js.map +1 -1
  260. package/dist/src/wrapper/SharePlugin.d.ts +10 -7
  261. package/dist/src/wrapper/SharePlugin.js +13 -17
  262. package/dist/src/wrapper/SharePlugin.js.map +1 -1
  263. package/dist/src/wrapper/TreeShakingSharedPlugin.d.ts +10 -0
  264. package/dist/src/wrapper/TreeShakingSharedPlugin.js +15 -0
  265. package/dist/src/wrapper/TreeShakingSharedPlugin.js.map +1 -0
  266. package/package.json +27 -29
  267. package/dist/package.json +0 -110
  268. package/dist/src/declarations/plugins/container/AsyncDependenciesBlock.d.ts +0 -57
  269. package/dist/src/declarations/plugins/container/ModuleFactory.d.ts +0 -33
  270. package/dist/src/declarations/plugins/container/ObjectDeserializerContext.d.ts +0 -4
  271. package/dist/src/declarations/plugins/container/StaticExportsDependency.d.ts +0 -28
  272. package/dist/src/declarations/plugins/container/Template.d.ts +0 -198
  273. package/dist/src/declarations/plugins/container/WebpackError.d.ts +0 -33
  274. package/dist/src/declarations/plugins/sharing/ConsumeSharedModule.d.ts +0 -82
  275. package/dist/src/declarations/plugins/sharing/ConsumeSharedPlugin.d.ts +0 -96
  276. package/dist/src/declarations/plugins/sharing/ProvideSharedPlugin.d.ts +0 -98
  277. package/dist/src/declarations/plugins/sharing/SharePlugin.d.ts +0 -108
  278. package/dist/src/lib/container/runtime/ChildCompilationRuntimePlugin.d.ts +0 -20
  279. package/dist/src/lib/container/runtime/ChildCompilationRuntimePlugin.js +0 -219
  280. package/dist/src/lib/container/runtime/ChildCompilationRuntimePlugin.js.map +0 -1
  281. package/dist/src/prefetch.d.ts +0 -2
  282. package/dist/src/prefetch.js +0 -8
  283. package/dist/src/prefetch.js.map +0 -1
  284. package/dist/src/rspack.js.map +0 -1
  285. package/dist/src/runtime.js.map +0 -1
  286. package/dist/src/types/runtime.d.ts +0 -10
  287. package/dist/src/types/runtime.js +0 -3
  288. package/dist/src/types/runtime.js.map +0 -1
  289. package/dist/src/webpack.js.map +0 -1
@@ -1,216 +1,147 @@
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_options = require('./options.js');
4
+ const require_lib_container_ContainerEntryDependency = require('./ContainerEntryDependency.js');
5
+ const require_lib_container_ContainerExposedDependency = require('./ContainerExposedDependency.js');
6
+ const require_lib_container_ContainerEntryModuleFactory = require('./ContainerEntryModuleFactory.js');
7
+ const require_lib_container_runtime_FederationModulesPlugin = require('./runtime/FederationModulesPlugin.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
+ const ModuleDependency = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/dependencies/ModuleDependency"));
14
+ const EntryDependency = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/dependencies/EntryDependency"));
15
+ const PLUGIN_NAME = "ContainerPlugin";
16
+ var ContainerPlugin = class ContainerPlugin {
17
+ constructor(options) {
18
+ this.name = PLUGIN_NAME;
19
+ this._options = {
20
+ name: options.name,
21
+ shareScope: options.shareScope || "default",
22
+ library: options.library || {
23
+ type: "global",
24
+ name: options.name
25
+ },
26
+ runtime: options.runtime,
27
+ filename: options.filename || void 0,
28
+ exposes: require_lib_container_options.parseOptions(options.exposes, (item) => ({
29
+ import: Array.isArray(item) ? item : [item],
30
+ name: void 0
31
+ }), (item) => ({
32
+ import: Array.isArray(item.import) ? item.import : [item.import],
33
+ name: item.name || void 0
34
+ })),
35
+ runtimePlugins: options.runtimePlugins
36
+ };
37
+ }
38
+ static patchChunkSplit(compiler, name) {
39
+ const { splitChunks } = compiler.options.optimization;
40
+ const patchChunkSplit = (cacheGroup) => {
41
+ switch (typeof cacheGroup) {
42
+ case "boolean":
43
+ case "string":
44
+ case "function": break;
45
+ case "object":
46
+ if (cacheGroup instanceof RegExp) break;
47
+ if (!cacheGroup.chunks) break;
48
+ if (typeof cacheGroup.chunks === "function") {
49
+ const prevChunks = cacheGroup.chunks;
50
+ cacheGroup.chunks = (chunk) => {
51
+ if (chunk.name && (chunk.name === name || chunk.name === name + "_partial")) return false;
52
+ return prevChunks(chunk);
53
+ };
54
+ break;
55
+ }
56
+ if (cacheGroup.chunks === "all") {
57
+ cacheGroup.chunks = (chunk) => {
58
+ if (chunk.name && (chunk.name === name || chunk.name === name + "_partial")) return false;
59
+ return true;
60
+ };
61
+ break;
62
+ }
63
+ if (cacheGroup.chunks === "initial") {
64
+ cacheGroup.chunks = (chunk) => {
65
+ if (chunk.name && (chunk.name === name || chunk.name === name + "_partial")) return false;
66
+ return chunk.isOnlyInitial();
67
+ };
68
+ break;
69
+ }
70
+ break;
71
+ }
72
+ };
73
+ if (!splitChunks) return;
74
+ patchChunkSplit(splitChunks);
75
+ const cacheGroups = splitChunks.cacheGroups;
76
+ if (!cacheGroups) return;
77
+ Object.keys(cacheGroups).forEach((cacheGroupKey) => {
78
+ patchChunkSplit(cacheGroups[cacheGroupKey]);
79
+ });
80
+ }
81
+ apply(compiler) {
82
+ if (!compiler.options.plugins.find((p) => {
83
+ if (typeof p !== "object" || !p) return false;
84
+ return p["name"] === "ModuleFederationPlugin";
85
+ })) ContainerPlugin.patchChunkSplit(compiler, this._options.name);
86
+ const federationRuntimePluginInstance = new require_lib_container_runtime_FederationRuntimePlugin.default();
87
+ federationRuntimePluginInstance.apply(compiler);
88
+ const { name, exposes, shareScope, filename, library, runtime } = this._options;
89
+ if (library && compiler.options.output && compiler.options.output.enabledLibraryTypes && !compiler.options.output.enabledLibraryTypes.includes(library.type)) compiler.options.output.enabledLibraryTypes.push(library.type);
90
+ compiler.hooks.make.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
91
+ const hooks = require_lib_container_runtime_FederationModulesPlugin.default.getCompilationHooks(compilation);
92
+ const federationRuntimeDependency = federationRuntimePluginInstance.getDependency(compiler);
93
+ const dep = new require_lib_container_ContainerEntryDependency.default(name, exposes, shareScope, federationRuntimePluginInstance.entryFilePath);
94
+ dep.loc = { name };
95
+ await new Promise((resolve, reject) => {
96
+ compilation.addEntry(compilation.options.context || "", dep, {
97
+ name,
98
+ filename,
99
+ runtime,
100
+ library
101
+ }, (error) => {
102
+ if (error) return reject(error);
103
+ hooks.addContainerEntryDependency.call(dep);
104
+ resolve(void 0);
105
+ });
106
+ }).catch(callback);
107
+ await new Promise((resolve, reject) => {
108
+ compilation.addInclude(compiler.context, federationRuntimeDependency, { name: void 0 }, (err, module) => {
109
+ if (err) return reject(err);
110
+ hooks.addFederationRuntimeDependency.call(federationRuntimeDependency);
111
+ resolve(void 0);
112
+ });
113
+ }).catch(callback);
114
+ callback();
115
+ });
116
+ compiler.hooks.finishMake.tapAsync(PLUGIN_NAME, (compilation, callback) => {
117
+ if (compilation.compiler.parentCompilation && compilation.compiler.parentCompilation !== compilation) return callback();
118
+ const hooks = require_lib_container_runtime_FederationModulesPlugin.default.getCompilationHooks(compilation);
119
+ const createdRuntimes = /* @__PURE__ */ new Set();
120
+ for (const entry of compilation.entries.values()) {
121
+ const runtime = entry.options.runtime;
122
+ if (runtime) createdRuntimes.add(runtime);
123
+ }
124
+ if (createdRuntimes.size === 0 && !compilation.options?.optimization?.runtimeChunk) return callback();
125
+ const dep = new require_lib_container_ContainerEntryDependency.default(name, exposes, shareScope, federationRuntimePluginInstance.entryFilePath);
126
+ dep.loc = { name };
127
+ compilation.addInclude(compilation.options.context || "", dep, { name: void 0 }, (error) => {
128
+ if (error) return callback(error);
129
+ hooks.addContainerEntryDependency.call(dep);
130
+ callback();
131
+ });
132
+ });
133
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation, { normalModuleFactory }) => {
134
+ compilation.dependencyFactories.set(require_lib_container_ContainerEntryDependency.default, new require_lib_container_ContainerEntryModuleFactory.default());
135
+ compilation.dependencyFactories.set(require_lib_container_ContainerExposedDependency.default, normalModuleFactory);
136
+ if (!compilation.dependencyFactories.has(EntryDependency)) compilation.dependencyFactories.set(EntryDependency, normalModuleFactory);
137
+ });
138
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation, { normalModuleFactory }) => {
139
+ compilation.dependencyFactories.set(require_lib_container_runtime_FederationRuntimeDependency.default, normalModuleFactory);
140
+ compilation.dependencyTemplates.set(require_lib_container_runtime_FederationRuntimeDependency.default, new ModuleDependency.Template());
141
+ });
142
+ }
4
143
  };
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 ContainerPlugin_check_1 = __importDefault(require("../../schemas/container/ContainerPlugin.check"));
18
- const ContainerPlugin_1 = __importDefault(require("../../schemas/container/ContainerPlugin"));
19
- const FederationRuntimeDependency_1 = __importDefault(require("./runtime/FederationRuntimeDependency"));
20
- const ModuleDependency = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/dependencies/ModuleDependency'));
21
- const EntryDependency = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/dependencies/EntryDependency'));
22
- const createSchemaValidation = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/util/create-schema-validation'));
23
- const validate = createSchemaValidation(ContainerPlugin_check_1.default, () => ContainerPlugin_1.default, {
24
- name: 'Container Plugin',
25
- baseDataPath: 'options',
26
- });
27
- const PLUGIN_NAME = 'ContainerPlugin';
28
- class ContainerPlugin {
29
- constructor(options) {
30
- validate(options);
31
- this.name = PLUGIN_NAME;
32
- this._options = {
33
- name: options.name,
34
- shareScope: options.shareScope || 'default',
35
- library: options.library || {
36
- type: 'var',
37
- name: options.name,
38
- },
39
- runtime: options.runtime,
40
- filename: options.filename || undefined,
41
- //@ts-ignore
42
- exposes: (0, options_1.parseOptions)(options.exposes, (item) => ({
43
- import: Array.isArray(item) ? item : [item],
44
- name: undefined,
45
- }), (item) => ({
46
- import: Array.isArray(item.import) ? item.import : [item.import],
47
- name: item.name || undefined,
48
- })),
49
- runtimePlugins: options.runtimePlugins,
50
- dataPrefetch: options.dataPrefetch,
51
- };
52
- }
53
- // container should not be affected by splitChunks
54
- static patchChunkSplit(compiler, name) {
55
- const { splitChunks } = compiler.options.optimization;
56
- const patchChunkSplit = (cacheGroup) => {
57
- switch (typeof cacheGroup) {
58
- case 'boolean':
59
- case 'string':
60
- case 'function':
61
- break;
62
- // cacheGroup.chunks will inherit splitChunks.chunks, so you only need to modify the chunks that are set separately
63
- case 'object':
64
- {
65
- if (cacheGroup instanceof RegExp) {
66
- break;
67
- }
68
- if (!cacheGroup.chunks) {
69
- break;
70
- }
71
- if (typeof cacheGroup.chunks === 'function') {
72
- const prevChunks = cacheGroup.chunks;
73
- cacheGroup.chunks = (chunk) => {
74
- if (chunk.name &&
75
- (chunk.name === name || chunk.name === name + '_partial')) {
76
- return false;
77
- }
78
- return prevChunks(chunk);
79
- };
80
- break;
81
- }
82
- if (cacheGroup.chunks === 'all') {
83
- cacheGroup.chunks = (chunk) => {
84
- if (chunk.name &&
85
- (chunk.name === name || chunk.name === name + '_partial')) {
86
- return false;
87
- }
88
- return true;
89
- };
90
- break;
91
- }
92
- if (cacheGroup.chunks === 'initial') {
93
- cacheGroup.chunks = (chunk) => {
94
- if (chunk.name &&
95
- (chunk.name === name || chunk.name === name + '_partial')) {
96
- return false;
97
- }
98
- return chunk.isOnlyInitial();
99
- };
100
- break;
101
- }
102
- }
103
- break;
104
- }
105
- };
106
- if (!splitChunks) {
107
- return;
108
- }
109
- // patch splitChunk.chunks
110
- patchChunkSplit(splitChunks);
111
- const cacheGroups = splitChunks.cacheGroups;
112
- if (!cacheGroups) {
113
- return;
114
- }
115
- // patch splitChunk.cacheGroups[key].chunks
116
- Object.keys(cacheGroups).forEach((cacheGroupKey) => {
117
- patchChunkSplit(cacheGroups[cacheGroupKey]);
118
- });
119
- }
120
- apply(compiler) {
121
- const useModuleFederationPlugin = compiler.options.plugins.find((p) => {
122
- if (typeof p !== 'object' || !p) {
123
- return false;
124
- }
125
- return p['name'] === 'ModuleFederationPlugin';
126
- });
127
- if (!useModuleFederationPlugin) {
128
- ContainerPlugin.patchChunkSplit(compiler, this._options.name);
129
- }
130
- const federationRuntimePluginInstance = new FederationRuntimePlugin_1.default();
131
- federationRuntimePluginInstance.apply(compiler);
132
- const { name, exposes, shareScope, filename, library, runtime } = this._options;
133
- if (library &&
134
- compiler.options.output &&
135
- compiler.options.output.enabledLibraryTypes &&
136
- !compiler.options.output.enabledLibraryTypes.includes(library.type)) {
137
- compiler.options.output.enabledLibraryTypes.push(library.type);
138
- }
139
- compiler.hooks.make.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
140
- const hooks = FederationModulesPlugin_1.default.getCompilationHooks(compilation);
141
- const federationRuntimeDependency = federationRuntimePluginInstance.getDependency(compiler);
142
- const dep = new ContainerEntryDependency_1.default(name,
143
- //@ts-ignore
144
- exposes, shareScope, federationRuntimePluginInstance.entryFilePath, this._options.dataPrefetch);
145
- dep.loc = { name };
146
- await new Promise((resolve, reject) => {
147
- compilation.addEntry(compilation.options.context || '', dep, {
148
- name,
149
- filename,
150
- runtime,
151
- library,
152
- }, (error) => {
153
- if (error)
154
- return reject(error);
155
- hooks.addContainerEntryDependency.call(dep);
156
- resolve(undefined);
157
- });
158
- }).catch(callback);
159
- await new Promise((resolve, reject) => {
160
- compilation.addInclude(compiler.context, federationRuntimeDependency, { name: undefined }, (err, module) => {
161
- if (err) {
162
- return reject(err);
163
- }
164
- hooks.addFederationRuntimeDependency.call(federationRuntimeDependency);
165
- resolve(undefined);
166
- });
167
- }).catch(callback);
168
- callback();
169
- });
170
- // this will still be copied into child compiler, so it needs a check to avoid running hook on child
171
- // we have to use finishMake in order to check the entries created and see if there are multiple runtime chunks
172
- compiler.hooks.finishMake.tapAsync(PLUGIN_NAME, (compilation, callback) => {
173
- if (compilation.compiler.parentCompilation &&
174
- compilation.compiler.parentCompilation !== compilation) {
175
- return callback();
176
- }
177
- const hooks = FederationModulesPlugin_1.default.getCompilationHooks(compilation);
178
- const createdRuntimes = new Set();
179
- for (const entry of compilation.entries.values()) {
180
- const runtime = entry.options.runtime;
181
- if (runtime) {
182
- createdRuntimes.add(runtime);
183
- }
184
- }
185
- if (createdRuntimes.size === 0 &&
186
- !compilation.options?.optimization?.runtimeChunk) {
187
- return callback();
188
- }
189
- const dep = new ContainerEntryDependency_1.default(name,
190
- //@ts-ignore
191
- exposes, shareScope, federationRuntimePluginInstance.entryFilePath, this._options.dataPrefetch);
192
- dep.loc = { name };
193
- compilation.addInclude(compilation.options.context || '', dep, { name: undefined }, (error) => {
194
- if (error)
195
- return callback(error);
196
- hooks.addContainerEntryDependency.call(dep);
197
- callback();
198
- });
199
- });
200
- // add the container entry module
201
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation, { normalModuleFactory }) => {
202
- compilation.dependencyFactories.set(ContainerEntryDependency_1.default, new ContainerEntryModuleFactory_1.default());
203
- compilation.dependencyFactories.set(ContainerExposedDependency_1.default, normalModuleFactory);
204
- if (!compilation.dependencyFactories.has(EntryDependency)) {
205
- compilation.dependencyFactories.set(EntryDependency, normalModuleFactory);
206
- }
207
- });
208
- // add include of federation runtime
209
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation, { normalModuleFactory }) => {
210
- compilation.dependencyFactories.set(FederationRuntimeDependency_1.default, normalModuleFactory);
211
- compilation.dependencyTemplates.set(FederationRuntimeDependency_1.default, new ModuleDependency.Template());
212
- });
213
- }
214
- }
144
+
145
+ //#endregion
215
146
  exports.default = ContainerPlugin;
216
147
  //# 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;AACxE,0GAAyE;AACzE,8FAA6D;AAC7D,wGAAgF;AAIhF,MA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QAAQ,EAAE,CAAC;YACb,CAAC,CACF,CAAC;QACJ,CAAC,CACF,CAAC;QAEF,iCAAiC;QACjC,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,kCAAwB,EACxB,IAAI,qCAA2B,EAAE,CAClC,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 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 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 };\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 );\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 );\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":";;;;;;;;;;;;AAuBA,MAAM,mBAAmB,gFACF,4CAA4C,CAClE;AAED,MAAM,kBAAkB,gFACD,2CAA2C,CACjE;AAED,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;IACP,IACA,UAAU;IACT,QAAQ,MAAM,QAAQ,KAAK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ChD,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,cACjC;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 { 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,104 +1,75 @@
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_options = require('./options.js');
4
+ const require_lib_container_runtime_FederationModulesPlugin = require('./runtime/FederationModulesPlugin.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
+ const { ExternalsPlugin } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
16
+ const slashCode = "/".charCodeAt(0);
17
+ var ContainerReferencePlugin = class {
18
+ constructor(options) {
19
+ this._remoteType = options.remoteType;
20
+ this._remotes = require_lib_container_options.parseOptions(options.remotes, (item) => ({
21
+ external: Array.isArray(item) ? item : [item],
22
+ shareScope: options.shareScope || "default"
23
+ }), (item) => ({
24
+ external: Array.isArray(item.external) ? item.external : [item.external],
25
+ shareScope: item.shareScope || options.shareScope || "default"
26
+ }));
27
+ }
28
+ /**
29
+ * Apply the plugin
30
+ * @param {Compiler} compiler the compiler instance
31
+ * @returns {void}
32
+ */
33
+ apply(compiler) {
34
+ const { _remotes: remotes, _remoteType: remoteType } = this;
35
+ new require_lib_container_runtime_FederationRuntimePlugin.default().apply(compiler);
36
+ /** @type {Record<string, string>} */
37
+ const remoteExternals = {};
38
+ for (const [key, config] of remotes) {
39
+ let i = 0;
40
+ for (const external of config.external) {
41
+ if (typeof external === "string" && external.startsWith("internal ")) continue;
42
+ remoteExternals[`webpack/container/reference/${key}${i ? `/fallback-${i}` : ""}`] = external;
43
+ i++;
44
+ }
45
+ }
46
+ new (compiler.webpack.ExternalsPlugin || ExternalsPlugin)(remoteType, remoteExternals).apply(compiler);
47
+ compiler.hooks.compilation.tap("ContainerReferencePlugin", (compilation, { normalModuleFactory }) => {
48
+ compilation.dependencyFactories.set(require_lib_container_RemoteToExternalDependency.default, normalModuleFactory);
49
+ compilation.dependencyFactories.set(require_lib_container_FallbackItemDependency.default, normalModuleFactory);
50
+ compilation.dependencyFactories.set(require_lib_container_FallbackDependency.default, new require_lib_container_FallbackModuleFactory.default());
51
+ const hooks = require_lib_container_runtime_FederationModulesPlugin.default.getCompilationHooks(compilation);
52
+ normalModuleFactory.hooks.factorize.tap("ContainerReferencePlugin", (data) => {
53
+ if (!data.request.includes("!")) {
54
+ for (const [key, config] of remotes) if (data.request.startsWith(`${key}`) && (data.request.length === key.length || data.request.charCodeAt(key.length) === slashCode)) {
55
+ 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);
56
+ hooks.addRemoteDependency.call(remoteModule);
57
+ return remoteModule;
58
+ }
59
+ }
60
+ });
61
+ compilation.hooks.runtimeRequirementInTree.for(compiler.webpack.RuntimeGlobals.ensureChunkHandlers).tap("ContainerReferencePlugin", (chunk, set) => {
62
+ set.add(compiler.webpack.RuntimeGlobals.module);
63
+ set.add(compiler.webpack.RuntimeGlobals.moduleFactoriesAddOnly);
64
+ set.add(compiler.webpack.RuntimeGlobals.hasOwnProperty);
65
+ set.add(compiler.webpack.RuntimeGlobals.initializeSharing);
66
+ set.add(compiler.webpack.RuntimeGlobals.shareScopeMap);
67
+ compilation.addRuntimeModule(chunk, new require_lib_container_RemoteRuntimeModule.default());
68
+ });
69
+ });
70
+ }
4
71
  };
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 ContainerReferencePlugin_1 = __importDefault(require("../../schemas/container/ContainerReferencePlugin"));
18
- const ContainerReferencePlugin_check_1 = __importDefault(require("../../schemas/container/ContainerReferencePlugin.check"));
19
- const { ExternalsPlugin } = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack'));
20
- const createSchemaValidation = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/util/create-schema-validation'));
21
- const validate = createSchemaValidation(
22
- //eslint-disable-next-line
23
- ContainerReferencePlugin_check_1.default, () => ContainerReferencePlugin_1.default, {
24
- name: 'Container Reference Plugin',
25
- baseDataPath: 'options',
26
- });
27
- const slashCode = '/'.charCodeAt(0);
28
- class ContainerReferencePlugin {
29
- constructor(options) {
30
- validate(options);
31
- this._remoteType = options.remoteType;
32
- this._remotes = (0, options_1.parseOptions)(options.remotes, (item) => ({
33
- external: Array.isArray(item) ? item : [item],
34
- shareScope: options.shareScope || 'default',
35
- }), (item) => ({
36
- external: Array.isArray(item.external)
37
- ? item.external
38
- : [item.external],
39
- shareScope: item.shareScope || options.shareScope || 'default',
40
- }));
41
- }
42
- /**
43
- * Apply the plugin
44
- * @param {Compiler} compiler the compiler instance
45
- * @returns {void}
46
- */
47
- apply(compiler) {
48
- const { _remotes: remotes, _remoteType: remoteType } = this;
49
- new FederationRuntimePlugin_1.default().apply(compiler);
50
- /** @type {Record<string, string>} */
51
- const remoteExternals = {};
52
- for (const [key, config] of remotes) {
53
- let i = 0;
54
- for (const external of config.external) {
55
- if (typeof external === 'string' && external.startsWith('internal ')) {
56
- continue;
57
- }
58
- remoteExternals[`webpack/container/reference/${key}${i ? `/fallback-${i}` : ''}`] = external;
59
- i++;
60
- }
61
- }
62
- const Externals = compiler.webpack.ExternalsPlugin || ExternalsPlugin;
63
- new Externals(remoteType, remoteExternals).apply(compiler);
64
- compiler.hooks.compilation.tap('ContainerReferencePlugin', (compilation, { normalModuleFactory }) => {
65
- compilation.dependencyFactories.set(RemoteToExternalDependency_1.default, normalModuleFactory);
66
- compilation.dependencyFactories.set(FallbackItemDependency_1.default, normalModuleFactory);
67
- compilation.dependencyFactories.set(FallbackDependency_1.default, new FallbackModuleFactory_1.default());
68
- const hooks = FederationModulesPlugin_1.default.getCompilationHooks(compilation);
69
- normalModuleFactory.hooks.factorize.tap('ContainerReferencePlugin',
70
- //@ts-ignore
71
- (data) => {
72
- if (!data.request.includes('!')) {
73
- for (const [key, config] of remotes) {
74
- if (data.request.startsWith(`${key}`) &&
75
- (data.request.length === key.length ||
76
- data.request.charCodeAt(key.length) === slashCode)) {
77
- const remoteModule = new RemoteModule_1.default(data.request,
78
- //@ts-ignore
79
- config.external.map((external, i) => external.startsWith('internal ')
80
- ? external.slice(9)
81
- : `webpack/container/reference/${key}${i ? `/fallback-${i}` : ''}`), `.${data.request.slice(key.length)}`,
82
- //@ts-ignore
83
- config.shareScope);
84
- hooks.addRemoteDependency.call(remoteModule);
85
- return remoteModule;
86
- }
87
- }
88
- }
89
- });
90
- compilation.hooks.runtimeRequirementInTree
91
- .for(compiler.webpack.RuntimeGlobals.ensureChunkHandlers)
92
- .tap('ContainerReferencePlugin', (chunk, set) => {
93
- set.add(compiler.webpack.RuntimeGlobals.module);
94
- set.add(compiler.webpack.RuntimeGlobals.moduleFactoriesAddOnly);
95
- set.add(compiler.webpack.RuntimeGlobals.hasOwnProperty);
96
- set.add(compiler.webpack.RuntimeGlobals.initializeSharing);
97
- set.add(compiler.webpack.RuntimeGlobals.shareScopeMap);
98
- compilation.addRuntimeModule(chunk, new RemoteRuntimeModule_1.default());
99
- });
100
- });
101
- }
102
- }
72
+
73
+ //#endregion
103
74
  exports.default = ContainerReferencePlugin;
104
75
  //# sourceMappingURL=ContainerReferencePlugin.js.map