@nx/react 0.0.0-pr-22179-271588f

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 (347) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +68 -0
  3. package/ast-utils.d.ts +1 -0
  4. package/ast-utils.js +11 -0
  5. package/babel.d.ts +20 -0
  6. package/babel.js +50 -0
  7. package/executors.json +14 -0
  8. package/generators.json +112 -0
  9. package/index.d.ts +22 -0
  10. package/index.js +47 -0
  11. package/mf/dynamic-federation.d.ts +4 -0
  12. package/mf/dynamic-federation.js +75 -0
  13. package/mf/index.d.ts +1 -0
  14. package/mf/index.js +7 -0
  15. package/migrations.json +310 -0
  16. package/module-federation.d.ts +4 -0
  17. package/module-federation.js +12 -0
  18. package/package.json +49 -0
  19. package/plugins/bundle-rollup.d.ts +1 -0
  20. package/plugins/bundle-rollup.js +47 -0
  21. package/plugins/component-testing/index.d.ts +37 -0
  22. package/plugins/component-testing/index.js +222 -0
  23. package/plugins/component-testing/webpack-fallback.d.ts +5 -0
  24. package/plugins/component-testing/webpack-fallback.js +125 -0
  25. package/plugins/jest.d.ts +1 -0
  26. package/plugins/jest.js +59 -0
  27. package/plugins/nx-react-webpack-plugin/lib/apply-react-config.d.ts +4 -0
  28. package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +60 -0
  29. package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.d.ts +8 -0
  30. package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.js +13 -0
  31. package/plugins/storybook/index.d.ts +3 -0
  32. package/plugins/storybook/index.js +174 -0
  33. package/plugins/storybook/merge-plugins.d.ts +3 -0
  34. package/plugins/storybook/merge-plugins.js +17 -0
  35. package/plugins/webpack.d.ts +1 -0
  36. package/plugins/webpack.js +6 -0
  37. package/plugins/with-react.d.ts +10 -0
  38. package/plugins/with-react.js +22 -0
  39. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +25 -0
  40. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +211 -0
  41. package/src/executors/module-federation-dev-server/schema.json +114 -0
  42. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +9 -0
  43. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +106 -0
  44. package/src/executors/module-federation-ssr-dev-server/schema.json +48 -0
  45. package/src/generators/application/application.d.ts +5 -0
  46. package/src/generators/application/application.js +232 -0
  47. package/src/generators/application/files/base-rspack/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
  48. package/src/generators/application/files/base-rspack/src/assets/.gitkeep +0 -0
  49. package/src/generators/application/files/base-rspack/src/favicon.ico +0 -0
  50. package/src/generators/application/files/base-rspack/src/index.html +14 -0
  51. package/src/generators/application/files/base-rspack/src/main.tsx__tmpl__ +10 -0
  52. package/src/generators/application/files/base-rspack/tsconfig.app.json__tmpl__ +14 -0
  53. package/src/generators/application/files/base-vite/index.html__tmpl__ +16 -0
  54. package/src/generators/application/files/base-vite/public/favicon.ico +0 -0
  55. package/src/generators/application/files/base-vite/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
  56. package/src/generators/application/files/base-vite/src/assets/.gitkeep +0 -0
  57. package/src/generators/application/files/base-vite/src/environments/environment.prod.ts__tmpl__ +3 -0
  58. package/src/generators/application/files/base-vite/src/environments/environment.ts__tmpl__ +6 -0
  59. package/src/generators/application/files/base-vite/src/main.tsx__tmpl__ +10 -0
  60. package/src/generators/application/files/base-vite/tsconfig.app.json__tmpl__ +14 -0
  61. package/src/generators/application/files/base-webpack/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
  62. package/src/generators/application/files/base-webpack/src/assets/.gitkeep +0 -0
  63. package/src/generators/application/files/base-webpack/src/favicon.ico +0 -0
  64. package/src/generators/application/files/base-webpack/src/index.html +12 -0
  65. package/src/generators/application/files/base-webpack/src/main.tsx__tmpl__ +10 -0
  66. package/src/generators/application/files/base-webpack/tsconfig.app.json__tmpl__ +14 -0
  67. package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +50 -0
  68. package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +886 -0
  69. package/src/generators/application/files/style-css-module/src/app/__fileName__.module.__style__ +1 -0
  70. package/src/generators/application/files/style-css-module/src/app/__fileName__.tsx__tmpl__ +36 -0
  71. package/src/generators/application/files/style-css-module/src/styles.__style__ +1 -0
  72. package/src/generators/application/files/style-global-css/src/app/__fileName__.__style__ +1 -0
  73. package/src/generators/application/files/style-global-css/src/app/__fileName__.tsx__tmpl__ +35 -0
  74. package/src/generators/application/files/style-global-css/src/styles.__style__ +1 -0
  75. package/src/generators/application/files/style-none/src/app/__fileName__.tsx__tmpl__ +34 -0
  76. package/src/generators/application/files/style-styled-jsx/src/app/__fileName__.tsx__tmpl__ +37 -0
  77. package/src/generators/application/files/style-styled-module/src/app/__fileName__.tsx__tmpl__ +40 -0
  78. package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +33 -0
  79. package/src/generators/application/files/style-tailwind/src/styles.css +1 -0
  80. package/src/generators/application/lib/add-e2e.d.ts +3 -0
  81. package/src/generators/application/lib/add-e2e.js +79 -0
  82. package/src/generators/application/lib/add-jest.d.ts +3 -0
  83. package/src/generators/application/lib/add-jest.js +21 -0
  84. package/src/generators/application/lib/add-project.d.ts +3 -0
  85. package/src/generators/application/lib/add-project.js +96 -0
  86. package/src/generators/application/lib/add-routing.d.ts +3 -0
  87. package/src/generators/application/lib/add-routing.js +27 -0
  88. package/src/generators/application/lib/create-application-files.d.ts +3 -0
  89. package/src/generators/application/lib/create-application-files.js +143 -0
  90. package/src/generators/application/lib/find-free-port.d.ts +2 -0
  91. package/src/generators/application/lib/find-free-port.js +16 -0
  92. package/src/generators/application/lib/get-app-tests.d.ts +2 -0
  93. package/src/generators/application/lib/get-app-tests.js +21 -0
  94. package/src/generators/application/lib/install-common-dependencies.d.ts +3 -0
  95. package/src/generators/application/lib/install-common-dependencies.js +47 -0
  96. package/src/generators/application/lib/normalize-options.d.ts +5 -0
  97. package/src/generators/application/lib/normalize-options.js +72 -0
  98. package/src/generators/application/lib/set-defaults.d.ts +3 -0
  99. package/src/generators/application/lib/set-defaults.js +43 -0
  100. package/src/generators/application/lib/show-possible-warnings.d.ts +3 -0
  101. package/src/generators/application/lib/show-possible-warnings.js +11 -0
  102. package/src/generators/application/lib/update-jest-config.d.ts +3 -0
  103. package/src/generators/application/lib/update-jest-config.js +30 -0
  104. package/src/generators/application/schema.d.ts +45 -0
  105. package/src/generators/application/schema.json +201 -0
  106. package/src/generators/component/component.d.ts +5 -0
  107. package/src/generators/component/component.js +93 -0
  108. package/src/generators/component/files/__fileName__.__style__ +0 -0
  109. package/src/generators/component/files/__fileName__.module.__style__ +7 -0
  110. package/src/generators/component/files/__fileName__.spec.tsx__tmpl__ +7 -0
  111. package/src/generators/component/files/__fileName__.tsx__tmpl__ +88 -0
  112. package/src/generators/component/lib/get-component-tests.d.ts +2 -0
  113. package/src/generators/component/lib/get-component-tests.js +12 -0
  114. package/src/generators/component/lib/normalize-options.d.ts +3 -0
  115. package/src/generators/component/lib/normalize-options.js +50 -0
  116. package/src/generators/component/schema.d.ts +48 -0
  117. package/src/generators/component/schema.json +150 -0
  118. package/src/generators/component-cypress-spec/component-cypress-spec.d.ts +13 -0
  119. package/src/generators/component-cypress-spec/component-cypress-spec.js +100 -0
  120. package/src/generators/component-cypress-spec/files/__componentName__.__fileExt__ +13 -0
  121. package/src/generators/component-cypress-spec/schema.json +44 -0
  122. package/src/generators/component-story/component-story.d.ts +12 -0
  123. package/src/generators/component-story/component-story.js +72 -0
  124. package/src/generators/component-story/files/jsx/__componentFileName__.stories.jsx__tmpl__ +29 -0
  125. package/src/generators/component-story/files/tsx/__componentFileName__.stories.tsx__tmpl__ +36 -0
  126. package/src/generators/component-story/schema.json +42 -0
  127. package/src/generators/component-test/component-test.d.ts +4 -0
  128. package/src/generators/component-test/component-test.js +76 -0
  129. package/src/generators/component-test/files/__fileName__.cy__ext__ +21 -0
  130. package/src/generators/component-test/schema.d.ts +4 -0
  131. package/src/generators/component-test/schema.js +2 -0
  132. package/src/generators/component-test/schema.json +31 -0
  133. package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +10 -0
  134. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +51 -0
  135. package/src/generators/cypress-component-configuration/lib/add-files.d.ts +4 -0
  136. package/src/generators/cypress-component-configuration/lib/add-files.js +45 -0
  137. package/src/generators/cypress-component-configuration/schema.d.ts +8 -0
  138. package/src/generators/cypress-component-configuration/schema.json +54 -0
  139. package/src/generators/federate-module/federate-module.d.ts +4 -0
  140. package/src/generators/federate-module/federate-module.js +70 -0
  141. package/src/generators/federate-module/lib/utils.d.ts +23 -0
  142. package/src/generators/federate-module/lib/utils.js +100 -0
  143. package/src/generators/federate-module/schema.d.ts +13 -0
  144. package/src/generators/federate-module/schema.json +83 -0
  145. package/src/generators/hook/files/__fileName__.spec.tsx__tmpl__ +18 -0
  146. package/src/generators/hook/files/__fileName__.ts__tmpl__ +15 -0
  147. package/src/generators/hook/hook.d.ts +5 -0
  148. package/src/generators/hook/hook.js +131 -0
  149. package/src/generators/hook/schema.d.ts +24 -0
  150. package/src/generators/hook/schema.json +84 -0
  151. package/src/generators/host/files/common/src/app/__fileName__.js__tmpl__ +33 -0
  152. package/src/generators/host/files/common/src/main.js__tmpl__ +10 -0
  153. package/src/generators/host/files/common/tsconfig.lint.json__tmpl__ +19 -0
  154. package/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +41 -0
  155. package/src/generators/host/files/common-ts/src/main.ts__tmpl__ +10 -0
  156. package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +21 -0
  157. package/src/generators/host/files/module-federation/webpack.config.js__tmpl__ +12 -0
  158. package/src/generators/host/files/module-federation/webpack.config.prod.js__tmpl__ +32 -0
  159. package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +16 -0
  160. package/src/generators/host/files/module-federation-ssr/server.ts__tmpl__ +28 -0
  161. package/src/generators/host/files/module-federation-ssr/tsconfig.server.json__tmpl__ +17 -0
  162. package/src/generators/host/files/module-federation-ssr/webpack.server.config.js__tmpl__ +12 -0
  163. package/src/generators/host/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +13 -0
  164. package/src/generators/host/files/module-federation-ssr-ts/server.ts__tmpl__ +28 -0
  165. package/src/generators/host/files/module-federation-ssr-ts/tsconfig.server.json__tmpl__ +17 -0
  166. package/src/generators/host/files/module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +12 -0
  167. package/src/generators/host/files/module-federation-ts/module-federation.config.ts__tmpl__ +25 -0
  168. package/src/generators/host/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +33 -0
  169. package/src/generators/host/files/module-federation-ts/webpack.config.ts__tmpl__ +12 -0
  170. package/src/generators/host/host.d.ts +5 -0
  171. package/src/generators/host/host.js +95 -0
  172. package/src/generators/host/lib/add-module-federation-files.d.ts +6 -0
  173. package/src/generators/host/lib/add-module-federation-files.js +52 -0
  174. package/src/generators/host/lib/normalize-remote.d.ts +4 -0
  175. package/src/generators/host/lib/normalize-remote.js +28 -0
  176. package/src/generators/host/lib/setup-ssr-for-host.d.ts +6 -0
  177. package/src/generators/host/lib/setup-ssr-for-host.js +33 -0
  178. package/src/generators/host/lib/update-module-federation-e2e-project.d.ts +3 -0
  179. package/src/generators/host/lib/update-module-federation-e2e-project.js +20 -0
  180. package/src/generators/host/schema.d.ts +37 -0
  181. package/src/generators/host/schema.json +184 -0
  182. package/src/generators/init/init.d.ts +4 -0
  183. package/src/generators/init/init.js +23 -0
  184. package/src/generators/init/schema.d.ts +5 -0
  185. package/src/generators/init/schema.json +27 -0
  186. package/src/generators/library/files/common/README.md +7 -0
  187. package/src/generators/library/files/common/package.json__tmpl__ +4 -0
  188. package/src/generators/library/files/common/src/index.ts__tmpl__ +0 -0
  189. package/src/generators/library/files/common/tsconfig.lib.json__tmpl__ +14 -0
  190. package/src/generators/library/files/vite/README.md +7 -0
  191. package/src/generators/library/files/vite/package.json__tmpl__ +12 -0
  192. package/src/generators/library/files/vite/tsconfig.lib.json__tmpl__ +14 -0
  193. package/src/generators/library/lib/add-linting.d.ts +3 -0
  194. package/src/generators/library/lib/add-linting.js +36 -0
  195. package/src/generators/library/lib/add-rollup-build-target.d.ts +4 -0
  196. package/src/generators/library/lib/add-rollup-build-target.js +59 -0
  197. package/src/generators/library/lib/create-files.d.ts +3 -0
  198. package/src/generators/library/lib/create-files.js +53 -0
  199. package/src/generators/library/lib/install-common-dependencies.d.ts +3 -0
  200. package/src/generators/library/lib/install-common-dependencies.js +47 -0
  201. package/src/generators/library/lib/normalize-options.d.ts +3 -0
  202. package/src/generators/library/lib/normalize-options.js +92 -0
  203. package/src/generators/library/lib/set-defaults.d.ts +3 -0
  204. package/src/generators/library/lib/set-defaults.js +23 -0
  205. package/src/generators/library/lib/update-app-routes.d.ts +3 -0
  206. package/src/generators/library/lib/update-app-routes.js +62 -0
  207. package/src/generators/library/library.d.ts +5 -0
  208. package/src/generators/library/library.js +193 -0
  209. package/src/generators/library/schema.d.ts +45 -0
  210. package/src/generators/library/schema.json +198 -0
  211. package/src/generators/redux/files/__fileName__.slice.spec.ts__tmpl__ +56 -0
  212. package/src/generators/redux/files/__fileName__.slice.ts__tmpl__ +129 -0
  213. package/src/generators/redux/redux.d.ts +5 -0
  214. package/src/generators/redux/redux.js +143 -0
  215. package/src/generators/redux/schema.d.ts +23 -0
  216. package/src/generators/redux/schema.json +51 -0
  217. package/src/generators/remote/files/common/src/main.js__tmpl__ +1 -0
  218. package/src/generators/remote/files/common/src/remote-entry.js__tmpl__ +1 -0
  219. package/src/generators/remote/files/common-ts/src/main.ts__tmpl__ +1 -0
  220. package/src/generators/remote/files/common-ts/src/remote-entry.ts__tmpl__ +1 -0
  221. package/src/generators/remote/files/module-federation/module-federation.config.js__tmpl__ +9 -0
  222. package/src/generators/remote/files/module-federation/webpack.config.js__tmpl__ +12 -0
  223. package/src/generators/remote/files/module-federation/webpack.config.prod.js__tmpl__ +1 -0
  224. package/src/generators/remote/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +6 -0
  225. package/src/generators/remote/files/module-federation-ssr/server.ts__tmpl__ +45 -0
  226. package/src/generators/remote/files/module-federation-ssr/webpack.server.config.js__tmpl__ +12 -0
  227. package/src/generators/remote/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +10 -0
  228. package/src/generators/remote/files/module-federation-ssr-ts/server.ts__tmpl__ +45 -0
  229. package/src/generators/remote/files/module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +19 -0
  230. package/src/generators/remote/files/module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +12 -0
  231. package/src/generators/remote/files/module-federation-ts/module-federation.config.ts__tmpl__ +13 -0
  232. package/src/generators/remote/files/module-federation-ts/tsconfig.lint.json__tmpl__ +19 -0
  233. package/src/generators/remote/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +1 -0
  234. package/src/generators/remote/files/module-federation-ts/webpack.config.ts__tmpl__ +12 -0
  235. package/src/generators/remote/lib/add-remote-to-dynamic-host.d.ts +2 -0
  236. package/src/generators/remote/lib/add-remote-to-dynamic-host.js +11 -0
  237. package/src/generators/remote/lib/setup-ssr-for-remote.d.ts +4 -0
  238. package/src/generators/remote/lib/setup-ssr-for-remote.js +40 -0
  239. package/src/generators/remote/lib/setup-tspath-for-remote.d.ts +3 -0
  240. package/src/generators/remote/lib/setup-tspath-for-remote.js +15 -0
  241. package/src/generators/remote/lib/update-host-with-remote.d.ts +2 -0
  242. package/src/generators/remote/lib/update-host-with-remote.js +64 -0
  243. package/src/generators/remote/remote.d.ts +7 -0
  244. package/src/generators/remote/remote.js +104 -0
  245. package/src/generators/remote/schema.d.ts +34 -0
  246. package/src/generators/remote/schema.json +183 -0
  247. package/src/generators/setup-ssr/files/server.ts__tmpl__ +28 -0
  248. package/src/generators/setup-ssr/files/src/main.server.tsx__tmpl__ +47 -0
  249. package/src/generators/setup-ssr/files/tsconfig.server.json__tmpl__ +17 -0
  250. package/src/generators/setup-ssr/schema.d.ts +7 -0
  251. package/src/generators/setup-ssr/schema.json +48 -0
  252. package/src/generators/setup-ssr/setup-ssr.d.ts +4 -0
  253. package/src/generators/setup-ssr/setup-ssr.js +183 -0
  254. package/src/generators/setup-tailwind/files/postcss.config.js__tmpl__ +15 -0
  255. package/src/generators/setup-tailwind/files/tailwind.config.js__tmpl__ +17 -0
  256. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.d.ts +3 -0
  257. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +36 -0
  258. package/src/generators/setup-tailwind/lib/update-project.d.ts +3 -0
  259. package/src/generators/setup-tailwind/lib/update-project.js +13 -0
  260. package/src/generators/setup-tailwind/schema.d.ts +6 -0
  261. package/src/generators/setup-tailwind/schema.js +2 -0
  262. package/src/generators/setup-tailwind/schema.json +47 -0
  263. package/src/generators/setup-tailwind/setup-tailwind.d.ts +4 -0
  264. package/src/generators/setup-tailwind/setup-tailwind.js +35 -0
  265. package/src/generators/stories/schema.json +67 -0
  266. package/src/generators/stories/stories.d.ts +15 -0
  267. package/src/generators/stories/stories.js +130 -0
  268. package/src/generators/storybook-configuration/configuration.d.ts +6 -0
  269. package/src/generators/storybook-configuration/configuration.js +74 -0
  270. package/src/generators/storybook-configuration/schema.d.ts +16 -0
  271. package/src/generators/storybook-configuration/schema.json +95 -0
  272. package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.d.ts +3 -0
  273. package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js +37 -0
  274. package/src/migrations/update-15-3-0/update-rollup-executor.d.ts +3 -0
  275. package/src/migrations/update-15-3-0/update-rollup-executor.js +15 -0
  276. package/src/migrations/update-15-6-3/webpack-config-setup.d.ts +2 -0
  277. package/src/migrations/update-15-6-3/webpack-config-setup.js +103 -0
  278. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  279. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
  280. package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.d.ts +2 -0
  281. package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.js +8 -0
  282. package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.d.ts +2 -0
  283. package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.js +8 -0
  284. package/src/migrations/update-16-7-0/add-babel-core.d.ts +2 -0
  285. package/src/migrations/update-16-7-0/add-babel-core.js +14 -0
  286. package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.d.ts +2 -0
  287. package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.js +57 -0
  288. package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.d.ts +2 -0
  289. package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +26 -0
  290. package/src/module-federation/ast-utils.d.ts +8 -0
  291. package/src/module-federation/ast-utils.js +102 -0
  292. package/src/module-federation/load-config.d.ts +3 -0
  293. package/src/module-federation/load-config.js +16 -0
  294. package/src/module-federation/models.d.ts +24 -0
  295. package/src/module-federation/models.js +2 -0
  296. package/src/module-federation/package-json.d.ts +8 -0
  297. package/src/module-federation/package-json.js +13 -0
  298. package/src/module-federation/utils.d.ts +12 -0
  299. package/src/module-federation/utils.js +76 -0
  300. package/src/module-federation/with-module-federation-ssr.d.ts +2 -0
  301. package/src/module-federation/with-module-federation-ssr.js +34 -0
  302. package/src/module-federation/with-module-federation.d.ts +7 -0
  303. package/src/module-federation/with-module-federation.js +50 -0
  304. package/src/rules/add-styled-dependencies.d.ts +5 -0
  305. package/src/rules/add-styled-dependencies.js +17 -0
  306. package/src/rules/update-module-federation-project.d.ts +9 -0
  307. package/src/rules/update-module-federation-project.js +50 -0
  308. package/src/utils/add-mf-env-to-inputs.d.ts +2 -0
  309. package/src/utils/add-mf-env-to-inputs.js +24 -0
  310. package/src/utils/assertion.d.ts +1 -0
  311. package/src/utils/assertion.js +19 -0
  312. package/src/utils/ast-utils.d.ts +29 -0
  313. package/src/utils/ast-utils.js +522 -0
  314. package/src/utils/component-props.d.ts +15 -0
  315. package/src/utils/component-props.js +60 -0
  316. package/src/utils/create-ts-config.d.ts +9 -0
  317. package/src/utils/create-ts-config.js +65 -0
  318. package/src/utils/ct-utils.d.ts +14 -0
  319. package/src/utils/ct-utils.js +94 -0
  320. package/src/utils/dependencies.d.ts +7 -0
  321. package/src/utils/dependencies.js +2 -0
  322. package/src/utils/format-file.d.ts +1 -0
  323. package/src/utils/format-file.js +12 -0
  324. package/src/utils/get-in-source-vitest-tests-template.d.ts +1 -0
  325. package/src/utils/get-in-source-vitest-tests-template.js +21 -0
  326. package/src/utils/has-vite-plugin.d.ts +2 -0
  327. package/src/utils/has-vite-plugin.js +11 -0
  328. package/src/utils/has-webpack-plugin.d.ts +2 -0
  329. package/src/utils/has-webpack-plugin.js +11 -0
  330. package/src/utils/jest-utils.d.ts +1 -0
  331. package/src/utils/jest-utils.js +9 -0
  332. package/src/utils/lint.d.ts +36 -0
  333. package/src/utils/lint.js +24 -0
  334. package/src/utils/maybe-js.d.ts +3 -0
  335. package/src/utils/maybe-js.js +9 -0
  336. package/src/utils/styled.d.ts +3 -0
  337. package/src/utils/styled.js +62 -0
  338. package/src/utils/testing-generators.d.ts +3 -0
  339. package/src/utils/testing-generators.js +30 -0
  340. package/src/utils/versions.d.ts +46 -0
  341. package/src/utils/versions.js +54 -0
  342. package/tailwind.d.ts +6 -0
  343. package/tailwind.js +29 -0
  344. package/typings/cssmodule.d.ts +19 -0
  345. package/typings/image.d.ts +48 -0
  346. package/typings/style.d.ts +9 -0
  347. package/typings/styled-jsx.d.ts +8 -0
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.libraryGeneratorInternal = exports.libraryGenerator = void 0;
4
+ const path_1 = require("path");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
7
+ const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
8
+ const js_1 = require("@nx/js");
9
+ const versions_1 = require("../../utils/versions");
10
+ const maybe_js_1 = require("../../utils/maybe-js");
11
+ const component_1 = require("../component/component");
12
+ const init_1 = require("../init/init");
13
+ const jest_utils_1 = require("../../utils/jest-utils");
14
+ const normalize_options_1 = require("./lib/normalize-options");
15
+ const add_rollup_build_target_1 = require("./lib/add-rollup-build-target");
16
+ const add_linting_1 = require("./lib/add-linting");
17
+ const update_app_routes_1 = require("./lib/update-app-routes");
18
+ const create_files_1 = require("./lib/create-files");
19
+ const create_ts_config_1 = require("../../utils/create-ts-config");
20
+ const install_common_dependencies_1 = require("./lib/install-common-dependencies");
21
+ const set_defaults_1 = require("./lib/set-defaults");
22
+ async function libraryGenerator(host, schema) {
23
+ return await libraryGeneratorInternal(host, {
24
+ addPlugin: false,
25
+ projectNameAndRootFormat: 'derived',
26
+ ...schema,
27
+ });
28
+ }
29
+ exports.libraryGenerator = libraryGenerator;
30
+ async function libraryGeneratorInternal(host, schema) {
31
+ const tasks = [];
32
+ const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
33
+ if (options.publishable === true && !schema.importPath) {
34
+ throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
35
+ }
36
+ if (!options.component) {
37
+ options.style = 'none';
38
+ }
39
+ const jsInitTask = await (0, js_1.initGenerator)(host, {
40
+ ...schema,
41
+ skipFormat: true,
42
+ });
43
+ tasks.push(jsInitTask);
44
+ const initTask = await (0, init_1.default)(host, {
45
+ ...options,
46
+ skipFormat: true,
47
+ });
48
+ tasks.push(initTask);
49
+ (0, devkit_1.addProjectConfiguration)(host, options.name, {
50
+ root: options.projectRoot,
51
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
52
+ projectType: 'library',
53
+ tags: options.parsedTags,
54
+ targets: {},
55
+ });
56
+ const lintTask = await (0, add_linting_1.addLinting)(host, options);
57
+ tasks.push(lintTask);
58
+ (0, create_files_1.createFiles)(host, options);
59
+ // Set up build target
60
+ if (options.buildable && options.bundler === 'vite') {
61
+ const { viteConfigurationGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
62
+ const viteTask = await viteConfigurationGenerator(host, {
63
+ uiFramework: 'react',
64
+ project: options.name,
65
+ newProject: true,
66
+ includeLib: true,
67
+ inSourceTests: options.inSourceTests,
68
+ includeVitest: options.unitTestRunner === 'vitest',
69
+ compiler: options.compiler,
70
+ skipFormat: true,
71
+ testEnvironment: 'jsdom',
72
+ addPlugin: options.addPlugin,
73
+ });
74
+ tasks.push(viteTask);
75
+ createOrEditViteConfig(host, {
76
+ project: options.name,
77
+ includeLib: true,
78
+ includeVitest: options.unitTestRunner === 'vitest',
79
+ inSourceTests: options.inSourceTests,
80
+ rollupOptionsExternal: [
81
+ "'react'",
82
+ "'react-dom'",
83
+ "'react/jsx-runtime'",
84
+ ],
85
+ imports: [
86
+ options.compiler === 'swc'
87
+ ? `import react from '@vitejs/plugin-react-swc'`
88
+ : `import react from '@vitejs/plugin-react'`,
89
+ ],
90
+ plugins: ['react()'],
91
+ }, false);
92
+ }
93
+ else if (options.buildable && options.bundler === 'rollup') {
94
+ const rollupTask = await (0, add_rollup_build_target_1.addRollupBuildTarget)(host, options);
95
+ tasks.push(rollupTask);
96
+ }
97
+ // Set up test target
98
+ if (options.unitTestRunner === 'jest') {
99
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
100
+ const jestTask = await configurationGenerator(host, {
101
+ ...options,
102
+ project: options.name,
103
+ setupFile: 'none',
104
+ supportTsx: true,
105
+ skipSerializers: true,
106
+ compiler: options.compiler,
107
+ skipFormat: true,
108
+ });
109
+ tasks.push(jestTask);
110
+ const jestConfigPath = (0, devkit_1.joinPathFragments)(options.projectRoot, options.js ? 'jest.config.js' : 'jest.config.ts');
111
+ if (options.compiler === 'babel' && host.exists(jestConfigPath)) {
112
+ const updatedContent = (0, jest_utils_1.updateJestConfigContent)(host.read(jestConfigPath, 'utf-8'));
113
+ host.write(jestConfigPath, updatedContent);
114
+ }
115
+ }
116
+ else if (options.unitTestRunner === 'vitest' &&
117
+ options.bundler !== 'vite' // tests are already configured if bundler is vite
118
+ ) {
119
+ const { vitestGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
120
+ const vitestTask = await vitestGenerator(host, {
121
+ uiFramework: 'react',
122
+ project: options.name,
123
+ coverageProvider: 'v8',
124
+ inSourceTests: options.inSourceTests,
125
+ skipFormat: true,
126
+ testEnvironment: 'jsdom',
127
+ addPlugin: options.addPlugin,
128
+ });
129
+ tasks.push(vitestTask);
130
+ createOrEditViteConfig(host, {
131
+ project: options.name,
132
+ includeLib: true,
133
+ includeVitest: true,
134
+ inSourceTests: options.inSourceTests,
135
+ rollupOptionsExternal: [
136
+ "'react'",
137
+ "'react-dom'",
138
+ "'react/jsx-runtime'",
139
+ ],
140
+ imports: [`import react from '@vitejs/plugin-react'`],
141
+ plugins: ['react()'],
142
+ }, true);
143
+ }
144
+ if (options.component) {
145
+ const relativeCwd = (0, artifact_name_and_directory_utils_1.getRelativeCwd)();
146
+ const name = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/lib', options.fileName);
147
+ const componentTask = await (0, component_1.default)(host, {
148
+ nameAndDirectoryFormat: 'as-provided',
149
+ name: relativeCwd ? (0, path_1.relative)(relativeCwd, name) : name,
150
+ project: options.name,
151
+ flat: true,
152
+ style: options.style,
153
+ skipTests: options.unitTestRunner === 'none' ||
154
+ (options.unitTestRunner === 'vitest' && options.inSourceTests == true),
155
+ export: true,
156
+ routing: options.routing,
157
+ js: options.js,
158
+ pascalCaseFiles: options.pascalCaseFiles,
159
+ inSourceTests: options.inSourceTests,
160
+ skipFormat: true,
161
+ globalCss: options.globalCss,
162
+ });
163
+ tasks.push(componentTask);
164
+ }
165
+ if (options.publishable || options.buildable) {
166
+ (0, devkit_1.updateJson)(host, `${options.projectRoot}/package.json`, (json) => {
167
+ json.name = options.importPath;
168
+ return json;
169
+ });
170
+ }
171
+ if (!options.skipPackageJson) {
172
+ const installReactTask = (0, install_common_dependencies_1.installCommonDependencies)(host, options);
173
+ tasks.push(installReactTask);
174
+ }
175
+ const routeTask = (0, update_app_routes_1.updateAppRoutes)(host, options);
176
+ tasks.push(routeTask);
177
+ (0, set_defaults_1.setDefaults)(host, options);
178
+ (0, create_ts_config_1.extractTsConfigBase)(host);
179
+ if (!options.skipTsConfig) {
180
+ (0, js_1.addTsConfigPath)(host, options.importPath, [
181
+ (0, maybe_js_1.maybeJs)(options, (0, devkit_1.joinPathFragments)(options.projectRoot, './src/index.ts')),
182
+ ]);
183
+ }
184
+ if (!options.skipFormat) {
185
+ await (0, devkit_1.formatFiles)(host);
186
+ }
187
+ tasks.push(() => {
188
+ (0, log_show_project_command_1.logShowProjectCommand)(options.name);
189
+ });
190
+ return (0, devkit_1.runTasksInSerial)(...tasks);
191
+ }
192
+ exports.libraryGeneratorInternal = libraryGeneratorInternal;
193
+ exports.default = libraryGenerator;
@@ -0,0 +1,45 @@
1
+ import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
+ import type { Linter } from '@nx/eslint';
3
+ import type { SupportedStyles } from '../../../typings/style';
4
+
5
+ export interface Schema {
6
+ appProject?: string;
7
+ buildable?: boolean;
8
+ bundler?: 'none' | 'rollup' | 'vite';
9
+ compiler?: 'babel' | 'swc';
10
+ component?: boolean;
11
+ directory?: string;
12
+ projectNameAndRootFormat?: ProjectNameAndRootFormat;
13
+ globalCss?: boolean;
14
+ importPath?: string;
15
+ inSourceTests?: boolean;
16
+ js?: boolean;
17
+ linter: Linter;
18
+ name: string;
19
+ pascalCaseFiles?: boolean;
20
+ publishable?: boolean;
21
+ routing?: boolean;
22
+ setParserOptionsProject?: boolean;
23
+ skipFormat?: boolean;
24
+ skipPackageJson?: boolean;
25
+ skipTsConfig?: boolean;
26
+ strict?: boolean;
27
+ style: SupportedStyles;
28
+ tags?: string;
29
+ unitTestRunner?: 'jest' | 'vitest' | 'none';
30
+ minimal?: boolean;
31
+ simpleName?: boolean;
32
+ addPlugin?: boolean;
33
+ }
34
+
35
+ export interface NormalizedSchema extends Schema {
36
+ js: boolean;
37
+ name: string;
38
+ fileName: string;
39
+ projectRoot: string;
40
+ routePath: string;
41
+ parsedTags: string[];
42
+ appMain?: string;
43
+ appSourceRoot?: string;
44
+ unitTestRunner: 'jest' | 'vitest' | 'none';
45
+ }
@@ -0,0 +1,198 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "NxReactLibrary",
5
+ "title": "Create a React Library",
6
+ "description": "Create a React Library for an Nx workspace.",
7
+ "type": "object",
8
+ "examples": [
9
+ {
10
+ "command": "nx g lib mylib --directory=myapp",
11
+ "description": "Generate `libs/myapp/mylib`"
12
+ },
13
+ {
14
+ "command": "nx g lib mylib --appProject=myapp",
15
+ "description": "Generate a library with routes and add them to `myapp`"
16
+ }
17
+ ],
18
+ "properties": {
19
+ "name": {
20
+ "type": "string",
21
+ "description": "Library name",
22
+ "$default": {
23
+ "$source": "argv",
24
+ "index": 0
25
+ },
26
+ "x-prompt": "What name would you like to use for the library?",
27
+ "pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$",
28
+ "x-priority": "important"
29
+ },
30
+ "directory": {
31
+ "type": "string",
32
+ "description": "A directory where the lib is placed.",
33
+ "alias": "dir",
34
+ "x-priority": "important"
35
+ },
36
+ "projectNameAndRootFormat": {
37
+ "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`).",
38
+ "type": "string",
39
+ "enum": ["as-provided", "derived"]
40
+ },
41
+ "style": {
42
+ "description": "The file extension to be used for style files.",
43
+ "type": "string",
44
+ "default": "css",
45
+ "alias": "s",
46
+ "x-prompt": {
47
+ "message": "Which stylesheet format would you like to use?",
48
+ "type": "list",
49
+ "items": [
50
+ { "value": "css", "label": "CSS" },
51
+ {
52
+ "value": "scss",
53
+ "label": "SASS(.scss) [ https://sass-lang.com ]"
54
+ },
55
+ {
56
+ "value": "less",
57
+ "label": "LESS [ https://lesscss.org ]"
58
+ },
59
+ {
60
+ "value": "styled-components",
61
+ "label": "styled-components [ https://styled-components.com ]"
62
+ },
63
+ {
64
+ "value": "@emotion/styled",
65
+ "label": "emotion [ https://emotion.sh ]"
66
+ },
67
+ {
68
+ "value": "styled-jsx",
69
+ "label": "styled-jsx [ https://www.npmjs.com/package/styled-jsx ]"
70
+ },
71
+ {
72
+ "value": "none",
73
+ "label": "None"
74
+ }
75
+ ]
76
+ }
77
+ },
78
+ "linter": {
79
+ "description": "The tool to use for running lint checks.",
80
+ "type": "string",
81
+ "enum": ["eslint", "none"],
82
+ "default": "eslint"
83
+ },
84
+ "unitTestRunner": {
85
+ "type": "string",
86
+ "enum": ["jest", "vitest", "none"],
87
+ "description": "Test runner to use for unit tests.",
88
+ "x-prompt": "What unit test runner should be used?"
89
+ },
90
+ "inSourceTests": {
91
+ "type": "boolean",
92
+ "default": false,
93
+ "description": "When using Vitest, separate spec files will not be generated and instead will be included within the source files."
94
+ },
95
+ "tags": {
96
+ "type": "string",
97
+ "description": "Add tags to the library (used for linting).",
98
+ "alias": "t"
99
+ },
100
+ "skipFormat": {
101
+ "description": "Skip formatting files.",
102
+ "type": "boolean",
103
+ "default": false,
104
+ "x-priority": "internal"
105
+ },
106
+ "skipTsConfig": {
107
+ "type": "boolean",
108
+ "default": false,
109
+ "description": "Do not update `tsconfig.json` for development experience.",
110
+ "x-priority": "internal"
111
+ },
112
+ "pascalCaseFiles": {
113
+ "type": "boolean",
114
+ "description": "Use pascal case component file name (e.g. `App.tsx`).",
115
+ "alias": "P",
116
+ "default": false
117
+ },
118
+ "routing": {
119
+ "type": "boolean",
120
+ "description": "Generate library with routes."
121
+ },
122
+ "appProject": {
123
+ "type": "string",
124
+ "description": "The application project to add the library route to.",
125
+ "alias": "a"
126
+ },
127
+ "publishable": {
128
+ "type": "boolean",
129
+ "description": "Create a publishable library."
130
+ },
131
+ "buildable": {
132
+ "type": "boolean",
133
+ "default": false,
134
+ "description": "Generate a buildable library that uses rollup to bundle.",
135
+ "x-deprecated": "Use the `bundler` option for greater control (none, vite, rollup)."
136
+ },
137
+ "importPath": {
138
+ "type": "string",
139
+ "description": "The library name used to import it, like `@myorg/my-awesome-lib`."
140
+ },
141
+ "component": {
142
+ "type": "boolean",
143
+ "description": "Generate a default component.",
144
+ "default": true
145
+ },
146
+ "js": {
147
+ "type": "boolean",
148
+ "description": "Generate JavaScript files rather than TypeScript files.",
149
+ "default": false
150
+ },
151
+ "globalCss": {
152
+ "type": "boolean",
153
+ "description": "When `true`, the stylesheet is generated using global CSS instead of CSS modules (e.g. file is `*.css` rather than `*.module.css`).",
154
+ "default": false
155
+ },
156
+ "strict": {
157
+ "type": "boolean",
158
+ "description": "Whether to enable tsconfig strict mode or not.",
159
+ "default": true
160
+ },
161
+ "setParserOptionsProject": {
162
+ "type": "boolean",
163
+ "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
164
+ "default": false
165
+ },
166
+ "bundler": {
167
+ "type": "string",
168
+ "description": "The bundler to use. Choosing 'none' means this library is not buildable.",
169
+ "enum": ["none", "vite", "rollup"],
170
+ "default": "none",
171
+ "x-prompt": "Which bundler would you like to use to build the library? Choose 'none' to skip build setup.",
172
+ "x-priority": "important"
173
+ },
174
+ "compiler": {
175
+ "type": "string",
176
+ "enum": ["babel", "swc"],
177
+ "default": "babel",
178
+ "description": "Which compiler to use."
179
+ },
180
+ "skipPackageJson": {
181
+ "description": "Do not add dependencies to `package.json`.",
182
+ "type": "boolean",
183
+ "default": false,
184
+ "x-priority": "internal"
185
+ },
186
+ "minimal": {
187
+ "description": "Create a React library with a minimal setup, no separate test files.",
188
+ "type": "boolean",
189
+ "default": false
190
+ },
191
+ "simpleName": {
192
+ "description": "Don't include the directory in the name of the module of the library.",
193
+ "type": "boolean",
194
+ "default": false
195
+ }
196
+ },
197
+ "required": ["name"]
198
+ }
@@ -0,0 +1,56 @@
1
+ import { fetch<%= className %>, <%= propertyName %>Adapter, <%= propertyName %>Reducer } from './<%= fileName %>.slice';
2
+
3
+ describe('<%= propertyName %> reducer', () => {
4
+ it('should handle initial state', () => {
5
+ const expected = <%= propertyName %>Adapter.getInitialState({
6
+ loadingStatus: 'not loaded',
7
+ error: null
8
+ });
9
+
10
+ expect(<%= propertyName %>Reducer(undefined, { type: '' })).toEqual(expected);
11
+ });
12
+
13
+ it('should handle fetch<%= className %>', () => {
14
+ let state = <%= propertyName %>Reducer(
15
+ undefined,
16
+ fetch<%= className %>.pending('')
17
+ );
18
+
19
+ expect(state).toEqual(
20
+ expect.objectContaining({
21
+ loadingStatus: 'loading',
22
+ error: null,
23
+ entities: {},
24
+ ids: []
25
+ })
26
+ );
27
+
28
+ state = <%= propertyName %>Reducer(
29
+ state,
30
+ fetch<%= className %>.fulfilled([{ id: 1 }], '')
31
+ );
32
+
33
+ expect(state).toEqual(
34
+ expect.objectContaining({
35
+ loadingStatus: 'loaded',
36
+ error: null,
37
+ entities: { 1: { id: 1 } },
38
+ ids: [1]
39
+ })
40
+ );
41
+
42
+ state = <%= propertyName %>Reducer(
43
+ state,
44
+ fetch<%= className %>.rejected(new Error('Uh oh'), '')
45
+ );
46
+
47
+ expect(state).toEqual(
48
+ expect.objectContaining({
49
+ loadingStatus: 'error',
50
+ error: 'Uh oh',
51
+ entities: { 1: { id: 1 } },
52
+ ids: [1]
53
+ })
54
+ );
55
+ });
56
+ });
@@ -0,0 +1,129 @@
1
+ import {
2
+ createAsyncThunk,
3
+ createEntityAdapter,
4
+ createSelector,
5
+ createSlice,
6
+ EntityState,
7
+ PayloadAction
8
+ } from '@reduxjs/toolkit';
9
+
10
+ export const <%= constantName %>_FEATURE_KEY = '<%= propertyName %>';
11
+
12
+ /*
13
+ * Update these interfaces according to your requirements.
14
+ */
15
+ export interface <%= className %>Entity {
16
+ id: number;
17
+ }
18
+
19
+ export interface <%= className %>State extends EntityState<<%= className %>Entity> {
20
+ loadingStatus: 'not loaded' | 'loading' | 'loaded' | 'error';
21
+ error?: string | null;
22
+ }
23
+
24
+ export const <%= propertyName %>Adapter = createEntityAdapter<<%= className %>Entity>();
25
+
26
+ /**
27
+ * Export an effect using createAsyncThunk from
28
+ * the Redux Toolkit: https://redux-toolkit.js.org/api/createAsyncThunk
29
+ *
30
+ * e.g.
31
+ * ```
32
+ * import React, { useEffect } from 'react';
33
+ * import { useDispatch } from 'react-redux';
34
+ *
35
+ * // ...
36
+ *
37
+ * const dispatch = useDispatch();
38
+ * useEffect(() => {
39
+ * dispatch(fetch<%= className %>())
40
+ * }, [dispatch]);
41
+ * ```
42
+ */
43
+ export const fetch<%= className %> = createAsyncThunk<<%= className %>Entity[]>(
44
+ '<%= propertyName %>/fetchStatus',
45
+ async (_, thunkAPI) => {
46
+ /**
47
+ * Replace this with your custom fetch call.
48
+ * For example, `return myApi.get<%= className %>s()`;
49
+ * Right now we just return an empty array.
50
+ */
51
+ return Promise.resolve([]);
52
+ }
53
+ );
54
+
55
+ export const initial<%= className %>State: <%= className %>State = <%= propertyName %>Adapter.getInitialState({
56
+ loadingStatus: 'not loaded',
57
+ error: null
58
+ });
59
+
60
+ export const <%= propertyName %>Slice = createSlice({
61
+ name: <%= constantName %>_FEATURE_KEY,
62
+ initialState: initial<%= className %>State,
63
+ reducers: {
64
+ add: <%= propertyName %>Adapter.addOne,
65
+ remove: <%= propertyName %>Adapter.removeOne
66
+ // ...
67
+ },
68
+ extraReducers: builder => {
69
+ builder
70
+ .addCase(fetch<%= className %>.pending, (state: <%= className %>State) => {
71
+ state.loadingStatus = 'loading';
72
+ })
73
+ .addCase(fetch<%= className %>.fulfilled, (state: <%= className %>State, action: PayloadAction<<%= className %>Entity[]>) => {
74
+ <%= propertyName %>Adapter.setAll(state, action.payload);
75
+ state.loadingStatus = 'loaded';
76
+ })
77
+ .addCase(fetch<%= className %>.rejected, (state: <%= className %>State, action) => {
78
+ state.loadingStatus = 'error';
79
+ state.error = action.error.message;
80
+ });
81
+ }
82
+ });
83
+
84
+ /*
85
+ * Export reducer for store configuration.
86
+ */
87
+ export const <%= propertyName %>Reducer = <%= propertyName %>Slice.reducer;
88
+
89
+ /*
90
+ * Export action creators to be dispatched. For use with the `useDispatch` hook.
91
+ *
92
+ * e.g.
93
+ * ```
94
+ * import React, { useEffect } from 'react';
95
+ * import { useDispatch } from 'react-redux';
96
+ *
97
+ * // ...
98
+ *
99
+ * const dispatch = useDispatch();
100
+ * useEffect(() => {
101
+ * dispatch(<%= propertyName %>Actions.add({ id: 1 }))
102
+ * }, [dispatch]);
103
+ * ```
104
+ *
105
+ * See: https://react-redux.js.org/next/api/hooks#usedispatch
106
+ */
107
+ export const <%= propertyName %>Actions = <%= propertyName %>Slice.actions;
108
+
109
+ /*
110
+ * Export selectors to query state. For use with the `useSelector` hook.
111
+ *
112
+ * e.g.
113
+ * ```
114
+ * import { useSelector } from 'react-redux';
115
+ *
116
+ * // ...
117
+ *
118
+ * const entities = useSelector(selectAll<%= className %>);
119
+ * ```
120
+ *
121
+ * See: https://react-redux.js.org/next/api/hooks#useselector
122
+ */
123
+ const { selectAll, selectEntities } = <%= propertyName %>Adapter.getSelectors();
124
+
125
+ export const get<%= className %>State = (rootState: {[<%= constantName %>_FEATURE_KEY]: <%= className %>State }): <%= className %>State => rootState[<%= constantName %>_FEATURE_KEY];
126
+
127
+ export const selectAll<%= className %> = createSelector(get<%= className %>State, selectAll);
128
+
129
+ export const select<%= className %>Entities = createSelector(get<%= className %>State, selectEntities);
@@ -0,0 +1,5 @@
1
+ import { Schema } from './schema';
2
+ import { Tree } from '@nx/devkit';
3
+ export declare function reduxGenerator(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
4
+ export declare function reduxGeneratorInternal(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
5
+ export default reduxGenerator;