@nx/react 16.0.0-beta.1

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 (421) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +22 -0
  3. package/README.md +63 -0
  4. package/ast-utils.d.ts +1 -0
  5. package/ast-utils.js +12 -0
  6. package/ast-utils.js.map +1 -0
  7. package/babel.d.ts +16 -0
  8. package/babel.js +52 -0
  9. package/babel.js.map +1 -0
  10. package/executors.json +26 -0
  11. package/generators.json +223 -0
  12. package/index.d.ts +21 -0
  13. package/index.js +47 -0
  14. package/index.js.map +1 -0
  15. package/migrations.json +870 -0
  16. package/module-federation.d.ts +4 -0
  17. package/module-federation.js +13 -0
  18. package/module-federation.js.map +1 -0
  19. package/package.json +49 -0
  20. package/plugins/bundle-rollup.d.ts +1 -0
  21. package/plugins/bundle-rollup.js +42 -0
  22. package/plugins/bundle-rollup.js.map +1 -0
  23. package/plugins/component-testing/index.d.ts +38 -0
  24. package/plugins/component-testing/index.js +122 -0
  25. package/plugins/component-testing/index.js.map +1 -0
  26. package/plugins/component-testing/webpack-fallback.d.ts +5 -0
  27. package/plugins/component-testing/webpack-fallback.js +135 -0
  28. package/plugins/component-testing/webpack-fallback.js.map +1 -0
  29. package/plugins/jest.d.ts +1 -0
  30. package/plugins/jest.js +62 -0
  31. package/plugins/jest.js.map +1 -0
  32. package/plugins/storybook/index.d.ts +3 -0
  33. package/plugins/storybook/index.js +77 -0
  34. package/plugins/storybook/index.js.map +1 -0
  35. package/plugins/storybook/merge-plugins.d.ts +3 -0
  36. package/plugins/storybook/merge-plugins.js +18 -0
  37. package/plugins/storybook/merge-plugins.js.map +1 -0
  38. package/plugins/webpack.d.ts +3 -0
  39. package/plugins/webpack.js +15 -0
  40. package/plugins/webpack.js.map +1 -0
  41. package/plugins/with-react.d.ts +12 -0
  42. package/plugins/with-react.js +82 -0
  43. package/plugins/with-react.js.map +1 -0
  44. package/src/executors/module-federation-dev-server/compat.d.ts +2 -0
  45. package/src/executors/module-federation-dev-server/compat.js +6 -0
  46. package/src/executors/module-federation-dev-server/compat.js.map +1 -0
  47. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +11 -0
  48. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +55 -0
  49. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js.map +1 -0
  50. package/src/executors/module-federation-dev-server/schema.json +96 -0
  51. package/src/executors/module-federation-ssr-dev-server/compat.d.ts +2 -0
  52. package/src/executors/module-federation-ssr-dev-server/compat.js +6 -0
  53. package/src/executors/module-federation-ssr-dev-server/compat.js.map +1 -0
  54. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +9 -0
  55. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +71 -0
  56. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js.map +1 -0
  57. package/src/executors/module-federation-ssr-dev-server/schema.json +48 -0
  58. package/src/generators/application/application.d.ts +5 -0
  59. package/src/generators/application/application.js +129 -0
  60. package/src/generators/application/application.js.map +1 -0
  61. package/src/generators/application/files/base-vite/index.html__tmpl__ +16 -0
  62. package/src/generators/application/files/base-vite/public/favicon.ico +0 -0
  63. package/src/generators/application/files/base-vite/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
  64. package/src/generators/application/files/base-vite/src/assets/.gitkeep +0 -0
  65. package/src/generators/application/files/base-vite/src/environments/environment.prod.ts__tmpl__ +3 -0
  66. package/src/generators/application/files/base-vite/src/environments/environment.ts__tmpl__ +6 -0
  67. package/src/generators/application/files/base-vite/src/main.tsx__tmpl__ +10 -0
  68. package/src/generators/application/files/base-vite/tsconfig.app.json__tmpl__ +14 -0
  69. package/src/generators/application/files/base-webpack/.babelrc__tmpl__ +13 -0
  70. package/src/generators/application/files/base-webpack/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
  71. package/src/generators/application/files/base-webpack/src/assets/.gitkeep +0 -0
  72. package/src/generators/application/files/base-webpack/src/environments/environment.prod.ts__tmpl__ +3 -0
  73. package/src/generators/application/files/base-webpack/src/environments/environment.ts__tmpl__ +6 -0
  74. package/src/generators/application/files/base-webpack/src/favicon.ico +0 -0
  75. package/src/generators/application/files/base-webpack/src/index.html +14 -0
  76. package/src/generators/application/files/base-webpack/src/main.tsx__tmpl__ +10 -0
  77. package/src/generators/application/files/base-webpack/tsconfig.app.json__tmpl__ +14 -0
  78. package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +9 -0
  79. package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +845 -0
  80. package/src/generators/application/files/style-css-module/src/app/__fileName__.module.__style__ +1 -0
  81. package/src/generators/application/files/style-css-module/src/app/__fileName__.tsx__tmpl__ +37 -0
  82. package/src/generators/application/files/style-css-module/src/styles.__style__ +1 -0
  83. package/src/generators/application/files/style-global-css/src/app/__fileName__.__style__ +1 -0
  84. package/src/generators/application/files/style-global-css/src/app/__fileName__.tsx__tmpl__ +36 -0
  85. package/src/generators/application/files/style-global-css/src/styles.__style__ +1 -0
  86. package/src/generators/application/files/style-none/src/app/__fileName__.tsx__tmpl__ +35 -0
  87. package/src/generators/application/files/style-styled-jsx/src/app/__fileName__.tsx__tmpl__ +29 -0
  88. package/src/generators/application/files/style-styled-module/src/app/__fileName__.tsx__tmpl__ +40 -0
  89. package/src/generators/application/lib/add-cypress.d.ts +3 -0
  90. package/src/generators/application/lib/add-cypress.js +22 -0
  91. package/src/generators/application/lib/add-cypress.js.map +1 -0
  92. package/src/generators/application/lib/add-jest.d.ts +3 -0
  93. package/src/generators/application/lib/add-jest.js +17 -0
  94. package/src/generators/application/lib/add-jest.js.map +1 -0
  95. package/src/generators/application/lib/add-project.d.ts +2 -0
  96. package/src/generators/application/lib/add-project.js +98 -0
  97. package/src/generators/application/lib/add-project.js.map +1 -0
  98. package/src/generators/application/lib/add-routing.d.ts +3 -0
  99. package/src/generators/application/lib/add-routing.js +32 -0
  100. package/src/generators/application/lib/add-routing.js.map +1 -0
  101. package/src/generators/application/lib/create-application-files.d.ts +3 -0
  102. package/src/generators/application/lib/create-application-files.js +47 -0
  103. package/src/generators/application/lib/create-application-files.js.map +1 -0
  104. package/src/generators/application/lib/find-free-port.d.ts +2 -0
  105. package/src/generators/application/lib/find-free-port.js +18 -0
  106. package/src/generators/application/lib/find-free-port.js.map +1 -0
  107. package/src/generators/application/lib/get-app-tests.d.ts +2 -0
  108. package/src/generators/application/lib/get-app-tests.js +22 -0
  109. package/src/generators/application/lib/get-app-tests.js.map +1 -0
  110. package/src/generators/application/lib/install-common-dependencies.d.ts +3 -0
  111. package/src/generators/application/lib/install-common-dependencies.js +29 -0
  112. package/src/generators/application/lib/install-common-dependencies.js.map +1 -0
  113. package/src/generators/application/lib/normalize-options.d.ts +5 -0
  114. package/src/generators/application/lib/normalize-options.js +60 -0
  115. package/src/generators/application/lib/normalize-options.js.map +1 -0
  116. package/src/generators/application/lib/set-defaults.d.ts +3 -0
  117. package/src/generators/application/lib/set-defaults.js +23 -0
  118. package/src/generators/application/lib/set-defaults.js.map +1 -0
  119. package/src/generators/application/lib/update-jest-config.d.ts +3 -0
  120. package/src/generators/application/lib/update-jest-config.js +30 -0
  121. package/src/generators/application/lib/update-jest-config.js.map +1 -0
  122. package/src/generators/application/schema.d.ts +44 -0
  123. package/src/generators/application/schema.json +196 -0
  124. package/src/generators/component/component.d.ts +5 -0
  125. package/src/generators/component/component.js +141 -0
  126. package/src/generators/component/component.js.map +1 -0
  127. package/src/generators/component/files/__fileName__.__style__ +0 -0
  128. package/src/generators/component/files/__fileName__.module.__style__ +7 -0
  129. package/src/generators/component/files/__fileName__.spec.tsx__tmpl__ +7 -0
  130. package/src/generators/component/files/__fileName__.tsx__tmpl__ +71 -0
  131. package/src/generators/component/get-component-tests.d.ts +2 -0
  132. package/src/generators/component/get-component-tests.js +13 -0
  133. package/src/generators/component/get-component-tests.js.map +1 -0
  134. package/src/generators/component/noramlized-schema.d.ts +8 -0
  135. package/src/generators/component/noramlized-schema.js +3 -0
  136. package/src/generators/component/noramlized-schema.js.map +1 -0
  137. package/src/generators/component/schema.d.ts +20 -0
  138. package/src/generators/component/schema.json +153 -0
  139. package/src/generators/component-cypress-spec/component-cypress-spec.d.ts +14 -0
  140. package/src/generators/component-cypress-spec/component-cypress-spec.js +105 -0
  141. package/src/generators/component-cypress-spec/component-cypress-spec.js.map +1 -0
  142. package/src/generators/component-cypress-spec/files/__componentName__.__fileExt__ +13 -0
  143. package/src/generators/component-cypress-spec/schema.json +44 -0
  144. package/src/generators/component-story/component-story.d.ts +12 -0
  145. package/src/generators/component-story/component-story.js +81 -0
  146. package/src/generators/component-story/component-story.js.map +1 -0
  147. package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +32 -0
  148. package/src/generators/component-story/schema.json +36 -0
  149. package/src/generators/component-test/component-test.d.ts +4 -0
  150. package/src/generators/component-test/component-test.js +78 -0
  151. package/src/generators/component-test/component-test.js.map +1 -0
  152. package/src/generators/component-test/files/__fileName__.cy__ext__ +21 -0
  153. package/src/generators/component-test/schema.d.ts +4 -0
  154. package/src/generators/component-test/schema.js +3 -0
  155. package/src/generators/component-test/schema.js.map +1 -0
  156. package/src/generators/component-test/schema.json +31 -0
  157. package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +9 -0
  158. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +34 -0
  159. package/src/generators/cypress-component-configuration/cypress-component-configuration.js.map +1 -0
  160. package/src/generators/cypress-component-configuration/files/cypress/support/commands.ts__tpl__ +42 -0
  161. package/src/generators/cypress-component-configuration/files/cypress.config.ts__tpl__ +8 -0
  162. package/src/generators/cypress-component-configuration/lib/add-files.d.ts +4 -0
  163. package/src/generators/cypress-component-configuration/lib/add-files.js +75 -0
  164. package/src/generators/cypress-component-configuration/lib/add-files.js.map +1 -0
  165. package/src/generators/cypress-component-configuration/lib/update-configs.d.ts +7 -0
  166. package/src/generators/cypress-component-configuration/lib/update-configs.js +30 -0
  167. package/src/generators/cypress-component-configuration/lib/update-configs.js.map +1 -0
  168. package/src/generators/cypress-component-configuration/schema.d.ts +7 -0
  169. package/src/generators/cypress-component-configuration/schema.json +54 -0
  170. package/src/generators/hook/files/__fileName__.spec.tsx__tmpl__ +18 -0
  171. package/src/generators/hook/files/__fileName__.ts__tmpl__ +15 -0
  172. package/src/generators/hook/hook.d.ts +5 -0
  173. package/src/generators/hook/hook.js +117 -0
  174. package/src/generators/hook/hook.js.map +1 -0
  175. package/src/generators/hook/schema.d.ts +11 -0
  176. package/src/generators/hook/schema.json +77 -0
  177. package/src/generators/host/files/common/src/app/__fileName__.tsx__tmpl__ +33 -0
  178. package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +6 -0
  179. package/src/generators/host/files/module-federation/src/main.ts__tmpl__ +1 -0
  180. package/src/generators/host/files/module-federation/src/remotes.d.ts__tmpl__ +4 -0
  181. package/src/generators/host/files/module-federation/webpack.config.js__tmpl__ +12 -0
  182. package/src/generators/host/files/module-federation/webpack.config.prod.js__tmpl__ +32 -0
  183. package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +13 -0
  184. package/src/generators/host/files/module-federation-ssr/server.ts__tmpl__ +28 -0
  185. package/src/generators/host/files/module-federation-ssr/tsconfig.server.json__tmpl__ +15 -0
  186. package/src/generators/host/files/module-federation-ssr/webpack.server.config.js__tmpl__ +12 -0
  187. package/src/generators/host/host.d.ts +4 -0
  188. package/src/generators/host/host.js +67 -0
  189. package/src/generators/host/host.js.map +1 -0
  190. package/src/generators/host/lib/add-module-federation-files.d.ts +5 -0
  191. package/src/generators/host/lib/add-module-federation-files.js +21 -0
  192. package/src/generators/host/lib/add-module-federation-files.js.map +1 -0
  193. package/src/generators/host/lib/setup-ssr-for-host.d.ts +6 -0
  194. package/src/generators/host/lib/setup-ssr-for-host.js +27 -0
  195. package/src/generators/host/lib/setup-ssr-for-host.js.map +1 -0
  196. package/src/generators/host/lib/update-module-federation-e2e-project.d.ts +3 -0
  197. package/src/generators/host/lib/update-module-federation-e2e-project.js +16 -0
  198. package/src/generators/host/lib/update-module-federation-e2e-project.js.map +1 -0
  199. package/src/generators/host/schema.d.ts +31 -0
  200. package/src/generators/host/schema.json +168 -0
  201. package/src/generators/init/init.d.ts +5 -0
  202. package/src/generators/init/init.js +80 -0
  203. package/src/generators/init/init.js.map +1 -0
  204. package/src/generators/init/schema.d.ts +11 -0
  205. package/src/generators/init/schema.json +49 -0
  206. package/src/generators/library/files/common/.babelrc__tmpl__ +16 -0
  207. package/src/generators/library/files/common/README.md +7 -0
  208. package/src/generators/library/files/common/package.json__tmpl__ +4 -0
  209. package/src/generators/library/files/common/src/index.ts__tmpl__ +0 -0
  210. package/src/generators/library/files/common/tsconfig.lib.json__tmpl__ +14 -0
  211. package/src/generators/library/files/vite/README.md +7 -0
  212. package/src/generators/library/files/vite/package.json__tmpl__ +12 -0
  213. package/src/generators/library/files/vite/tsconfig.lib.json__tmpl__ +14 -0
  214. package/src/generators/library/lib/add-linting.d.ts +3 -0
  215. package/src/generators/library/lib/add-linting.js +38 -0
  216. package/src/generators/library/lib/add-linting.js.map +1 -0
  217. package/src/generators/library/lib/add-rollup-build-target.d.ts +3 -0
  218. package/src/generators/library/lib/add-rollup-build-target.js +59 -0
  219. package/src/generators/library/lib/add-rollup-build-target.js.map +1 -0
  220. package/src/generators/library/lib/create-files.d.ts +3 -0
  221. package/src/generators/library/lib/create-files.js +26 -0
  222. package/src/generators/library/lib/create-files.js.map +1 -0
  223. package/src/generators/library/lib/install-common-dependencies.d.ts +3 -0
  224. package/src/generators/library/lib/install-common-dependencies.js +30 -0
  225. package/src/generators/library/lib/install-common-dependencies.js.map +1 -0
  226. package/src/generators/library/lib/maybe-js.d.ts +2 -0
  227. package/src/generators/library/lib/maybe-js.js +10 -0
  228. package/src/generators/library/lib/maybe-js.js.map +1 -0
  229. package/src/generators/library/lib/normalize-options.d.ts +3 -0
  230. package/src/generators/library/lib/normalize-options.js +57 -0
  231. package/src/generators/library/lib/normalize-options.js.map +1 -0
  232. package/src/generators/library/lib/set-defaults.d.ts +3 -0
  233. package/src/generators/library/lib/set-defaults.js +16 -0
  234. package/src/generators/library/lib/set-defaults.js.map +1 -0
  235. package/src/generators/library/lib/update-app-routes.d.ts +3 -0
  236. package/src/generators/library/lib/update-app-routes.js +63 -0
  237. package/src/generators/library/lib/update-app-routes.js.map +1 -0
  238. package/src/generators/library/library.d.ts +5 -0
  239. package/src/generators/library/library.js +128 -0
  240. package/src/generators/library/library.js.map +1 -0
  241. package/src/generators/library/schema.d.ts +43 -0
  242. package/src/generators/library/schema.json +192 -0
  243. package/src/generators/redux/files/__directory__/__fileName__.slice.spec.ts__tmpl__ +53 -0
  244. package/src/generators/redux/files/__directory__/__fileName__.slice.ts__tmpl__ +129 -0
  245. package/src/generators/redux/redux.d.ts +5 -0
  246. package/src/generators/redux/redux.js +117 -0
  247. package/src/generators/redux/redux.js.map +1 -0
  248. package/src/generators/redux/schema.d.ts +20 -0
  249. package/src/generators/redux/schema.json +47 -0
  250. package/src/generators/remote/files/module-federation/module-federation.config.js__tmpl__ +6 -0
  251. package/src/generators/remote/files/module-federation/src/main.ts__tmpl__ +1 -0
  252. package/src/generators/remote/files/module-federation/src/remote-entry.ts__tmpl__ +1 -0
  253. package/src/generators/remote/files/module-federation/webpack.config.js__tmpl__ +12 -0
  254. package/src/generators/remote/files/module-federation/webpack.config.prod.js__tmpl__ +1 -0
  255. package/src/generators/remote/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +6 -0
  256. package/src/generators/remote/files/module-federation-ssr/server.ts__tmpl__ +45 -0
  257. package/src/generators/remote/files/module-federation-ssr/webpack.server.config.js__tmpl__ +12 -0
  258. package/src/generators/remote/lib/setup-ssr-for-remote.d.ts +4 -0
  259. package/src/generators/remote/lib/setup-ssr-for-remote.js +32 -0
  260. package/src/generators/remote/lib/setup-ssr-for-remote.js.map +1 -0
  261. package/src/generators/remote/lib/update-host-with-remote.d.ts +2 -0
  262. package/src/generators/remote/lib/update-host-with-remote.js +53 -0
  263. package/src/generators/remote/lib/update-host-with-remote.js.map +1 -0
  264. package/src/generators/remote/remote.d.ts +6 -0
  265. package/src/generators/remote/remote.js +56 -0
  266. package/src/generators/remote/remote.js.map +1 -0
  267. package/src/generators/remote/schema.d.ts +26 -0
  268. package/src/generators/remote/schema.json +167 -0
  269. package/src/generators/setup-ssr/files/server.ts__tmpl__ +28 -0
  270. package/src/generators/setup-ssr/files/src/main.server.tsx__tmpl__ +47 -0
  271. package/src/generators/setup-ssr/files/tsconfig.server.json__tmpl__ +15 -0
  272. package/src/generators/setup-ssr/schema.d.ts +7 -0
  273. package/src/generators/setup-ssr/schema.json +48 -0
  274. package/src/generators/setup-ssr/setup-ssr.d.ts +5 -0
  275. package/src/generators/setup-ssr/setup-ssr.js +162 -0
  276. package/src/generators/setup-ssr/setup-ssr.js.map +1 -0
  277. package/src/generators/setup-tailwind/files/postcss.config.js__tmpl__ +15 -0
  278. package/src/generators/setup-tailwind/files/tailwind.config.js__tmpl__ +17 -0
  279. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.d.ts +3 -0
  280. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +36 -0
  281. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js.map +1 -0
  282. package/src/generators/setup-tailwind/lib/update-project.d.ts +3 -0
  283. package/src/generators/setup-tailwind/lib/update-project.js +15 -0
  284. package/src/generators/setup-tailwind/lib/update-project.js.map +1 -0
  285. package/src/generators/setup-tailwind/schema.d.ts +6 -0
  286. package/src/generators/setup-tailwind/schema.js +3 -0
  287. package/src/generators/setup-tailwind/schema.js.map +1 -0
  288. package/src/generators/setup-tailwind/schema.json +47 -0
  289. package/src/generators/setup-tailwind/setup-tailwind.d.ts +5 -0
  290. package/src/generators/setup-tailwind/setup-tailwind.js +39 -0
  291. package/src/generators/setup-tailwind/setup-tailwind.js.map +1 -0
  292. package/src/generators/stories/schema.json +59 -0
  293. package/src/generators/stories/stories.d.ts +15 -0
  294. package/src/generators/stories/stories.js +118 -0
  295. package/src/generators/stories/stories.js.map +1 -0
  296. package/src/generators/storybook-configuration/configuration.d.ts +5 -0
  297. package/src/generators/storybook-configuration/configuration.js +64 -0
  298. package/src/generators/storybook-configuration/configuration.js.map +1 -0
  299. package/src/generators/storybook-configuration/schema.d.ts +17 -0
  300. package/src/generators/storybook-configuration/schema.json +103 -0
  301. package/src/migrations/update-12-0-0/remove-react-redux-types-package.d.ts +3 -0
  302. package/src/migrations/update-12-0-0/remove-react-redux-types-package.js +13 -0
  303. package/src/migrations/update-12-0-0/remove-react-redux-types-package.js.map +1 -0
  304. package/src/migrations/update-12-0-0/update-emotion-setup.d.ts +3 -0
  305. package/src/migrations/update-12-0-0/update-emotion-setup.js +67 -0
  306. package/src/migrations/update-12-0-0/update-emotion-setup.js.map +1 -0
  307. package/src/migrations/update-12-0-0/use-react-jsx-in-tsconfig.d.ts +3 -0
  308. package/src/migrations/update-12-0-0/use-react-jsx-in-tsconfig.js +27 -0
  309. package/src/migrations/update-12-0-0/use-react-jsx-in-tsconfig.js.map +1 -0
  310. package/src/migrations/update-12-8-0/update-12-8-0.d.ts +3 -0
  311. package/src/migrations/update-12-8-0/update-12-8-0.js +15 -0
  312. package/src/migrations/update-12-8-0/update-12-8-0.js.map +1 -0
  313. package/src/migrations/update-13-0-0/migrate-storybook-to-webpack-5.d.ts +3 -0
  314. package/src/migrations/update-13-0-0/migrate-storybook-to-webpack-5.js +38 -0
  315. package/src/migrations/update-13-0-0/migrate-storybook-to-webpack-5.js.map +1 -0
  316. package/src/migrations/update-13-0-0/update-emotion-setup.d.ts +3 -0
  317. package/src/migrations/update-13-0-0/update-emotion-setup.js +39 -0
  318. package/src/migrations/update-13-0-0/update-emotion-setup.js.map +1 -0
  319. package/src/migrations/update-13-0-0/webpack5-changes-utils.d.ts +11 -0
  320. package/src/migrations/update-13-0-0/webpack5-changes-utils.js +269 -0
  321. package/src/migrations/update-13-0-0/webpack5-changes-utils.js.map +1 -0
  322. package/src/migrations/update-13-10-0/update-13-10-0.d.ts +3 -0
  323. package/src/migrations/update-13-10-0/update-13-10-0.js +29 -0
  324. package/src/migrations/update-13-10-0/update-13-10-0.js.map +1 -0
  325. package/src/migrations/update-14-0-0/add-default-development-configurations.d.ts +3 -0
  326. package/src/migrations/update-14-0-0/add-default-development-configurations.js +40 -0
  327. package/src/migrations/update-14-0-0/add-default-development-configurations.js.map +1 -0
  328. package/src/migrations/update-14-0-0/replace-testing-library-react-hook.d.ts +3 -0
  329. package/src/migrations/update-14-0-0/replace-testing-library-react-hook.js +27 -0
  330. package/src/migrations/update-14-0-0/replace-testing-library-react-hook.js.map +1 -0
  331. package/src/migrations/update-14-0-0/update-react-dom-render-for-v18.d.ts +5 -0
  332. package/src/migrations/update-14-0-0/update-react-dom-render-for-v18.js +69 -0
  333. package/src/migrations/update-14-0-0/update-react-dom-render-for-v18.js.map +1 -0
  334. package/src/migrations/update-14-1-0/update-external-emotion-jsx-runtime.d.ts +3 -0
  335. package/src/migrations/update-14-1-0/update-external-emotion-jsx-runtime.js +38 -0
  336. package/src/migrations/update-14-1-0/update-external-emotion-jsx-runtime.js.map +1 -0
  337. package/src/migrations/update-14-6-0/add-preset-jest-config.d.ts +3 -0
  338. package/src/migrations/update-14-6-0/add-preset-jest-config.js +40 -0
  339. package/src/migrations/update-14-6-0/add-preset-jest-config.js.map +1 -0
  340. package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.d.ts +3 -0
  341. package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js +39 -0
  342. package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js.map +1 -0
  343. package/src/migrations/update-15-3-0/update-rollup-executor.d.ts +3 -0
  344. package/src/migrations/update-15-3-0/update-rollup-executor.js +17 -0
  345. package/src/migrations/update-15-3-0/update-rollup-executor.js.map +1 -0
  346. package/src/migrations/update-15-6-3/webpack-config-setup.d.ts +2 -0
  347. package/src/migrations/update-15-6-3/webpack-config-setup.js +108 -0
  348. package/src/migrations/update-15-6-3/webpack-config-setup.js.map +1 -0
  349. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  350. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
  351. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
  352. package/src/module-federation/ast-utils.d.ts +8 -0
  353. package/src/module-federation/ast-utils.js +103 -0
  354. package/src/module-federation/ast-utils.js.map +1 -0
  355. package/src/module-federation/load-config.d.ts +3 -0
  356. package/src/module-federation/load-config.js +17 -0
  357. package/src/module-federation/load-config.js.map +1 -0
  358. package/src/module-federation/models.d.ts +24 -0
  359. package/src/module-federation/models.js +3 -0
  360. package/src/module-federation/models.js.map +1 -0
  361. package/src/module-federation/package-json.d.ts +8 -0
  362. package/src/module-federation/package-json.js +14 -0
  363. package/src/module-federation/package-json.js.map +1 -0
  364. package/src/module-federation/utils.d.ts +10 -0
  365. package/src/module-federation/utils.js +38 -0
  366. package/src/module-federation/utils.js.map +1 -0
  367. package/src/module-federation/with-module-federation-ssr.d.ts +2 -0
  368. package/src/module-federation/with-module-federation-ssr.js +48 -0
  369. package/src/module-federation/with-module-federation-ssr.js.map +1 -0
  370. package/src/module-federation/with-module-federation.d.ts +7 -0
  371. package/src/module-federation/with-module-federation.js +50 -0
  372. package/src/module-federation/with-module-federation.js.map +1 -0
  373. package/src/rules/add-styled-dependencies.d.ts +2 -0
  374. package/src/rules/add-styled-dependencies.js +16 -0
  375. package/src/rules/add-styled-dependencies.js.map +1 -0
  376. package/src/rules/update-module-federation-project.d.ts +6 -0
  377. package/src/rules/update-module-federation-project.js +34 -0
  378. package/src/rules/update-module-federation-project.js.map +1 -0
  379. package/src/utils/assertion.d.ts +1 -0
  380. package/src/utils/assertion.js +20 -0
  381. package/src/utils/assertion.js.map +1 -0
  382. package/src/utils/ast-utils.d.ts +29 -0
  383. package/src/utils/ast-utils.js +526 -0
  384. package/src/utils/ast-utils.js.map +1 -0
  385. package/src/utils/component-props.d.ts +15 -0
  386. package/src/utils/component-props.js +61 -0
  387. package/src/utils/component-props.js.map +1 -0
  388. package/src/utils/create-ts-config.d.ts +9 -0
  389. package/src/utils/create-ts-config.js +64 -0
  390. package/src/utils/create-ts-config.js.map +1 -0
  391. package/src/utils/dependencies.d.ts +7 -0
  392. package/src/utils/dependencies.js +3 -0
  393. package/src/utils/dependencies.js.map +1 -0
  394. package/src/utils/format-file.d.ts +1 -0
  395. package/src/utils/format-file.js +13 -0
  396. package/src/utils/format-file.js.map +1 -0
  397. package/src/utils/get-in-source-vitest-tests-template.d.ts +1 -0
  398. package/src/utils/get-in-source-vitest-tests-template.js +22 -0
  399. package/src/utils/get-in-source-vitest-tests-template.js.map +1 -0
  400. package/src/utils/jest-utils.d.ts +1 -0
  401. package/src/utils/jest-utils.js +10 -0
  402. package/src/utils/jest-utils.js.map +1 -0
  403. package/src/utils/lint.d.ts +37 -0
  404. package/src/utils/lint.js +68 -0
  405. package/src/utils/lint.js.map +1 -0
  406. package/src/utils/styled.d.ts +4 -0
  407. package/src/utils/styled.js +33 -0
  408. package/src/utils/styled.js.map +1 -0
  409. package/src/utils/testing-generators.d.ts +3 -0
  410. package/src/utils/testing-generators.js +35 -0
  411. package/src/utils/testing-generators.js.map +1 -0
  412. package/src/utils/versions.d.ts +43 -0
  413. package/src/utils/versions.js +51 -0
  414. package/src/utils/versions.js.map +1 -0
  415. package/tailwind.d.ts +6 -0
  416. package/tailwind.js +30 -0
  417. package/tailwind.js.map +1 -0
  418. package/typings/cssmodule.d.ts +24 -0
  419. package/typings/image.d.ts +48 -0
  420. package/typings/style.d.ts +9 -0
  421. package/typings/styled-jsx.d.ts +8 -0
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addStyledModuleDependencies = void 0;
4
+ const styled_1 = require("../utils/styled");
5
+ const devkit_1 = require("@nx/devkit");
6
+ function addStyledModuleDependencies(host, styledModule) {
7
+ const extraDependencies = styled_1.CSS_IN_JS_DEPENDENCIES[styledModule];
8
+ if (extraDependencies) {
9
+ return (0, devkit_1.addDependenciesToPackageJson)(host, extraDependencies.dependencies, extraDependencies.devDependencies);
10
+ }
11
+ else {
12
+ return () => { };
13
+ }
14
+ }
15
+ exports.addStyledModuleDependencies = addStyledModuleDependencies;
16
+ //# sourceMappingURL=add-styled-dependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-styled-dependencies.js","sourceRoot":"","sources":["../../../../../packages/react/src/rules/add-styled-dependencies.ts"],"names":[],"mappings":";;;AAAA,4CAAyD;AACzD,uCAAgE;AAEhE,SAAgB,2BAA2B,CAAC,IAAU,EAAE,YAAoB;IAC1E,MAAM,iBAAiB,GAAG,+BAAsB,CAAC,YAAY,CAAC,CAAC;IAE/D,IAAI,iBAAiB,EAAE;QACrB,OAAO,IAAA,qCAA4B,EACjC,IAAI,EACJ,iBAAiB,CAAC,YAAY,EAC9B,iBAAiB,CAAC,eAAe,CAClC,CAAC;KACH;SAAM;QACL,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;KACjB;AACH,CAAC;AAZD,kEAYC"}
@@ -0,0 +1,6 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ export declare function updateModuleFederationProject(host: Tree, options: {
3
+ projectName: string;
4
+ appProjectRoot: string;
5
+ devServerPort?: number;
6
+ }): GeneratorCallback;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateModuleFederationProject = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../utils/versions");
6
+ function updateModuleFederationProject(host, options) {
7
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
8
+ projectConfig.targets.build.options = Object.assign(Object.assign({}, projectConfig.targets.build.options), { main: `${options.appProjectRoot}/src/main.ts`, webpackConfig: `${options.appProjectRoot}/webpack.config.js` });
9
+ projectConfig.targets.build.configurations.production = Object.assign(Object.assign({}, projectConfig.targets.build.configurations.production), { webpackConfig: `${options.appProjectRoot}/webpack.config.prod.js` });
10
+ projectConfig.targets.serve.executor =
11
+ '@nrwl/react:module-federation-dev-server';
12
+ projectConfig.targets.serve.options.port = options.devServerPort;
13
+ // `serve-static` for remotes that don't need to be in development mode
14
+ projectConfig.targets['serve-static'] = {
15
+ executor: '@nrwl/web:file-server',
16
+ defaultConfiguration: 'development',
17
+ options: {
18
+ buildTarget: `${options.projectName}:build`,
19
+ port: options.devServerPort,
20
+ },
21
+ configurations: {
22
+ development: {
23
+ buildTarget: `${options.projectName}:build:development`,
24
+ },
25
+ production: {
26
+ buildTarget: `${options.projectName}:build:production`,
27
+ },
28
+ },
29
+ };
30
+ (0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
31
+ return (0, devkit_1.addDependenciesToPackageJson)(host, {}, { '@nrwl/web': versions_1.nxVersion });
32
+ }
33
+ exports.updateModuleFederationProject = updateModuleFederationProject;
34
+ //# sourceMappingURL=update-module-federation-project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-module-federation-project.js","sourceRoot":"","sources":["../../../../../packages/react/src/rules/update-module-federation-project.ts"],"names":[],"mappings":";;;AAAA,uCAMoB;AACpB,gDAA8C;AAE9C,SAAgB,6BAA6B,CAC3C,IAAU,EACV,OAIC;IAED,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAE1E,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,mCAC9B,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,KACtC,IAAI,EAAE,GAAG,OAAO,CAAC,cAAc,cAAc,EAC7C,aAAa,EAAE,GAAG,OAAO,CAAC,cAAc,oBAAoB,GAC7D,CAAC;IAEF,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,mCAChD,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,KACxD,aAAa,EAAE,GAAG,OAAO,CAAC,cAAc,yBAAyB,GAClE,CAAC;IAEF,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ;QAClC,0CAA0C,CAAC;IAC7C,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC;IAEjE,uEAAuE;IACvE,aAAa,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG;QACtC,QAAQ,EAAE,uBAAuB;QACjC,oBAAoB,EAAE,aAAa;QACnC,OAAO,EAAE;YACP,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,QAAQ;YAC3C,IAAI,EAAE,OAAO,CAAC,aAAa;SAC5B;QACD,cAAc,EAAE;YACd,WAAW,EAAE;gBACX,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,oBAAoB;aACxD;YACD,UAAU,EAAE;gBACV,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,mBAAmB;aACvD;SACF;KACF,CAAC;IAEF,IAAA,mCAA0B,EAAC,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAErE,OAAO,IAAA,qCAA4B,EAAC,IAAI,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,oBAAS,EAAE,CAAC,CAAC;AAC5E,CAAC;AA9CD,sEA8CC"}
@@ -0,0 +1 @@
1
+ export declare function assertValidStyle(style: string): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertValidStyle = void 0;
4
+ const VALID_STYLES = [
5
+ 'css',
6
+ 'scss',
7
+ 'less',
8
+ 'styl',
9
+ 'styled-components',
10
+ '@emotion/styled',
11
+ 'styled-jsx',
12
+ 'none',
13
+ ];
14
+ function assertValidStyle(style) {
15
+ if (VALID_STYLES.indexOf(style) === -1) {
16
+ throw new Error(`Unsupported style option found: ${style}. Valid values are: "${VALID_STYLES.join('", "')}"`);
17
+ }
18
+ }
19
+ exports.assertValidStyle = assertValidStyle;
20
+ //# sourceMappingURL=assertion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertion.js","sourceRoot":"","sources":["../../../../../packages/react/src/utils/assertion.ts"],"names":[],"mappings":";;;AAAA,MAAM,YAAY,GAAG;IACnB,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,mBAAmB;IACnB,iBAAiB;IACjB,YAAY;IACZ,MAAM;CACP,CAAC;AACF,SAAgB,gBAAgB,CAAC,KAAa;IAC5C,IAAI,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE;QACtC,MAAM,IAAI,KAAK,CACb,mCAAmC,KAAK,wBAAwB,YAAY,CAAC,IAAI,CAC/E,MAAM,CACP,GAAG,CACL,CAAC;KACH;AACH,CAAC;AARD,4CAQC"}
@@ -0,0 +1,29 @@
1
+ import type * as ts from 'typescript';
2
+ import { StringChange } from '@nx/devkit';
3
+ export declare function addImport(source: ts.SourceFile, statement: string): StringChange[];
4
+ export declare function findMainRenderStatement(source: ts.SourceFile): ts.CallExpression | null;
5
+ export declare function findDefaultExport(source: ts.SourceFile): ts.VariableDeclaration | ts.FunctionDeclaration | ts.ClassDeclaration | null;
6
+ export declare function findDefaultExportDeclaration(source: ts.SourceFile): ts.VariableDeclaration | ts.FunctionDeclaration | ts.ClassDeclaration | null;
7
+ export declare function findExportDeclarationsForJsx(source: ts.SourceFile): Array<ts.VariableDeclaration | ts.FunctionDeclaration | ts.ClassDeclaration> | null;
8
+ export declare function findDefaultExportIdentifier(source: ts.SourceFile): ts.Identifier | null;
9
+ export declare function findDefaultClassOrFunction(source: ts.SourceFile | null): ts.FunctionDeclaration | ts.ClassDeclaration | null;
10
+ export declare function findComponentImportPath(componentName: string, source: ts.SourceFile): string;
11
+ export declare function findElements(source: ts.SourceFile, tagName: string): ts.Node[];
12
+ export declare function findClosestOpening(tagName: string, node: ts.Node): any;
13
+ export declare function isTag(tagName: string, node: ts.Node): boolean;
14
+ export declare function addInitialRoutes(sourcePath: string, source: ts.SourceFile): StringChange[];
15
+ export declare function addRoute(sourcePath: string, source: ts.SourceFile, options: {
16
+ routePath: string;
17
+ componentName: string;
18
+ moduleName: string;
19
+ }): StringChange[];
20
+ export declare function addBrowserRouter(sourcePath: string, source: ts.SourceFile): StringChange[];
21
+ export declare function addStaticRouter(sourcePath: string, source: ts.SourceFile): StringChange[];
22
+ export declare function addReduxStoreToMain(sourcePath: string, source: ts.SourceFile): StringChange[];
23
+ export declare function updateReduxStore(sourcePath: string, source: ts.SourceFile, feature: {
24
+ keyName: string;
25
+ reducerName: string;
26
+ modulePath: string;
27
+ }): StringChange[];
28
+ export declare function getComponentNode(sourceFile: ts.SourceFile): ts.Node | null;
29
+ export declare function getComponentPropsInterface(sourceFile: ts.SourceFile, cmpDeclaration: ts.Node): ts.InterfaceDeclaration | null;
@@ -0,0 +1,526 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getComponentPropsInterface = exports.getComponentNode = exports.updateReduxStore = exports.addReduxStoreToMain = exports.addStaticRouter = exports.addBrowserRouter = exports.addRoute = exports.addInitialRoutes = exports.isTag = exports.findClosestOpening = exports.findElements = exports.findComponentImportPath = exports.findDefaultClassOrFunction = exports.findDefaultExportIdentifier = exports.findExportDeclarationsForJsx = exports.findDefaultExportDeclaration = exports.findDefaultExport = exports.findMainRenderStatement = exports.addImport = void 0;
4
+ const typescript_1 = require("nx/src/utils/typescript");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
7
+ let tsModule;
8
+ function addImport(source, statement) {
9
+ if (!tsModule) {
10
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
11
+ }
12
+ const allImports = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.ImportDeclaration);
13
+ if (allImports.length > 0) {
14
+ const lastImport = allImports[allImports.length - 1];
15
+ return [
16
+ {
17
+ type: devkit_1.ChangeType.Insert,
18
+ index: lastImport.end + 1,
19
+ text: `\n${statement}\n`,
20
+ },
21
+ ];
22
+ }
23
+ else {
24
+ return [
25
+ {
26
+ type: devkit_1.ChangeType.Insert,
27
+ index: 0,
28
+ text: `\n${statement}\n`,
29
+ },
30
+ ];
31
+ }
32
+ }
33
+ exports.addImport = addImport;
34
+ function findMainRenderStatement(source) {
35
+ if (!tsModule) {
36
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
37
+ }
38
+ // 1. Try to find ReactDOM.render.
39
+ const calls = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.CallExpression);
40
+ for (const expr of calls) {
41
+ const inner = expr.expression;
42
+ // React 17 and below
43
+ if (tsModule.isPropertyAccessExpression(inner) &&
44
+ /ReactDOM/i.test(inner.expression.getText()) &&
45
+ inner.name.getText() === 'render') {
46
+ return expr;
47
+ }
48
+ // React 18
49
+ if (tsModule.isPropertyAccessExpression(inner) &&
50
+ /root/.test(inner.expression.getText()) &&
51
+ inner.name.getText() === 'render') {
52
+ return expr;
53
+ }
54
+ }
55
+ // 2. Try to find render from 'react-dom'.
56
+ const imports = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.ImportDeclaration);
57
+ const hasRenderImport = imports.some((i) => i.moduleSpecifier.getText().includes('react-dom') &&
58
+ /\brender\b/.test(i.importClause.namedBindings.getText()));
59
+ if (hasRenderImport) {
60
+ const calls = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.CallExpression);
61
+ for (const expr of calls) {
62
+ if (expr.expression.getText() === 'render') {
63
+ return expr;
64
+ }
65
+ }
66
+ }
67
+ return null;
68
+ }
69
+ exports.findMainRenderStatement = findMainRenderStatement;
70
+ function findDefaultExport(source) {
71
+ return (findDefaultExportDeclaration(source) || findDefaultClassOrFunction(source));
72
+ }
73
+ exports.findDefaultExport = findDefaultExport;
74
+ function findDefaultExportDeclaration(source) {
75
+ if (!tsModule) {
76
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
77
+ }
78
+ const identifier = findDefaultExportIdentifier(source);
79
+ if (identifier) {
80
+ const variables = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.VariableDeclaration);
81
+ const fns = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.FunctionDeclaration);
82
+ const cls = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.ClassDeclaration);
83
+ const all = [...variables, ...fns, ...cls];
84
+ const exported = all
85
+ .filter((x) => x.name.kind === tsModule.SyntaxKind.Identifier)
86
+ .find((x) => x.name.text === identifier.text);
87
+ return exported || null;
88
+ }
89
+ else {
90
+ return null;
91
+ }
92
+ }
93
+ exports.findDefaultExportDeclaration = findDefaultExportDeclaration;
94
+ function findExportDeclarationsForJsx(source) {
95
+ if (!tsModule) {
96
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
97
+ }
98
+ const variables = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.VariableDeclaration);
99
+ const variableStatements = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.VariableStatement);
100
+ const fns = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.FunctionDeclaration);
101
+ const cls = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.ClassDeclaration);
102
+ const exportDeclarations = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.ExportDeclaration);
103
+ let componentNamesNodes = [];
104
+ exportDeclarations.forEach((node) => {
105
+ componentNamesNodes = [
106
+ ...componentNamesNodes,
107
+ ...(0, typescript_1.findNodes)(node, tsModule.SyntaxKind.ExportSpecifier),
108
+ ];
109
+ });
110
+ const componentNames = componentNamesNodes === null || componentNamesNodes === void 0 ? void 0 : componentNamesNodes.map((node) => node.getText());
111
+ const all = [...variables, ...variableStatements, ...fns, ...cls];
112
+ let foundExport;
113
+ let foundJSX;
114
+ const nodesContainingJSX = all.filter((x) => {
115
+ foundJSX = (0, typescript_1.findNodes)(x, [
116
+ tsModule.SyntaxKind.JsxSelfClosingElement,
117
+ tsModule.SyntaxKind.JsxOpeningElement,
118
+ ]);
119
+ return foundJSX === null || foundJSX === void 0 ? void 0 : foundJSX.length;
120
+ });
121
+ const exported = nodesContainingJSX.filter((x) => {
122
+ var _a, _b, _c;
123
+ foundExport = (0, typescript_1.findNodes)(x, tsModule.SyntaxKind.ExportKeyword);
124
+ if (x.kind === tsModule.SyntaxKind.VariableStatement) {
125
+ const nameNode = (_a = (0, typescript_1.findNodes)(x, tsModule.SyntaxKind.VariableDeclaration)) === null || _a === void 0 ? void 0 : _a[0];
126
+ return (((_b = nameNode === null || nameNode === void 0 ? void 0 : nameNode.name) === null || _b === void 0 ? void 0 : _b.kind) === tsModule.SyntaxKind.Identifier ||
127
+ (foundExport === null || foundExport === void 0 ? void 0 : foundExport.length) ||
128
+ (componentNames === null || componentNames === void 0 ? void 0 : componentNames.includes((_c = nameNode === null || nameNode === void 0 ? void 0 : nameNode.name) === null || _c === void 0 ? void 0 : _c.getText())));
129
+ }
130
+ else {
131
+ return ((x.name.kind === tsModule.SyntaxKind.Identifier &&
132
+ (foundExport === null || foundExport === void 0 ? void 0 : foundExport.length)) ||
133
+ (componentNames === null || componentNames === void 0 ? void 0 : componentNames.includes(x.name.getText())));
134
+ }
135
+ });
136
+ const exportedDeclarations = exported.map((x) => {
137
+ var _a;
138
+ if (x.kind === tsModule.SyntaxKind.VariableStatement) {
139
+ const nameNode = (_a = (0, typescript_1.findNodes)(x, tsModule.SyntaxKind.VariableDeclaration)) === null || _a === void 0 ? void 0 : _a[0];
140
+ return nameNode;
141
+ }
142
+ return x;
143
+ });
144
+ return exportedDeclarations || null;
145
+ }
146
+ exports.findExportDeclarationsForJsx = findExportDeclarationsForJsx;
147
+ function findDefaultExportIdentifier(source) {
148
+ if (!tsModule) {
149
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
150
+ }
151
+ const exports = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.ExportAssignment);
152
+ const identifier = exports
153
+ .map((x) => x.expression)
154
+ .find((x) => x.kind === tsModule.SyntaxKind.Identifier);
155
+ return identifier || null;
156
+ }
157
+ exports.findDefaultExportIdentifier = findDefaultExportIdentifier;
158
+ function findDefaultClassOrFunction(source) {
159
+ if (!tsModule) {
160
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
161
+ }
162
+ const fns = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.FunctionDeclaration);
163
+ const cls = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.ClassDeclaration);
164
+ return (fns.find(hasDefaultExportModifier) ||
165
+ cls.find(hasDefaultExportModifier) ||
166
+ null);
167
+ }
168
+ exports.findDefaultClassOrFunction = findDefaultClassOrFunction;
169
+ function hasDefaultExportModifier(x) {
170
+ if (!tsModule) {
171
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
172
+ }
173
+ return (x.modifiers &&
174
+ x.modifiers.some((m) => m.kind === tsModule.SyntaxKind.ExportKeyword) &&
175
+ x.modifiers.some((m) => m.kind === tsModule.SyntaxKind.DefaultKeyword));
176
+ }
177
+ function findComponentImportPath(componentName, source) {
178
+ if (!tsModule) {
179
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
180
+ }
181
+ const allImports = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.ImportDeclaration);
182
+ const matching = allImports.filter((i) => {
183
+ return (i.importClause &&
184
+ i.importClause.name &&
185
+ i.importClause.name.getText() === componentName);
186
+ });
187
+ if (matching.length === 0) {
188
+ return null;
189
+ }
190
+ const appImport = matching[0];
191
+ return appImport.moduleSpecifier.getText().replace(/['"]/g, '');
192
+ }
193
+ exports.findComponentImportPath = findComponentImportPath;
194
+ function findElements(source, tagName) {
195
+ if (!tsModule) {
196
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
197
+ }
198
+ const nodes = (0, typescript_1.findNodes)(source, [
199
+ tsModule.SyntaxKind.JsxSelfClosingElement,
200
+ tsModule.SyntaxKind.JsxOpeningElement,
201
+ ]);
202
+ return nodes.filter((node) => isTag(tagName, node));
203
+ }
204
+ exports.findElements = findElements;
205
+ function findClosestOpening(tagName, node) {
206
+ if (!node) {
207
+ return null;
208
+ }
209
+ if (isTag(tagName, node)) {
210
+ return node;
211
+ }
212
+ else {
213
+ return findClosestOpening(tagName, node.parent);
214
+ }
215
+ }
216
+ exports.findClosestOpening = findClosestOpening;
217
+ function isTag(tagName, node) {
218
+ if (!tsModule) {
219
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
220
+ }
221
+ if (tsModule.isJsxOpeningLikeElement(node)) {
222
+ return (node.tagName.kind === tsModule.SyntaxKind.Identifier &&
223
+ node.tagName.text === tagName);
224
+ }
225
+ if (tsModule.isJsxElement(node) && node.openingElement) {
226
+ return (node.openingElement.tagName.kind === tsModule.SyntaxKind.Identifier &&
227
+ node.openingElement.tagName.getText() === tagName);
228
+ }
229
+ return false;
230
+ }
231
+ exports.isTag = isTag;
232
+ function addInitialRoutes(sourcePath, source) {
233
+ if (!tsModule) {
234
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
235
+ }
236
+ const jsxClosingElements = (0, typescript_1.findNodes)(source, [
237
+ tsModule.SyntaxKind.JsxClosingElement,
238
+ tsModule.SyntaxKind.JsxClosingFragment,
239
+ ]);
240
+ const outerMostJsxClosing = jsxClosingElements[jsxClosingElements.length - 1];
241
+ if (!outerMostJsxClosing) {
242
+ devkit_1.logger.warn(`Could not find JSX elements in ${sourcePath}; Skipping insert routes`);
243
+ return [];
244
+ }
245
+ const insertRoutes = {
246
+ type: devkit_1.ChangeType.Insert,
247
+ index: outerMostJsxClosing.getStart(),
248
+ text: `
249
+ {/* START: routes */}
250
+ {/* These routes and navigation have been generated for you */}
251
+ {/* Feel free to move and update them to fit your needs */}
252
+ <br/>
253
+ <hr/>
254
+ <br/>
255
+ <div role="navigation">
256
+ <ul>
257
+ <li><Link to="/">Home</Link></li>
258
+ <li><Link to="/page-2">Page 2</Link></li>
259
+ </ul>
260
+ </div>
261
+ <Routes>
262
+ <Route
263
+ path="/"
264
+ element={
265
+ <div>This is the generated root route. <Link to="/page-2">Click here for page 2.</Link></div>
266
+ }
267
+ />
268
+ <Route
269
+ path="/page-2"
270
+ element={
271
+ <div><Link to="/">Click here to go back to root page.</Link></div>
272
+ }
273
+ />
274
+ </Routes>
275
+ {/* END: routes */}
276
+ `,
277
+ };
278
+ return [
279
+ ...addImport(source, `import { Route, Routes, Link } from 'react-router-dom';`),
280
+ insertRoutes,
281
+ ];
282
+ }
283
+ exports.addInitialRoutes = addInitialRoutes;
284
+ function addRoute(sourcePath, source, options) {
285
+ const routes = findElements(source, 'Route');
286
+ const links = findElements(source, 'Link');
287
+ if (routes.length === 0) {
288
+ devkit_1.logger.warn(`Could not find <Route/> components in ${sourcePath}; Skipping add route`);
289
+ return [];
290
+ }
291
+ else {
292
+ const changes = [];
293
+ const firstRoute = routes[0];
294
+ const firstLink = links[0];
295
+ changes.push(...addImport(source, `import { ${options.componentName} } from '${options.moduleName}';`));
296
+ changes.push({
297
+ type: devkit_1.ChangeType.Insert,
298
+ index: firstRoute.getEnd(),
299
+ text: `<Route path="${options.routePath}" element={<${options.componentName}/>} />`,
300
+ });
301
+ if (firstLink) {
302
+ const parentLi = findClosestOpening('li', firstLink);
303
+ if (parentLi) {
304
+ changes.push({
305
+ type: devkit_1.ChangeType.Insert,
306
+ index: parentLi.getEnd(),
307
+ text: `<li><Link to="${options.routePath}">${options.componentName}</Link></li>`,
308
+ });
309
+ }
310
+ else {
311
+ changes.push({
312
+ type: devkit_1.ChangeType.Insert,
313
+ index: firstLink.parent.getEnd(),
314
+ text: `<Link to="${options.routePath}">${options.componentName}</Link>`,
315
+ });
316
+ }
317
+ }
318
+ return changes;
319
+ }
320
+ }
321
+ exports.addRoute = addRoute;
322
+ function addBrowserRouter(sourcePath, source) {
323
+ const app = findElements(source, 'App')[0];
324
+ if (app) {
325
+ return [
326
+ ...addImport(source, `import { BrowserRouter } from 'react-router-dom';`),
327
+ {
328
+ type: devkit_1.ChangeType.Insert,
329
+ index: app.getStart(),
330
+ text: `<BrowserRouter>`,
331
+ },
332
+ {
333
+ type: devkit_1.ChangeType.Insert,
334
+ index: app.getEnd(),
335
+ text: `</BrowserRouter>`,
336
+ },
337
+ ];
338
+ }
339
+ else {
340
+ devkit_1.logger.warn(`Could not find App component in ${sourcePath}; Skipping add <BrowserRouter>`);
341
+ return [];
342
+ }
343
+ }
344
+ exports.addBrowserRouter = addBrowserRouter;
345
+ function addStaticRouter(sourcePath, source) {
346
+ const app = findElements(source, 'App')[0];
347
+ if (app) {
348
+ return [
349
+ ...addImport(source, `import { StaticRouter } from 'react-router-dom/server';`),
350
+ {
351
+ type: devkit_1.ChangeType.Insert,
352
+ index: app.getStart(),
353
+ text: `<StaticRouter location={req.originalUrl}>`,
354
+ },
355
+ {
356
+ type: devkit_1.ChangeType.Insert,
357
+ index: app.getEnd(),
358
+ text: `</StaticRouter>`,
359
+ },
360
+ ];
361
+ }
362
+ else {
363
+ devkit_1.logger.warn(`Could not find App component in ${sourcePath}; Skipping add <StaticRouter>`);
364
+ return [];
365
+ }
366
+ }
367
+ exports.addStaticRouter = addStaticRouter;
368
+ function addReduxStoreToMain(sourcePath, source) {
369
+ const renderStmt = findMainRenderStatement(source);
370
+ if (!renderStmt) {
371
+ devkit_1.logger.warn(`Could not find render(...) in ${sourcePath}`);
372
+ return [];
373
+ }
374
+ const jsx = renderStmt.arguments[0];
375
+ return [
376
+ ...addImport(source, `import { configureStore } from '@reduxjs/toolkit';
377
+ import { Provider } from 'react-redux';`),
378
+ {
379
+ type: devkit_1.ChangeType.Insert,
380
+ index: renderStmt.getStart(),
381
+ text: `
382
+ const store = configureStore({
383
+ reducer: {},
384
+ // Additional middleware can be passed to this array
385
+ middleware: getDefaultMiddleware => getDefaultMiddleware(),
386
+ devTools: process.env.NODE_ENV !== 'production',
387
+ // Optional Redux store enhancers
388
+ enhancers: [],
389
+ });
390
+
391
+ `,
392
+ },
393
+ {
394
+ type: devkit_1.ChangeType.Insert,
395
+ index: jsx.getStart(),
396
+ text: `<Provider store={store}>`,
397
+ },
398
+ {
399
+ type: devkit_1.ChangeType.Insert,
400
+ index: jsx.getEnd(),
401
+ text: `</Provider>`,
402
+ },
403
+ ];
404
+ }
405
+ exports.addReduxStoreToMain = addReduxStoreToMain;
406
+ function updateReduxStore(sourcePath, source, feature) {
407
+ if (!tsModule) {
408
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
409
+ }
410
+ const calls = (0, typescript_1.findNodes)(source, tsModule.SyntaxKind.CallExpression);
411
+ let reducerDescriptor;
412
+ // Look for configureStore call
413
+ for (const expr of calls) {
414
+ if (!expr.expression.getText().includes('configureStore')) {
415
+ continue;
416
+ }
417
+ const arg = expr.arguments[0];
418
+ if (tsModule.isObjectLiteralExpression(arg)) {
419
+ let found;
420
+ for (const prop of arg.properties) {
421
+ if (tsModule.isPropertyAssignment(prop) &&
422
+ prop.name.getText() === 'reducer' &&
423
+ tsModule.isObjectLiteralExpression(prop.initializer)) {
424
+ found = prop.initializer;
425
+ break;
426
+ }
427
+ }
428
+ if (found) {
429
+ reducerDescriptor = found;
430
+ break;
431
+ }
432
+ }
433
+ }
434
+ // Look for combineReducer call
435
+ if (!reducerDescriptor) {
436
+ for (const expr of calls) {
437
+ if (!expr.expression.getText().includes('combineReducer')) {
438
+ continue;
439
+ }
440
+ const arg = expr.arguments[0];
441
+ if (tsModule.isObjectLiteralExpression(arg)) {
442
+ reducerDescriptor = arg;
443
+ break;
444
+ }
445
+ }
446
+ }
447
+ if (!reducerDescriptor) {
448
+ devkit_1.logger.warn(`Could not find configureStore/combineReducer call in ${sourcePath}`);
449
+ return [];
450
+ }
451
+ return [
452
+ ...addImport(source, `import { ${feature.keyName}, ${feature.reducerName} } from '${feature.modulePath}';`),
453
+ {
454
+ type: devkit_1.ChangeType.Insert,
455
+ index: reducerDescriptor.getStart() + 1,
456
+ text: `[${feature.keyName}]: ${feature.reducerName}${reducerDescriptor.properties.length > 0 ? ',' : ''}`,
457
+ },
458
+ ];
459
+ }
460
+ exports.updateReduxStore = updateReduxStore;
461
+ function getComponentNode(sourceFile) {
462
+ if (!tsModule) {
463
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
464
+ }
465
+ const defaultExport = findDefaultExport(sourceFile);
466
+ if (!(defaultExport &&
467
+ ((0, typescript_1.findNodes)(defaultExport, tsModule.SyntaxKind.JsxElement).length > 0 ||
468
+ (0, typescript_1.findNodes)(defaultExport, tsModule.SyntaxKind.JsxSelfClosingElement)
469
+ .length > 0))) {
470
+ return null;
471
+ }
472
+ return defaultExport;
473
+ }
474
+ exports.getComponentNode = getComponentNode;
475
+ function getComponentPropsInterface(sourceFile, cmpDeclaration) {
476
+ var _a, _b, _c, _d;
477
+ if (!tsModule) {
478
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
479
+ }
480
+ let propsTypeName = null;
481
+ if (tsModule.isFunctionDeclaration(cmpDeclaration)) {
482
+ const propsParam = cmpDeclaration.parameters.find((x) => tsModule.isParameter(x) && x.name.text === 'props');
483
+ if ((_a = propsParam === null || propsParam === void 0 ? void 0 : propsParam.type) === null || _a === void 0 ? void 0 : _a['typeName']) {
484
+ propsTypeName = propsParam.type.typeName.text;
485
+ }
486
+ }
487
+ else if (cmpDeclaration.initializer &&
488
+ tsModule.isArrowFunction(cmpDeclaration.initializer)) {
489
+ const arrowFn = cmpDeclaration
490
+ .initializer;
491
+ const propsParam = arrowFn.parameters.find((x) => tsModule.isParameter(x) && x.name.text === 'props');
492
+ if ((_b = propsParam === null || propsParam === void 0 ? void 0 : propsParam.type) === null || _b === void 0 ? void 0 : _b['typeName']) {
493
+ propsTypeName = propsParam.type.typeName.text;
494
+ }
495
+ }
496
+ else if (
497
+ // do we have a class component extending from React.Component
498
+ tsModule.isClassDeclaration(cmpDeclaration) &&
499
+ cmpDeclaration.heritageClauses &&
500
+ cmpDeclaration.heritageClauses.length > 0) {
501
+ const heritageClause = cmpDeclaration.heritageClauses[0];
502
+ if (heritageClause) {
503
+ const propsTypeExpression = heritageClause.types.find((x) => {
504
+ const name = x.expression.escapedText ||
505
+ x.expression.name.text;
506
+ return name === 'Component' || name === 'PureComponent';
507
+ });
508
+ if ((_d = (_c = propsTypeExpression === null || propsTypeExpression === void 0 ? void 0 : propsTypeExpression.typeArguments) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d['typeName']) {
509
+ propsTypeName = propsTypeExpression.typeArguments[0].typeName.getText();
510
+ }
511
+ }
512
+ }
513
+ else {
514
+ return null;
515
+ }
516
+ if (propsTypeName) {
517
+ return (0, typescript_1.findNodes)(sourceFile, tsModule.SyntaxKind.InterfaceDeclaration).find((x) => {
518
+ return x.name.getText() === propsTypeName;
519
+ });
520
+ }
521
+ else {
522
+ return null;
523
+ }
524
+ }
525
+ exports.getComponentPropsInterface = getComponentPropsInterface;
526
+ //# sourceMappingURL=ast-utils.js.map