@module-federation/enhanced 0.0.0-canary-1701764602388

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 (235) hide show
  1. package/global.d.js +14 -0
  2. package/global.d.js.map +1 -0
  3. package/package.json +19 -0
  4. package/src/declarations/plugins/container/AsyncDependenciesBlock.d.js +14 -0
  5. package/src/declarations/plugins/container/AsyncDependenciesBlock.d.js.map +1 -0
  6. package/src/declarations/plugins/container/ContainerPlugin.d.js +12 -0
  7. package/src/declarations/plugins/container/ContainerPlugin.d.js.map +1 -0
  8. package/src/declarations/plugins/container/ContainerReferencePlugin.d.js +12 -0
  9. package/src/declarations/plugins/container/ContainerReferencePlugin.d.js.map +1 -0
  10. package/src/declarations/plugins/container/Dependency.d.js +14 -0
  11. package/src/declarations/plugins/container/Dependency.d.js.map +1 -0
  12. package/src/declarations/plugins/container/Module.d.js +3 -0
  13. package/src/declarations/plugins/container/Module.d.js.map +1 -0
  14. package/src/declarations/plugins/container/ModuleFactory.d.js +3 -0
  15. package/src/declarations/plugins/container/ModuleFactory.d.js.map +1 -0
  16. package/src/declarations/plugins/container/ModuleFederationPlugin.d.js +12 -0
  17. package/src/declarations/plugins/container/ModuleFederationPlugin.d.js.map +1 -0
  18. package/src/declarations/plugins/container/ObjectDeserializerContext.d.js +6 -0
  19. package/src/declarations/plugins/container/ObjectDeserializerContext.d.js.map +1 -0
  20. package/src/declarations/plugins/container/StaticExportsDependency.d.js +14 -0
  21. package/src/declarations/plugins/container/StaticExportsDependency.d.js.map +1 -0
  22. package/src/declarations/plugins/container/Template.d.js +4 -0
  23. package/src/declarations/plugins/container/Template.d.js.map +1 -0
  24. package/src/declarations/plugins/container/WebpackError.d.js +3 -0
  25. package/src/declarations/plugins/container/WebpackError.d.js.map +1 -0
  26. package/src/declarations/plugins/container/WebpackOptions.d.js +6 -0
  27. package/src/declarations/plugins/container/WebpackOptions.d.js.map +1 -0
  28. package/src/declarations/plugins/sharing/ConsumeSharedPlugin.d.js +12 -0
  29. package/src/declarations/plugins/sharing/ConsumeSharedPlugin.d.js.map +1 -0
  30. package/src/declarations/plugins/sharing/ProvideSharedPlugin.d.js +12 -0
  31. package/src/declarations/plugins/sharing/ProvideSharedPlugin.d.js.map +1 -0
  32. package/src/declarations/plugins/sharing/SharePlugin.d.js +12 -0
  33. package/src/declarations/plugins/sharing/SharePlugin.d.js.map +1 -0
  34. package/src/index.d.ts +7 -0
  35. package/src/index.js +43 -0
  36. package/src/index.js.map +1 -0
  37. package/src/lib/Constants.d.ts +117 -0
  38. package/src/lib/Constants.js +103 -0
  39. package/src/lib/Constants.js.map +1 -0
  40. package/src/lib/RuntimeGlobals.d.ts +0 -0
  41. package/src/lib/RuntimeGlobals.js +246 -0
  42. package/src/lib/RuntimeGlobals.js.map +1 -0
  43. package/src/lib/container/AsyncBoundaryPlugin.d.ts +21 -0
  44. package/src/lib/container/AsyncBoundaryPlugin.js +180 -0
  45. package/src/lib/container/AsyncBoundaryPlugin.js.map +1 -0
  46. package/src/lib/container/ContainerEntryDependency.d.js +4 -0
  47. package/src/lib/container/ContainerEntryDependency.d.js.map +1 -0
  48. package/src/lib/container/ContainerEntryDependency.d.ts +22 -0
  49. package/src/lib/container/ContainerEntryDependency.js +45 -0
  50. package/src/lib/container/ContainerEntryDependency.js.map +1 -0
  51. package/src/lib/container/ContainerEntryModule.d.js +14 -0
  52. package/src/lib/container/ContainerEntryModule.d.js.map +1 -0
  53. package/src/lib/container/ContainerEntryModule.d.ts +86 -0
  54. package/src/lib/container/ContainerEntryModule.js +260 -0
  55. package/src/lib/container/ContainerEntryModule.js.map +1 -0
  56. package/src/lib/container/ContainerEntryModuleFactory.d.js +4 -0
  57. package/src/lib/container/ContainerEntryModuleFactory.d.js.map +1 -0
  58. package/src/lib/container/ContainerEntryModuleFactory.d.ts +10 -0
  59. package/src/lib/container/ContainerEntryModuleFactory.js +32 -0
  60. package/src/lib/container/ContainerEntryModuleFactory.js.map +1 -0
  61. package/src/lib/container/ContainerExposedDependency.d.js +4 -0
  62. package/src/lib/container/ContainerExposedDependency.d.js.map +1 -0
  63. package/src/lib/container/ContainerExposedDependency.d.ts +26 -0
  64. package/src/lib/container/ContainerExposedDependency.js +53 -0
  65. package/src/lib/container/ContainerExposedDependency.js.map +1 -0
  66. package/src/lib/container/ContainerPlugin.d.js +4 -0
  67. package/src/lib/container/ContainerPlugin.d.js.map +1 -0
  68. package/src/lib/container/ContainerPlugin.d.ts +13 -0
  69. package/src/lib/container/ContainerPlugin.js +167 -0
  70. package/src/lib/container/ContainerPlugin.js.map +1 -0
  71. package/src/lib/container/ContainerReferencePlugin.d.js +4 -0
  72. package/src/lib/container/ContainerReferencePlugin.d.js.map +1 -0
  73. package/src/lib/container/ContainerReferencePlugin.d.ts +14 -0
  74. package/src/lib/container/ContainerReferencePlugin.js +102 -0
  75. package/src/lib/container/ContainerReferencePlugin.js.map +1 -0
  76. package/src/lib/container/FallbackDependency.d.js +14 -0
  77. package/src/lib/container/FallbackDependency.d.js.map +1 -0
  78. package/src/lib/container/FallbackDependency.d.ts +25 -0
  79. package/src/lib/container/FallbackDependency.js +55 -0
  80. package/src/lib/container/FallbackDependency.js.map +1 -0
  81. package/src/lib/container/FallbackItemDependency.d.js +4 -0
  82. package/src/lib/container/FallbackItemDependency.d.js.map +1 -0
  83. package/src/lib/container/FallbackItemDependency.d.ts +10 -0
  84. package/src/lib/container/FallbackItemDependency.js +33 -0
  85. package/src/lib/container/FallbackItemDependency.js.map +1 -0
  86. package/src/lib/container/FallbackModule.d.js +4 -0
  87. package/src/lib/container/FallbackModule.d.js.map +1 -0
  88. package/src/lib/container/FallbackModule.d.ts +73 -0
  89. package/src/lib/container/FallbackModule.js +149 -0
  90. package/src/lib/container/FallbackModule.js.map +1 -0
  91. package/src/lib/container/FallbackModuleFactory.d.js +4 -0
  92. package/src/lib/container/FallbackModuleFactory.d.js.map +1 -0
  93. package/src/lib/container/FallbackModuleFactory.d.ts +10 -0
  94. package/src/lib/container/FallbackModuleFactory.js +30 -0
  95. package/src/lib/container/FallbackModuleFactory.js.map +1 -0
  96. package/src/lib/container/HoistContainerReferencesPlugin.d.ts +19 -0
  97. package/src/lib/container/HoistContainerReferencesPlugin.js +78 -0
  98. package/src/lib/container/HoistContainerReferencesPlugin.js.map +1 -0
  99. package/src/lib/container/ModuleFederationPlugin.d.js +4 -0
  100. package/src/lib/container/ModuleFederationPlugin.d.js.map +1 -0
  101. package/src/lib/container/ModuleFederationPlugin.d.ts +17 -0
  102. package/src/lib/container/ModuleFederationPlugin.js +93 -0
  103. package/src/lib/container/ModuleFederationPlugin.js.map +1 -0
  104. package/src/lib/container/ModuleFederationPluginTypes.d.js +12 -0
  105. package/src/lib/container/ModuleFederationPluginTypes.d.js.map +1 -0
  106. package/src/lib/container/RemoteModule.d.js +13 -0
  107. package/src/lib/container/RemoteModule.d.js.map +1 -0
  108. package/src/lib/container/RemoteModule.d.ts +78 -0
  109. package/src/lib/container/RemoteModule.js +150 -0
  110. package/src/lib/container/RemoteModule.js.map +1 -0
  111. package/src/lib/container/RemoteRuntimeModule.d.js +13 -0
  112. package/src/lib/container/RemoteRuntimeModule.d.js.map +1 -0
  113. package/src/lib/container/RemoteRuntimeModule.d.ts +9 -0
  114. package/src/lib/container/RemoteRuntimeModule.js +98 -0
  115. package/src/lib/container/RemoteRuntimeModule.js.map +1 -0
  116. package/src/lib/container/RemoteToExternalDependency.d.js +15 -0
  117. package/src/lib/container/RemoteToExternalDependency.d.js.map +1 -0
  118. package/src/lib/container/RemoteToExternalDependency.d.ts +10 -0
  119. package/src/lib/container/RemoteToExternalDependency.js +33 -0
  120. package/src/lib/container/RemoteToExternalDependency.js.map +1 -0
  121. package/src/lib/container/constant.d.ts +3 -0
  122. package/src/lib/container/constant.js +26 -0
  123. package/src/lib/container/constant.js.map +1 -0
  124. package/src/lib/container/options.d.js +6 -0
  125. package/src/lib/container/options.d.js.map +1 -0
  126. package/src/lib/container/options.d.ts +18 -0
  127. package/src/lib/container/options.js +91 -0
  128. package/src/lib/container/options.js.map +1 -0
  129. package/src/lib/container/runtime/FederationRuntimeEntryDependency.d.ts +7 -0
  130. package/src/lib/container/runtime/FederationRuntimeEntryDependency.js +37 -0
  131. package/src/lib/container/runtime/FederationRuntimeEntryDependency.js.map +1 -0
  132. package/src/lib/container/runtime/FederationRuntimeModule.d.ts +13 -0
  133. package/src/lib/container/runtime/FederationRuntimeModule.js +31 -0
  134. package/src/lib/container/runtime/FederationRuntimeModule.js.map +1 -0
  135. package/src/lib/container/runtime/FederationRuntimePlugin.d.ts +17 -0
  136. package/src/lib/container/runtime/FederationRuntimePlugin.js +223 -0
  137. package/src/lib/container/runtime/FederationRuntimePlugin.js.map +1 -0
  138. package/src/lib/container/runtime/InitializeRemoteEntryRuntimePlugin.d.ts +6 -0
  139. package/src/lib/container/runtime/InitializeRemoteEntryRuntimePlugin.js +26 -0
  140. package/src/lib/container/runtime/InitializeRemoteEntryRuntimePlugin.js.map +1 -0
  141. package/src/lib/container/runtime/getFederationGlobal.d.ts +5 -0
  142. package/src/lib/container/runtime/getFederationGlobal.js +42 -0
  143. package/src/lib/container/runtime/getFederationGlobal.js.map +1 -0
  144. package/src/lib/container/runtime/utils.d.ts +15 -0
  145. package/src/lib/container/runtime/utils.js +95 -0
  146. package/src/lib/container/runtime/utils.js.map +1 -0
  147. package/src/lib/sharing/ConsumeSharedFallbackDependency.d.js +4 -0
  148. package/src/lib/sharing/ConsumeSharedFallbackDependency.d.js.map +1 -0
  149. package/src/lib/sharing/ConsumeSharedFallbackDependency.d.ts +10 -0
  150. package/src/lib/sharing/ConsumeSharedFallbackDependency.js +33 -0
  151. package/src/lib/sharing/ConsumeSharedFallbackDependency.js.map +1 -0
  152. package/src/lib/sharing/ConsumeSharedModule.d.js +4 -0
  153. package/src/lib/sharing/ConsumeSharedModule.d.js.map +1 -0
  154. package/src/lib/sharing/ConsumeSharedModule.d.ts +106 -0
  155. package/src/lib/sharing/ConsumeSharedModule.js +195 -0
  156. package/src/lib/sharing/ConsumeSharedModule.js.map +1 -0
  157. package/src/lib/sharing/ConsumeSharedPlugin.d.js +4 -0
  158. package/src/lib/sharing/ConsumeSharedPlugin.d.js.map +1 -0
  159. package/src/lib/sharing/ConsumeSharedPlugin.d.ts +8 -0
  160. package/src/lib/sharing/ConsumeSharedPlugin.js +225 -0
  161. package/src/lib/sharing/ConsumeSharedPlugin.js.map +1 -0
  162. package/src/lib/sharing/ConsumeSharedRuntimeModule.d.js +4 -0
  163. package/src/lib/sharing/ConsumeSharedRuntimeModule.d.js.map +1 -0
  164. package/src/lib/sharing/ConsumeSharedRuntimeModule.d.ts +13 -0
  165. package/src/lib/sharing/ConsumeSharedRuntimeModule.js +310 -0
  166. package/src/lib/sharing/ConsumeSharedRuntimeModule.js.map +1 -0
  167. package/src/lib/sharing/ProvideForSharedDependency.d.js +4 -0
  168. package/src/lib/sharing/ProvideForSharedDependency.d.js.map +1 -0
  169. package/src/lib/sharing/ProvideForSharedDependency.d.ts +11 -0
  170. package/src/lib/sharing/ProvideForSharedDependency.js +34 -0
  171. package/src/lib/sharing/ProvideForSharedDependency.js.map +1 -0
  172. package/src/lib/sharing/ProvideSharedDependency.d.js +14 -0
  173. package/src/lib/sharing/ProvideSharedDependency.d.js.map +1 -0
  174. package/src/lib/sharing/ProvideSharedDependency.d.ts +32 -0
  175. package/src/lib/sharing/ProvideSharedDependency.js +65 -0
  176. package/src/lib/sharing/ProvideSharedDependency.js.map +1 -0
  177. package/src/lib/sharing/ProvideSharedModule.d.js +4 -0
  178. package/src/lib/sharing/ProvideSharedModule.d.js.map +1 -0
  179. package/src/lib/sharing/ProvideSharedModule.d.ts +79 -0
  180. package/src/lib/sharing/ProvideSharedModule.js +169 -0
  181. package/src/lib/sharing/ProvideSharedModule.js.map +1 -0
  182. package/src/lib/sharing/ProvideSharedModuleFactory.d.js +4 -0
  183. package/src/lib/sharing/ProvideSharedModuleFactory.d.js.map +1 -0
  184. package/src/lib/sharing/ProvideSharedModuleFactory.d.ts +11 -0
  185. package/src/lib/sharing/ProvideSharedModuleFactory.js +32 -0
  186. package/src/lib/sharing/ProvideSharedModuleFactory.js.map +1 -0
  187. package/src/lib/sharing/ProvideSharedPlugin.d.js +4 -0
  188. package/src/lib/sharing/ProvideSharedPlugin.d.js.map +1 -0
  189. package/src/lib/sharing/ProvideSharedPlugin.d.ts +34 -0
  190. package/src/lib/sharing/ProvideSharedPlugin.js +168 -0
  191. package/src/lib/sharing/ProvideSharedPlugin.js.map +1 -0
  192. package/src/lib/sharing/SharePlugin.d.js +4 -0
  193. package/src/lib/sharing/SharePlugin.d.js.map +1 -0
  194. package/src/lib/sharing/SharePlugin.d.ts +15 -0
  195. package/src/lib/sharing/SharePlugin.js +73 -0
  196. package/src/lib/sharing/SharePlugin.js.map +1 -0
  197. package/src/lib/sharing/ShareRuntimeModule.d.js +4 -0
  198. package/src/lib/sharing/ShareRuntimeModule.d.js.map +1 -0
  199. package/src/lib/sharing/ShareRuntimeModule.d.ts +9 -0
  200. package/src/lib/sharing/ShareRuntimeModule.js +95 -0
  201. package/src/lib/sharing/ShareRuntimeModule.js.map +1 -0
  202. package/src/lib/sharing/resolveMatchedConfigs.d.js +6 -0
  203. package/src/lib/sharing/resolveMatchedConfigs.d.js.map +1 -0
  204. package/src/lib/sharing/resolveMatchedConfigs.d.ts +8 -0
  205. package/src/lib/sharing/resolveMatchedConfigs.js +69 -0
  206. package/src/lib/sharing/resolveMatchedConfigs.js.map +1 -0
  207. package/src/lib/sharing/utils.d.js +6 -0
  208. package/src/lib/sharing/utils.d.js.map +1 -0
  209. package/src/lib/sharing/utils.d.ts +45 -0
  210. package/src/lib/sharing/utils.js +348 -0
  211. package/src/lib/sharing/utils.js.map +1 -0
  212. package/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +5 -0
  213. package/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js +34 -0
  214. package/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -0
  215. package/src/runtime/ModuleInfoRuntimeModule.d.ts +16 -0
  216. package/src/runtime/ModuleInfoRuntimeModule.js +88 -0
  217. package/src/runtime/ModuleInfoRuntimeModule.js.map +1 -0
  218. package/src/runtime/ModuleInfoRuntimePlugin.d.ts +5 -0
  219. package/src/runtime/ModuleInfoRuntimePlugin.js +29 -0
  220. package/src/runtime/ModuleInfoRuntimePlugin.js.map +1 -0
  221. package/src/schemas/container/ContainerPlugin.check.d.ts +7 -0
  222. package/src/schemas/container/ContainerPlugin.check.js +2229 -0
  223. package/src/schemas/container/ContainerPlugin.check.js.map +1 -0
  224. package/src/schemas/container/ContainerPlugin.d.ts +268 -0
  225. package/src/schemas/container/ContainerPlugin.js +324 -0
  226. package/src/schemas/container/ContainerPlugin.js.map +1 -0
  227. package/src/schemas/container/ModuleFederationPlugin.check.d.ts +7 -0
  228. package/src/schemas/container/ModuleFederationPlugin.check.js +3818 -0
  229. package/src/schemas/container/ModuleFederationPlugin.check.js.map +1 -0
  230. package/src/schemas/container/ModuleFederationPlugin.d.ts +441 -0
  231. package/src/schemas/container/ModuleFederationPlugin.js +556 -0
  232. package/src/schemas/container/ModuleFederationPlugin.js.map +1 -0
  233. package/src/types/runtime.d.ts +7 -0
  234. package/src/types/runtime.js +6 -0
  235. package/src/types/runtime.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/options.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\nexport type ContainerOptionsFormat<T> =\n | (string | Record<string, string | string[] | T>)[]\n | Record<string, string | string[] | T>;\n\n/** @template T @typedef {(string | Record<string, string | string[] | T>)[] | Record<string, string | string[] | T>} ContainerOptionsFormat */\n\n/**\n * @template T\n * @template N\n * @param {ContainerOptionsFormat<T>} options options passed by the user\n * @param {function(string | string[], string) : N} normalizeSimple normalize a simple item\n * @param {function(T, string) : N} normalizeOptions normalize a complex item\n * @param {function(string, N): void} fn processing function\n * @returns {void}\n */\nconst process = <T, N>(\n options: ContainerOptionsFormat<T>,\n normalizeSimple: (item: string | string[], name: string) => N,\n normalizeOptions: (item: T, name: string) => N,\n fn: (name: string, item: N) => void,\n): void => {\n const array = (\n items: (string | Record<string, string | string[] | T>)[],\n ): void => {\n for (const item of items) {\n if (typeof item === 'string') {\n fn(item, normalizeSimple(item, item));\n } else if (item && typeof item === 'object') {\n object(item as Record<string, string | string[] | T>);\n } else {\n throw new Error('Unexpected options format');\n }\n }\n };\n const object = (obj: Record<string, string | string[] | T>): void => {\n for (const [key, value] of Object.entries(obj)) {\n if (typeof value === 'string' || Array.isArray(value)) {\n fn(key, normalizeSimple(value, key));\n } else {\n fn(key, normalizeOptions(value as T, key));\n }\n }\n };\n if (!options) {\n return;\n } else if (Array.isArray(options)) {\n array(options);\n } else if (typeof options === 'object') {\n object(options);\n } else {\n throw new Error('Unexpected options format');\n }\n};\n\n/**\n * @template T\n * @template R\n * @param {ContainerOptionsFormat<T>} options options passed by the user\n * @param {function(string | string[], string) : R} normalizeSimple normalize a simple item\n * @param {function(T, string) : R} normalizeOptions normalize a complex item\n * @returns {[string, R][]} parsed options\n */\nconst parseOptions = <T, R>(\n options: ContainerOptionsFormat<T>,\n normalizeSimple: (item: string | string[], name: string) => R,\n normalizeOptions: (item: T, name: string) => R,\n): [string, R][] => {\n const items: [string, R][] = [];\n process(options, normalizeSimple, normalizeOptions, (key, value) => {\n items.push([key, value]);\n });\n return items;\n};\n\n/**\n * @template T\n * @param {string} scope scope name\n * @param {ContainerOptionsFormat<T>} options options passed by the user\n * @returns {Record<string, string | string[] | T>} options to spread or pass\n */\nconst scope = <T>(\n scope: string,\n options: ContainerOptionsFormat<T>,\n): Record<string, string | string[] | T> => {\n const obj: Record<string, string | string[] | T> = {};\n process(\n options,\n (item) => item as string | string[] | T,\n (item) => item as string | string[] | T,\n (key, value) => {\n obj[\n key.startsWith('./') ? `${scope}${key.slice(1)}` : `${scope}/${key}`\n ] = value;\n },\n );\n return obj;\n};\n\nexport { parseOptions, scope };\n"],"names":["parseOptions","scope","process","options","normalizeSimple","normalizeOptions","fn","array","items","item","object","Error","obj","key","value","Object","entries","Array","isArray","push","startsWith","slice"],"mappings":"AAAA;;;AAGA;;;;;;;;;;;IAmGSA,YAAY;eAAZA;;IAAcC,KAAK;eAALA;;;AA9FvB,6IAA6I,GAE7I;;;;;;;;CAQC,GACD,MAAMC,UAAU,CACdC,SACAC,iBACAC,kBACAC;IAEA,MAAMC,QAAQ,CACZC;QAEA,KAAK,MAAMC,QAAQD,MAAO;YACxB,IAAI,OAAOC,SAAS,UAAU;gBAC5BH,GAAGG,MAAML,gBAAgBK,MAAMA;YACjC,OAAO,IAAIA,QAAQ,OAAOA,SAAS,UAAU;gBAC3CC,OAAOD;YACT,OAAO;gBACL,MAAM,IAAIE,MAAM;YAClB;QACF;IACF;IACA,MAAMD,SAAS,CAACE;QACd,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACJ,KAAM;YAC9C,IAAI,OAAOE,UAAU,YAAYG,MAAMC,OAAO,CAACJ,QAAQ;gBACrDR,GAAGO,KAAKT,gBAAgBU,OAAOD;YACjC,OAAO;gBACLP,GAAGO,KAAKR,iBAAiBS,OAAYD;YACvC;QACF;IACF;IACA,IAAI,CAACV,SAAS;QACZ;IACF,OAAO,IAAIc,MAAMC,OAAO,CAACf,UAAU;QACjCI,MAAMJ;IACR,OAAO,IAAI,OAAOA,YAAY,UAAU;QACtCO,OAAOP;IACT,OAAO;QACL,MAAM,IAAIQ,MAAM;IAClB;AACF;AAEA;;;;;;;CAOC,GACD,MAAMX,eAAe,CACnBG,SACAC,iBACAC;IAEA,MAAMG,QAAuB,EAAE;IAC/BN,QAAQC,SAASC,iBAAiBC,kBAAkB,CAACQ,KAAKC;QACxDN,MAAMW,IAAI,CAAC;YAACN;YAAKC;SAAM;IACzB;IACA,OAAON;AACT;AAEA;;;;;CAKC,GACD,MAAMP,QAAQ,CACZA,OACAE;IAEA,MAAMS,MAA6C,CAAC;IACpDV,QACEC,SACA,CAACM,OAASA,MACV,CAACA,OAASA,MACV,CAACI,KAAKC;QACJF,GAAG,CACDC,IAAIO,UAAU,CAAC,QAAQ,CAAC,EAAEnB,MAAM,EAAEY,IAAIQ,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAEpB,MAAM,CAAC,EAAEY,IAAI,CAAC,CACrE,GAAGC;IACN;IAEF,OAAOF;AACT"}
