@nx/react 0.0.0-pr-31222-862e973 → 0.0.0-pr-31313-387cdca

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 (306) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/generators.json +9 -13
  4. package/index.d.ts +1 -2
  5. package/index.js +2 -5
  6. package/mf/dynamic-federation.d.ts +64 -0
  7. package/mf/dynamic-federation.js +64 -0
  8. package/migrations.json +80 -148
  9. package/module-federation.d.ts +6 -4
  10. package/module-federation.js +16 -7
  11. package/package.json +11 -11
  12. package/plugins/bundle-rollup.js +4 -1
  13. package/plugins/component-testing/index.js +1 -1
  14. package/plugins/jest.js +6 -11
  15. package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +6 -22
  16. package/plugins/storybook/index.js +1 -2
  17. package/plugins/with-react.d.ts +4 -0
  18. package/router-plugin.d.ts +1 -0
  19. package/router-plugin.js +5 -0
  20. package/src/executors/module-federation-dev-server/lib/index.d.ts +2 -0
  21. package/src/executors/module-federation-dev-server/lib/index.js +5 -0
  22. package/src/executors/module-federation-dev-server/lib/normalize-options.d.ts +4 -0
  23. package/src/executors/module-federation-dev-server/lib/normalize-options.js +19 -0
  24. package/src/executors/module-federation-dev-server/lib/start-remotes.d.ts +5 -0
  25. package/src/executors/module-federation-dev-server/lib/start-remotes.js +33 -0
  26. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +1 -1
  27. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +6 -110
  28. package/src/executors/module-federation-dev-server/schema.d.ts +9 -7
  29. package/src/executors/module-federation-dev-server/schema.json +15 -10
  30. package/src/executors/module-federation-ssr-dev-server/lib/index.d.ts +2 -0
  31. package/src/executors/module-federation-ssr-dev-server/lib/index.js +5 -0
  32. package/src/executors/module-federation-ssr-dev-server/lib/normalize-options.d.ts +4 -0
  33. package/src/executors/module-federation-ssr-dev-server/lib/normalize-options.js +23 -0
  34. package/src/executors/module-federation-ssr-dev-server/lib/start-remotes.d.ts +5 -0
  35. package/src/executors/module-federation-ssr-dev-server/lib/start-remotes.js +34 -0
  36. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +1 -17
  37. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +5 -153
  38. package/src/executors/module-federation-ssr-dev-server/schema.d.ts +29 -0
  39. package/src/executors/module-federation-ssr-dev-server/schema.json +14 -9
  40. package/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts +2 -2
  41. package/src/executors/module-federation-static-server/module-federation-static-server.impl.js +11 -12
  42. package/src/executors/module-federation-static-server/schema.json +2 -1
  43. package/src/generators/application/application.d.ts +3 -3
  44. package/src/generators/application/application.js +108 -186
  45. package/src/generators/application/files/base-rsbuild/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
  46. package/src/generators/application/files/base-rsbuild/src/assets/.gitkeep +0 -0
  47. package/src/generators/application/files/base-rsbuild/src/favicon.ico +0 -0
  48. package/src/generators/application/files/base-rsbuild/src/index.html +14 -0
  49. package/src/generators/application/files/base-rsbuild/src/main.tsx__tmpl__ +32 -0
  50. package/src/generators/application/files/base-rsbuild/tsconfig.app.json__tmpl__ +31 -0
  51. package/src/generators/application/files/base-rspack/rspack.config.js__tmpl__ +53 -0
  52. package/src/generators/application/files/base-rspack/src/app/__fileName__.spec.tsx__tmpl__ +3 -3
  53. package/src/generators/application/files/base-rspack/src/main.tsx__tmpl__ +27 -5
  54. package/src/generators/application/files/base-rspack/tsconfig.app.json__tmpl__ +21 -4
  55. package/src/generators/application/files/base-vite/src/app/__fileName__.spec.tsx__tmpl__ +3 -3
  56. package/src/generators/application/files/base-vite/src/main.tsx__tmpl__ +31 -6
  57. package/src/generators/application/files/base-vite/tsconfig.app.json__tmpl__ +20 -3
  58. package/src/generators/application/files/base-webpack/src/app/__fileName__.spec.tsx__tmpl__ +3 -3
  59. package/src/generators/application/files/base-webpack/src/main.tsx__tmpl__ +22 -2
  60. package/src/generators/application/files/base-webpack/tsconfig.app.json__tmpl__ +21 -4
  61. package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +4 -4
  62. package/src/generators/application/files/react-router-ssr/common/app/app-nav.tsx__tmpl__ +14 -0
  63. package/src/generators/application/files/react-router-ssr/common/app/entry.client.tsx__tmpl__ +18 -0
  64. package/src/generators/application/files/react-router-ssr/common/app/entry.server.tsx__tmpl__ +74 -0
  65. package/src/generators/application/files/react-router-ssr/common/app/root.tsx__tmpl__ +51 -0
  66. package/src/generators/application/files/react-router-ssr/common/app/routes/about.tsx__tmpl__ +7 -0
  67. package/src/generators/application/files/react-router-ssr/common/app/routes.tsx__tmpl__ +6 -0
  68. package/src/generators/application/files/react-router-ssr/common/public/favicon.ico +0 -0
  69. package/src/generators/application/files/react-router-ssr/common/react-router.config.ts__tmpl__ +5 -0
  70. package/src/generators/application/files/react-router-ssr/common/tests/routes/_index.spec.tsx__tmpl__ +16 -0
  71. package/src/generators/application/files/react-router-ssr/common/tsconfig.app.json__tmpl__ +23 -0
  72. package/src/generators/application/files/react-router-ssr/common/tsconfig.json__tmpl__ +27 -0
  73. package/src/generators/application/files/react-router-ssr/non-root/.gitignore__tmpl__ +5 -0
  74. package/src/generators/application/files/react-router-ssr/non-root/package.json__tmpl__ +21 -0
  75. package/src/generators/application/files/react-router-ssr/nx-welcome/claimed/app/nx-welcome.tsx__tmpl__ +866 -0
  76. package/src/generators/application/files/react-router-ssr/nx-welcome/not-configured/app/nx-welcome.tsx__tmpl__ +866 -0
  77. package/src/generators/application/files/react-router-ssr/nx-welcome/unclaimed/app/nx-welcome.tsx__tmpl__ +864 -0
  78. package/src/generators/application/files/react-router-ssr/ts-solution/package.json__tmpl__ +21 -0
  79. package/src/generators/application/files/react-router-ssr/ts-solution/tsconfig.app.json__tmpl__ +39 -0
  80. package/src/generators/application/files/style-css-module/src/app/__fileName__.tsx__tmpl__ +28 -18
  81. package/src/generators/application/files/style-global-css/src/app/__fileName__.tsx__tmpl__ +29 -20
  82. package/src/generators/application/files/style-none/src/app/__fileName__.tsx__tmpl__ +26 -16
  83. package/src/generators/application/files/style-styled-jsx/src/app/__fileName__.tsx__tmpl__ +31 -22
  84. package/src/generators/application/files/style-styled-module/src/app/__fileName__.tsx__tmpl__ +30 -21
  85. package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +29 -19
  86. package/src/generators/application/lib/add-e2e.d.ts +1 -1
  87. package/src/generators/application/lib/add-e2e.js +74 -65
  88. package/src/generators/application/lib/add-jest.js +27 -2
  89. package/src/generators/application/lib/add-linting.d.ts +4 -0
  90. package/src/generators/application/lib/add-linting.js +86 -0
  91. package/src/generators/application/lib/add-project.js +112 -6
  92. package/src/generators/application/lib/add-routing.js +1 -1
  93. package/src/generators/application/lib/bundlers/add-rsbuild.d.ts +4 -0
  94. package/src/generators/application/lib/bundlers/add-rsbuild.js +63 -0
  95. package/src/generators/application/lib/bundlers/add-rspack.d.ts +4 -0
  96. package/src/generators/application/lib/bundlers/add-rspack.js +37 -0
  97. package/src/generators/application/lib/bundlers/add-vite.d.ts +4 -0
  98. package/src/generators/application/lib/bundlers/add-vite.js +76 -0
  99. package/src/generators/application/lib/bundlers/add-webpack.d.ts +3 -0
  100. package/src/generators/application/lib/bundlers/add-webpack.js +18 -0
  101. package/src/generators/application/lib/create-application-files.d.ts +61 -0
  102. package/src/generators/application/lib/create-application-files.js +102 -19
  103. package/src/generators/application/lib/get-app-tests.js +10 -11
  104. package/src/generators/application/lib/install-common-dependencies.d.ts +1 -1
  105. package/src/generators/application/lib/install-common-dependencies.js +18 -4
  106. package/src/generators/application/lib/normalize-options.d.ts +1 -3
  107. package/src/generators/application/lib/normalize-options.js +17 -19
  108. package/src/generators/application/lib/update-jest-config.js +5 -0
  109. package/src/generators/application/schema.d.ts +12 -6
  110. package/src/generators/application/schema.json +44 -42
  111. package/src/generators/component/component.d.ts +0 -1
  112. package/src/generators/component/component.js +19 -37
  113. package/src/generators/component/files/__fileName__.__ext__ +83 -0
  114. package/src/generators/component/lib/normalize-options.js +13 -15
  115. package/src/generators/component/schema.d.ts +13 -25
  116. package/src/generators/component/schema.json +13 -49
  117. package/src/generators/component-story/component-story.js +1 -2
  118. package/src/generators/component-story/files/jsx/__componentFileName__.stories.jsx__tmpl__ +5 -5
  119. package/src/generators/component-story/files/tsx/__componentFileName__.stories.tsx__tmpl__ +3 -4
  120. package/src/generators/component-test/component-test.js +1 -1
  121. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +0 -2
  122. package/src/generators/cypress-component-configuration/lib/add-files.d.ts +1 -1
  123. package/src/generators/cypress-component-configuration/lib/add-files.js +7 -4
  124. package/src/generators/federate-module/federate-module.js +12 -22
  125. package/src/generators/federate-module/schema.d.ts +0 -1
  126. package/src/generators/federate-module/schema.json +13 -12
  127. package/src/generators/hook/files/{__fileName__.ts__tmpl__ → __fileName__.__ext__} +3 -1
  128. package/src/generators/hook/hook.d.ts +0 -1
  129. package/src/generators/hook/hook.js +35 -83
  130. package/src/generators/hook/schema.d.ts +4 -17
  131. package/src/generators/hook/schema.json +19 -46
  132. package/src/generators/host/files/common/src/app/__fileName__.js__tmpl__ +28 -21
  133. package/src/generators/host/files/common/src/main.js__tmpl__ +12 -9
  134. package/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +28 -28
  135. package/src/generators/host/files/common-ts/src/main.ts__tmpl__ +12 -9
  136. package/src/generators/host/files/rspack-common/src/app/__fileName__.jsx__tmpl__ +22 -13
  137. package/src/generators/host/files/rspack-common/src/main.jsx__tmpl__ +12 -9
  138. package/src/generators/host/files/rspack-module-federation/module-federation.config.js__tmpl__ +8 -5
  139. package/src/generators/host/files/rspack-module-federation/rspack.config.js__tmpl__ +37 -13
  140. package/src/generators/host/files/rspack-module-federation/rspack.config.prod.js__tmpl__ +60 -30
  141. package/src/generators/host/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +16 -5
  142. package/src/generators/host/files/rspack-module-federation-ssr/rspack.config.js__tmpl__ +66 -0
  143. package/src/generators/host/files/rspack-module-federation-ssr/server.ts__tmpl__ +1 -1
  144. package/src/generators/host/files/rspack-module-federation-ssr/src/main.server.tsx__tmpl__ +49 -0
  145. package/src/generators/host/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +16 -7
  146. package/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +66 -0
  147. package/src/generators/host/files/rspack-module-federation-ssr-ts/server.ts__tmpl__ +1 -1
  148. package/src/generators/host/files/rspack-module-federation-ssr-ts/src/main.server.tsx__tmpl__ +49 -0
  149. package/src/generators/host/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +22 -19
  150. package/src/generators/host/files/rspack-module-federation-ts/rspack.config.prod.ts__tmpl__ +61 -30
  151. package/src/generators/host/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +37 -13
  152. package/src/generators/host/files/webpack-module-federation/module-federation.config.js__tmpl__ +8 -5
  153. package/src/generators/host/files/webpack-module-federation/webpack.config.js__tmpl__ +1 -1
  154. package/src/generators/host/files/webpack-module-federation/webpack.config.prod.js__tmpl__ +24 -22
  155. package/src/generators/host/files/webpack-module-federation-ssr/module-federation.server.config.js__tmpl__ +10 -7
  156. package/src/generators/host/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +2 -2
  157. package/src/generators/host/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +10 -7
  158. package/src/generators/host/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +2 -2
  159. package/src/generators/host/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +22 -19
  160. package/src/generators/host/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__ +25 -23
  161. package/src/generators/host/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +4 -3
  162. package/src/generators/host/host.d.ts +0 -1
  163. package/src/generators/host/host.js +31 -27
  164. package/src/generators/host/lib/add-module-federation-files.js +29 -13
  165. package/src/generators/host/lib/normalize-host-name.d.ts +2 -0
  166. package/src/generators/host/lib/normalize-host-name.js +12 -0
  167. package/src/generators/host/lib/normalize-remote.js +10 -6
  168. package/src/generators/host/lib/setup-ssr-for-host.d.ts +3 -3
  169. package/src/generators/host/lib/setup-ssr-for-host.js +46 -22
  170. package/src/generators/host/lib/update-module-federation-tsconfig.d.ts +3 -0
  171. package/src/generators/host/lib/update-module-federation-tsconfig.js +39 -0
  172. package/src/generators/host/schema.d.ts +2 -5
  173. package/src/generators/host/schema.json +16 -27
  174. package/src/generators/init/init.d.ts +1 -1
  175. package/src/generators/init/init.js +31 -6
  176. package/src/generators/init/schema.d.ts +2 -0
  177. package/src/generators/library/files/common/tsconfig.lib.json__tmpl__ +1 -1
  178. package/src/generators/library/files/vite/tsconfig.lib.json__tmpl__ +1 -1
  179. package/src/generators/library/lib/add-linting.js +1 -1
  180. package/src/generators/library/lib/add-rollup-build-target.d.ts +3 -1
  181. package/src/generators/library/lib/add-rollup-build-target.js +34 -32
  182. package/src/generators/library/lib/create-files.d.ts +1 -1
  183. package/src/generators/library/lib/create-files.js +23 -2
  184. package/src/generators/library/lib/determine-entry-fields.d.ts +3 -0
  185. package/src/generators/library/lib/determine-entry-fields.js +22 -0
  186. package/src/generators/library/lib/install-common-dependencies.d.ts +1 -1
  187. package/src/generators/library/lib/install-common-dependencies.js +5 -3
  188. package/src/generators/library/lib/normalize-options.js +11 -6
  189. package/src/generators/library/library.js +80 -35
  190. package/src/generators/library/schema.d.ts +5 -5
  191. package/src/generators/library/schema.json +38 -36
  192. package/src/generators/redux/files/js/__fileName__.__ext__ +114 -0
  193. package/src/generators/redux/files/{__fileName__.slice.spec.ts__tmpl__ → js/__fileName__.spec.__ext__} +1 -1
  194. package/src/generators/redux/files/ts/__fileName__.spec.__ext__ +56 -0
  195. package/src/generators/redux/redux.d.ts +0 -1
  196. package/src/generators/redux/redux.js +27 -36
  197. package/src/generators/redux/schema.d.ts +12 -8
  198. package/src/generators/redux/schema.json +21 -23
  199. package/src/generators/remote/files/rspack-module-federation/module-federation.config.js__tmpl__ +10 -7
  200. package/src/generators/remote/files/rspack-module-federation/rspack.config.js__tmpl__ +40 -13
  201. package/src/generators/remote/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +13 -4
  202. package/src/generators/remote/files/rspack-module-federation-ssr/rspack.config.js__tmpl__ +69 -0
  203. package/src/generators/remote/files/rspack-module-federation-ssr/server.ts__tmpl__ +2 -2
  204. package/src/generators/remote/files/rspack-module-federation-ssr/src/main.server.tsx__tmpl__ +45 -0
  205. package/src/generators/remote/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +13 -4
  206. package/src/generators/remote/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +69 -0
  207. package/src/generators/remote/files/rspack-module-federation-ssr-ts/server.ts__tmpl__ +2 -2
  208. package/src/generators/remote/files/rspack-module-federation-ssr-ts/src/main.server.tsx__tmpl__ +45 -0
  209. package/src/generators/remote/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +11 -8
  210. package/src/generators/remote/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +40 -13
  211. package/src/generators/remote/files/webpack-module-federation/module-federation.config.js__tmpl__ +10 -7
  212. package/src/generators/remote/files/webpack-module-federation/webpack.config.js__tmpl__ +1 -1
  213. package/src/generators/remote/files/webpack-module-federation-ssr/module-federation.server.config.js__tmpl__ +7 -4
  214. package/src/generators/remote/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +2 -2
  215. package/src/generators/remote/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +8 -5
  216. package/src/generators/remote/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +2 -2
  217. package/src/generators/remote/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +11 -8
  218. package/src/generators/remote/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +2 -2
  219. package/src/generators/remote/lib/setup-ssr-for-remote.d.ts +1 -1
  220. package/src/generators/remote/lib/setup-ssr-for-remote.js +37 -15
  221. package/src/generators/remote/lib/setup-tspath-for-remote.js +1 -3
  222. package/src/generators/remote/lib/update-host-with-remote.js +2 -2
  223. package/src/generators/remote/remote.d.ts +0 -1
  224. package/src/generators/remote/remote.js +57 -33
  225. package/src/generators/remote/schema.d.ts +2 -5
  226. package/src/generators/remote/schema.json +16 -27
  227. package/src/generators/setup-tailwind/lib/update-project.js +1 -2
  228. package/src/generators/stories/schema.json +0 -10
  229. package/src/generators/stories/stories.d.ts +1 -3
  230. package/src/generators/stories/stories.js +9 -20
  231. package/src/generators/storybook-configuration/configuration.js +2 -11
  232. package/src/generators/storybook-configuration/schema.d.ts +0 -3
  233. package/src/generators/storybook-configuration/schema.json +0 -15
  234. package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +11 -6
  235. package/src/migrations/update-20-2-0/migrate-mf-imports-to-new-package.d.ts +2 -0
  236. package/src/migrations/update-20-2-0/migrate-mf-imports-to-new-package.js +66 -0
  237. package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.d.ts +2 -0
  238. package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.js +41 -0
  239. package/src/migrations/update-20-3-0/ensure-nx-module-federation-package.d.ts +2 -0
  240. package/src/migrations/update-20-3-0/ensure-nx-module-federation-package.js +18 -0
  241. package/src/migrations/update-21-0-0/update-babel-loose.d.ts +2 -0
  242. package/src/migrations/update-21-0-0/update-babel-loose.js +30 -0
  243. package/src/plugins/router-plugin.d.ts +10 -0
  244. package/src/plugins/router-plugin.js +221 -0
  245. package/src/rules/update-module-federation-project.d.ts +2 -1
  246. package/src/rules/update-module-federation-project.js +37 -48
  247. package/src/utils/add-mf-env-to-inputs.d.ts +1 -1
  248. package/src/utils/add-mf-env-to-inputs.js +8 -11
  249. package/src/utils/assertion.d.ts +2 -0
  250. package/src/utils/assertion.js +6 -0
  251. package/src/utils/ast-utils.d.ts +1 -1
  252. package/src/utils/ast-utils.js +2 -2
  253. package/src/utils/create-ts-config.js +57 -7
  254. package/src/utils/ct-utils.d.ts +1 -1
  255. package/src/utils/ct-utils.js +2 -7
  256. package/src/utils/has-rsbuild-plugin.d.ts +2 -0
  257. package/src/utils/has-rsbuild-plugin.js +10 -0
  258. package/src/utils/has-rspack-plugin.d.ts +2 -0
  259. package/src/utils/has-rspack-plugin.js +10 -0
  260. package/src/utils/testing-generators.js +2 -4
  261. package/src/utils/version-utils.d.ts +14 -0
  262. package/src/utils/version-utils.js +56 -0
  263. package/src/utils/versions.d.ts +25 -17
  264. package/src/utils/versions.js +28 -19
  265. package/src/generators/component/files/__fileName__.tsx__tmpl__ +0 -84
  266. package/src/generators/component-cypress-spec/component-cypress-spec.d.ts +0 -13
  267. package/src/generators/component-cypress-spec/component-cypress-spec.js +0 -104
  268. package/src/generators/component-cypress-spec/files/__componentName__.__fileExt__ +0 -13
  269. package/src/generators/component-cypress-spec/schema.json +0 -45
  270. package/src/generators/host/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__ +0 -16
  271. package/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__ +0 -16
  272. package/src/generators/library/files/common/package.json__tmpl__ +0 -4
  273. package/src/generators/library/files/vite/package.json__tmpl__ +0 -12
  274. package/src/generators/remote/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__ +0 -16
  275. package/src/generators/remote/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__ +0 -16
  276. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
  277. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
  278. package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.d.ts +0 -2
  279. package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.js +0 -8
  280. package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.d.ts +0 -2
  281. package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.js +0 -8
  282. package/src/migrations/update-16-7-0/add-babel-core.d.ts +0 -2
  283. package/src/migrations/update-16-7-0/add-babel-core.js +0 -14
  284. package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.d.ts +0 -2
  285. package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.js +0 -57
  286. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +0 -2
  287. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +0 -53
  288. package/src/module-federation/load-config.d.ts +0 -3
  289. package/src/module-federation/load-config.js +0 -15
  290. package/src/module-federation/models.d.ts +0 -24
  291. package/src/module-federation/models.js +0 -2
  292. package/src/module-federation/package-json.d.ts +0 -8
  293. package/src/module-federation/package-json.js +0 -12
  294. package/src/module-federation/utils.d.ts +0 -12
  295. package/src/module-federation/utils.js +0 -75
  296. package/src/module-federation/with-module-federation-ssr.d.ts +0 -2
  297. package/src/module-federation/with-module-federation-ssr.js +0 -50
  298. package/src/module-federation/with-module-federation.d.ts +0 -7
  299. package/src/module-federation/with-module-federation.js +0 -63
  300. package/src/utils/build-static.remotes.d.ts +0 -4
  301. package/src/utils/build-static.remotes.js +0 -65
  302. package/src/utils/format-file.d.ts +0 -1
  303. package/src/utils/format-file.js +0 -11
  304. /package/src/generators/component/files/{__fileName__.spec.tsx__tmpl__ → __fileName__.spec.__ext__} +0 -0
  305. /package/src/generators/hook/files/{__fileName__.spec.tsx__tmpl__ → __fileName__.spec.__specExt__} +0 -0
  306. /package/src/generators/redux/files/{__fileName__.slice.ts__tmpl__ → ts/__fileName__.__ext__} +0 -0
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.componentGenerator = componentGenerator;
4
- exports.componentGeneratorInternal = componentGeneratorInternal;
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
7
6
  const path_1 = require("path");
