@nx/react 0.0.0-pr-31222-862e973 → 0.0.0-pr-31313-387cdca
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/generators.json +9 -13
- package/index.d.ts +1 -2
- package/index.js +2 -5
- package/mf/dynamic-federation.d.ts +64 -0
- package/mf/dynamic-federation.js +64 -0
- package/migrations.json +80 -148
- package/module-federation.d.ts +6 -4
- package/module-federation.js +16 -7
- package/package.json +11 -11
- package/plugins/bundle-rollup.js +4 -1
- package/plugins/component-testing/index.js +1 -1
- package/plugins/jest.js +6 -11
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +6 -22
- package/plugins/storybook/index.js +1 -2
- package/plugins/with-react.d.ts +4 -0
- package/router-plugin.d.ts +1 -0
- package/router-plugin.js +5 -0
- package/src/executors/module-federation-dev-server/lib/index.d.ts +2 -0
- package/src/executors/module-federation-dev-server/lib/index.js +5 -0
- package/src/executors/module-federation-dev-server/lib/normalize-options.d.ts +4 -0
- package/src/executors/module-federation-dev-server/lib/normalize-options.js +19 -0
- package/src/executors/module-federation-dev-server/lib/start-remotes.d.ts +5 -0
- package/src/executors/module-federation-dev-server/lib/start-remotes.js +33 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +1 -1
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +6 -110
- package/src/executors/module-federation-dev-server/schema.d.ts +9 -7
- package/src/executors/module-federation-dev-server/schema.json +15 -10
- package/src/executors/module-federation-ssr-dev-server/lib/index.d.ts +2 -0
- package/src/executors/module-federation-ssr-dev-server/lib/index.js +5 -0
- package/src/executors/module-federation-ssr-dev-server/lib/normalize-options.d.ts +4 -0
- package/src/executors/module-federation-ssr-dev-server/lib/normalize-options.js +23 -0
- package/src/executors/module-federation-ssr-dev-server/lib/start-remotes.d.ts +5 -0
- package/src/executors/module-federation-ssr-dev-server/lib/start-remotes.js +34 -0
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +1 -17
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +5 -153
- package/src/executors/module-federation-ssr-dev-server/schema.d.ts +29 -0
- package/src/executors/module-federation-ssr-dev-server/schema.json +14 -9
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts +2 -2
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.js +11 -12
- package/src/executors/module-federation-static-server/schema.json +2 -1
- package/src/generators/application/application.d.ts +3 -3
- package/src/generators/application/application.js +108 -186
- package/src/generators/application/files/base-rsbuild/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
- package/src/generators/application/files/base-rsbuild/src/assets/.gitkeep +0 -0
- package/src/generators/application/files/base-rsbuild/src/favicon.ico +0 -0
- package/src/generators/application/files/base-rsbuild/src/index.html +14 -0
- package/src/generators/application/files/base-rsbuild/src/main.tsx__tmpl__ +32 -0
- package/src/generators/application/files/base-rsbuild/tsconfig.app.json__tmpl__ +31 -0
- package/src/generators/application/files/base-rspack/rspack.config.js__tmpl__ +53 -0
- package/src/generators/application/files/base-rspack/src/app/__fileName__.spec.tsx__tmpl__ +3 -3
- package/src/generators/application/files/base-rspack/src/main.tsx__tmpl__ +27 -5
- package/src/generators/application/files/base-rspack/tsconfig.app.json__tmpl__ +21 -4
- package/src/generators/application/files/base-vite/src/app/__fileName__.spec.tsx__tmpl__ +3 -3
- package/src/generators/application/files/base-vite/src/main.tsx__tmpl__ +31 -6
- package/src/generators/application/files/base-vite/tsconfig.app.json__tmpl__ +20 -3
- package/src/generators/application/files/base-webpack/src/app/__fileName__.spec.tsx__tmpl__ +3 -3
- package/src/generators/application/files/base-webpack/src/main.tsx__tmpl__ +22 -2
- package/src/generators/application/files/base-webpack/tsconfig.app.json__tmpl__ +21 -4
- package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +4 -4
- package/src/generators/application/files/react-router-ssr/common/app/app-nav.tsx__tmpl__ +14 -0
- package/src/generators/application/files/react-router-ssr/common/app/entry.client.tsx__tmpl__ +18 -0
- package/src/generators/application/files/react-router-ssr/common/app/entry.server.tsx__tmpl__ +74 -0
- package/src/generators/application/files/react-router-ssr/common/app/root.tsx__tmpl__ +51 -0
- package/src/generators/application/files/react-router-ssr/common/app/routes/about.tsx__tmpl__ +7 -0
- package/src/generators/application/files/react-router-ssr/common/app/routes.tsx__tmpl__ +6 -0
- package/src/generators/application/files/react-router-ssr/common/public/favicon.ico +0 -0
- package/src/generators/application/files/react-router-ssr/common/react-router.config.ts__tmpl__ +5 -0
- package/src/generators/application/files/react-router-ssr/common/tests/routes/_index.spec.tsx__tmpl__ +16 -0
- package/src/generators/application/files/react-router-ssr/common/tsconfig.app.json__tmpl__ +23 -0
- package/src/generators/application/files/react-router-ssr/common/tsconfig.json__tmpl__ +27 -0
- package/src/generators/application/files/react-router-ssr/non-root/.gitignore__tmpl__ +5 -0
- package/src/generators/application/files/react-router-ssr/non-root/package.json__tmpl__ +21 -0
- package/src/generators/application/files/react-router-ssr/nx-welcome/claimed/app/nx-welcome.tsx__tmpl__ +866 -0
- package/src/generators/application/files/react-router-ssr/nx-welcome/not-configured/app/nx-welcome.tsx__tmpl__ +866 -0
- package/src/generators/application/files/react-router-ssr/nx-welcome/unclaimed/app/nx-welcome.tsx__tmpl__ +864 -0
- package/src/generators/application/files/react-router-ssr/ts-solution/package.json__tmpl__ +21 -0
- package/src/generators/application/files/react-router-ssr/ts-solution/tsconfig.app.json__tmpl__ +39 -0
- package/src/generators/application/files/style-css-module/src/app/__fileName__.tsx__tmpl__ +28 -18
- package/src/generators/application/files/style-global-css/src/app/__fileName__.tsx__tmpl__ +29 -20
- package/src/generators/application/files/style-none/src/app/__fileName__.tsx__tmpl__ +26 -16
- package/src/generators/application/files/style-styled-jsx/src/app/__fileName__.tsx__tmpl__ +31 -22
- package/src/generators/application/files/style-styled-module/src/app/__fileName__.tsx__tmpl__ +30 -21
- package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +29 -19
- package/src/generators/application/lib/add-e2e.d.ts +1 -1
- package/src/generators/application/lib/add-e2e.js +74 -65
- package/src/generators/application/lib/add-jest.js +27 -2
- package/src/generators/application/lib/add-linting.d.ts +4 -0
- package/src/generators/application/lib/add-linting.js +86 -0
- package/src/generators/application/lib/add-project.js +112 -6
- package/src/generators/application/lib/add-routing.js +1 -1
- package/src/generators/application/lib/bundlers/add-rsbuild.d.ts +4 -0
- package/src/generators/application/lib/bundlers/add-rsbuild.js +63 -0
- package/src/generators/application/lib/bundlers/add-rspack.d.ts +4 -0
- package/src/generators/application/lib/bundlers/add-rspack.js +37 -0
- package/src/generators/application/lib/bundlers/add-vite.d.ts +4 -0
- package/src/generators/application/lib/bundlers/add-vite.js +76 -0
- package/src/generators/application/lib/bundlers/add-webpack.d.ts +3 -0
- package/src/generators/application/lib/bundlers/add-webpack.js +18 -0
- package/src/generators/application/lib/create-application-files.d.ts +61 -0
- package/src/generators/application/lib/create-application-files.js +102 -19
- package/src/generators/application/lib/get-app-tests.js +10 -11
- package/src/generators/application/lib/install-common-dependencies.d.ts +1 -1
- package/src/generators/application/lib/install-common-dependencies.js +18 -4
- package/src/generators/application/lib/normalize-options.d.ts +1 -3
- package/src/generators/application/lib/normalize-options.js +17 -19
- package/src/generators/application/lib/update-jest-config.js +5 -0
- package/src/generators/application/schema.d.ts +12 -6
- package/src/generators/application/schema.json +44 -42
- package/src/generators/component/component.d.ts +0 -1
- package/src/generators/component/component.js +19 -37
- package/src/generators/component/files/__fileName__.__ext__ +83 -0
- package/src/generators/component/lib/normalize-options.js +13 -15
- package/src/generators/component/schema.d.ts +13 -25
- package/src/generators/component/schema.json +13 -49
- package/src/generators/component-story/component-story.js +1 -2
- package/src/generators/component-story/files/jsx/__componentFileName__.stories.jsx__tmpl__ +5 -5
- package/src/generators/component-story/files/tsx/__componentFileName__.stories.tsx__tmpl__ +3 -4
- package/src/generators/component-test/component-test.js +1 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +0 -2
- package/src/generators/cypress-component-configuration/lib/add-files.d.ts +1 -1
- package/src/generators/cypress-component-configuration/lib/add-files.js +7 -4
- package/src/generators/federate-module/federate-module.js +12 -22
- package/src/generators/federate-module/schema.d.ts +0 -1
- package/src/generators/federate-module/schema.json +13 -12
- package/src/generators/hook/files/{__fileName__.ts__tmpl__ → __fileName__.__ext__} +3 -1
- package/src/generators/hook/hook.d.ts +0 -1
- package/src/generators/hook/hook.js +35 -83
- package/src/generators/hook/schema.d.ts +4 -17
- package/src/generators/hook/schema.json +19 -46
- package/src/generators/host/files/common/src/app/__fileName__.js__tmpl__ +28 -21
- package/src/generators/host/files/common/src/main.js__tmpl__ +12 -9
- package/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +28 -28
- package/src/generators/host/files/common-ts/src/main.ts__tmpl__ +12 -9
- package/src/generators/host/files/rspack-common/src/app/__fileName__.jsx__tmpl__ +22 -13
- package/src/generators/host/files/rspack-common/src/main.jsx__tmpl__ +12 -9
- package/src/generators/host/files/rspack-module-federation/module-federation.config.js__tmpl__ +8 -5
- package/src/generators/host/files/rspack-module-federation/rspack.config.js__tmpl__ +37 -13
- package/src/generators/host/files/rspack-module-federation/rspack.config.prod.js__tmpl__ +60 -30
- package/src/generators/host/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +16 -5
- package/src/generators/host/files/rspack-module-federation-ssr/rspack.config.js__tmpl__ +66 -0
- package/src/generators/host/files/rspack-module-federation-ssr/server.ts__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ssr/src/main.server.tsx__tmpl__ +49 -0
- package/src/generators/host/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +16 -7
- package/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +66 -0
- package/src/generators/host/files/rspack-module-federation-ssr-ts/server.ts__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ssr-ts/src/main.server.tsx__tmpl__ +49 -0
- package/src/generators/host/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +22 -19
- package/src/generators/host/files/rspack-module-federation-ts/rspack.config.prod.ts__tmpl__ +61 -30
- package/src/generators/host/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +37 -13
- package/src/generators/host/files/webpack-module-federation/module-federation.config.js__tmpl__ +8 -5
- package/src/generators/host/files/webpack-module-federation/webpack.config.js__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation/webpack.config.prod.js__tmpl__ +24 -22
- package/src/generators/host/files/webpack-module-federation-ssr/module-federation.server.config.js__tmpl__ +10 -7
- package/src/generators/host/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +2 -2
- package/src/generators/host/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +10 -7
- package/src/generators/host/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +2 -2
- package/src/generators/host/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +22 -19
- package/src/generators/host/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__ +25 -23
- package/src/generators/host/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +4 -3
- package/src/generators/host/host.d.ts +0 -1
- package/src/generators/host/host.js +31 -27
- package/src/generators/host/lib/add-module-federation-files.js +29 -13
- package/src/generators/host/lib/normalize-host-name.d.ts +2 -0
- package/src/generators/host/lib/normalize-host-name.js +12 -0
- package/src/generators/host/lib/normalize-remote.js +10 -6
- package/src/generators/host/lib/setup-ssr-for-host.d.ts +3 -3
- package/src/generators/host/lib/setup-ssr-for-host.js +46 -22
- package/src/generators/host/lib/update-module-federation-tsconfig.d.ts +3 -0
- package/src/generators/host/lib/update-module-federation-tsconfig.js +39 -0
- package/src/generators/host/schema.d.ts +2 -5
- package/src/generators/host/schema.json +16 -27
- package/src/generators/init/init.d.ts +1 -1
- package/src/generators/init/init.js +31 -6
- package/src/generators/init/schema.d.ts +2 -0
- package/src/generators/library/files/common/tsconfig.lib.json__tmpl__ +1 -1
- package/src/generators/library/files/vite/tsconfig.lib.json__tmpl__ +1 -1
- package/src/generators/library/lib/add-linting.js +1 -1
- package/src/generators/library/lib/add-rollup-build-target.d.ts +3 -1
- package/src/generators/library/lib/add-rollup-build-target.js +34 -32
- package/src/generators/library/lib/create-files.d.ts +1 -1
- package/src/generators/library/lib/create-files.js +23 -2
- package/src/generators/library/lib/determine-entry-fields.d.ts +3 -0
- package/src/generators/library/lib/determine-entry-fields.js +22 -0
- package/src/generators/library/lib/install-common-dependencies.d.ts +1 -1
- package/src/generators/library/lib/install-common-dependencies.js +5 -3
- package/src/generators/library/lib/normalize-options.js +11 -6
- package/src/generators/library/library.js +80 -35
- package/src/generators/library/schema.d.ts +5 -5
- package/src/generators/library/schema.json +38 -36
- package/src/generators/redux/files/js/__fileName__.__ext__ +114 -0
- package/src/generators/redux/files/{__fileName__.slice.spec.ts__tmpl__ → js/__fileName__.spec.__ext__} +1 -1
- package/src/generators/redux/files/ts/__fileName__.spec.__ext__ +56 -0
- package/src/generators/redux/redux.d.ts +0 -1
- package/src/generators/redux/redux.js +27 -36
- package/src/generators/redux/schema.d.ts +12 -8
- package/src/generators/redux/schema.json +21 -23
- package/src/generators/remote/files/rspack-module-federation/module-federation.config.js__tmpl__ +10 -7
- package/src/generators/remote/files/rspack-module-federation/rspack.config.js__tmpl__ +40 -13
- package/src/generators/remote/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +13 -4
- package/src/generators/remote/files/rspack-module-federation-ssr/rspack.config.js__tmpl__ +69 -0
- package/src/generators/remote/files/rspack-module-federation-ssr/server.ts__tmpl__ +2 -2
- package/src/generators/remote/files/rspack-module-federation-ssr/src/main.server.tsx__tmpl__ +45 -0
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +13 -4
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +69 -0
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/server.ts__tmpl__ +2 -2
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/src/main.server.tsx__tmpl__ +45 -0
- package/src/generators/remote/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +11 -8
- package/src/generators/remote/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +40 -13
- package/src/generators/remote/files/webpack-module-federation/module-federation.config.js__tmpl__ +10 -7
- package/src/generators/remote/files/webpack-module-federation/webpack.config.js__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation-ssr/module-federation.server.config.js__tmpl__ +7 -4
- package/src/generators/remote/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +2 -2
- package/src/generators/remote/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +8 -5
- package/src/generators/remote/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +2 -2
- package/src/generators/remote/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +11 -8
- package/src/generators/remote/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +2 -2
- package/src/generators/remote/lib/setup-ssr-for-remote.d.ts +1 -1
- package/src/generators/remote/lib/setup-ssr-for-remote.js +37 -15
- package/src/generators/remote/lib/setup-tspath-for-remote.js +1 -3
- package/src/generators/remote/lib/update-host-with-remote.js +2 -2
- package/src/generators/remote/remote.d.ts +0 -1
- package/src/generators/remote/remote.js +57 -33
- package/src/generators/remote/schema.d.ts +2 -5
- package/src/generators/remote/schema.json +16 -27
- package/src/generators/setup-tailwind/lib/update-project.js +1 -2
- package/src/generators/stories/schema.json +0 -10
- package/src/generators/stories/stories.d.ts +1 -3
- package/src/generators/stories/stories.js +9 -20
- package/src/generators/storybook-configuration/configuration.js +2 -11
- package/src/generators/storybook-configuration/schema.d.ts +0 -3
- package/src/generators/storybook-configuration/schema.json +0 -15
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +11 -6
- package/src/migrations/update-20-2-0/migrate-mf-imports-to-new-package.d.ts +2 -0
- package/src/migrations/update-20-2-0/migrate-mf-imports-to-new-package.js +66 -0
- package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.d.ts +2 -0
- package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.js +41 -0
- package/src/migrations/update-20-3-0/ensure-nx-module-federation-package.d.ts +2 -0
- package/src/migrations/update-20-3-0/ensure-nx-module-federation-package.js +18 -0
- package/src/migrations/update-21-0-0/update-babel-loose.d.ts +2 -0
- package/src/migrations/update-21-0-0/update-babel-loose.js +30 -0
- package/src/plugins/router-plugin.d.ts +10 -0
- package/src/plugins/router-plugin.js +221 -0
- package/src/rules/update-module-federation-project.d.ts +2 -1
- package/src/rules/update-module-federation-project.js +37 -48
- package/src/utils/add-mf-env-to-inputs.d.ts +1 -1
- package/src/utils/add-mf-env-to-inputs.js +8 -11
- package/src/utils/assertion.d.ts +2 -0
- package/src/utils/assertion.js +6 -0
- package/src/utils/ast-utils.d.ts +1 -1
- package/src/utils/ast-utils.js +2 -2
- package/src/utils/create-ts-config.js +57 -7
- package/src/utils/ct-utils.d.ts +1 -1
- package/src/utils/ct-utils.js +2 -7
- package/src/utils/has-rsbuild-plugin.d.ts +2 -0
- package/src/utils/has-rsbuild-plugin.js +10 -0
- package/src/utils/has-rspack-plugin.d.ts +2 -0
- package/src/utils/has-rspack-plugin.js +10 -0
- package/src/utils/testing-generators.js +2 -4
- package/src/utils/version-utils.d.ts +14 -0
- package/src/utils/version-utils.js +56 -0
- package/src/utils/versions.d.ts +25 -17
- package/src/utils/versions.js +28 -19
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +0 -84
- package/src/generators/component-cypress-spec/component-cypress-spec.d.ts +0 -13
- package/src/generators/component-cypress-spec/component-cypress-spec.js +0 -104
- package/src/generators/component-cypress-spec/files/__componentName__.__fileExt__ +0 -13
- package/src/generators/component-cypress-spec/schema.json +0 -45
- package/src/generators/host/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__ +0 -16
- package/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__ +0 -16
- package/src/generators/library/files/common/package.json__tmpl__ +0 -4
- package/src/generators/library/files/vite/package.json__tmpl__ +0 -12
- package/src/generators/remote/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__ +0 -16
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__ +0 -16
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
- package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.d.ts +0 -2
- package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.js +0 -8
- package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.d.ts +0 -2
- package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.js +0 -8
- package/src/migrations/update-16-7-0/add-babel-core.d.ts +0 -2
- package/src/migrations/update-16-7-0/add-babel-core.js +0 -14
- package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.d.ts +0 -2
- package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.js +0 -57
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +0 -2
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +0 -53
- package/src/module-federation/load-config.d.ts +0 -3
- package/src/module-federation/load-config.js +0 -15
- package/src/module-federation/models.d.ts +0 -24
- package/src/module-federation/models.js +0 -2
- package/src/module-federation/package-json.d.ts +0 -8
- package/src/module-federation/package-json.js +0 -12
- package/src/module-federation/utils.d.ts +0 -12
- package/src/module-federation/utils.js +0 -75
- package/src/module-federation/with-module-federation-ssr.d.ts +0 -2
- package/src/module-federation/with-module-federation-ssr.js +0 -50
- package/src/module-federation/with-module-federation.d.ts +0 -7
- package/src/module-federation/with-module-federation.js +0 -63
- package/src/utils/build-static.remotes.d.ts +0 -4
- package/src/utils/build-static.remotes.js +0 -65
- package/src/utils/format-file.d.ts +0 -1
- package/src/utils/format-file.js +0 -11
- /package/src/generators/component/files/{__fileName__.spec.tsx__tmpl__ → __fileName__.spec.__ext__} +0 -0
- /package/src/generators/hook/files/{__fileName__.spec.tsx__tmpl__ → __fileName__.spec.__specExt__} +0 -0
- /package/src/generators/redux/files/{__fileName__.slice.ts__tmpl__ → ts/__fileName__.__ext__} +0 -0
|
@@ -5,17 +5,17 @@ exports.containsComponentDeclaration = containsComponentDeclaration;
|
|
|
5
5
|
exports.createAllStories = createAllStories;
|
|
6
6
|
exports.storiesGenerator = storiesGenerator;
|
|
7
7
|
const component_story_1 = require("../component-story/component-story");
|
|
8
|
-
const component_cypress_spec_1 = require("../component-cypress-spec/component-cypress-spec");
|
|
9
8
|
const ast_utils_1 = require("../../utils/ast-utils");
|
|
10
9
|
const devkit_1 = require("@nx/devkit");
|
|
11
10
|
const path_1 = require("path");
|
|
12
11
|
const minimatch_1 = require("minimatch");
|
|
13
12
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
14
13
|
const versions_1 = require("../../utils/versions");
|
|
14
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
15
15
|
let tsModule;
|
|
16
16
|
async function projectRootPath(tree, config) {
|
|
17
17
|
let projectDir;
|
|
18
|
-
if (config.projectType === 'application') {
|
|
18
|
+
if ((0, ts_solution_setup_1.getProjectType)(tree, config.root, config.projectType) === 'application') {
|
|
19
19
|
const isNextJs = await isNextJsProject(tree, config);
|
|
20
20
|
if (isNextJs) {
|
|
21
21
|
// Next.js apps
|
|
@@ -30,7 +30,10 @@ async function projectRootPath(tree, config) {
|
|
|
30
30
|
// libs/test-lib/src/lib
|
|
31
31
|
projectDir = 'lib';
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
else {
|
|
34
|
+
projectDir = '.';
|
|
35
|
+
}
|
|
36
|
+
return (0, devkit_1.joinPathFragments)(config.sourceRoot ?? config.root, projectDir);
|
|
34
37
|
}
|
|
35
38
|
function containsComponentDeclaration(tree, componentPath) {
|
|
36
39
|
if (!tsModule) {
|
|
@@ -44,7 +47,7 @@ function containsComponentDeclaration(tree, componentPath) {
|
|
|
44
47
|
return !!((0, ast_utils_1.getComponentNode)(sourceFile) ||
|
|
45
48
|
(0, ast_utils_1.findExportDeclarationsForJsx)(sourceFile)?.length);
|
|
46
49
|
}
|
|
47
|
-
async function createAllStories(tree, projectName, interactionTests, js, projects, projectConfiguration,
|
|
50
|
+
async function createAllStories(tree, projectName, interactionTests, js, projects, projectConfiguration, ignorePaths) {
|
|
48
51
|
const { isTheFileAStory } = await Promise.resolve().then(() => require('@nx/storybook/src/utils/utilities'));
|
|
49
52
|
const { sourceRoot, root } = projectConfiguration;
|
|
50
53
|
let componentPaths = [];
|
|
@@ -70,13 +73,8 @@ async function createAllStories(tree, projectName, interactionTests, js, project
|
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
});
|
|
73
|
-
const e2eProjectName = cypressProject || `${projectName}-e2e`;
|
|
74
|
-
const e2eProject = projects.get(e2eProjectName);
|
|
75
|
-
if (generateCypressSpecs && !e2eProject) {
|
|
76
|
-
devkit_1.logger.info(`There was no e2e project "${e2eProjectName}" found, so cypress specs will not be generated. Pass "--cypressProject" to specify a different e2e project name`);
|
|
77
|
-
}
|
|
78
76
|
await Promise.all(componentPaths.map(async (componentPath) => {
|
|
79
|
-
const relativeCmpDir = componentPath.replace((0, path_1.join)(sourceRoot, '/'), '');
|
|
77
|
+
const relativeCmpDir = componentPath.replace((0, path_1.join)(sourceRoot ?? root, '/'), '');
|
|
80
78
|
if (!containsComponentDeclaration(tree, componentPath)) {
|
|
81
79
|
return;
|
|
82
80
|
}
|
|
@@ -86,22 +84,13 @@ async function createAllStories(tree, projectName, interactionTests, js, project
|
|
|
86
84
|
skipFormat: true,
|
|
87
85
|
interactionTests,
|
|
88
86
|
});
|
|
89
|
-
if (generateCypressSpecs && e2eProject) {
|
|
90
|
-
await (0, component_cypress_spec_1.default)(tree, {
|
|
91
|
-
project: projectName,
|
|
92
|
-
componentPath: relativeCmpDir,
|
|
93
|
-
js,
|
|
94
|
-
cypressProject,
|
|
95
|
-
skipFormat: true,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
87
|
}));
|
|
99
88
|
}
|
|
100
89
|
async function storiesGenerator(host, schema) {
|
|
101
90
|
const projects = (0, devkit_1.getProjects)(host);
|
|
102
91
|
const projectConfiguration = projects.get(schema.project);
|
|
103
92
|
schema.interactionTests = schema.interactionTests ?? true;
|
|
104
|
-
await createAllStories(host, schema.project, schema.interactionTests, schema.js, projects, projectConfiguration, schema.
|
|
93
|
+
await createAllStories(host, schema.project, schema.interactionTests, schema.js, projects, projectConfiguration, schema.ignorePaths);
|
|
105
94
|
const tasks = [];
|
|
106
95
|
if (schema.interactionTests) {
|
|
107
96
|
const { interactionTestsDependencies, addInteractionsInAddons } = (0, devkit_1.ensurePackage)('@nx/storybook', versions_1.nxVersion);
|
|
@@ -7,16 +7,10 @@ const stories_1 = require("../stories/stories");
|
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
8
|
const versions_1 = require("../../utils/versions");
|
|
9
9
|
async function generateStories(host, schema) {
|
|
10
|
-
// TODO(katerina): Nx 19 -> remove Cypress
|
|
11
|
-
(0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
12
|
-
const { getE2eProjectName } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/project-name'));
|
|
13
10
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(host, schema.project);
|
|
14
|
-
const cypressProject = getE2eProjectName(schema.project, projectConfig.root, schema.cypressDirectory);
|
|
15
11
|
await (0, stories_1.default)(host, {
|
|
16
12
|
project: schema.project,
|
|
17
|
-
generateCypressSpecs: schema.configureCypress && schema.generateCypressSpecs,
|
|
18
13
|
js: schema.js,
|
|
19
|
-
cypressProject,
|
|
20
14
|
ignorePaths: schema.ignorePaths,
|
|
21
15
|
skipFormat: true,
|
|
22
16
|
interactionTests: schema.interactionTests ?? true,
|
|
@@ -38,9 +32,8 @@ async function storybookConfigurationGeneratorInternal(host, schema) {
|
|
|
38
32
|
let uiFramework = '@storybook/react-vite';
|
|
39
33
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(host, schema.project);
|
|
40
34
|
if (findWebpackConfig(host, projectConfig.root) ||
|
|
41
|
-
projectConfig.targets['build']?.executor === '@nx/rollup:rollup' ||
|
|
42
|
-
projectConfig.targets['build']?.executor === '@
|
|
43
|
-
projectConfig.targets['build']?.executor === '@nx/expo:build') {
|
|
35
|
+
projectConfig.targets?.['build']?.executor === '@nx/rollup:rollup' ||
|
|
36
|
+
projectConfig.targets?.['build']?.executor === '@nx/expo:build') {
|
|
44
37
|
uiFramework = '@storybook/react-webpack5';
|
|
45
38
|
}
|
|
46
39
|
if (uiFramework === '@storybook/react-vite') {
|
|
@@ -48,10 +41,8 @@ async function storybookConfigurationGeneratorInternal(host, schema) {
|
|
|
48
41
|
}
|
|
49
42
|
const installTask = await configurationGenerator(host, {
|
|
50
43
|
project: schema.project,
|
|
51
|
-
configureCypress: schema.configureCypress,
|
|
52
44
|
js: schema.js,
|
|
53
45
|
linter: schema.linter,
|
|
54
|
-
cypressDirectory: schema.cypressDirectory,
|
|
55
46
|
tsConfiguration: schema.tsConfiguration ?? true, // default is true
|
|
56
47
|
interactionTests: schema.interactionTests ?? true, // default is true
|
|
57
48
|
configureStaticServe: schema.configureStaticServe,
|
|
@@ -26,11 +26,6 @@
|
|
|
26
26
|
"alias": ["configureTestRunner"],
|
|
27
27
|
"default": true
|
|
28
28
|
},
|
|
29
|
-
"configureCypress": {
|
|
30
|
-
"type": "boolean",
|
|
31
|
-
"description": "Run the cypress-configure generator.",
|
|
32
|
-
"x-deprecated": "Use interactionTests instead. This option will be removed in v20."
|
|
33
|
-
},
|
|
34
29
|
"generateStories": {
|
|
35
30
|
"type": "boolean",
|
|
36
31
|
"description": "Automatically generate `*.stories.ts` files for components declared in this project?",
|
|
@@ -38,11 +33,6 @@
|
|
|
38
33
|
"default": true,
|
|
39
34
|
"x-priority": "important"
|
|
40
35
|
},
|
|
41
|
-
"generateCypressSpecs": {
|
|
42
|
-
"type": "boolean",
|
|
43
|
-
"description": "Automatically generate test files in the Cypress E2E app generated by the `cypress-configure` generator.",
|
|
44
|
-
"x-deprecated": "Use interactionTests instead. This option will be removed in v20."
|
|
45
|
-
},
|
|
46
36
|
"configureStaticServe": {
|
|
47
37
|
"type": "boolean",
|
|
48
38
|
"description": "Specifies whether to configure a static file server target for serving storybook. Helpful for speeding up CI build/test times.",
|
|
@@ -50,11 +40,6 @@
|
|
|
50
40
|
"default": true,
|
|
51
41
|
"x-priority": "important"
|
|
52
42
|
},
|
|
53
|
-
"cypressDirectory": {
|
|
54
|
-
"type": "string",
|
|
55
|
-
"description": "A directory where the Cypress project will be placed. Placed at the root by default.",
|
|
56
|
-
"x-deprecated": "Use interactionTests instead. This option will be removed in v20."
|
|
57
|
-
},
|
|
58
43
|
"js": {
|
|
59
44
|
"type": "boolean",
|
|
60
45
|
"description": "Generate JavaScript story files rather than TypeScript story files.",
|
|
@@ -4,10 +4,11 @@ exports.default = default_1;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
|
6
6
|
async function default_1(tree) {
|
|
7
|
-
|
|
7
|
+
const bundler = hasModuleFederationProject(tree);
|
|
8
|
+
if (!bundler) {
|
|
8
9
|
return;
|
|
9
10
|
}
|
|
10
|
-
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(tree);
|
|
11
|
+
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(tree, bundler);
|
|
11
12
|
await (0, devkit_1.formatFiles)(tree);
|
|
12
13
|
}
|
|
13
14
|
function hasModuleFederationProject(tree) {
|
|
@@ -15,10 +16,14 @@ function hasModuleFederationProject(tree) {
|
|
|
15
16
|
for (const project of projects.values()) {
|
|
16
17
|
const targets = project.targets || {};
|
|
17
18
|
for (const [_, target] of Object.entries(targets)) {
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||
|
|
20
|
+
tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.js'))) {
|
|
21
|
+
if (target.executor === '@nx/webpack:webpack') {
|
|
22
|
+
return 'webpack';
|
|
23
|
+
}
|
|
24
|
+
else if (target.executor === '@nx/rspack:rspack') {
|
|
25
|
+
return 'rspack';
|
|
26
|
+
}
|
|
22
27
|
}
|
|
23
28
|
}
|
|
24
29
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = migrateMfImportsToNewPackage;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const devkit_2 = require("@nx/devkit");
|
|
6
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
|
+
const MF_IMPORT_TO_UPDATE = 'ModuleFederationConfig';
|
|
8
|
+
const MF_CONFIG_IMPORT_SELECTOR = `ImportDeclaration:has(StringLiteral[value=@nx/webpack]):has(Identifier[name=ModuleFederationConfig]),ImportDeclaration:has(StringLiteral[value=@nx/rspack/module-federation]):has(Identifier[name=ModuleFederationConfig])`;
|
|
9
|
+
const IMPORT_TOKENS_SELECTOR = `ImportClause ImportSpecifier`;
|
|
10
|
+
const MF_CONFIG_IMPORT_SPECIFIER_SELECTOR = `ImportClause ImportSpecifier > Identifier[name=ModuleFederationConfig]`;
|
|
11
|
+
const WEBPACK_IMPORT_SELECTOR = `ImportDeclaration > StringLiteral[value=@nx/webpack]`;
|
|
12
|
+
const RSPACK_IMPORT_SELECTOR = `ImportDeclaration > StringLiteral[value=@nx/rspack/module-federation]`;
|
|
13
|
+
async function migrateMfImportsToNewPackage(tree) {
|
|
14
|
+
const rootsToCheck = new Set();
|
|
15
|
+
const graph = await (0, devkit_1.createProjectGraphAsync)();
|
|
16
|
+
for (const [project, dependencies] of Object.entries(graph.dependencies)) {
|
|
17
|
+
if (!graph.nodes[project]) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const usesNxWebpackOrRspack = dependencies.some((dep) => dep.target === 'npm:@nx/webpack' || dep.target === 'npm:@nx/rspack');
|
|
21
|
+
if (usesNxWebpackOrRspack) {
|
|
22
|
+
const root = graph.nodes[project].data.root;
|
|
23
|
+
rootsToCheck.add(root);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
for (const root of rootsToCheck) {
|
|
27
|
+
(0, devkit_2.visitNotIgnoredFiles)(tree, root, (filePath) => {
|
|
28
|
+
if (!filePath.endsWith('.ts') && !filePath.endsWith('.js')) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
let contents = tree.read(filePath, 'utf-8');
|
|
32
|
+
if (!contents.includes(MF_IMPORT_TO_UPDATE)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const ast = tsquery_1.tsquery.ast(contents);
|
|
36
|
+
const importNodes = (0, tsquery_1.tsquery)(ast, MF_CONFIG_IMPORT_SELECTOR);
|
|
37
|
+
if (importNodes.length === 0) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const importNode = importNodes[0];
|
|
41
|
+
const importSpecifiers = (0, tsquery_1.tsquery)(importNode, IMPORT_TOKENS_SELECTOR);
|
|
42
|
+
if (importSpecifiers.length > 1) {
|
|
43
|
+
const mfConfigImportSpecifierNode = (0, tsquery_1.tsquery)(importNode, MF_CONFIG_IMPORT_SPECIFIER_SELECTOR)[0];
|
|
44
|
+
const end = contents.charAt(mfConfigImportSpecifierNode.getEnd()) === ','
|
|
45
|
+
? mfConfigImportSpecifierNode.getEnd() + 1
|
|
46
|
+
: mfConfigImportSpecifierNode.getEnd();
|
|
47
|
+
contents = `import { ${MF_IMPORT_TO_UPDATE} } from '@nx/module-federation';
|
|
48
|
+
${contents.slice(0, mfConfigImportSpecifierNode.getStart())}${contents.slice(end)}`;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const nxWebpackImportStringNodes = (0, tsquery_1.tsquery)(importNode, WEBPACK_IMPORT_SELECTOR);
|
|
52
|
+
const nxRspackImportStringNodes = (0, tsquery_1.tsquery)(importNode, RSPACK_IMPORT_SELECTOR);
|
|
53
|
+
if (nxWebpackImportStringNodes.length === 0 &&
|
|
54
|
+
nxRspackImportStringNodes.length === 0) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const bundlerImportStringNode = nxWebpackImportStringNodes.length
|
|
58
|
+
? nxWebpackImportStringNodes[0]
|
|
59
|
+
: nxRspackImportStringNodes[0];
|
|
60
|
+
contents = `${contents.slice(0, bundlerImportStringNode.getStart())}'@nx/module-federation'${contents.slice(bundlerImportStringNode.getEnd())}`;
|
|
61
|
+
}
|
|
62
|
+
tree.write(filePath, contents);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
await (0, devkit_2.formatFiles)(tree);
|
|
66
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = migrateWithMfImport;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
|
+
const versions_1 = require("../../utils/versions");
|
|
8
|
+
const NX_RSPACK_MODULE_FEDERATION_IMPORT_SELECTOR = 'ImportDeclaration > StringLiteral[value=@nx/react/module-federation], VariableStatement CallExpression:has(Identifier[name=require]) > StringLiteral[value=@nx/react/module-federation]';
|
|
9
|
+
const NEW_IMPORT_PATH = `'@nx/module-federation/webpack'`;
|
|
10
|
+
async function migrateWithMfImport(tree) {
|
|
11
|
+
const projects = new Set();
|
|
12
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/react:module-federation-dev-server', (options, project, target) => {
|
|
13
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
14
|
+
projects.add(projectConfig.root);
|
|
15
|
+
});
|
|
16
|
+
for (const projectRoot of projects) {
|
|
17
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, projectRoot, (filePath) => {
|
|
18
|
+
if (!filePath.endsWith('.ts') && !filePath.endsWith('.js')) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
let contents = tree.read(filePath, 'utf-8');
|
|
22
|
+
if (!contents.includes('@nx/react/module-federation')) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const ast = tsquery_1.tsquery.ast(contents);
|
|
26
|
+
const importNodes = (0, tsquery_1.tsquery)(ast, NX_RSPACK_MODULE_FEDERATION_IMPORT_SELECTOR);
|
|
27
|
+
if (importNodes.length === 0) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const importPathNode = importNodes[0];
|
|
31
|
+
contents = `${contents.slice(0, importPathNode.getStart())}${NEW_IMPORT_PATH}${contents.slice(importPathNode.getEnd())}`;
|
|
32
|
+
tree.write(filePath, contents);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (projects.size !== 0) {
|
|
36
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
37
|
+
'@nx/module-federation': versions_1.nxVersion,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
41
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ensureMfPackage;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
const versions_1 = require("../../utils/versions");
|
|
7
|
+
async function ensureMfPackage(tree) {
|
|
8
|
+
const projects = new Set();
|
|
9
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/react:module-federation-dev-server', (options, project, target) => {
|
|
10
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
11
|
+
projects.add(projectConfig.root);
|
|
12
|
+
});
|
|
13
|
+
if (projects.size !== 0) {
|
|
14
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
15
|
+
'@nx/module-federation': versions_1.nxVersion,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = updateBabelLoose;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
async function updateBabelLoose(tree) {
|
|
6
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '', (path) => {
|
|
7
|
+
if (!path.endsWith('.babelrc'))
|
|
8
|
+
return;
|
|
9
|
+
try {
|
|
10
|
+
(0, devkit_1.updateJson)(tree, path, (babelConfig) => {
|
|
11
|
+
if (!Array.isArray(babelConfig.presets))
|
|
12
|
+
return babelConfig;
|
|
13
|
+
const ourPreset = babelConfig.presets.find((p) => Array.isArray(p) && p[0] === '@nx/react/babel');
|
|
14
|
+
if (!ourPreset || !ourPreset[1])
|
|
15
|
+
return babelConfig;
|
|
16
|
+
const options = ourPreset[1];
|
|
17
|
+
if (options['classProperties']?.loose !== undefined) {
|
|
18
|
+
options.loose = options['classProperties'].loose;
|
|
19
|
+
delete options['classProperties'];
|
|
20
|
+
}
|
|
21
|
+
return babelConfig;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// Skip if JSON does not parse for whatever reason
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
30
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type CreateNodesV2 } from '@nx/devkit';
|
|
2
|
+
export interface ReactRouterPluginOptions {
|
|
3
|
+
buildTargetName?: string;
|
|
4
|
+
devTargetName?: string;
|
|
5
|
+
startTargetName?: string;
|
|
6
|
+
typecheckTargetName?: string;
|
|
7
|
+
buildDepsTargetName?: string;
|
|
8
|
+
watchDepsTargetName?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const createNodesV2: CreateNodesV2<ReactRouterPluginOptions>;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNodesV2 = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
8
|
+
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
9
|
+
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
10
|
+
const js_1 = require("@nx/js");
|
|
11
|
+
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
12
|
+
const util_1 = require("@nx/js/src/plugins/typescript/util");
|
|
13
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
14
|
+
const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
|
|
15
|
+
const pmCommand = (0, devkit_1.getPackageManagerCommand)();
|
|
16
|
+
const reactRouterConfigBlob = '**/react-router.config.{ts,js,cjs,cts,mjs,mts}';
|
|
17
|
+
function readTargetsCache(cachePath) {
|
|
18
|
+
return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, fs_1.existsSync)(cachePath)
|
|
19
|
+
? (0, devkit_1.readJsonFile)(cachePath)
|
|
20
|
+
: {};
|
|
21
|
+
}
|
|
22
|
+
function writeTargetsToCache(cachePath, results) {
|
|
23
|
+
(0, devkit_1.writeJsonFile)(cachePath, results);
|
|
24
|
+
}
|
|
25
|
+
exports.createNodesV2 = [
|
|
26
|
+
reactRouterConfigBlob,
|
|
27
|
+
async (configFiles, options, context) => {
|
|
28
|
+
const optionsHash = (0, devkit_internals_1.hashObject)(options);
|
|
29
|
+
const normalizedOptions = normalizeOptions(options);
|
|
30
|
+
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `react-router-${optionsHash}.hash`);
|
|
31
|
+
const targetsCache = readTargetsCache(cachePath);
|
|
32
|
+
const isUsingTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
|
|
33
|
+
const { roots: projectRoots, configFiles: validConfigFiles } = configFiles.reduce((acc, configFile) => {
|
|
34
|
+
const potentialRoot = (0, path_1.dirname)(configFile);
|
|
35
|
+
if (checkIfConfigFileShouldBeProject(potentialRoot, context)) {
|
|
36
|
+
acc.roots.push(potentialRoot);
|
|
37
|
+
acc.configFiles.push(configFile);
|
|
38
|
+
}
|
|
39
|
+
return acc;
|
|
40
|
+
}, {
|
|
41
|
+
roots: [],
|
|
42
|
+
configFiles: [],
|
|
43
|
+
});
|
|
44
|
+
const lockfile = (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
|
|
45
|
+
const hashes = await (0, calculate_hash_for_create_nodes_1.calculateHashesForCreateNodes)(projectRoots, { ...normalizedOptions, isUsingTsSolutionSetup }, context, projectRoots.map((_) => [lockfile]));
|
|
46
|
+
try {
|
|
47
|
+
return await (0, devkit_1.createNodesFromFiles)(async (configFile, _, context, idx) => {
|
|
48
|
+
const projectRoot = (0, path_1.dirname)(configFile);
|
|
49
|
+
const siblingFiles = (0, fs_1.readdirSync)((0, devkit_1.joinPathFragments)(context.workspaceRoot, projectRoot));
|
|
50
|
+
const hash = hashes[idx] + configFile;
|
|
51
|
+
const { projectType, metadata, targets } = (targetsCache[hash] ??=
|
|
52
|
+
await buildReactRouterTargets(configFile, projectRoot, normalizedOptions, context, siblingFiles, isUsingTsSolutionSetup));
|
|
53
|
+
const project = {
|
|
54
|
+
root: projectRoot,
|
|
55
|
+
targets,
|
|
56
|
+
metadata,
|
|
57
|
+
};
|
|
58
|
+
if (project.targets[normalizedOptions.buildTargetName]) {
|
|
59
|
+
project.projectType = projectType;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
projects: {
|
|
63
|
+
[projectRoot]: project,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}, validConfigFiles, options, context);
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
writeTargetsToCache(cachePath, targetsCache);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
async function buildReactRouterTargets(configFilePath, projectRoot, options, context, siblingFiles, isUsingTsSolutionSetup) {
|
|
74
|
+
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
75
|
+
const configPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
|
|
76
|
+
if (require.cache[configPath])
|
|
77
|
+
(0, config_utils_1.clearRequireCache)();
|
|
78
|
+
const reactRouterConfig = await (0, config_utils_1.loadConfigFile)(configPath);
|
|
79
|
+
const isLibMode = reactRouterConfig?.ssr !== undefined && reactRouterConfig.ssr === false;
|
|
80
|
+
const { buildDirectory, serverBuildPath } = await getBuildPaths(reactRouterConfig, isLibMode);
|
|
81
|
+
const targets = {};
|
|
82
|
+
targets[options.buildTargetName] = await getBuildTargetConfig(options.buildTargetName, projectRoot, buildDirectory, serverBuildPath, namedInputs, isUsingTsSolutionSetup);
|
|
83
|
+
targets[options.devTargetName] = await devTarget(projectRoot, isUsingTsSolutionSetup);
|
|
84
|
+
if (serverBuildPath) {
|
|
85
|
+
targets[options.startTargetName] = await startTarget(projectRoot, serverBuildPath, options.buildTargetName, isUsingTsSolutionSetup);
|
|
86
|
+
}
|
|
87
|
+
targets[options.typecheckTargetName] = await typecheckTarget(projectRoot, options.typecheckTargetName, namedInputs, siblingFiles, isUsingTsSolutionSetup);
|
|
88
|
+
(0, util_1.addBuildAndWatchDepsTargets)(context.workspaceRoot, projectRoot, targets, options, pmCommand);
|
|
89
|
+
const metadata = {};
|
|
90
|
+
return {
|
|
91
|
+
targets,
|
|
92
|
+
metadata,
|
|
93
|
+
projectType: isLibMode ? 'library' : 'application',
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async function getBuildTargetConfig(buildTargetName, projectRoot, buildDirectory, serverBuildDirectory, namedInputs, isUsingTsSolutionSetup) {
|
|
97
|
+
const basePath = projectRoot === '.'
|
|
98
|
+
? `{workspaceRoot}`
|
|
99
|
+
: (0, devkit_1.joinPathFragments)(`{workspaceRoot}`, projectRoot);
|
|
100
|
+
const outputs = [
|
|
101
|
+
(0, devkit_1.joinPathFragments)(basePath, buildDirectory),
|
|
102
|
+
...(serverBuildDirectory
|
|
103
|
+
? [(0, devkit_1.joinPathFragments)(basePath, serverBuildDirectory)]
|
|
104
|
+
: []),
|
|
105
|
+
];
|
|
106
|
+
const buildTarget = {
|
|
107
|
+
cache: true,
|
|
108
|
+
dependsOn: [`^${buildTargetName}`],
|
|
109
|
+
inputs: [
|
|
110
|
+
...('production' in namedInputs
|
|
111
|
+
? ['production', '^production']
|
|
112
|
+
: ['default', '^default']),
|
|
113
|
+
{ externalDependencies: ['@react-router/dev'] },
|
|
114
|
+
],
|
|
115
|
+
outputs,
|
|
116
|
+
command: 'react-router build',
|
|
117
|
+
options: { cwd: projectRoot },
|
|
118
|
+
};
|
|
119
|
+
if (isUsingTsSolutionSetup) {
|
|
120
|
+
buildTarget.syncGenerators = ['@nx/js:typescript-sync'];
|
|
121
|
+
}
|
|
122
|
+
return buildTarget;
|
|
123
|
+
}
|
|
124
|
+
async function getBuildPaths(reactRouterConfig, isLibMode) {
|
|
125
|
+
return {
|
|
126
|
+
buildDirectory: reactRouterConfig?.buildDirectory ?? 'build/client',
|
|
127
|
+
...(isLibMode
|
|
128
|
+
? undefined
|
|
129
|
+
: {
|
|
130
|
+
serverBuildPath: reactRouterConfig?.buildDirectory
|
|
131
|
+
? (0, path_1.join)((0, path_1.dirname)(reactRouterConfig.buildDirectory), `server`)
|
|
132
|
+
: 'build/server',
|
|
133
|
+
}),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
async function devTarget(projectRoot, isUsingTsSolutionSetup) {
|
|
137
|
+
const devTarget = {
|
|
138
|
+
continuous: true,
|
|
139
|
+
command: 'react-router dev',
|
|
140
|
+
options: { cwd: projectRoot },
|
|
141
|
+
};
|
|
142
|
+
if (isUsingTsSolutionSetup) {
|
|
143
|
+
devTarget.syncGenerators = ['@nx/js:typescript-sync'];
|
|
144
|
+
}
|
|
145
|
+
return devTarget;
|
|
146
|
+
}
|
|
147
|
+
async function startTarget(projectRoot, serverBuildPath, buildTargetName, isUsingTsSolutionSetup) {
|
|
148
|
+
const serverPath = serverBuildPath === 'build/server'
|
|
149
|
+
? `${serverBuildPath}/index.js`
|
|
150
|
+
: serverBuildPath;
|
|
151
|
+
const startTarget = {
|
|
152
|
+
continuous: true,
|
|
153
|
+
dependsOn: [buildTargetName],
|
|
154
|
+
command: `react-router-serve ${serverPath}`,
|
|
155
|
+
options: { cwd: projectRoot },
|
|
156
|
+
};
|
|
157
|
+
if (isUsingTsSolutionSetup) {
|
|
158
|
+
startTarget.syncGenerators = ['@nx/js:typescript-sync'];
|
|
159
|
+
}
|
|
160
|
+
return startTarget;
|
|
161
|
+
}
|
|
162
|
+
async function typecheckTarget(projectRoot, typecheckTargetName, namedInputs, siblingFiles, isUsingTsSolutionSetup) {
|
|
163
|
+
const hasTsConfigAppJson = siblingFiles.includes('tsconfig.app.json');
|
|
164
|
+
const typecheckTarget = {
|
|
165
|
+
cache: true,
|
|
166
|
+
inputs: [
|
|
167
|
+
...('production' in namedInputs
|
|
168
|
+
? ['production', '^production']
|
|
169
|
+
: ['default', '^default']),
|
|
170
|
+
{ externalDependencies: ['typescript'] },
|
|
171
|
+
],
|
|
172
|
+
command: isUsingTsSolutionSetup
|
|
173
|
+
? `tsc --build --emitDeclarationOnly`
|
|
174
|
+
: `tsc${hasTsConfigAppJson ? ` -p tsconfig.app.json` : ``} --noEmit`,
|
|
175
|
+
options: {
|
|
176
|
+
cwd: projectRoot,
|
|
177
|
+
},
|
|
178
|
+
metadata: {
|
|
179
|
+
description: `Runs type-checking for the project.`,
|
|
180
|
+
technologies: ['typescript'],
|
|
181
|
+
help: {
|
|
182
|
+
command: isUsingTsSolutionSetup
|
|
183
|
+
? `${pmCommand.exec} tsc --build --help`
|
|
184
|
+
: `${pmCommand.exec} tsc${hasTsConfigAppJson ? ` -p tsconfig.app.json` : ``} --help`,
|
|
185
|
+
example: isUsingTsSolutionSetup
|
|
186
|
+
? { args: ['--force'] }
|
|
187
|
+
: { options: { noEmit: true } },
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
if (isUsingTsSolutionSetup) {
|
|
192
|
+
typecheckTarget.dependsOn = [`^${typecheckTargetName}`];
|
|
193
|
+
typecheckTarget.syncGenerators = ['@nx/js:typescript-sync'];
|
|
194
|
+
}
|
|
195
|
+
return typecheckTarget;
|
|
196
|
+
}
|
|
197
|
+
function normalizeOptions(options) {
|
|
198
|
+
options ??= {};
|
|
199
|
+
options.buildTargetName ??= 'build';
|
|
200
|
+
options.devTargetName ??= 'dev';
|
|
201
|
+
options.startTargetName ??= 'start';
|
|
202
|
+
options.typecheckTargetName ??= 'typecheck';
|
|
203
|
+
return options;
|
|
204
|
+
}
|
|
205
|
+
function checkIfConfigFileShouldBeProject(projectRoot, context) {
|
|
206
|
+
// Do not create a project if package.json and project.json isn't there.
|
|
207
|
+
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
208
|
+
return hasRequiredConfigs(siblingFiles);
|
|
209
|
+
}
|
|
210
|
+
function hasRequiredConfigs(files) {
|
|
211
|
+
const lowerFiles = files.map((file) => file.toLowerCase());
|
|
212
|
+
// Check if vite.config.{ext} is present
|
|
213
|
+
const hasViteConfig = lowerFiles.some((file) => {
|
|
214
|
+
const parts = file.split('.');
|
|
215
|
+
return parts[0] === 'vite' && parts[1] === 'config' && parts.length > 2;
|
|
216
|
+
});
|
|
217
|
+
if (!hasViteConfig)
|
|
218
|
+
return false;
|
|
219
|
+
const hasProjectOrPackageJson = lowerFiles.includes('project.json') || lowerFiles.includes('package.json');
|
|
220
|
+
return hasProjectOrPackageJson;
|
|
221
|
+
}
|