@@ -0,0 +1,7 @@
1
+ import EntryDependency from 'webpack/lib/dependencies/EntryDependency';
2
+ declare class FederationRuntimeEntryDependency extends EntryDependency {
3
+ constructor();
4
+ get type(): string;
5
+ get category(): string;
6
+ }
7
+ export default FederationRuntimeEntryDependency;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
+ const _EntryDependency = /*#__PURE__*/ _interop_require_default._(require("webpack/lib/dependencies/EntryDependency"));
13
+ const _makeSerializable = /*#__PURE__*/ _interop_require_default._(require("webpack/lib/util/makeSerializable"));
14
+ let FederationRuntimeEntryDependency = class FederationRuntimeEntryDependency extends _EntryDependency.default {
15
+ get type() {
16
+ return 'entry';
17
+ }
18
+ get category() {
19
+ return 'esm';
20
+ }
21
+ // eslint-disable-next-line no-useless-constructor
22
+ constructor(){
23
+ const code = `import * as runtime from '@vmok/runtime';
24
+ __webpack_require__.vmok.runtime = runtime;
25
+ __webpack_require__.vmok.instance = __webpack_require__.vmok.runtime.init(
26
+ __webpack_require__.vmok.initOptions,
27
+ );`;
28
+ const mimeType = 'text/javascript';
29
+ const encodedCode = encodeURIComponent(code);
30
+ const request = `data:${mimeType},${encodedCode}`;
31
+ super(request);
32
+ }
33
+ };
34
+ (0, _makeSerializable.default)(FederationRuntimeEntryDependency, 'enhanced/lib/container/runtime/FederationRuntimeEntryDependency');
35
+ const _default = FederationRuntimeEntryDependency;
36
+
37
+ //# sourceMappingURL=FederationRuntimeEntryDependency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../packages/enhanced/src/lib/container/runtime/FederationRuntimeEntryDependency.ts"],"sourcesContent":["import EntryDependency from 'webpack/lib/dependencies/EntryDependency';\nimport makeSerializable from 'webpack/lib/util/makeSerializable';\n\nclass FederationRuntimeEntryDependency extends EntryDependency {\n // eslint-disable-next-line no-useless-constructor\n constructor() {\n const code = `import * as runtime from '@vmok/runtime';\n\t\t__webpack_require__.vmok.runtime = runtime;\n\t\t__webpack_require__.vmok.instance = __webpack_require__.vmok.runtime.init(\n\t\t\t__webpack_require__.vmok.initOptions,\n\t\t);`;\n const mimeType = 'text/javascript';\n const encodedCode = encodeURIComponent(code);\n const request = `data:${mimeType},${encodedCode}`;\n super(request);\n }\n\n override get type() {\n return 'entry';\n }\n\n override get category() {\n return 'esm';\n }\n}\n\nmakeSerializable(\n FederationRuntimeEntryDependency,\n 'enhanced/lib/container/runtime/FederationRuntimeEntryDependency',\n);\n\nexport default FederationRuntimeEntryDependency;\n"],"names":["FederationRuntimeEntryDependency","EntryDependency","type","category","constructor","code","mimeType","encodedCode","encodeURIComponent","request","makeSerializable"],"mappings":";;;;+BA+BA;;;eAAA;;;;0EA/B4B;2EACC;AAE7B,IAAA,AAAMA,mCAAN,MAAMA,yCAAyCC,wBAAe;IAc5D,IAAaC,OAAO;QAClB,OAAO;IACT;IAEA,IAAaC,WAAW;QACtB,OAAO;IACT;IAnBA,kDAAkD;IAClDC,aAAc;QACZ,MAAMC,OAAO,CAAC;;;;IAId,CAAC;QACD,MAAMC,WAAW;QACjB,MAAMC,cAAcC,mBAAmBH;QACvC,MAAMI,UAAU,CAAC,KAAK,EAAEH,SAAS,CAAC,EAAEC,YAAY,CAAC;QACjD,KAAK,CAACE;IACR;AASF;AAEAC,IAAAA,yBAAgB,EACdV,kCACA;MAGF,WAAeA"}
@@ -0,0 +1,13 @@
1
+ import { RuntimeModule } from 'webpack';
2
+ import { NormalizedRuntimeInitOptionsWithOutShared } from '../../../types/runtime';
3
+ declare class FederationRuntimeModule extends RuntimeModule {
4
+ runtimeRequirements: Set<string>;
5
+ containerName: string;
6
+ initOptionsWithoutShared: NormalizedRuntimeInitOptionsWithOutShared;
7
+ constructor(runtimeRequirements: Set<string>, containerName: string, initOptionsWithoutShared: NormalizedRuntimeInitOptionsWithOutShared);
8
+ /**
9
+ * @returns {string | null} runtime code
10
+ */
11
+ generate(): string;
12
+ }
13
+ export default FederationRuntimeModule;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
+ const _webpack = require("webpack");
13
+ const _getFederationGlobal = /*#__PURE__*/ _interop_require_default._(require("./getFederationGlobal"));
14
+ let FederationRuntimeModule = class FederationRuntimeModule extends _webpack.RuntimeModule {
15
+ /**
16
+ * @returns {string | null} runtime code
17
+ */ generate() {
18
+ return _webpack.Template.asString([
19
+ (0, _getFederationGlobal.default)(_webpack.Template, _webpack.RuntimeGlobals, this.initOptionsWithoutShared)
20
+ ]);
21
+ }
22
+ constructor(runtimeRequirements, containerName, initOptionsWithoutShared){
23
+ super('federation runtime', _webpack.RuntimeModule.STAGE_NORMAL - 1);
24
+ this.runtimeRequirements = runtimeRequirements;
25
+ this.containerName = containerName;
26
+ this.initOptionsWithoutShared = initOptionsWithoutShared;
27
+ }
28
+ };
29
+ const _default = FederationRuntimeModule;
30
+
31
+ //# sourceMappingURL=FederationRuntimeModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../packages/enhanced/src/lib/container/runtime/FederationRuntimeModule.ts"],"sourcesContent":["import { RuntimeGlobals, RuntimeModule, Template } from 'webpack';\n// inspired by react-refresh-webpack-plugin\nimport getFederationGlobal from './getFederationGlobal';\nimport { NormalizedRuntimeInitOptionsWithOutShared } from '../../../types/runtime';\n\nclass FederationRuntimeModule extends RuntimeModule {\n runtimeRequirements: Set<string>;\n containerName: string;\n initOptionsWithoutShared: NormalizedRuntimeInitOptionsWithOutShared;\n\n constructor(\n runtimeRequirements: Set<string>,\n containerName: string,\n initOptionsWithoutShared: NormalizedRuntimeInitOptionsWithOutShared,\n ) {\n super('federation runtime', RuntimeModule.STAGE_NORMAL - 1);\n this.runtimeRequirements = runtimeRequirements;\n this.containerName = containerName;\n this.initOptionsWithoutShared = initOptionsWithoutShared;\n }\n\n /**\n * @returns {string | null} runtime code\n */\n override generate() {\n return Template.asString([\n getFederationGlobal(\n Template,\n RuntimeGlobals,\n this.initOptionsWithoutShared,\n ),\n ]);\n }\n}\nexport default FederationRuntimeModule;\n"],"names":["FederationRuntimeModule","RuntimeModule","generate","Template","asString","getFederationGlobal","RuntimeGlobals","initOptionsWithoutShared","constructor","runtimeRequirements","containerName","STAGE_NORMAL"],"mappings":";;;;+BAkCA;;;eAAA;;;;yBAlCwD;8EAExB;AAGhC,IAAA,AAAMA,0BAAN,MAAMA,gCAAgCC,sBAAa;IAgBjD;;GAEC,GACD,AAASC,WAAW;QAClB,OAAOC,iBAAQ,CAACC,QAAQ,CAAC;YACvBC,IAAAA,4BAAmB,EACjBF,iBAAQ,EACRG,uBAAc,EACd,IAAI,CAACC,wBAAwB;SAEhC;IACH;IAtBAC,YACEC,mBAAgC,EAChCC,aAAqB,EACrBH,wBAAmE,CACnE;QACA,KAAK,CAAC,sBAAsBN,sBAAa,CAACU,YAAY,GAAG;QACzD,IAAI,CAACF,mBAAmB,GAAGA;QAC3B,IAAI,CAACC,aAAa,GAAGA;QACrB,IAAI,CAACH,wBAAwB,GAAGA;IAClC;AAcF;MACA,WAAeP"}
@@ -0,0 +1,17 @@
1
+ import type { Compiler } from 'webpack';
2
+ import type { ModuleFederationPluginOptions } from '../../../declarations/plugins/container/ModuleFederationPlugin';
3
+ declare class FederationRuntimePlugin {
4
+ options?: ModuleFederationPluginOptions;
5
+ entryFilePath: string;
6
+ constructor(options?: ModuleFederationPluginOptions);
7
+ static getTemplate(runtimePlugins: string[]): string;
8
+ static getFilePath(containerName: string, runtimePlugins: string[]): string;
9
+ getFilePath(): string;
10
+ ensureFile(): void;
11
+ prependEntry(compiler: Compiler): void;
12
+ injectRuntime(compiler: Compiler): void;
13
+ mergeContainerRuntime(compiler: Compiler): void;
14
+ setRuntimeAlias(compiler: Compiler): void;
15
+ apply(compiler: Compiler): void;
16
+ }
17
+ export default FederationRuntimePlugin;
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _extends = require("@swc/helpers/_/_extends");
12
+ const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
13
+ const _webpack = require("webpack");
14
+ const _RuntimeGlobals = /*#__PURE__*/ _interop_require_default._(require("webpack/lib/RuntimeGlobals"));
15
+ const _FederationRuntimeModule = /*#__PURE__*/ _interop_require_default._(require("./FederationRuntimeModule"));
16
+ const _utils = require("./utils");
17
+ const _fs = require("webpack/lib/util/fs");
18
+ const _fs1 = /*#__PURE__*/ _interop_require_default._(require("fs"));
19
+ const _path = /*#__PURE__*/ _interop_require_default._(require("path"));
20
+ const _constant = require("../constant");
21
+ const BundlerRuntimePath = require.resolve('@module-federation/webpack-bundler-runtime');
22
+ const RuntimePath = require.resolve('@module-federation/runtime', {
23
+ paths: [
24
+ BundlerRuntimePath
25
+ ]
26
+ });
27
+ const InitializeRemoteEntryRuntimePluginPath = require.resolve('./InitializeRemoteEntryRuntimePlugin');
28
+ const DEFAULT_REMOTE_ENTRY = 'remoteEntry.js';
29
+ const federationGlobal = (0, _utils.getFederationGlobalScope)(_RuntimeGlobals.default);
30
+ let FederationRuntimePlugin = class FederationRuntimePlugin {
31
+ static getTemplate(runtimePlugins) {
32
+ // internal runtime plugin
33
+ const internalRuntimePlugin = `import initializeRemoteEntryRuntimePlugin from '${InitializeRemoteEntryRuntimePluginPath}';\n`;
34
+ const internalRuntimePluginName = 'initializeRemoteEntryRuntimePlugin';
35
+ let runtimePluginTemplates = '';
36
+ const runtimePLuginNames = [];
37
+ if (Array.isArray(runtimePlugins)) {
38
+ runtimePlugins.forEach((runtimePlugin, index)=>{
39
+ const runtimePluginName = `plugin_${index}`;
40
+ const runtimePluginPath = _path.default.isAbsolute(runtimePlugin) ? runtimePlugin : _path.default.join(process.cwd(), runtimePlugin);
41
+ runtimePluginTemplates += `import ${runtimePluginName} from '${runtimePluginPath}';\n`;
42
+ runtimePLuginNames.push(runtimePluginName);
43
+ });
44
+ }
45
+ runtimePluginTemplates += internalRuntimePlugin;
46
+ runtimePLuginNames.push(internalRuntimePluginName);
47
+ return _webpack.Template.asString([
48
+ `import federation from '${BundlerRuntimePath}';`,
49
+ runtimePluginTemplates,
50
+ `${federationGlobal} = {...federation,...${federationGlobal}};`,
51
+ runtimePLuginNames.length ? _webpack.Template.asString([
52
+ `${federationGlobal}.initOptions.plugins = ([`,
53
+ _webpack.Template.indent(runtimePLuginNames.map((item)=>`${item}(),`)),
54
+ '])'
55
+ ]) : '',
56
+ `${federationGlobal}.instance = ${federationGlobal}.runtime.init(${federationGlobal}.initOptions);`,
57
+ `if(${federationGlobal}.installInitialConsumes){`,
58
+ _webpack.Template.indent([
59
+ `${federationGlobal}.installInitialConsumes()`
60
+ ]),
61
+ '}'
62
+ ]);
63
+ }
64
+ static getFilePath(containerName, runtimePlugins) {
65
+ const hash = (0, _utils.createHash)(`${containerName} ${FederationRuntimePlugin.getTemplate(runtimePlugins)}`);
66
+ return _path.default.join(_constant.TEMP_DIR, `entry.${hash}.js`);
67
+ }
68
+ getFilePath() {
69
+ if (this.entryFilePath) {
70
+ return this.entryFilePath;
71
+ }
72
+ if (!this.options) {
73
+ return '';
74
+ }
75
+ this.entryFilePath = FederationRuntimePlugin.getFilePath(this.options.name, this.options.runtimePlugins);
76
+ return this.entryFilePath;
77
+ }
78
+ ensureFile() {
79
+ if (!this.options) {
80
+ return;
81
+ }
82
+ const filePath = this.getFilePath();
83
+ try {
84
+ _fs1.default.readFileSync(filePath);
85
+ } catch (err) {
86
+ (0, _fs.mkdirpSync)(_fs1.default, _constant.TEMP_DIR);
87
+ _fs1.default.writeFileSync(filePath, FederationRuntimePlugin.getTemplate(this.options.runtimePlugins));
88
+ }
89
+ }
90
+ prependEntry(compiler) {
91
+ this.ensureFile();
92
+ const entryFilePath = this.getFilePath();
93
+ (0, _utils.modifyEntry)({
94
+ compiler,
95
+ prependEntry: (entry)=>{
96
+ Object.keys(entry).forEach((entryName)=>{
97
+ const entryItem = entry[entryName];
98
+ if (!entryItem.import) {
99
+ // TODO: maybe set this variable as constant is better https://github.com/webpack/webpack/blob/main/lib/config/defaults.js#L176
100
+ entryItem.import = [
101
+ './src'
102
+ ];
103
+ }
104
+ if (!entryItem.import.includes(entryFilePath)) {
105
+ entryItem.import.unshift(entryFilePath);
106
+ }
107
+ });
108
+ }
109
+ });
110
+ }
111
+ injectRuntime(compiler) {
112
+ if (!this.options || !this.options.name) {
113
+ return;
114
+ }
115
+ const name = this.options.name;
116
+ const initOptionsWithoutShared = (0, _utils.normalizeRuntimeInitOptionsWithOutShared)(this.options);
117
+ const federationGlobal = (0, _utils.getFederationGlobalScope)(_RuntimeGlobals.default || {});
118
+ compiler.hooks.thisCompilation.tap(this.constructor.name, (compilation, { normalModuleFactory })=>{
119
+ compilation.hooks.additionalTreeRuntimeRequirements.tap(this.constructor.name, // Setup react-refresh globals with a Webpack runtime module
120
+ (chunk, runtimeRequirements)=>{
121
+ if (runtimeRequirements.has(federationGlobal)) {
122
+ return;
123
+ }
124
+ runtimeRequirements.add(_RuntimeGlobals.default.interceptModuleExecution);
125
+ runtimeRequirements.add(_RuntimeGlobals.default.moduleCache);
126
+ runtimeRequirements.add(_RuntimeGlobals.default.compatGetDefaultExport);
127
+ runtimeRequirements.add(federationGlobal);
128
+ runtimeRequirements.add(_RuntimeGlobals.default.global);
129
+ compilation.addRuntimeModule(chunk, new _FederationRuntimeModule.default(runtimeRequirements, name, initOptionsWithoutShared));
130
+ });
131
+ });
132
+ }
133
+ // merge runtime chunk into container
134
+ mergeContainerRuntime(compiler) {
135
+ if (!this.options) {
136
+ return;
137
+ }
138
+ const { name, filename } = this.options;
139
+ if (!name || !filename) {
140
+ return;
141
+ }
142
+ let enableRuntimeChunk = false;
143
+ if (compiler.options.optimization) {
144
+ switch(typeof compiler.options.optimization.runtimeChunk){
145
+ case 'boolean':
146
+ enableRuntimeChunk = compiler.options.optimization.runtimeChunk;
147
+ break;
148
+ case 'object':
149
+ enableRuntimeChunk = true;
150
+ break;
151
+ default:
152
+ enableRuntimeChunk = false;
153
+ break;
154
+ }
155
+ }
156
+ // merge runtime into container
157
+ if (enableRuntimeChunk) {
158
+ compiler.hooks.emit.tap('EnableSingleRunTimeForFederationPlugin', (compilation)=>{
159
+ const { assets } = compilation;
160
+ const entryPoint = compilation.entrypoints.get(name);
161
+ if (!entryPoint) {
162
+ return;
163
+ }
164
+ const runtimeChunk = entryPoint.getRuntimeChunk();
165
+ if (!runtimeChunk) {
166
+ return;
167
+ }
168
+ const runtimeAssets = [];
169
+ runtimeChunk.files.forEach((fileName)=>{
170
+ runtimeAssets.push(assets[fileName]);
171
+ });
172
+ const remoteEntry = assets[filename || DEFAULT_REMOTE_ENTRY];
173
+ const mergedSource = new compiler.webpack.sources.ConcatSource(...runtimeAssets, remoteEntry);
174
+ assets[filename || DEFAULT_REMOTE_ENTRY] = mergedSource;
175
+ });
176
+ }
177
+ }
178
+ setRuntimeAlias(compiler) {
179
+ compiler.options.resolve.alias = _extends._({}, compiler.options.resolve.alias, {
180
+ '@vmok/kit/runtime$': RuntimePath,
181
+ '@vmok/kit$': RuntimePath,
182
+ '@vmok/runtime$': RuntimePath
183
+ });
184
+ }
185
+ apply(compiler) {
186
+ const useModuleFederationPlugin = compiler.options.plugins.find((p)=>{
187
+ if (typeof p !== 'object' || !p) {
188
+ return false;
189
+ }
190
+ return p['name'] === 'ModuleFederationPlugin';
191
+ });
192
+ if (useModuleFederationPlugin && !this.options) {
193
+ // @ts-ignore
194
+ this.options = useModuleFederationPlugin._options;
195
+ }
196
+ const useContainerPlugin = compiler.options.plugins.find((p)=>{
197
+ if (typeof p !== 'object' || !p) {
198
+ return false;
199
+ }
200
+ return p['name'] === 'ContainerPlugin';
201
+ });
202
+ if (useContainerPlugin && !this.options) {
203
+ // @ts-ignore
204
+ this.options = useContainerPlugin._options;
205
+ }
206
+ if (!useContainerPlugin && !useModuleFederationPlugin) {
207
+ this.options = _extends._({}, this.options, {
208
+ name: compiler.options.output.uniqueName || 'container',
209
+ remotes: {}
210
+ });
211
+ }
212
+ this.prependEntry(compiler);
213
+ this.injectRuntime(compiler);
214
+ this.setRuntimeAlias(compiler);
215
+ }
216
+ constructor(options){
217
+ this.options = options;
218
+ this.entryFilePath = '';
219
+ }
220
+ };
221
+ const _default = FederationRuntimePlugin;
222
+
223
+ //# sourceMappingURL=FederationRuntimePlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../packages/enhanced/src/lib/container/runtime/FederationRuntimePlugin.ts"],"sourcesContent":["import type { Compiler, sources } from 'webpack';\nimport { Template } from 'webpack';\nimport RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport FederationRuntimeModule from './FederationRuntimeModule';\nimport {\n getFederationGlobalScope,\n normalizeRuntimeInitOptionsWithOutShared,\n modifyEntry,\n createHash,\n} from './utils';\nimport { mkdirpSync } from 'webpack/lib/util/fs';\nimport fs from 'fs';\nimport path from 'path';\nimport { TEMP_DIR } from '../constant';\nimport type { ModuleFederationPluginOptions } from '../../../declarations/plugins/container/ModuleFederationPlugin';\n\nconst BundlerRuntimePath = require.resolve(\n '@module-federation/webpack-bundler-runtime',\n);\nconst RuntimePath = require.resolve('@module-federation/runtime', {\n paths: [BundlerRuntimePath],\n});\nconst InitializeRemoteEntryRuntimePluginPath = require.resolve(\n './InitializeRemoteEntryRuntimePlugin',\n);\n\nconst DEFAULT_REMOTE_ENTRY = 'remoteEntry.js';\n\nconst federationGlobal = getFederationGlobalScope(RuntimeGlobals);\n\nclass FederationRuntimePlugin {\n options?: ModuleFederationPluginOptions;\n entryFilePath: string;\n\n constructor(options?: ModuleFederationPluginOptions) {\n this.options = options;\n this.entryFilePath = '';\n }\n\n static getTemplate(runtimePlugins: string[]) {\n // internal runtime plugin\n const internalRuntimePlugin = `import initializeRemoteEntryRuntimePlugin from '${InitializeRemoteEntryRuntimePluginPath}';\\n`;\n const internalRuntimePluginName = 'initializeRemoteEntryRuntimePlugin';\n let runtimePluginTemplates = '';\n const runtimePLuginNames: string[] = [];\n\n if (Array.isArray(runtimePlugins)) {\n runtimePlugins.forEach((runtimePlugin, index) => {\n const runtimePluginName = `plugin_${index}`;\n const runtimePluginPath = path.isAbsolute(runtimePlugin)\n ? runtimePlugin\n : path.join(process.cwd(), runtimePlugin);\n\n runtimePluginTemplates += `import ${runtimePluginName} from '${runtimePluginPath}';\\n`;\n runtimePLuginNames.push(runtimePluginName);\n });\n }\n runtimePluginTemplates += internalRuntimePlugin;\n runtimePLuginNames.push(internalRuntimePluginName);\n\n return Template.asString([\n `import federation from '${BundlerRuntimePath}';`,\n runtimePluginTemplates,\n `${federationGlobal} = {...federation,...${federationGlobal}};`,\n runtimePLuginNames.length\n ? Template.asString([\n `${federationGlobal}.initOptions.plugins = ([`,\n Template.indent(runtimePLuginNames.map((item) => `${item}(),`)),\n '])',\n ])\n : '',\n `${federationGlobal}.instance = ${federationGlobal}.runtime.init(${federationGlobal}.initOptions);`,\n `if(${federationGlobal}.installInitialConsumes){`,\n Template.indent([`${federationGlobal}.installInitialConsumes()`]),\n '}',\n ]);\n }\n\n static getFilePath(containerName: string, runtimePlugins: string[]) {\n const hash = createHash(\n `${containerName} ${FederationRuntimePlugin.getTemplate(runtimePlugins)}`,\n );\n return path.join(TEMP_DIR, `entry.${hash}.js`);\n }\n\n getFilePath() {\n if (this.entryFilePath) {\n return this.entryFilePath;\n }\n\n if (!this.options) {\n return '';\n }\n\n this.entryFilePath = FederationRuntimePlugin.getFilePath(\n this.options.name!,\n this.options.runtimePlugins!,\n );\n return this.entryFilePath;\n }\n\n ensureFile() {\n if (!this.options) {\n return;\n }\n const filePath = this.getFilePath();\n try {\n fs.readFileSync(filePath);\n } catch (err) {\n mkdirpSync(fs, TEMP_DIR);\n fs.writeFileSync(\n filePath,\n FederationRuntimePlugin.getTemplate(this.options.runtimePlugins!),\n );\n }\n }\n\n prependEntry(compiler: Compiler) {\n this.ensureFile();\n const entryFilePath = this.getFilePath();\n\n modifyEntry({\n compiler,\n prependEntry: (entry) => {\n Object.keys(entry).forEach((entryName) => {\n const entryItem = entry[entryName];\n if (!entryItem.import) {\n // TODO: maybe set this variable as constant is better https://github.com/webpack/webpack/blob/main/lib/config/defaults.js#L176\n entryItem.import = ['./src'];\n }\n if (!entryItem.import.includes(entryFilePath)) {\n entryItem.import.unshift(entryFilePath);\n }\n });\n },\n });\n }\n\n injectRuntime(compiler: Compiler) {\n if (!this.options || !this.options.name) {\n return;\n }\n const name = this.options.name;\n const initOptionsWithoutShared = normalizeRuntimeInitOptionsWithOutShared(\n this.options,\n );\n const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});\n\n compiler.hooks.thisCompilation.tap(\n this.constructor.name,\n (compilation, { normalModuleFactory }) => {\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n this.constructor.name,\n // Setup react-refresh globals with a Webpack runtime module\n (chunk, runtimeRequirements) => {\n if (runtimeRequirements.has(federationGlobal)) {\n return;\n }\n runtimeRequirements.add(RuntimeGlobals.interceptModuleExecution);\n runtimeRequirements.add(RuntimeGlobals.moduleCache);\n runtimeRequirements.add(RuntimeGlobals.compatGetDefaultExport);\n runtimeRequirements.add(federationGlobal);\n runtimeRequirements.add(RuntimeGlobals.global);\n compilation.addRuntimeModule(\n chunk,\n new FederationRuntimeModule(\n runtimeRequirements,\n name,\n initOptionsWithoutShared,\n ),\n );\n },\n );\n },\n );\n }\n\n // merge runtime chunk into container\n mergeContainerRuntime(compiler: Compiler) {\n if (!this.options) {\n return;\n }\n\n const { name, filename } = this.options;\n if (!name || !filename) {\n return;\n }\n\n let enableRuntimeChunk = false;\n\n if (compiler.options.optimization) {\n switch (typeof compiler.options.optimization.runtimeChunk) {\n case 'boolean':\n enableRuntimeChunk = compiler.options.optimization.runtimeChunk;\n break;\n case 'object':\n enableRuntimeChunk = true;\n break;\n default:\n enableRuntimeChunk = false;\n break;\n }\n }\n\n // merge runtime into container\n if (enableRuntimeChunk) {\n compiler.hooks.emit.tap(\n 'EnableSingleRunTimeForFederationPlugin',\n (compilation) => {\n const { assets } = compilation;\n const entryPoint = compilation.entrypoints.get(name);\n if (!entryPoint) {\n return;\n }\n\n const runtimeChunk = entryPoint.getRuntimeChunk();\n if (!runtimeChunk) {\n return;\n }\n const runtimeAssets: sources.Source[] = [];\n runtimeChunk.files.forEach((fileName) => {\n runtimeAssets.push(assets[fileName]);\n });\n const remoteEntry = assets[filename || DEFAULT_REMOTE_ENTRY];\n const mergedSource = new compiler.webpack.sources.ConcatSource(\n ...runtimeAssets,\n remoteEntry,\n );\n assets[filename || DEFAULT_REMOTE_ENTRY] = mergedSource;\n },\n );\n }\n }\n\n setRuntimeAlias(compiler: Compiler) {\n compiler.options.resolve.alias = {\n ...compiler.options.resolve.alias,\n '@vmok/kit/runtime$': RuntimePath,\n '@vmok/kit$': RuntimePath,\n '@vmok/runtime$': RuntimePath,\n };\n }\n\n apply(compiler: Compiler) {\n const useModuleFederationPlugin = compiler.options.plugins.find((p) => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n\n return p['name'] === 'ModuleFederationPlugin';\n });\n\n if (useModuleFederationPlugin && !this.options) {\n // @ts-ignore\n this.options = useModuleFederationPlugin._options;\n }\n\n const useContainerPlugin = compiler.options.plugins.find((p) => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n\n return p['name'] === 'ContainerPlugin';\n });\n\n if (useContainerPlugin && !this.options) {\n // @ts-ignore\n this.options = useContainerPlugin._options;\n }\n\n if (!useContainerPlugin && !useModuleFederationPlugin) {\n this.options = {\n ...this.options,\n name: compiler.options.output.uniqueName || 'container',\n remotes: {},\n };\n }\n\n this.prependEntry(compiler);\n this.injectRuntime(compiler);\n this.setRuntimeAlias(compiler);\n }\n}\n\nexport default FederationRuntimePlugin;\n"],"names":["BundlerRuntimePath","require","resolve","RuntimePath","paths","InitializeRemoteEntryRuntimePluginPath","DEFAULT_REMOTE_ENTRY","federationGlobal","getFederationGlobalScope","RuntimeGlobals","FederationRuntimePlugin","getTemplate","runtimePlugins","internalRuntimePlugin","internalRuntimePluginName","runtimePluginTemplates","runtimePLuginNames","Array","isArray","forEach","runtimePlugin","index","runtimePluginName","runtimePluginPath","path","isAbsolute","join","process","cwd","push","Template","asString","length","indent","map","item","getFilePath","containerName","hash","createHash","TEMP_DIR","entryFilePath","options","name","ensureFile","filePath","fs","readFileSync","err","mkdirpSync","writeFileSync","prependEntry","compiler","modifyEntry","entry","Object","keys","entryName","entryItem","import","includes","unshift","injectRuntime","initOptionsWithoutShared","normalizeRuntimeInitOptionsWithOutShared","hooks","thisCompilation","tap","constructor","compilation","normalModuleFactory","additionalTreeRuntimeRequirements","chunk","runtimeRequirements","has","add","interceptModuleExecution","moduleCache","compatGetDefaultExport","global","addRuntimeModule","FederationRuntimeModule","mergeContainerRuntime","filename","enableRuntimeChunk","optimization","runtimeChunk","emit","assets","entryPoint","entrypoints","get","getRuntimeChunk","runtimeAssets","files","fileName","remoteEntry","mergedSource","webpack","sources","ConcatSource","setRuntimeAlias","alias","apply","useModuleFederationPlugin","plugins","find","p","_options","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;QACnB,IAAI,CAACiD,eAAe,CAACjD;IACvB;IAvPAgB,YAAY1B,OAAuC,CAAE;QACnD,IAAI,CAACA,OAAO,GAAGA;QACf,IAAI,CAACD,aAAa,GAAG;IACvB;AAqPF;MAEA,WAAe/B"}
@@ -0,0 +1,6 @@
1
+ import type { init } from '@module-federation/runtime';
2
+ type ExcludeUndefined<T> = T extends undefined ? never : T;
3
+ type NonUndefined<T> = ExcludeUndefined<T>;
4
+ type FederationRuntimePlugin = NonUndefined<Parameters<typeof init>[0]['plugins']>[0];
5
+ export default function (): FederationRuntimePlugin;
6
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ function _default() {
12
+ return {
13
+ name: 'initialize-remote-entry-runtime-plugin',
14
+ beforeLoadShare (args) {
15
+ const { shareInfo, origin } = args;
16
+ if (shareInfo == null ? void 0 : shareInfo.scope) {
17
+ shareInfo.scope.forEach((shareScope)=>{
18
+ origin.initializeSharing(shareScope);
19
+ });
20
+ }
21
+ return args;
22
+ }
23
+ };
24
+ }
25
+
26
+ //# sourceMappingURL=InitializeRemoteEntryRuntimePlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../packages/enhanced/src/lib/container/runtime/InitializeRemoteEntryRuntimePlugin.ts"],"sourcesContent":["import type { init } from '@module-federation/runtime';\n\ntype ExcludeUndefined<T> = T extends undefined ? never : T;\ntype NonUndefined<T> = ExcludeUndefined<T>;\n\ntype FederationRuntimePlugin = NonUndefined<\n Parameters<typeof init>[0]['plugins']\n>[0];\n\nexport default function (): FederationRuntimePlugin {\n return {\n name: 'initialize-remote-entry-runtime-plugin',\n beforeLoadShare(args) {\n const { shareInfo, origin } = args;\n if (shareInfo?.scope) {\n shareInfo.scope.forEach((shareScope) => {\n origin.initializeSharing(shareScope);\n });\n }\n\n return args;\n },\n };\n}\n"],"names":["name","beforeLoadShare","args","shareInfo","origin","scope","forEach","shareScope","initializeSharing"],"mappings":";;;;+BASA;;;eAAA;;;AAAe,SAAf;IACE,OAAO;QACLA,MAAM;QACNC,iBAAgBC,IAAI;YAClB,MAAM,EAAEC,SAAS,EAAEC,MAAM,EAAE,GAAGF;YAC9B,IAAIC,6BAAAA,UAAWE,KAAK,EAAE;gBACpBF,UAAUE,KAAK,CAACC,OAAO,CAAC,CAACC;oBACvBH,OAAOI,iBAAiB,CAACD;gBAC3B;YACF;YAEA,OAAOL;QACT;IACF;AACF"}
@@ -0,0 +1,5 @@
1
+ import { Template } from 'webpack';
2
+ import type RuntimeGlobals from 'webpack/lib/RuntimeGlobals';
3
+ import { NormalizedRuntimeInitOptionsWithOutShared } from '../../../types/runtime';
4
+ declare function getFederationGlobal(template: typeof Template, runtimeGlobals: typeof RuntimeGlobals, initOptionsWithoutShared: NormalizedRuntimeInitOptionsWithOutShared): string;
5
+ export default getFederationGlobal;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _utils = require("./utils");
12
+ function getFederationGlobal(template, runtimeGlobals, initOptionsWithoutShared) {
13
+ const federationGlobal = (0, _utils.getFederationGlobalScope)(runtimeGlobals);
14
+ // TODO: get shared getter
15
+ const initOptionsStrWithoutShared = JSON.stringify(initOptionsWithoutShared);
16
+ // return Template.asString([
17
+ // `if(!${federationGlobal}){`,
18
+ // "// inject vmok runtime",
19
+ // getRuntimeCode(),
20
+ // `${federationGlobal} = ${RuntimeGlobals.compatGetDefaultExport}(VmokBundlerRuntime)();`,
21
+ // `${federationGlobal}.initOptions = ${initOptionsStrWithoutShared};`,
22
+ // "}"
23
+ // ]);
24
+ return template.asString([
25
+ `if(!${federationGlobal}){`,
26
+ template.indent([
27
+ `${federationGlobal} = {`,
28
+ template.indent([
29
+ // "runtime: undefined,",
30
+ // "instance: undefined,",
31
+ `initOptions: ${initOptionsStrWithoutShared},`,
32
+ `initialConsumes: undefined,`,
33
+ "bundlerRuntimeOptions: {}"
34
+ ]),
35
+ '};'
36
+ ]),
37
+ '}'
38
+ ]);
39
+ }
40
+ const _default = getFederationGlobal;
41
+
42
+ //# sourceMappingURL=getFederationGlobal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../packages/enhanced/src/lib/container/runtime/getFederationGlobal.ts"],"sourcesContent":["import { getFederationGlobalScope } from './utils';\nimport { Template } from 'webpack';\nimport type RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport { NormalizedRuntimeInitOptionsWithOutShared } from '../../../types/runtime';\n\nfunction getFederationGlobal(\n template: typeof Template,\n runtimeGlobals: typeof RuntimeGlobals,\n initOptionsWithoutShared: NormalizedRuntimeInitOptionsWithOutShared,\n): string {\n const federationGlobal = getFederationGlobalScope(runtimeGlobals);\n // TODO: get shared getter\n const initOptionsStrWithoutShared = JSON.stringify(initOptionsWithoutShared);\n // return Template.asString([\n // \t`if(!${federationGlobal}){`,\n // \t\"// inject vmok runtime\",\n // \tgetRuntimeCode(),\n // \t`${federationGlobal} = ${RuntimeGlobals.compatGetDefaultExport}(VmokBundlerRuntime)();`,\n // \t`${federationGlobal}.initOptions = ${initOptionsStrWithoutShared};`,\n // \t\"}\"\n // ]);\n return template.asString([\n `if(!${federationGlobal}){`,\n template.indent([\n `${federationGlobal} = {`,\n template.indent([\n // \"runtime: undefined,\",\n // \"instance: undefined,\",\n `initOptions: ${initOptionsStrWithoutShared},`,\n `initialConsumes: undefined,`,\n\t\t\t\t\"bundlerRuntimeOptions: {}\"\n ]),\n '};',\n ]),\n '}',\n // \"// inject vmok runtime\",\n // getRuntimeCode(),\n // `${federationGlobal}.runtime = VmokRuntime;`\n ]);\n}\n\nexport default getFederationGlobal;\n"],"names":["getFederationGlobal","template","runtimeGlobals","initOptionsWithoutShared","federationGlobal","getFederationGlobalScope","initOptionsStrWithoutShared","JSON","stringify","asString","indent"],"mappings":";;;;+BAyCA;;;eAAA;;;uBAzCyC;AAKzC,SAASA,oBACPC,QAAyB,EACzBC,cAAqC,EACrCC,wBAAmE;IAEnE,MAAMC,mBAAmBC,IAAAA,+BAAwB,EAACH;IAClD,0BAA0B;IAC1B,MAAMI,8BAA8BC,KAAKC,SAAS,CAACL;IACnD,6BAA6B;IAC7B,gCAAgC;IAChC,6BAA6B;IAC7B,qBAAqB;IACrB,4FAA4F;IAC5F,wEAAwE;IACxE,OAAO;IACP,MAAM;IACN,OAAOF,SAASQ,QAAQ,CAAC;QACvB,CAAC,IAAI,EAAEL,iBAAiB,EAAE,CAAC;QAC3BH,SAASS,MAAM,CAAC;YACd,CAAC,EAAEN,iBAAiB,IAAI,CAAC;YACzBH,SAASS,MAAM,CAAC;gBACd,yBAAyB;gBACzB,0BAA0B;gBAC1B,CAAC,aAAa,EAAEJ,4BAA4B,CAAC,CAAC;gBAC9C,CAAC,2BAA2B,CAAC;gBACjC;aACG;YACD;SACD;QACD;KAID;AACH;MAEA,WAAeN"}
@@ -0,0 +1,15 @@
1
+ import type webpack from 'webpack';
2
+ import type RuntimeGlobals from 'webpack/lib/RuntimeGlobals';
3
+ import type { ModuleFederationPluginOptions } from '../../../declarations/plugins/container/ModuleFederationPlugin';
4
+ import { NormalizedRuntimeInitOptionsWithOutShared } from '../../../types/runtime';
5
+ type EntryStaticNormalized = Awaited<ReturnType<Extract<webpack.WebpackOptionsNormalized['entry'], () => any>>>;
6
+ interface ModifyEntryOptions {
7
+ compiler: webpack.Compiler;
8
+ prependEntry?: (entry: EntryStaticNormalized) => void;
9
+ staticEntry?: EntryStaticNormalized;
10
+ }
11
+ export declare function getFederationGlobalScope(runtimeGlobals: typeof RuntimeGlobals): string;
12
+ export declare function normalizeRuntimeInitOptionsWithOutShared(options: ModuleFederationPluginOptions): NormalizedRuntimeInitOptionsWithOutShared;
13
+ export declare function modifyEntry(options: ModifyEntryOptions): void;
14
+ export declare function createHash(contents: string): string;
15
+ export {};
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ createHash: function() {
13
+ return createHash;
14
+ },
15
+ getFederationGlobalScope: function() {
16
+ return getFederationGlobalScope;
17
+ },
18
+ modifyEntry: function() {
19
+ return modifyEntry;
20
+ },
21
+ normalizeRuntimeInitOptionsWithOutShared: function() {
22
+ return normalizeRuntimeInitOptionsWithOutShared;
23
+ }
24
+ });
25
+ const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
26
+ const _crypto = /*#__PURE__*/ _interop_require_default._(require("crypto"));
27
+ const _options = require("../options");
28
+ const _extractUrlAndGlobal = /*#__PURE__*/ _interop_require_default._(require("webpack/lib/util/extractUrlAndGlobal"));
29
+ function getFederationGlobalScope(runtimeGlobals) {
30
+ return `${runtimeGlobals.require || '__webpack_require__'}.federation`;
31
+ }
32
+ function normalizeRuntimeInitOptionsWithOutShared(options) {
33
+ const parsedOptions = (0, _options.parseOptions)(options.remotes || [], (item)=>({
34
+ external: Array.isArray(item) ? item : [
35
+ item
36
+ ],
37
+ shareScope: options.shareScope || 'default'
38
+ }), (item)=>({
39
+ external: Array.isArray(item.external) ? item.external : [
40
+ item.external
41
+ ],
42
+ shareScope: item.shareScope || options.shareScope || 'default'
43
+ }));
44
+ const remoteOptions = [];
45
+ parsedOptions.forEach((parsedOption)=>{
46
+ const [alias, remoteInfos] = parsedOption;
47
+ // TODO: Handle the case of multiple elements in the external array (处理 external 数组多元素的情况)
48
+ const { external } = remoteInfos;
49
+ try {
50
+ // only fit for remoteType: 'script'
51
+ const [url, globalName] = (0, _extractUrlAndGlobal.default)(external[0]);
52
+ remoteOptions.push({
53
+ alias,
54
+ name: globalName,
55
+ entry: url
56
+ });
57
+ } catch (err) {
58
+ return;
59
+ }
60
+ });
61
+ const initOptionsWithoutShared = {
62
+ name: options.name,
63
+ remotes: remoteOptions
64
+ };
65
+ return initOptionsWithoutShared;
66
+ }
67
+ function modifyEntry(options) {
68
+ const { compiler, staticEntry, prependEntry } = options;
69
+ const operator = (oriEntry, newEntry)=>Object.assign(oriEntry, newEntry);
70
+ if (typeof compiler.options.entry === 'function') {
71
+ const prevEntryFn = compiler.options.entry;
72
+ compiler.options.entry = async ()=>{
73
+ let res = await prevEntryFn();
74
+ if (staticEntry) {
75
+ res = operator(res, staticEntry);
76
+ }
77
+ if (prependEntry) {
78
+ prependEntry(res);
79
+ }
80
+ return res;
81
+ };
82
+ } else {
83
+ if (staticEntry) {
84
+ compiler.options.entry = operator(compiler.options.entry, staticEntry);
85
+ }
86
+ if (prependEntry) {
87
+ prependEntry(compiler.options.entry);
88
+ }
89
+ }
90
+ }
91
+ function createHash(contents) {
92
+ return _crypto.default.createHash('md5').update(contents).digest('hex');
93
+ }
94
+
95
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../packages/enhanced/src/lib/container/runtime/utils.ts"],"sourcesContent":["import crypto from 'crypto';\nimport { parseOptions } from '../options';\nimport type { init } from '@module-federation/runtime';\nimport type webpack from 'webpack';\nimport type RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport extractUrlAndGlobal from 'webpack/lib/util/extractUrlAndGlobal';\nimport type { ModuleFederationPluginOptions } from '../../../declarations/plugins/container/ModuleFederationPlugin';\nimport { NormalizedRuntimeInitOptionsWithOutShared } from '../../../types/runtime';\n\ntype EntryStaticNormalized = Awaited<\n ReturnType<Extract<webpack.WebpackOptionsNormalized['entry'], () => any>>\n>;\n\ntype Remotes = Parameters<typeof init>[0]['remotes'];\n\ninterface ModifyEntryOptions {\n compiler: webpack.Compiler;\n prependEntry?: (entry: EntryStaticNormalized) => void;\n staticEntry?: EntryStaticNormalized;\n}\n\nexport function getFederationGlobalScope(\n runtimeGlobals: typeof RuntimeGlobals,\n): string {\n return `${runtimeGlobals.require || '__webpack_require__'}.federation`;\n}\n\nexport function normalizeRuntimeInitOptionsWithOutShared(\n options: ModuleFederationPluginOptions,\n): NormalizedRuntimeInitOptionsWithOutShared {\n const parsedOptions = parseOptions(\n options.remotes || [],\n (item) => ({\n external: Array.isArray(item) ? item : [item],\n shareScope: options.shareScope || 'default',\n }),\n (item) => ({\n external: Array.isArray(item.external) ? item.external : [item.external],\n shareScope: item.shareScope || options.shareScope || 'default',\n }),\n );\n const remoteOptions: Remotes = [];\n parsedOptions.forEach((parsedOption) => {\n const [alias, remoteInfos] = parsedOption;\n // TODO: Handle the case of multiple elements in the external array (处理 external 数组多元素的情况)\n const { external } = remoteInfos;\n try {\n // only fit for remoteType: 'script'\n const [url, globalName] = extractUrlAndGlobal(external[0]);\n remoteOptions.push({\n alias,\n name: globalName,\n entry: url,\n });\n } catch (err) {\n return;\n }\n });\n\n const initOptionsWithoutShared = {\n name: options.name!,\n remotes: remoteOptions,\n };\n\n return initOptionsWithoutShared;\n}\n\nexport function modifyEntry(options: ModifyEntryOptions): void {\n const { compiler, staticEntry, prependEntry } = options;\n const operator = (\n oriEntry: EntryStaticNormalized,\n newEntry: EntryStaticNormalized,\n ): EntryStaticNormalized => Object.assign(oriEntry, newEntry);\n\n if (typeof compiler.options.entry === 'function') {\n const prevEntryFn = compiler.options.entry;\n compiler.options.entry = async () => {\n let res = await prevEntryFn();\n if (staticEntry) {\n res = operator(res, staticEntry);\n }\n if (prependEntry) {\n prependEntry(res);\n }\n return res;\n };\n } else {\n if (staticEntry) {\n compiler.options.entry = operator(compiler.options.entry, staticEntry);\n }\n if (prependEntry) {\n prependEntry(compiler.options.entry);\n }\n }\n}\n\nexport function createHash(contents: string): string {\n return crypto.createHash('md5').update(contents).digest('hex');\n}\n"],"names":["createHash","getFederationGlobalScope","modifyEntry","normalizeRuntimeInitOptionsWithOutShared","runtimeGlobals","require","options","parsedOptions","parseOptions","remotes","item","external","Array","isArray","shareScope","remoteOptions","forEach","parsedOption","alias","remoteInfos","url","globalName","extractUrlAndGlobal","push","name","entry","err","initOptionsWithoutShared","compiler","staticEntry","prependEntry","operator","oriEntry","newEntry","Object","assign","prevEntryFn","res","contents","crypto","update","digest"],"mappings":";;;;;;;;;;;IAgGgBA,UAAU;eAAVA;;IA3EAC,wBAAwB;eAAxBA;;IA8CAC,WAAW;eAAXA;;IAxCAC,wCAAwC;eAAxCA;;;;iEA3BG;yBACU;8EAIG;AAgBzB,SAASF,yBACdG,cAAqC;IAErC,OAAO,CAAC,EAAEA,eAAeC,OAAO,IAAI,sBAAsB,WAAW,CAAC;AACxE;AAEO,SAASF,yCACdG,OAAsC;IAEtC,MAAMC,gBAAgBC,IAAAA,qBAAY,EAChCF,QAAQG,OAAO,IAAI,EAAE,EACrB,CAACC,OAAU,CAAA;YACTC,UAAUC,MAAMC,OAAO,CAACH,QAAQA,OAAO;gBAACA;aAAK;YAC7CI,YAAYR,QAAQQ,UAAU,IAAI;QACpC,CAAA,GACA,CAACJ,OAAU,CAAA;YACTC,UAAUC,MAAMC,OAAO,CAACH,KAAKC,QAAQ,IAAID,KAAKC,QAAQ,GAAG;gBAACD,KAAKC,QAAQ;aAAC;YACxEG,YAAYJ,KAAKI,UAAU,IAAIR,QAAQQ,UAAU,IAAI;QACvD,CAAA;IAEF,MAAMC,gBAAyB,EAAE;IACjCR,cAAcS,OAAO,CAAC,CAACC;QACrB,MAAM,CAACC,OAAOC,YAAY,GAAGF;QAC7B,0FAA0F;QAC1F,MAAM,EAAEN,QAAQ,EAAE,GAAGQ;QACrB,IAAI;YACF,oCAAoC;YACpC,MAAM,CAACC,KAAKC,WAAW,GAAGC,IAAAA,4BAAmB,EAACX,QAAQ,CAAC,EAAE;YACzDI,cAAcQ,IAAI,CAAC;gBACjBL;gBACAM,MAAMH;gBACNI,OAAOL;YACT;QACF,EAAE,OAAOM,KAAK;YACZ;QACF;IACF;IAEA,MAAMC,2BAA2B;QAC/BH,MAAMlB,QAAQkB,IAAI;QAClBf,SAASM;IACX;IAEA,OAAOY;AACT;AAEO,SAASzB,YAAYI,OAA2B;IACrD,MAAM,EAAEsB,QAAQ,EAAEC,WAAW,EAAEC,YAAY,EAAE,GAAGxB;IAChD,MAAMyB,WAAW,CACfC,UACAC,WAC0BC,OAAOC,MAAM,CAACH,UAAUC;IAEpD,IAAI,OAAOL,SAAStB,OAAO,CAACmB,KAAK,KAAK,YAAY;QAChD,MAAMW,cAAcR,SAAStB,OAAO,CAACmB,KAAK;QAC1CG,SAAStB,OAAO,CAACmB,KAAK,GAAG;YACvB,IAAIY,MAAM,MAAMD;YAChB,IAAIP,aAAa;gBACfQ,MAAMN,SAASM,KAAKR;YACtB;YACA,IAAIC,cAAc;gBAChBA,aAAaO;YACf;YACA,OAAOA;QACT;IACF,OAAO;QACL,IAAIR,aAAa;YACfD,SAAStB,OAAO,CAACmB,KAAK,GAAGM,SAASH,SAAStB,OAAO,CAACmB,KAAK,EAAEI;QAC5D;QACA,IAAIC,cAAc;YAChBA,aAAaF,SAAStB,OAAO,CAACmB,KAAK;QACrC;IACF;AACF;AAEO,SAASzB,WAAWsC,QAAgB;IACzC,OAAOC,eAAM,CAACvC,UAAU,CAAC,OAAOwC,MAAM,CAACF,UAAUG,MAAM,CAAC;AAC1D"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ module.exports = ConsumeSharedFallbackDependency;
3
+
4
+ //# sourceMappingURL=ConsumeSharedFallbackDependency.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/ConsumeSharedFallbackDependency.d.ts"],"sourcesContent":["export = ConsumeSharedFallbackDependency;\ndeclare class ConsumeSharedFallbackDependency extends ModuleDependency {}\nimport ModuleDependency = require('webpack/lib/dependencies/ModuleDependency');\n"],"names":["ConsumeSharedFallbackDependency"],"mappings":";iBAASA"}