@@ -12,12 +11,6 @@ const versions_1 = require("../../utils/versions");
12
11
  const get_component_tests_1 = require("./lib/get-component-tests");
13
12
  const normalize_options_1 = require("./lib/normalize-options");
14
13
  async function componentGenerator(host, schema) {
15
- return componentGeneratorInternal(host, {
16
- nameAndDirectoryFormat: 'derived',
17
- ...schema,
18
- });
19
- }
20
- async function componentGeneratorInternal(host, schema) {
21
14
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
22
15
  createComponentFiles(host, options);
23
16
  const tasks = [];
@@ -39,31 +32,17 @@ function createComponentFiles(host, options) {
39
32
  ...options,
40
33
  componentTests,
41
34
  inSourceVitestTests: (0, get_in_source_vitest_tests_template_1.getInSourceVitestTestsTemplate)(componentTests),
42
- tmpl: '',
35
+ isTs: options.fileExtensionType === 'ts',
36
+ ext: options.fileExtension,
43
37
  });
44
- for (const c of host.listChanges()) {
45
- let deleteFile = false;
46
- if ((options.skipTests || options.inSourceTests) &&
47
- /.*spec.tsx/.test(c.path)) {
48
- deleteFile = true;
49
- }
50
- if ((options.styledModule || !options.hasStyles) &&
51
- c.path.endsWith(`.${options.style}`)) {
52
- deleteFile = true;
53
- }
54
- if (options.globalCss && c.path.endsWith(`.module.${options.style}`)) {
55
- deleteFile = true;
56
- }
57
- if (!options.globalCss &&
58
- c.path.endsWith(`${options.fileName}.${options.style}`)) {
59
- deleteFile = true;
60
- }
61
- if (deleteFile) {
62
- host.delete(c.path);
63
- }
38
+ if (options.skipTests || options.inSourceTests) {
39
+ host.delete((0, devkit_1.joinPathFragments)(options.directory, `${options.fileName}.spec.${options.fileExtension}`));
40
+ }
41
+ if (options.styledModule || !options.hasStyles || !options.globalCss) {
42
+ host.delete((0, path_1.join)(options.directory, `${options.fileName}.${options.style}`));
64
43
  }
65
- if (options.js) {
66
- (0, devkit_1.toJS)(host);
44
+ if (options.styledModule || !options.hasStyles || options.globalCss) {
45
+ host.delete((0, path_1.join)(options.directory, `${options.fileName}.module.${options.style}`));
67
46
  }
68
47
  }
69
48
  let tsModule;
@@ -74,14 +53,17 @@ function addExportsToBarrel(host, options) {
74
53
  const workspace = (0, devkit_1.getProjects)(host);
75
54
  const isApp = workspace.get(options.projectName).projectType === 'application';
76
55
  if (options.export && !isApp) {
77
- const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts');
78
- const indexSource = host.read(indexFilePath, 'utf-8');
79
- if (indexSource !== null) {
80
- const indexSourceFile = tsModule.createSourceFile(indexFilePath, indexSource, tsModule.ScriptTarget.Latest, true);
81
- const relativePathFromIndex = getRelativeImportToFile(indexFilePath, options.filePath);
82
- const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, ast_utils_1.addImport)(indexSourceFile, `export * from '${relativePathFromIndex}';`));
83
- host.write(indexFilePath, changes);
56
+ const indexFilePath = (0, devkit_1.joinPathFragments)(...(options.projectSourceRoot
57
+ ? [options.projectSourceRoot]
58
+ : [options.projectRoot, 'src']), options.fileExtensionType === 'js' ? 'index.js' : 'index.ts');
59
+ if (!host.exists(indexFilePath)) {
60
+ return;
84
61
  }
62
+ const indexSource = host.read(indexFilePath, 'utf-8');
63
+ const indexSourceFile = tsModule.createSourceFile(indexFilePath, indexSource, tsModule.ScriptTarget.Latest, true);
64
+ const relativePathFromIndex = getRelativeImportToFile(indexFilePath, options.filePath);
65
+ const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, ast_utils_1.addImport)(indexSourceFile, `export * from '${relativePathFromIndex}';`));
66
+ host.write(indexFilePath, changes);
85
67
  }
