@nx/react 24.0.0-pr.37405.acdaf31 → 24.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/index.d.ts +0 -2
  2. package/dist/index.js +1 -5
  3. package/dist/internal.d.ts +1 -0
  4. package/dist/internal.js +3 -1
  5. package/dist/module-federation.d.ts +6 -5
  6. package/dist/module-federation.js +29 -18
  7. package/dist/plugins/component-testing/index.js +92 -33
  8. package/dist/plugins/storybook/index.js +18 -18
  9. package/dist/plugins/with-react.d.ts +3 -7
  10. package/dist/plugins/with-react.js +5 -19
  11. package/dist/ready-check.d.ts +1 -0
  12. package/dist/ready-check.js +5 -0
  13. package/dist/src/generators/_utils/mf-dependencies.js +3 -0
  14. package/dist/src/generators/application/application.js +1 -36
  15. package/dist/src/generators/application/files/base-rspack/rspack.config.js__tmpl__ +1 -24
  16. package/dist/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +1 -26
  17. package/dist/src/generators/application/lib/add-e2e.js +11 -11
  18. package/dist/src/generators/application/lib/add-linting.js +1 -2
  19. package/dist/src/generators/application/lib/add-project.js +0 -167
  20. package/dist/src/generators/application/lib/bundlers/add-rsbuild.js +0 -1
  21. package/dist/src/generators/application/lib/bundlers/add-vite.js +0 -2
  22. package/dist/src/generators/application/lib/bundlers/add-webpack.js +0 -1
  23. package/dist/src/generators/application/lib/create-application-files.d.ts +0 -2
  24. package/dist/src/generators/application/lib/create-application-files.js +2 -11
  25. package/dist/src/generators/application/lib/normalize-options.js +0 -4
  26. package/dist/src/generators/application/schema.d.ts +0 -6
  27. package/dist/src/generators/application/schema.json +0 -6
  28. package/dist/src/generators/consumer/consumer.js +2 -0
  29. package/dist/src/generators/consumer/files/rsbuild/package.json__tmpl__ +1 -0
  30. package/dist/src/generators/consumer/files/rsbuild/rsbuild.config.ts__tmpl__ +2 -0
  31. package/dist/src/generators/consumer/files/rspack/package.json__tmpl__ +1 -0
  32. package/dist/src/generators/consumer/files/rspack/rspack.config.ts__tmpl__ +2 -0
  33. package/dist/src/generators/consumer/files/vite/package.json__tmpl__ +1 -0
  34. package/dist/src/generators/consumer/files/vite/vite.config.mts__tmpl__ +2 -0
  35. package/dist/src/generators/cypress-component-configuration/cypress-component-configuration.js +4 -16
  36. package/dist/src/generators/cypress-component-configuration/lib/add-files.d.ts +1 -2
  37. package/dist/src/generators/cypress-component-configuration/lib/add-files.js +4 -2
  38. package/dist/src/generators/cypress-component-configuration/schema.d.ts +0 -1
  39. package/dist/src/generators/init/init.js +3 -5
  40. package/dist/src/generators/init/schema.d.ts +0 -1
  41. package/dist/src/generators/library/lib/add-linting.js +1 -2
  42. package/dist/src/generators/library/lib/add-rollup-build-target.js +3 -47
  43. package/dist/src/generators/library/lib/normalize-options.js +0 -4
  44. package/dist/src/generators/library/library.js +1 -4
  45. package/dist/src/generators/library/schema.d.ts +0 -5
  46. package/dist/src/generators/library/schema.json +0 -6
  47. package/dist/src/generators/provider/files/rsbuild/package.json__tmpl__ +1 -0
  48. package/dist/src/generators/provider/files/rsbuild/rsbuild.config.ts__tmpl__ +2 -0
  49. package/dist/src/generators/provider/files/rspack/package.json__tmpl__ +1 -0
  50. package/dist/src/generators/provider/files/rspack/rspack.config.ts__tmpl__ +2 -0
  51. package/dist/src/generators/provider/files/vite/package.json__tmpl__ +1 -0
  52. package/dist/src/generators/provider/files/vite/vite.config.mts__tmpl__ +2 -0
  53. package/dist/src/generators/provider/provider.js +2 -0
  54. package/dist/src/generators/stories/stories.js +0 -5
  55. package/dist/src/generators/storybook-configuration/configuration.js +1 -9
  56. package/dist/src/generators/storybook-configuration/schema.d.ts +0 -1
  57. package/dist/src/migrations/update-23-2-0/add-optional-module-federation-packages.js +2 -1
  58. package/dist/src/migrations/update-24-0-0/register-typescript-plugin-for-typecheck.d.ts +4 -0
  59. package/dist/src/migrations/update-24-0-0/register-typescript-plugin-for-typecheck.js +13 -0
  60. package/dist/src/migrations/update-24-0-0/register-typescript-plugin-for-typecheck.md +40 -0
  61. package/dist/src/plugins/router-plugin-utils.d.ts +4 -0
  62. package/dist/src/plugins/router-plugin-utils.js +15 -0
  63. package/dist/src/plugins/router-plugin.d.ts +0 -1
  64. package/dist/src/plugins/router-plugin.js +35 -44
  65. package/dist/src/utils/ast-utils.d.ts +0 -1
  66. package/dist/src/utils/ast-utils.js +0 -23
  67. package/dist/src/utils/ct-utils.d.ts +0 -7
  68. package/dist/src/utils/ct-utils.js +71 -55
  69. package/dist/src/utils/deprecation.d.ts +1 -1
  70. package/dist/src/utils/deprecation.js +3 -5
  71. package/dist/src/utils/framework.js +1 -3
  72. package/dist/src/utils/react-router-serve-ready-check.d.ts +11 -0
  73. package/dist/src/utils/react-router-serve-ready-check.js +25 -0
  74. package/dist/src/utils/versions.d.ts +0 -7
  75. package/dist/src/utils/versions.js +2 -9
  76. package/executors.json +1 -17
  77. package/generators.json +0 -27
  78. package/migrations.json +6 -0
  79. package/package.json +25 -39
  80. package/dist/mf/dynamic-federation.d.ts +0 -69
  81. package/dist/mf/dynamic-federation.js +0 -141
  82. package/dist/mf/index.d.ts +0 -1
  83. package/dist/mf/index.js +0 -8
  84. package/dist/src/executors/module-federation-dev-server/lib/index.d.ts +0 -2
  85. package/dist/src/executors/module-federation-dev-server/lib/index.js +0 -5
  86. package/dist/src/executors/module-federation-dev-server/lib/normalize-options.d.ts +0 -4
  87. package/dist/src/executors/module-federation-dev-server/lib/normalize-options.js +0 -19
  88. package/dist/src/executors/module-federation-dev-server/lib/start-remotes.d.ts +0 -5
  89. package/dist/src/executors/module-federation-dev-server/lib/start-remotes.js +0 -33
  90. package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +0 -6
  91. package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +0 -80
  92. package/dist/src/executors/module-federation-dev-server/schema.d.ts +0 -19
  93. package/dist/src/executors/module-federation-dev-server/schema.json +0 -142
  94. package/dist/src/executors/module-federation-ssr-dev-server/lib/index.d.ts +0 -2
  95. package/dist/src/executors/module-federation-ssr-dev-server/lib/index.js +0 -5
  96. package/dist/src/executors/module-federation-ssr-dev-server/lib/normalize-options.d.ts +0 -4
  97. package/dist/src/executors/module-federation-ssr-dev-server/lib/normalize-options.js +0 -23
  98. package/dist/src/executors/module-federation-ssr-dev-server/lib/start-remotes.d.ts +0 -5
  99. package/dist/src/executors/module-federation-ssr-dev-server/lib/start-remotes.js +0 -34
  100. package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +0 -3
  101. package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +0 -83
  102. package/dist/src/executors/module-federation-ssr-dev-server/schema.d.ts +0 -29
  103. package/dist/src/executors/module-federation-ssr-dev-server/schema.json +0 -81
  104. package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts +0 -12
  105. package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.js +0 -244
  106. package/dist/src/executors/module-federation-static-server/schema.d.ts +0 -3
  107. package/dist/src/executors/module-federation-static-server/schema.json +0 -16
  108. package/dist/src/generators/federate-module/federate-module.d.ts +0 -4
  109. package/dist/src/generators/federate-module/federate-module.js +0 -67
  110. package/dist/src/generators/federate-module/lib/utils.d.ts +0 -23
  111. package/dist/src/generators/federate-module/lib/utils.js +0 -99
  112. package/dist/src/generators/federate-module/schema.d.ts +0 -15
  113. package/dist/src/generators/federate-module/schema.json +0 -89
  114. package/dist/src/generators/host/files/common/src/app/__fileName__.js__tmpl__ +0 -40
  115. package/dist/src/generators/host/files/common/src/main.js__tmpl__ +0 -13
  116. package/dist/src/generators/host/files/common/tsconfig.lint.json__tmpl__ +0 -19
  117. package/dist/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +0 -41
  118. package/dist/src/generators/host/files/common-ts/src/main.ts__tmpl__ +0 -13
  119. package/dist/src/generators/host/files/rspack-common/src/app/__fileName__.jsx__tmpl__ +0 -42
  120. package/dist/src/generators/host/files/rspack-common/src/main.jsx__tmpl__ +0 -13
  121. package/dist/src/generators/host/files/rspack-common/tsconfig.lint.json__tmpl__ +0 -19
  122. package/dist/src/generators/host/files/rspack-module-federation/module-federation.config.js__tmpl__ +0 -24
  123. package/dist/src/generators/host/files/rspack-module-federation/rspack.config.js__tmpl__ +0 -42
  124. package/dist/src/generators/host/files/rspack-module-federation/rspack.config.prod.js__tmpl__ +0 -66
  125. package/dist/src/generators/host/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +0 -27
  126. package/dist/src/generators/host/files/rspack-module-federation-ssr/rspack.config.js__tmpl__ +0 -68
  127. package/dist/src/generators/host/files/rspack-module-federation-ssr/server.ts__tmpl__ +0 -28
  128. package/dist/src/generators/host/files/rspack-module-federation-ssr/src/main.server.tsx__tmpl__ +0 -49
  129. package/dist/src/generators/host/files/rspack-module-federation-ssr/tsconfig.server.json__tmpl__ +0 -17
  130. package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +0 -22
  131. package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +0 -68
  132. package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/server.ts__tmpl__ +0 -28
  133. package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/src/main.server.tsx__tmpl__ +0 -49
  134. package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/tsconfig.server.json__tmpl__ +0 -17
  135. package/dist/src/generators/host/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +0 -28
  136. package/dist/src/generators/host/files/rspack-module-federation-ts/rspack.config.prod.ts__tmpl__ +0 -67
  137. package/dist/src/generators/host/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +0 -42
  138. package/dist/src/generators/host/files/webpack-module-federation/module-federation.config.js__tmpl__ +0 -24
  139. package/dist/src/generators/host/files/webpack-module-federation/webpack.config.js__tmpl__ +0 -17
  140. package/dist/src/generators/host/files/webpack-module-federation/webpack.config.prod.js__tmpl__ +0 -39
  141. package/dist/src/generators/host/files/webpack-module-federation-ssr/module-federation.server.config.js__tmpl__ +0 -19
  142. package/dist/src/generators/host/files/webpack-module-federation-ssr/server.ts__tmpl__ +0 -28
  143. package/dist/src/generators/host/files/webpack-module-federation-ssr/tsconfig.server.json__tmpl__ +0 -17
  144. package/dist/src/generators/host/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +0 -17
  145. package/dist/src/generators/host/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +0 -16
  146. package/dist/src/generators/host/files/webpack-module-federation-ssr-ts/server.ts__tmpl__ +0 -28
  147. package/dist/src/generators/host/files/webpack-module-federation-ssr-ts/tsconfig.server.json__tmpl__ +0 -17
  148. package/dist/src/generators/host/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +0 -17
  149. package/dist/src/generators/host/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +0 -28
  150. package/dist/src/generators/host/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__ +0 -40
  151. package/dist/src/generators/host/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +0 -18
  152. package/dist/src/generators/host/host.d.ts +0 -4
  153. package/dist/src/generators/host/host.js +0 -174
  154. package/dist/src/generators/host/lib/add-module-federation-files.d.ts +0 -6
  155. package/dist/src/generators/host/lib/add-module-federation-files.js +0 -92
  156. package/dist/src/generators/host/lib/normalize-host-name.d.ts +0 -2
  157. package/dist/src/generators/host/lib/normalize-host-name.js +0 -12
  158. package/dist/src/generators/host/lib/setup-ssr-for-host.d.ts +0 -6
  159. package/dist/src/generators/host/lib/setup-ssr-for-host.js +0 -59
  160. package/dist/src/generators/host/lib/update-module-federation-e2e-project.d.ts +0 -3
  161. package/dist/src/generators/host/lib/update-module-federation-e2e-project.js +0 -19
  162. package/dist/src/generators/host/lib/update-module-federation-tsconfig.d.ts +0 -3
  163. package/dist/src/generators/host/lib/update-module-federation-tsconfig.js +0 -34
  164. package/dist/src/generators/host/schema.d.ts +0 -44
  165. package/dist/src/generators/host/schema.json +0 -173
  166. package/dist/src/generators/remote/files/common/src/main.js__tmpl__ +0 -1
  167. package/dist/src/generators/remote/files/common/src/remote-entry.js__tmpl__ +0 -1
  168. package/dist/src/generators/remote/files/common-ts/src/main.ts__tmpl__ +0 -1
  169. package/dist/src/generators/remote/files/common-ts/src/remote-entry.ts__tmpl__ +0 -1
  170. package/dist/src/generators/remote/files/rspack-common/src/main.jsx__tmpl__ +0 -1
  171. package/dist/src/generators/remote/files/rspack-common/src/remote-entry.js__tmpl__ +0 -1
  172. package/dist/src/generators/remote/files/rspack-module-federation/module-federation.config.js__tmpl__ +0 -12
  173. package/dist/src/generators/remote/files/rspack-module-federation/rspack.config.js__tmpl__ +0 -45
  174. package/dist/src/generators/remote/files/rspack-module-federation/rspack.config.prod.js__tmpl__ +0 -1
  175. package/dist/src/generators/remote/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +0 -15
  176. package/dist/src/generators/remote/files/rspack-module-federation-ssr/rspack.config.js__tmpl__ +0 -71
  177. package/dist/src/generators/remote/files/rspack-module-federation-ssr/server.ts__tmpl__ +0 -45
  178. package/dist/src/generators/remote/files/rspack-module-federation-ssr/src/main.server.tsx__tmpl__ +0 -45
  179. package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +0 -19
  180. package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +0 -71
  181. package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/server.ts__tmpl__ +0 -45
  182. package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/src/main.server.tsx__tmpl__ +0 -45
  183. package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +0 -19
  184. package/dist/src/generators/remote/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +0 -16
  185. package/dist/src/generators/remote/files/rspack-module-federation-ts/rspack.config.prod.ts__tmpl__ +0 -1
  186. package/dist/src/generators/remote/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +0 -45
  187. package/dist/src/generators/remote/files/rspack-module-federation-ts/tsconfig.lint.json__tmpl__ +0 -19
  188. package/dist/src/generators/remote/files/webpack-module-federation/module-federation.config.js__tmpl__ +0 -12
  189. package/dist/src/generators/remote/files/webpack-module-federation/webpack.config.js__tmpl__ +0 -17
  190. package/dist/src/generators/remote/files/webpack-module-federation/webpack.config.prod.js__tmpl__ +0 -1
  191. package/dist/src/generators/remote/files/webpack-module-federation-ssr/module-federation.server.config.js__tmpl__ +0 -9
  192. package/dist/src/generators/remote/files/webpack-module-federation-ssr/server.ts__tmpl__ +0 -45
  193. package/dist/src/generators/remote/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +0 -17
  194. package/dist/src/generators/remote/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +0 -13
  195. package/dist/src/generators/remote/files/webpack-module-federation-ssr-ts/server.ts__tmpl__ +0 -45
  196. package/dist/src/generators/remote/files/webpack-module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +0 -19
  197. package/dist/src/generators/remote/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +0 -17
  198. package/dist/src/generators/remote/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +0 -16
  199. package/dist/src/generators/remote/files/webpack-module-federation-ts/tsconfig.lint.json__tmpl__ +0 -19
  200. package/dist/src/generators/remote/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__ +0 -1
  201. package/dist/src/generators/remote/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +0 -17
  202. package/dist/src/generators/remote/lib/add-remote-to-dynamic-host.d.ts +0 -2
  203. package/dist/src/generators/remote/lib/add-remote-to-dynamic-host.js +0 -12
  204. package/dist/src/generators/remote/lib/setup-package-json-exports-for-remote.d.ts +0 -3
  205. package/dist/src/generators/remote/lib/setup-package-json-exports-for-remote.js +0 -30
  206. package/dist/src/generators/remote/lib/setup-ssr-for-remote.d.ts +0 -4
  207. package/dist/src/generators/remote/lib/setup-ssr-for-remote.js +0 -61
  208. package/dist/src/generators/remote/lib/setup-tspath-for-remote.d.ts +0 -3
  209. package/dist/src/generators/remote/lib/setup-tspath-for-remote.js +0 -14
  210. package/dist/src/generators/remote/lib/update-host-with-remote.d.ts +0 -2
  211. package/dist/src/generators/remote/lib/update-host-with-remote.js +0 -79
  212. package/dist/src/generators/remote/remote.d.ts +0 -6
  213. package/dist/src/generators/remote/remote.js +0 -201
  214. package/dist/src/generators/remote/schema.d.ts +0 -39
  215. package/dist/src/generators/remote/schema.json +0 -173
  216. package/dist/src/generators/setup-ssr/files/server.ts__tmpl__ +0 -28
  217. package/dist/src/generators/setup-ssr/files/src/main.server.tsx__tmpl__ +0 -47
  218. package/dist/src/generators/setup-ssr/files/tsconfig.server.json__tmpl__ +0 -17
  219. package/dist/src/generators/setup-ssr/schema.d.ts +0 -8
  220. package/dist/src/generators/setup-ssr/schema.json +0 -54
  221. package/dist/src/generators/setup-ssr/setup-ssr.d.ts +0 -4
  222. package/dist/src/generators/setup-ssr/setup-ssr.js +0 -198
  223. package/dist/src/module-federation/ast-utils.d.ts +0 -8
  224. package/dist/src/module-federation/ast-utils.js +0 -101
  225. package/dist/src/rules/update-module-federation-project.d.ts +0 -11
  226. package/dist/src/rules/update-module-federation-project.js +0 -72
  227. package/dist/src/utils/add-mf-env-to-inputs.d.ts +0 -2
  228. package/dist/src/utils/add-mf-env-to-inputs.js +0 -29
  229. package/dist/src/utils/module-federation-deprecation.d.ts +0 -12
  230. package/dist/src/utils/module-federation-deprecation.js +0 -46
  231. package/dist/src/utils/normalize-remote.d.ts +0 -8
  232. package/dist/src/utils/normalize-remote.js +0 -31