86
68
  }
87
69
  function getRelativeImportToFile(indexPath, filePath) {
@@ -0,0 +1,83 @@
1
+ <%_ if (classComponent) { _%>
2
+ import { Component } from 'react';
3
+ <%_ } _%>
4
+ <%_ if (routing) { _%>
5
+ import { Route, Link } from 'react-router-dom';
6
+ <%_ } _%>
7
+
8
+ <%_ if (hasStyles) {
9
+ if (styledModule && styledModule !== 'styled-jsx' && styledModule !== 'tailwind') {
10
+ var wrapper = 'Styled' + className;
11
+ var extras = '';
12
+ _%>
13
+ import styled from '<%= styledModule %>';
14
+ <%_ } else {
15
+ var wrapper = 'div';
16
+ var extras = globalCss || styledModule === 'styled-jsx' ? '' : " className={styles['container']}";
17
+ _%>
18
+ <%- style !== 'styled-jsx' && style!== 'tailwind' ? globalCss ? `import './${fileName}.${style}';` : `import styles from './${fileName}.module.${style}';`: '' %>
19
+ <%_ }
20
+ } else {
21
+ var wrapper = 'div';
22
+ var extras = '';
23
+ } _%>
24
+
25
+ <%_ if (styledModule && styledModule !== 'styled-jsx' && styledModule !== 'tailwind') { _%>
26
+ const Styled<%= className %> = styled.div`
27
+ color: pink;
28
+ `;
29
+ <%_ } _%>
30
+ <%_ if(!isNextPage) { _%>
31
+ <%_ if (classComponent) { _%>
32
+ export class <%= className %> extends Component<% if (isTs) { %><{}><% } %> {
33
+ <% if (isTs) { %>override<% } %> render() {
34
+ return (
35
+ <<%= wrapper %><%- extras %>>
36
+ <%= styledModule === 'styled-jsx' ? `<style jsx>{\`div { color: pink; }\`}</style>` : `` %>
37
+ <p>Welcome to <%= className %>!</p>
38
+ <%_ if (routing) { _%>
39
+ <ul>
40
+ <li><Link to="/"><%= name %> root</Link></li>
41
+ </ul>
42
+ <Route path="/" element={<div>This is the <%= name %> root route.</div>} />
43
+ <%_ } _%>
44
+ </<%= wrapper %>>
45
+ );
46
+ }
47
+ }
48
+ <%_ } else { _%>
49
+ export function <%= className %>() {
50
+ return (
51
+ <<%= wrapper %><%- extras %>>
52
+ <%_ if (styledModule === 'styled-jsx') { _%><style jsx>{`div { color: pink; }`}</style><%_ } _%>
53
+ <h1>Welcome to <%= className %>!</h1>
54
+ <%_ if (routing) { _%>
55
+ <ul>
56
+ <li><Link to="/"><%= name %> root</Link></li>
57
+ </ul>
58
+ <Route path="/" element={<div>This is the <%= name %> root route.</div>} />
59
+ <%_ } _%>
60
+ </<%= wrapper %>>
61
+ );
62
+ }
63
+ <%_ } _%>
64
+
65
+ export default <%= className %>;
66
+ <%_ } else { _%>
67
+ export default function <%= className %>() {
68
+ return (
69
+ <<%= wrapper %><%- extras %>>
70
+ <%_ if (styledModule === 'styled-jsx') { _%><style jsx>{`div { color: pink; }`}</style><%_ } _%>
71
+ <h1>Welcome to <%= className %>!</h1>
72
+ <% if (routing) { %>
73
+ <ul>
74
+ <li><Link to="/"><%= name %> root</Link></li>
75
+ </ul>
76
+ <Route path="/" element={<div>This is the <%= name %> root route.</div>} />
77
+ <% } %>
78
+ </<%= wrapper %>>
79
+ );
80
+ };
81
+ <% } %>
82
+
83
+ <% if (inSourceTests === true) { %> <%- inSourceVitestTests %> <% } %>
@@ -4,21 +4,15 @@ exports.normalizeOptions = normalizeOptions;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
6
6
  const assertion_1 = require("../../../utils/assertion");
7
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
8
  async function normalizeOptions(tree, options) {
8
9
  (0, assertion_1.assertValidStyle)(options.style);
9
- const { artifactName: name, directory, fileName, filePath, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
10
- artifactType: 'component',
11
- callingGenerator: '@nx/react:component',
10
+ const { artifactName: name, directory, fileName, filePath, fileExtension, fileExtensionType, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
11
+ path: options.path,
12
12
  name: options.name,
13
- directory: options.directory,
14
- derivedDirectory: options.derivedDirectory ?? options.directory,
15
- flat: options.flat,
16
- nameAndDirectoryFormat: options.nameAndDirectoryFormat,
17
- project: options.project,
18
- fileExtension: 'tsx',
19
- fileName: options.fileName,
20
- pascalCaseFile: options.pascalCaseFiles,
21
- pascalCaseDirectory: options.pascalCaseDirectory,
13
+ allowedFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
14
+ fileExtension: options.js ? 'js' : 'tsx',
15
+ js: options.js,
22
16
  });
23
17
  const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
24
18
  const { className } = (0, devkit_1.names)(name);
@@ -26,7 +20,8 @@ async function normalizeOptions(tree, options) {
26
20
  const styledModule = /^(css|scss|less|none)$/.test(options.style)
27
21
  ? null
28
22
  : options.style;
29
- if (options.export && projectType === 'application') {
23
+ if (options.export &&
24
+ (0, ts_solution_setup_1.getProjectType)(tree, projectRoot, projectType) === 'application') {
30
25
  devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
31
26
  }
32
27
  options.classComponent = options.classComponent ?? false;
@@ -37,13 +32,16 @@ async function normalizeOptions(tree, options) {
37
32
  options.isNextPage = options.isNextPage ?? false;
38
33
  return {
39
34
  ...options,
40
- projectName,
41
35
  directory,
36
+ projectName,
42
37
  styledModule,
43
38
  hasStyles: options.style !== 'none',
44
39
  className,
45
40
  fileName,
46
41
  filePath,
47
- projectSourceRoot: projectSourceRoot ?? projectRoot,
42
+ projectRoot,
43
+ projectSourceRoot,
44
+ fileExtension,
45
+ fileExtensionType,
48
46
  };
49
47
  }
@@ -1,47 +1,35 @@
1
+ import type { FileExtensionType } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
1
2
  import { SupportedStyles } from '../../../typings/style';
2
3
 
3
4
  export interface Schema {
4
- name: string;
5
- /**
6
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20.
7
- */
8
- project?: string;
5
+ path: string;
6
+ name?: string;
9
7
  style: SupportedStyles;
10
8
  skipTests?: boolean;
11
- directory?: string;
12
9
  export?: boolean;
13
- /**
14
- * @deprecated Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
15
- */
16
- pascalCaseFiles?: boolean;
17
- /**
18
- * @deprecated Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
19
- */
20
- pascalCaseDirectory?: boolean;
21
10
  classComponent?: boolean;
22
11
  routing?: boolean;
23
- js?: boolean;
24
- /**
25
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
26
- */
27
- flat?: boolean;
28
12
  globalCss?: boolean;
29
- fileName?: string;
30
13
  inSourceTests?: boolean;
31
14
  skipFormat?: boolean;
32
- nameAndDirectoryFormat?: 'as-provided' | 'derived';
33
- // Used by other wrapping generators to preserve previous behavior
34
- // e.g. @nx/next:component
35
- derivedDirectory?: string;
36
15
  // Used by Next.js to determine how React should generate the page
37
16
  isNextPage?: boolean;
17
+
18
+ /**
19
+ * @deprecated Provide the full file path including the file extension in the `path` option. This option will be removed in Nx v21.
20
+ */
21
+ js?: boolean;
38
22
  }
39
23
 
40
- export interface NormalizedSchema extends Schema {
24
+ export interface NormalizedSchema extends Omit<Schema, 'js'> {
25
+ directory: string;
26
+ projectRoot: string;
41
27
  projectSourceRoot: string;
42
28
  projectName: string;
43
29
  fileName: string;
44
30
  filePath: string;
31
+ fileExtension: string;
32
+ fileExtensionType: FileExtensionType;
45
33
  className: string;
46
34
  styledModule: null | string;
47
35
  hasStyles: boolean;
@@ -6,25 +6,20 @@
6
6
  "description": "Create a React Component for Nx.",
7
7
  "type": "object",
8
8
  "properties": {
9
- "project": {
9
+ "path": {
10
10
  "type": "string",
11
- "description": "The name of the project.",
12
- "alias": "p",
13
- "$default": {
14
- "$source": "projectName"
15
- },
16
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
17
- },
18
- "name": {
19
- "type": "string",
20
- "description": "The name of the component.",
11
+ "description": "The file path to the component. Relative to the current working directory.",
21
12
  "$default": {
22
13
  "$source": "argv",
23
14
  "index": 0
24
15
  },
25
- "x-prompt": "What name would you like to use for the component?",
16
+ "x-prompt": "What is the component file path?",
26
17
  "x-priority": "important"
27
18
  },
19
+ "name": {
20
+ "type": "string",
21
+ "description": "The component symbol name. Defaults to the last segment of the file path."
22
+ },
28
23
  "style": {
29
24
  "description": "The file extension to be used for style files.",
30
25
  "type": "string",
@@ -46,6 +41,10 @@
46
41
  "value": "less",
47
42
  "label": "LESS [ https://lesscss.org ]"
48
43
  },
44
+ {
45
+ "value": "tailwind",
46
+ "label": "tailwind [ https://tailwindcss.com/ ]"
47
+ },
49
48
  {
50
49
  "value": "styled-components",
51
50
  "label": "styled-components [ https://styled-components.com ]"
@@ -68,7 +67,7 @@
68
67
  "js": {
69
68
  "type": "boolean",
70
69
  "description": "Generate JavaScript files rather than TypeScript files.",
71
- "default": false
70
+ "x-deprecated": "Provide the full file path including the file extension in the `path` option. This option will be removed in Nx v21."
72
71
  },
73
72
  "skipTests": {
74
73
  "type": "boolean",
@@ -76,23 +75,6 @@
76
75
  "default": false,
77
76
  "x-priority": "internal"
78
77
  },
79
- "directory": {
80
- "type": "string",
81
- "description": "The directory at which to create the component file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the project root.",
82
- "alias": "dir",
83
- "x-priority": "important"
84
- },
85
- "nameAndDirectoryFormat": {
86
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
87
- "type": "string",
88
- "enum": ["as-provided", "derived"]
89
- },
90
- "flat": {
91
- "type": "boolean",
92
- "description": "Create component at the source root rather than its own directory.",
93
- "default": false,
94
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19."
95
- },
96
78
  "export": {
97
79
  "type": "boolean",
98
80
  "description": "When true, the component is exported from the project `index.ts` (if it exists).",
@@ -100,20 +82,6 @@
100
82
  "default": false,
101
83
  "x-prompt": "Should this component be exported in the project?"
102
84
  },
103
- "pascalCaseFiles": {
104
- "type": "boolean",
105
- "description": "Use pascal case component file name (e.g. `App.tsx`).",
106
- "alias": "P",
107
- "default": false,
108
- "x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
109
- },
110
- "pascalCaseDirectory": {
111
- "type": "boolean",
112
- "description": "Use pascal case directory name (e.g. `App/App.tsx`).",
113
- "alias": "R",
114
- "default": false,
115
- "x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
116
- },
117
85
  "classComponent": {
118
86
  "type": "boolean",
119
87
  "alias": "C",
@@ -129,10 +97,6 @@
129
97
  "description": "Default is `false`. When `true`, the component is generated with `*.css`/`*.scss` instead of `*.module.css`/`*.module.scss`.",
130
98
  "default": false
131
99
  },
132
- "fileName": {
133
- "type": "string",
134
- "description": "Create a component with this file name."
135
- },
136
100
  "inSourceTests": {
137
101
  "type": "boolean",
138
102
  "default": false,
@@ -145,6 +109,6 @@
145
109
  "x-priority": "internal"
146
110
  }
147
111
  },
148
- "required": ["name"],
112
+ "required": ["path"],
149
113
  "examplesFile": "../../../docs/component-examples.md"
150
114
  }
@@ -13,8 +13,7 @@ function createComponentStoriesFile(host, { project, componentPath, interactionT
13
13
  tsModule = (0, ensure_typescript_1.ensureTypescript)();
14
14
  }
15
15
  const proj = (0, devkit_1.getProjects)(host).get(project);
16
- const sourceRoot = proj.sourceRoot;
17
- const componentFilePath = (0, devkit_1.joinPathFragments)(sourceRoot, componentPath);
16
+ const componentFilePath = (0, devkit_1.joinPathFragments)(proj.sourceRoot ?? proj.root, componentPath);
18
17
  const componentDirectory = componentFilePath.replace(componentFilePath.slice(componentFilePath.lastIndexOf('/')), '');
19
18
  const isPlainJs = componentFilePath.endsWith('.jsx') || componentFilePath.endsWith('.js');
20
19
  const componentFileName = componentFilePath
@@ -1,8 +1,8 @@
1
1
  import componentName from './<%= componentImportFileName %>';
2
- <% if ( interactionTests ) { %>
2
+ <%_ if ( interactionTests ) { _%>
3
3
  import { within } from '@storybook/testing-library';
4
4
  import { expect } from '@storybook/jest';
5
- <% } %>
5
+ <%_ } _%>
6
6
 
7
7
  export default {
8
8
  component: <%= componentName %>,
@@ -10,7 +10,7 @@ export default {
10
10
  argTypes: {<% for (let argType of argTypes) { %>
11
11
  <%= argType.name %>: { <%- argType.type %> : "<%- argType.actionText %>" },<% } %>
12
12
  }
13
- <% } %>
13
+ <%_ } _%>
14
14
  };
15
15
 
16
16
  export const Primary = {
@@ -19,11 +19,11 @@ export const Primary = {
19
19
  },
20
20
  };
21
21
 
22
- <% if ( interactionTests ) { %>
22
+ <%_ if ( interactionTests ) { _%>
23
23
  export const Heading: Story = {
24
24
  play: async ({ canvasElement }) => {
25
25
  const canvas = within(canvasElement);
26
26
  expect(canvas.getByText(/Welcome to <%=componentName%>!/gi)).toBeTruthy();
27
27
  },
28
28
  };
29
- <% } %>
29
+ <%_ } _%>
@@ -1,9 +1,9 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
  import { <%= componentName %> } from './<%= componentImportFileName %>';
3
- <% if ( interactionTests ) { %>
3
+ <%_ if ( interactionTests ) { _%>
4
4
  import { within } from '@storybook/testing-library';
5
5
  import { expect } from '@storybook/jest';
6
- <% } %>
6
+ <%_ } _%>
7
7
 
8
8
  const meta: Meta<typeof <%= componentName %>> = {
9
9
  component: <%= componentName %>,
@@ -16,14 +16,13 @@ const meta: Meta<typeof <%= componentName %>> = {
16
16
  export default meta;
17
17
  type Story = StoryObj<typeof <%= componentName %>>;
18
18
 
19
-
20
19
  export const Primary = {
21
20
  args: {<% for (let prop of props) { %>
22
21
  <%= prop.name %>: <%- prop.defaultValue %>,<% } %>
23
22
  },
24
23
  };
25
24
 
26
- <% if ( interactionTests ) { %>
25
+ <%_ if ( interactionTests ) { _%>
27
26
  export const Heading: Story = {
28
27
  args: {<% for (let prop of props) { %>
29
28
  <%= prop.name %>: <%- prop.defaultValue %>,<% } %>
@@ -10,7 +10,7 @@ const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescri
10
10
  let tsModule;
11
11
  async function componentTestGenerator(tree, options) {
12
12
  (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
13
- const { assertMinimumCypressVersion } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/cypress-version'));
13
+ const { assertMinimumCypressVersion } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/versions'));
14
14
  assertMinimumCypressVersion(10);
15
15
  // normalize any windows paths
16
16
  options.componentPath = options.componentPath.replace(/\\/g, '/');
@@ -37,8 +37,6 @@ async function cypressComponentConfigGeneratorInternal(tree, options) {
37
37
  validExecutorNames: new Set([
38
38
  '@nx/webpack:webpack',
39
39
  '@nx/vite:build',
40
- '@nrwl/webpack:webpack',
41
- '@nrwl/vite:build',
42
40
  ]),
43
41
  });
44
42
  await (0, add_files_1.addFiles)(tree, projectConfig, options, found);
@@ -1,4 +1,4 @@
1
+ import type { FoundTarget } from '@nx/cypress/src/utils/find-target-options';
1
2
  import { ProjectConfiguration, Tree } from '@nx/devkit';
2
3
  import type { CypressComponentConfigurationSchema } from '../schema';
3
- import { FoundTarget } from '@nx/cypress/src/utils/find-target-options';
4
4
  export declare function addFiles(tree: Tree, projectConfig: ProjectConfiguration, options: CypressComponentConfigurationSchema, found: FoundTarget): Promise<void>;
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addFiles = addFiles;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const versions_1 = require("nx/src/utils/versions");
6
- const component_test_1 = require("../../component-test/component-test");
7
6
  const ct_utils_1 = require("../../../utils/ct-utils");
7
+ const component_test_1 = require("../../component-test/component-test");
8
8
  async function addFiles(tree, projectConfig, options, found) {
9
- // must dyanmicaly import to prevent packages not using cypress from erroring out
9
+ // must dynamicaly import to prevent packages not using cypress from erroring out
10
10
  // when importing react
11
- const { addMountDefinition, addDefaultCTConfig } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/config'));
11
+ const { addMountDefinition } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/config'));
12
+ const { getInstalledCypressMajorVersion } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/versions'));
13
+ const installedCypressMajorVersion = getInstalledCypressMajorVersion(tree);
12
14
  // Specifically undefined to allow Remix workaround of passing an empty string
13
15
  const actualBundler = await (0, ct_utils_1.getActualBundler)(tree, options, found);
14
16
  if (options.bundler && options.bundler !== actualBundler) {
@@ -18,7 +20,8 @@ async function addFiles(tree, projectConfig, options, found) {
18
20
  const bundlerToUse = options.bundler ?? actualBundler;
19
21
  const commandFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'support', 'component.ts');
20
22
  const updatedCommandFile = await addMountDefinition(tree.read(commandFile, 'utf-8'));
21
- tree.write(commandFile, `import { mount } from 'cypress/react18';\n${updatedCommandFile}`);
23
+ const moduleSpecifier = installedCypressMajorVersion >= 14 ? 'cypress/react' : 'cypress/react18';
24
+ tree.write(commandFile, `import { mount } from '${moduleSpecifier}';\n${updatedCommandFile}`);
22
25
  if (options.bundler === 'webpack' ||
23
26
  (!options.bundler && actualBundler === 'webpack')) {
24
27
  (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/webpack': versions_1.nxVersion });
@@ -14,43 +14,33 @@ async function federateModuleGenerator(tree, schema) {
14
14
  Path: ${schema.path}`);
15
15
  }
16
16
  const tasks = [];
17
+ const { projectName: remoteName, projectRoot: remoteRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
18
+ name: schema.remote,
19
+ directory: schema.remoteDirectory,
20
+ projectType: 'application',
21
+ });
17
22
  // Check remote exists
18
- const remote = (0, utils_1.checkRemoteExists)(tree, schema.remote);
19
- let projectRoot, remoteName;
23
+ const remote = (0, utils_1.checkRemoteExists)(tree, remoteName);
20
24
  if (!remote) {
21
25
  // create remote
22
- const remoteGenerator = await (0, remote_1.remoteGeneratorInternal)(tree, {
23
- name: schema.remote,
24
- directory: schema.remoteDirectory,
26
+ const remoteGeneratorTask = await (0, remote_1.remoteGenerator)(tree, {
27
+ name: remoteName,
28
+ directory: remoteRoot,
25
29
  e2eTestRunner: schema.e2eTestRunner,
26
30
  skipFormat: schema.skipFormat,
27
31
  linter: schema.linter,
28
32
  style: schema.style,
29
33
  unitTestRunner: schema.unitTestRunner,
30
34
  host: schema.host,
31
- projectNameAndRootFormat: schema.projectNameAndRootFormat ?? 'derived',
32
35
  bundler: schema.bundler ?? 'rspack',
33
36
  });
34
- tasks.push(remoteGenerator);
35
- const { projectName, projectRoot: remoteRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
36
- name: schema.remote,
37
- directory: schema.remoteDirectory,
38
- projectType: 'application',
39
- projectNameAndRootFormat: schema.projectNameAndRootFormat ?? 'derived',
40
- callingGenerator: '@nx/react:federate-module',
41
- });
42
- projectRoot = remoteRoot;
43
- remoteName = projectName;
44
- }
45
- else {
46
- projectRoot = remote.root;
47
- remoteName = remote.name;
37
+ tasks.push(remoteGeneratorTask);
48
38
  }
49
39
  // add path to exposes property
50
40
  const normalizedModulePath = schema.bundler === 'rspack'
51
- ? (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(projectRoot), schema.path)
41
+ ? (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(remoteRoot), schema.path)
52
42
  : schema.path;
53
- (0, utils_1.addPathToExposes)(tree, projectRoot, schema.name, normalizedModulePath);
43
+ (0, utils_1.addPathToExposes)(tree, remoteRoot, schema.name, normalizedModulePath);
54
44
  // Add new path to tsconfig
55
45
  const rootJSON = (0, devkit_1.readJson)(tree, (0, js_1.getRootTsConfigPathInTree)(tree));
56
46
  if (!rootJSON?.compilerOptions?.paths[`${remoteName}/${schema.name}`]) {
@@ -5,7 +5,6 @@ export interface Schema {
5
5
  path: string;
6
6
  remote: string;
7
7
  remoteDirectory?: string;
8
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
9
8
  e2eTestRunner?: 'cypress' | 'playwright' | 'none';
10
9
  host?: string;
11
10
  linter?: Linter | LinterType;
@@ -3,11 +3,15 @@
3
3
  "cli": "nx",
4
4
  "$id": "NxReactFederateModule",
5
5
  "title": "Federate Module",
6
- "description": "Create a federated module, which can be loaded by a remote host.",
6
+ "description": "Create a federated module, which can be loaded by a Consumer (host) via a Producer (remote).",
7
7
  "examples": [
8
8
  {
9
- "command": "nx g federate-module MyModule --path=./src/component/my-cmp.ts --remote=my-remote-app --remoteDirectory=apps/my-remote-app",
10
- "description": "Create a federated module from my-remote-app, that exposes my-cmp from ./src/component/my-cmp.ts as MyModule."
9
+ "command": "nx g federate-module MyModule --path=./src/component/my-cmp.ts --remote=myRemote --remoteDirectory=apps/myRemote",
10
+ "description": "Create a federated module from myRemote, that exposes my-cmp from ./src/component/my-cmp.ts as MyModule."
11
+ },
12
+ {
13
+ "command": "nx g federate-module MyModule --path=./src/component/my-cmp.ts --producer=myProducer --producerDirectory=apps/myProducer",
14
+ "description": "Create a federated module from myProducer, that exposes my-cmp from ./src/component/my-cmp.ts as MyModule."
11
15
  }
12
16
  ],
13
17
  "type": "object",
@@ -30,17 +34,14 @@
30
34
  },
31
35
  "remote": {
32
36
  "type": "string",
33
- "description": "The name of the remote.",
34
- "x-prompt": "What is/should the remote be named?"
37
+ "description": "The name of the Producer (remote).",
38
+ "x-prompt": "What is/should the Producer (remote) be named?",
39
+ "alias": "producer"
35
40
  },
36
41
  "remoteDirectory": {
37
- "description": "The directory of the new remote application if one needs to be created.",
38
- "type": "string"
39
- },
40
- "projectNameAndRootFormat": {
41
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
42
+ "description": "The directory of the new Producer (remote) application if one needs to be created.",
42
43
  "type": "string",
43
- "enum": ["as-provided", "derived"]
44
+ "alias": "producerDirectory"
44
45
  },
45
46
  "style": {
46
47
  "description": "The file extension to be used for style files.",
@@ -75,7 +76,7 @@
75
76
  },
76
77
  "host": {
77
78
  "type": "string",
78
- "description": "The host / shell application for this remote."
79
+ "description": "The Consumer (host) application for this Producer (remote)."
79
80
  },
80
81
  "bundler": {
81
82
  "description": "The bundler to use.",