@@ -1,29 +0,0 @@
1
- import { WebSsrDevServerOptions } from '@nx/webpack/internal';
2
- import { DevRemoteDefinition } from '@nx/module-federation/internal';
3
-
4
- export type ModuleFederationSsrDevServerOptions = WebSsrDevServerOptions & {
5
- devRemotes?: (
6
- | string
7
- | {
8
- remoteName: string;
9
- configuration: string;
10
- }
11
- )[];
12
-
13
- skipRemotes?: string[];
14
- host: string;
15
- pathToManifestFile?: string;
16
- staticRemotesPort?: number;
17
- parallel?: number;
18
- ssl?: boolean;
19
- sslKey?: string;
20
- sslCert?: string;
21
- isInitialHost?: boolean;
22
- verbose?: boolean;
23
- };
24
-
25
- export type NormalizedModuleFederationSsrDevServerOptions =
26
- ModuleFederationSsrDevServerOptions & {
27
- devRemotes: DevRemoteDefinition[];
28
- verbose: boolean;
29
- };
@@ -1,81 +0,0 @@
1
- {
2
- "version": 2,
3
- "continuous": true,
4
- "outputCapture": "direct-nodejs",
5
- "title": "Module Federation SSR Dev Server",
6
- "x-deprecated": "The `@nx/react:module-federation-ssr-dev-server` executor is deprecated. SSR is not first-classed in the new `@nx/react:consumer`/`@nx/react:provider` generators. Removed in Nx v24.",
7
- "description": "Serve a SSR Consumer (host) application along with its known Producers (remotes).",
8
- "cli": "nx",
9
- "type": "object",
10
- "properties": {
11
- "browserTarget": {
12
- "type": "string",
13
- "description": "Target which builds the browser application.",
14
- "x-priority": "important"
15
- },
16
- "serverTarget": {
17
- "type": "string",
18
- "description": "Target which builds the server application.",
19
- "x-priority": "important"
20
- },
21
- "port": {
22
- "type": "number",
23
- "description": "The port to be set on `process.env.PORT` for use in the server.",
24
- "default": 4200,
25
- "x-priority": "important"
26
- },
27
- "devRemotes": {
28
- "type": "array",
29
- "items": {
30
- "type": "string"
31
- },
32
- "description": "List of Producer (remote) applications to run in development mode (i.e. using serve target).",
33
- "x-priority": "important",
34
- "alias": "devProducers"
35
- },
36
- "skipRemotes": {
37
- "type": "array",
38
- "items": {
39
- "type": "string"
40
- },
41
- "description": "List of Producer (remote) applications to not automatically serve, either statically or in development mode.",
42
- "x-priority": "important",
43
- "alias": "skipProducers"
44
- },
45
- "host": {
46
- "type": "string",
47
- "description": "Host to listen on.",
48
- "default": "localhost"
49
- },
50
- "staticRemotesPort": {
51
- "type": "number",
52
- "description": "The port at which to serve the file-server for the static Producers (remotes).",
53
- "alias": "staticProducersPort"
54
- },
55
- "pathToManifestFile": {
56
- "type": "string",
57
- "description": "Path to a Module Federation manifest file (e.g. `my/path/to/module-federation.manifest.json`) containing the dynamic Producer (remote) applications relative to the workspace root."
58
- },
59
- "ssl": {
60
- "type": "boolean",
61
- "description": "Serve using HTTPS.",
62
- "default": false
63
- },
64
- "sslKey": {
65
- "type": "string",
66
- "description": "SSL key to use for serving HTTPS."
67
- },
68
- "sslCert": {
69
- "type": "string",
70
- "description": "SSL certificate to use for serving HTTPS."
71
- },
72
- "isInitialHost": {
73
- "type": "boolean",
74
- "description": "Whether the Consumer (host) that is running this executor is the first in the project tree to do so.",
75
- "default": true,
76
- "x-priority": "internal",
77
- "alias": "isInitialConsumer"
78
- }
79
- },
80
- "required": ["browserTarget", "serverTarget"]
81
- }
@@ -1,12 +0,0 @@
1
- import { ExecutorContext } from '@nx/devkit';
2
- import type { StaticRemotesConfig } from '@nx/module-federation/internal';
3
- import { ModuleFederationDevServerOptions } from '../module-federation-dev-server/schema';
4
- import { ModuleFederationStaticServerSchema } from './schema';
5
- export declare function startProxies(staticRemotesConfig: StaticRemotesConfig, hostServeOptions: ModuleFederationDevServerOptions, mappedLocationOfHost: string, mappedLocationsOfRemotes: Record<string, string>, sslOptions?: {
6
- pathToCert: string;
7
- pathToKey: string;
8
- }): void;
9
- export default function moduleFederationStaticServer(schema: ModuleFederationStaticServerSchema, context: ExecutorContext): AsyncGenerator<{
10
- success: boolean;
11
- baseUrl: string;
12
- }, any, any>;
@@ -1,244 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.startProxies = startProxies;
4
- exports.default = moduleFederationStaticServer;
5
- const internal_1 = require("@nx/devkit/internal");
6
- const devkit_1 = require("@nx/devkit");
7
- const internal_2 = require("@nx/js/internal");
8
- const internal_3 = require("@nx/web/internal");
9
- const assert_package_1 = require("../../utils/assert-package");
10
- const module_federation_deprecation_1 = require("../../utils/module-federation-deprecation");
11
- const child_process_1 = require("child_process");
12
- const fs_1 = require("fs");
13
- const path_1 = require("path");
14
- function getBuildAndServeOptionsFromServeTarget(serveTarget, context) {
15
- const target = (0, devkit_1.parseTargetString)(serveTarget, context);
16
- const serveOptions = (0, devkit_1.readTargetOptions)(target, context);
17
- const buildTarget = (0, devkit_1.parseTargetString)(serveOptions.buildTarget, context);
18
- const buildOptions = (0, devkit_1.readTargetOptions)(buildTarget, context);
19
- let pathToManifestFile = (0, path_1.join)(context.root, (0, internal_2.getProjectSourceRoot)(context.projectGraph.nodes[context.projectName].data), 'assets/module-federation.manifest.json');
20
- if (serveOptions.pathToManifestFile) {
21
- const userPathToManifestFile = (0, path_1.join)(context.root, serveOptions.pathToManifestFile);
22
- if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
23
- throw new Error(`The provided Module Federation manifest file path does not exist. Please check the file exists at "${userPathToManifestFile}".`);
24
- }
25
- else if ((0, path_1.extname)(serveOptions.pathToManifestFile) !== '.json') {
26
- throw new Error(`The Module Federation manifest file must be a JSON. Please ensure the file at ${userPathToManifestFile} is a JSON.`);
27
- }
28
- pathToManifestFile = userPathToManifestFile;
29
- }
30
- return {
31
- buildTarget,
32
- buildOptions,
33
- serveOptions,
34
- pathToManifestFile,
35
- };
36
- }
37
- async function buildHost(nxBin, buildTarget, context) {
38
- await new Promise((res, rej) => {
39
- const staticProcess = (0, child_process_1.fork)(nxBin, [
40
- `run`,
41
- `${buildTarget.project}:${buildTarget.target}${buildTarget.configuration
42
- ? `:${buildTarget.configuration}`
43
- : context.configurationName
44
- ? `:${context.configurationName}`
45
- : ''}`,
46
- ], {
47
- cwd: context.root,
48
- stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
49
- });
50
- staticProcess.stdout.on('data', (data) => {
51
- const ANSII_CODE_REGEX = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
52
- const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
53
- // in addition to writing into the stdout stream, also show error directly in console
54
- // so the error is easily discoverable. 'ERROR in' is the key word to search in webpack output.
55
- if (stdoutString.includes('ERROR in')) {
56
- devkit_1.logger.log(stdoutString);
57
- }
58
- if (stdoutString.includes('Successfully ran target build')) {
59
- staticProcess.stdout.removeAllListeners('data');
60
- devkit_1.logger.info(`NX Built Consumer (host)`);
61
- res();
62
- }
63
- });
64
- staticProcess.stderr.on('data', (data) => devkit_1.logger.info(data.toString()));
65
- staticProcess.once('exit', (code) => {
66
- staticProcess.stdout.removeAllListeners('data');
67
- staticProcess.stderr.removeAllListeners('data');
68
- if (code !== 0) {
69
- rej(`Consumer (host) failed to build. See above for details.`);
70
- }
71
- else {
72
- res();
73
- }
74
- });
75
- process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
76
- process.on('exit', () => staticProcess.kill('SIGTERM'));
77
- });
78
- }
79
- function moveToTmpDirectory(staticRemotesConfig, hostOutputPath, hostUrlSegment) {
80
- const commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-module-federation');
81
- for (const app of staticRemotesConfig.remotes) {
82
- const remoteConfig = staticRemotesConfig.config[app];
83
- (0, fs_1.cpSync)(remoteConfig.outputPath, (0, path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
84
- force: true,
85
- recursive: true,
86
- });
87
- }
88
- (0, fs_1.cpSync)(hostOutputPath, (0, path_1.join)(commonOutputDirectory, hostUrlSegment), {
89
- force: true,
90
- recursive: true,
91
- });
92
- const cleanup = () => {
93
- (0, fs_1.rmSync)(commonOutputDirectory, { force: true, recursive: true });
94
- };
95
- process.on('SIGTERM', () => {
96
- cleanup();
97
- });
98
- process.on('exit', () => {
99
- cleanup();
100
- });
101
- return commonOutputDirectory;
102
- }
103
- function startProxies(staticRemotesConfig, hostServeOptions, mappedLocationOfHost, mappedLocationsOfRemotes, sslOptions) {
104
- const { createProxyMiddleware } = require('http-proxy-middleware');
105
- const express = require('express');
106
- let sslCert;
107
- let sslKey;
108
- if (sslOptions && sslOptions.pathToCert && sslOptions.pathToKey) {
109
- if ((0, fs_1.existsSync)(sslOptions.pathToCert) && (0, fs_1.existsSync)(sslOptions.pathToKey)) {
110
- sslCert = (0, fs_1.readFileSync)(sslOptions.pathToCert);
111
- sslKey = (0, fs_1.readFileSync)(sslOptions.pathToKey);
112
- }
113
- else {
114
- devkit_1.logger.warn(`Encountered SSL options in project.json, however, the certificate files do not exist in the filesystem. Using http.`);
115
- devkit_1.logger.warn(`Attempted to find '${sslOptions.pathToCert}' and '${sslOptions.pathToKey}'.`);
116
- }
117
- }
118
- const http = require('http');
119
- const https = require('https');
120
- devkit_1.logger.info(`NX Starting static remotes proxies...`);
121
- for (const app of staticRemotesConfig.remotes) {
122
- const expressProxy = express();
123
- expressProxy.use(createProxyMiddleware({
124
- target: mappedLocationsOfRemotes[app],
125
- changeOrigin: true,
126
- secure: sslCert ? false : undefined,
127
- }));
128
- const proxyServer = (sslCert ? https : http)
129
- .createServer({ cert: sslCert, key: sslKey }, expressProxy)
130
- .listen(staticRemotesConfig.config[app].port);
131
- process.on('SIGTERM', () => proxyServer.close());
132
- process.on('exit', () => proxyServer.close());
133
- }
134
- devkit_1.logger.info(`NX Static Producers (remotes) proxies started successfully`);
135
- devkit_1.logger.info(`NX Starting static Consumer (host) proxy...`);
136
- const expressProxy = express();
137
- expressProxy.use(createProxyMiddleware({
138
- target: mappedLocationOfHost,
139
- changeOrigin: true,
140
- secure: sslCert ? false : undefined,
141
- pathRewrite: (path) => {
142
- let pathRewrite = path;
143
- for (const app of staticRemotesConfig.remotes) {
144
- if (path.endsWith(app)) {
145
- pathRewrite = '/';
146
- break;
147
- }
148
- }
149
- return pathRewrite;
150
- },
151
- }));
152
- const proxyServer = (sslCert ? https : http)
153
- .createServer({ cert: sslCert, key: sslKey }, expressProxy)
154
- .listen(hostServeOptions.port);
155
- process.on('SIGTERM', () => proxyServer.close());
156
- process.on('exit', () => proxyServer.close());
157
- devkit_1.logger.info('NX Static Consumer (host) proxy started successfully');
158
- }
159
- async function* moduleFederationStaticServer(schema, context) {
160
- const executorName = '@nx/react:module-federation-static-server';
161
- (0, assert_package_1.assertPackageIsInstalled)('@nx/module-federation', executorName);
162
- (0, assert_package_1.assertPackageIsInstalled)('express', executorName);
163
- (0, assert_package_1.assertPackageIsInstalled)('http-proxy-middleware', executorName);
164
- const { buildStaticRemotes, getModuleFederationConfig, getRemotes, parseStaticRemotesConfig, } = await import('@nx/module-federation/internal');
165
- (0, module_federation_deprecation_1.warnReactMfStaticServerExecutorDeprecation)();
166
- // Force Node to resolve to look for the nx binary that is inside node_modules
167
- const nxBin = require.resolve('nx/bin/nx');
168
- // Get the remotes from the module federation config
169
- const p = context.projectsConfigurations.projects[context.projectName];
170
- const options = getBuildAndServeOptionsFromServeTarget(schema.serveTarget, context);
171
- const moduleFederationConfig = getModuleFederationConfig(options.buildOptions.tsConfig, context.root, p.root, 'react');
172
- const remotes = getRemotes([], options.serveOptions.skipRemotes, moduleFederationConfig, {
173
- projectName: context.projectName,
174
- projectGraph: context.projectGraph,
175
- root: context.root,
176
- }, options.pathToManifestFile);
177
- const staticRemotesConfig = parseStaticRemotesConfig([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
178
- options.serveOptions.staticRemotesPort ??= remotes.staticRemotePort;
179
- const mappedLocationsOfStaticRemotes = await buildStaticRemotes(staticRemotesConfig, nxBin, context, options.serveOptions);
180
- // Build the host
181
- const hostUrlSegment = (0, path_1.basename)(options.buildOptions.outputPath);
182
- const mappedLocationOfHost = `http${options.serveOptions.ssl ? 's' : ''}://${options.serveOptions.host}:${options.serveOptions.staticRemotesPort}/${hostUrlSegment}`;
183
- await buildHost(nxBin, options.buildTarget, context);
184
- // Move to a temporary directory
185
- const commonOutputDirectory = moveToTmpDirectory(staticRemotesConfig, options.buildOptions.outputPath, hostUrlSegment);
186
- // File Serve the temporary directory
187
- const staticFileServerIter = (0, internal_3.fileServerExecutor)({
188
- cors: true,
189
- watch: false,
190
- staticFilePath: commonOutputDirectory,
191
- parallel: false,
192
- spa: false,
193
- withDeps: false,
194
- host: options.serveOptions.host,
195
- port: options.serveOptions.staticRemotesPort,
196
- ssl: options.serveOptions.ssl,
197
- sslCert: options.serveOptions.sslCert,
198
- sslKey: options.serveOptions.sslKey,
199
- cacheSeconds: -1,
200
- }, context);
201
- // express proxy all of it
202
- startProxies(staticRemotesConfig, options.serveOptions, mappedLocationOfHost, mappedLocationsOfStaticRemotes, options.serveOptions.ssl
203
- ? {
204
- pathToCert: (0, path_1.join)(devkit_1.workspaceRoot, options.serveOptions.sslCert),
205
- pathToKey: (0, path_1.join)(devkit_1.workspaceRoot, options.serveOptions.sslKey),
206
- }
207
- : undefined);
208
- return yield* (0, internal_1.combineAsyncIterables)(staticFileServerIter, (0, internal_1.createAsyncIterable)(async ({ next, done }) => {
209
- const host = options.serveOptions.host ?? 'localhost';
210
- const baseUrl = `http${options.serveOptions.ssl ? 's' : ''}://${host}:${options.serveOptions.port}`;
211
- if (remotes.remotePorts.length === 0) {
212
- const portsToWaitFor = [options.serveOptions.staticRemotesPort];
213
- await Promise.all(portsToWaitFor.map((port) => (0, internal_3.waitForPortOpen)(port, {
214
- retries: 480,
215
- retryDelay: 2500,
216
- host: host,
217
- })));
218
- devkit_1.logger.info(`NX Server ready at ${baseUrl}`);
219
- next({ success: true, baseUrl: baseUrl });
220
- done();
221
- return;
222
- }
223
- try {
224
- const portsToWaitFor = staticFileServerIter && options.serveOptions.staticRemotesPort
225
- ? [options.serveOptions.staticRemotesPort, ...remotes.remotePorts]
226
- : [...remotes.remotePorts];
227
- await Promise.all(portsToWaitFor.map((port) => (0, internal_3.waitForPortOpen)(port, {
228
- retries: 480,
229
- retryDelay: 2500,
230
- host: host,
231
- })));
232
- devkit_1.logger.info(`NX Server ready at ${baseUrl}`);
233
- next({ success: true, baseUrl: baseUrl });
234
- }
235
- catch (err) {
236
- throw new Error(`Failed to start. Check above for any errors.`, {
237
- cause: err,
238
- });
239
- }
240
- finally {
241
- done();
242
- }
243
- }));
244
- }
@@ -1,3 +0,0 @@
1
- export interface ModuleFederationStaticServerSchema {
2
- serveTarget: string;
3
- }
@@ -1,16 +0,0 @@
1
- {
2
- "version": 2,
3
- "continuous": true,
4
- "outputCapture": "direct-nodejs",
5
- "title": "Module Federation Static Dev Server",
6
- "x-deprecated": "The `@nx/react:module-federation-static-server` executor is deprecated. Use `vite preview` / `rsbuild preview` via `nx:run-commands` instead. Removed in Nx v24.",
7
- "description": "Serve a Consumer (host) application statically along with its Producers (remotes).",
8
- "cli": "nx",
9
- "type": "object",
10
- "properties": {
11
- "serveTarget": {
12
- "type": "string"
13
- }
14
- },
15
- "required": ["serveTarget"]
16
- }
@@ -1,4 +0,0 @@
1
- import { GeneratorCallback, Tree } from '@nx/devkit';
2
- import { Schema } from './schema';
3
- export declare function federateModuleGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
4
- export default federateModuleGenerator;
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.federateModuleGenerator = federateModuleGenerator;
4
- const internal_1 = require("@nx/devkit/internal");
5
- const assert_supported_react_version_1 = require("../../utils/assert-supported-react-version");
6
- const devkit_1 = require("@nx/devkit");
7
- const remote_1 = require("../remote/remote");
8
- const utils_1 = require("./lib/utils");
9
- const js_1 = require("@nx/js");
10
- const module_federation_deprecation_1 = require("../../utils/module-federation-deprecation");
11
- async function federateModuleGenerator(tree, schema) {
12
- (0, assert_supported_react_version_1.assertSupportedReactVersion)(tree);
13
- (0, module_federation_deprecation_1.warnReactFederateModuleGeneratorDeprecation)();
14
- // Check if the file exists
15
- if (!tree.exists(schema.path)) {
16
- throw new Error((0, devkit_1.stripIndents) `The "path" provided does not exist. Please verify the path is correct and pointing to a file that exists in the workspace.
17
-
18
- Path: ${schema.path}`);
19
- }
20
- const tasks = [];
21
- const { projectName: remoteName, projectRoot: remoteRoot } = await (0, internal_1.determineProjectNameAndRootOptions)(tree, {
22
- name: schema.remote,
23
- directory: schema.remoteDirectory,
24
- projectType: 'application',
25
- });
26
- // Check remote exists
27
- const remote = (0, utils_1.checkRemoteExists)(tree, remoteName);
28
- if (!remote) {
29
- // create remote
30
- const remoteGeneratorTask = await (0, remote_1.remoteGenerator)(tree, {
31
- name: remoteName,
32
- directory: remoteRoot,
33
- e2eTestRunner: schema.e2eTestRunner,
34
- skipFormat: schema.skipFormat,
35
- linter: schema.linter,
36
- style: schema.style,
37
- unitTestRunner: schema.unitTestRunner,
38
- host: schema.host,
39
- bundler: schema.bundler ?? 'rspack',
40
- });
41
- tasks.push(remoteGeneratorTask);
42
- }
43
- // add path to exposes property
44
- const normalizedModulePath = schema.bundler === 'rspack'
45
- ? (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(remoteRoot), schema.path)
46
- : schema.path;
47
- (0, utils_1.addPathToExposes)(tree, remoteRoot, schema.name, normalizedModulePath);
48
- // Add new path to tsconfig
49
- const rootJSON = (0, devkit_1.readJson)(tree, (0, js_1.getRootTsConfigPathInTree)(tree));
50
- if (!rootJSON?.compilerOptions?.paths[`${remoteName}/${schema.name}`]) {
51
- (0, js_1.addTsConfigPath)(tree, `${remoteName}/${schema.name}`, [schema.path]);
52
- }
53
- if (!schema.skipFormat) {
54
- await (0, devkit_1.formatFiles)(tree);
55
- }
56
- devkit_1.logger.info(`✅️ Updated module federation config.
57
- Now you can use the module from your host app like this:
58
-
59
- Static import:
60
- import { MyComponent } from '${remoteName}/${schema.name}';
61
-
62
- Dynamic import:
63
- import('${remoteName}/${schema.name}').then((m) => m.${schema.name});
64
- `);
65
- return (0, devkit_1.runTasksInSerial)(...tasks);
66
- }
67
- exports.default = federateModuleGenerator;
@@ -1,23 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- import type { SourceFile, ObjectLiteralExpression, PropertyAssignment } from 'typescript';
3
- /**
4
- * Adds a Module Federation path to the exposes property of the module federation config
5
- * The assumption here is made the we will only update a TypeScript Module Federation file namely 'module-federation.config.js'
6
- * @param tree Tree for the workspace
7
- * @param projectPath Project path relative to the workspace
8
- * @param moduleName The name of the module to expose
9
- * @param modulePath The path to the module to expose (e.g. './src/my-lib/my-lib.ts')
10
- */
11
- export declare function addPathToExposes(tree: Tree, projectPath: string, moduleName: string, modulePath: string): void;
12
- /**
13
- * @param tree The workspace tree
14
- * @param remoteName The name of the remote to check
15
- * @returns Remote ProjectConfig if it exists, false otherwise
16
- */
17
- export declare function checkRemoteExists(tree: Tree, remoteName: string): false | import("@nx/devkit").ProjectConfiguration;
18
- export declare function getRemote(tree: Tree, remoteName: string): import("@nx/devkit").ProjectConfiguration;
19
- export declare function findExposes(sourceFile: SourceFile): ObjectLiteralExpression;
20
- export declare function createObjectEntry(moduleName: string, modulePath: string): PropertyAssignment;
21
- export declare function updateExposesPropertyinAST(source: SourceFile, exposesObject: ObjectLiteralExpression, newEntry: PropertyAssignment): SourceFile;
22
- export declare function writeToConfig(tree: Tree, filename: string, source: SourceFile, updatedSourceFile: SourceFile): void;
23
- export declare function updateExposesProperty(tree: Tree, filename: string, moduleName: string, modulePath: string): void;
@@ -1,99 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addPathToExposes = addPathToExposes;
4
- exports.checkRemoteExists = checkRemoteExists;
5
- exports.getRemote = getRemote;
6
- exports.findExposes = findExposes;
7
- exports.createObjectEntry = createObjectEntry;
8
- exports.updateExposesPropertyinAST = updateExposesPropertyinAST;
9
- exports.writeToConfig = writeToConfig;
10
- exports.updateExposesProperty = updateExposesProperty;
11
- const devkit_1 = require("@nx/devkit");
12
- const internal_1 = require("@nx/js/internal");
13
- let tsModule;
14
- if (!tsModule) {
15
- tsModule = (0, internal_1.ensureTypescript)();
16
- }
17
- /**
18
- * Adds a Module Federation path to the exposes property of the module federation config
19
- * The assumption here is made the we will only update a TypeScript Module Federation file namely 'module-federation.config.js'
20
- * @param tree Tree for the workspace
21
- * @param projectPath Project path relative to the workspace
22
- * @param moduleName The name of the module to expose
23
- * @param modulePath The path to the module to expose (e.g. './src/my-lib/my-lib.ts')
24
- */
25
- function addPathToExposes(tree, projectPath, moduleName, modulePath) {
26
- const moduleFederationConfigPath = (0, devkit_1.joinPathFragments)(projectPath, tree.exists((0, devkit_1.joinPathFragments)(projectPath, 'module-federation.config.ts'))
27
- ? 'module-federation.config.ts'
28
- : 'module-federation.config.js');
29
- updateExposesProperty(tree, moduleFederationConfigPath, moduleName, modulePath);
30
- }
31
- /**
32
- * @param tree The workspace tree
33
- * @param remoteName The name of the remote to check
34
- * @returns Remote ProjectConfig if it exists, false otherwise
35
- */
36
- function checkRemoteExists(tree, remoteName) {
37
- const remote = getRemote(tree, remoteName);
38
- if (!remote)
39
- return false;
40
- const hasModuleFederationConfig = tree.exists((0, devkit_1.joinPathFragments)(remote.root, 'module-federation.config.js')) ||
41
- tree.exists((0, devkit_1.joinPathFragments)(remote.root, 'module-federation.config.ts'));
42
- return hasModuleFederationConfig ? remote : false;
43
- }
44
- function getRemote(tree, remoteName) {
45
- const projects = (0, devkit_1.getProjects)(tree);
46
- const remote = projects.get(remoteName);
47
- return remote;
48
- }
49
- // Check if the exposes property exists in the AST
50
- function findExposes(sourceFile) {
51
- let exposesObject = null;
52
- const visit = (node) => {
53
- if (tsModule.isPropertyAssignment(node) &&
54
- tsModule.isIdentifier(node.name) &&
55
- node.name.text === 'exposes' &&
56
- tsModule.isObjectLiteralExpression(node.initializer)) {
57
- exposesObject = node.initializer;
58
- }
59
- else {
60
- tsModule.forEachChild(node, visit);
61
- }
62
- };
63
- tsModule.forEachChild(sourceFile, visit);
64
- return exposesObject;
65
- }
66
- // Create a new property assignment
67
- function createObjectEntry(moduleName, modulePath) {
68
- return tsModule.factory.createPropertyAssignment(tsModule.factory.createStringLiteral(`./${moduleName}`, true), tsModule.factory.createStringLiteral(modulePath, true));
69
- }
70
- // Update the exposes property in the AST
71
- function updateExposesPropertyinAST(source, exposesObject, newEntry) {
72
- const updatedExposes = tsModule.factory.updateObjectLiteralExpression(exposesObject, [...exposesObject.properties, newEntry]);
73
- const transform = (context) => {
74
- const visit = (node) => {
75
- // Comparing nodes indirectly to ensure type compatibility. You must ensure that the nodes are identical.
76
- return tsModule.isObjectLiteralExpression(node) && node === exposesObject
77
- ? updatedExposes
78
- : tsModule.visitEachChild(node, visit, context);
79
- };
80
- return (node) => tsModule.visitNode(node, visit);
81
- };
82
- return tsModule.transform(source, [transform]).transformed[0];
83
- }
84
- // Write the updated AST to the file (module-federation.config.js)
85
- function writeToConfig(tree, filename, source, updatedSourceFile) {
86
- const printer = tsModule.createPrinter();
87
- const update = printer.printNode(tsModule.EmitHint.Unspecified, updatedSourceFile, source);
88
- tree.write(filename, update);
89
- }
90
- function updateExposesProperty(tree, filename, moduleName, modulePath) {
91
- const fileContent = tree.read(filename).toString();
92
- const source = tsModule.createSourceFile(filename, fileContent, tsModule.ScriptTarget.ES2015, true);
93
- const exposesObject = findExposes(source);
94
- if (!exposesObject)
95
- return;
96
- const newEntry = createObjectEntry(moduleName, modulePath);
97
- const updatedSourceFile = updateExposesPropertyinAST(source, exposesObject, newEntry);
98
- writeToConfig(tree, filename, source, updatedSourceFile);
99
- }
@@ -1,15 +0,0 @@
1
- import { LinterType } from '@nx/js';
2
-
3
- export interface Schema {
4
- name: string;
5
- path: string;
6
- remote: string;
7
- remoteDirectory?: string;
8
- e2eTestRunner?: 'cypress' | 'playwright' | 'none';
9
- host?: string;
10
- linter?: LinterType;
11
- skipFormat?: boolean;
12
- style?: SupportedStyles;
13
- unitTestRunner?: 'jest' | 'vitest' | 'none';
14
- bundler?: 'rspack' | 'webpack';
15
- }