@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
|
@@ -3,18 +3,43 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addJest = addJest;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const versions_1 = require("../../../utils/versions");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
6
7
|
async function addJest(host, options) {
|
|
7
8
|
if (options.unitTestRunner === 'none') {
|
|
8
9
|
return () => { };
|
|
9
10
|
}
|
|
10
11
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
|
|
11
|
-
|
|
12
|
+
await configurationGenerator(host, {
|
|
12
13
|
...options,
|
|
13
14
|
project: options.projectName,
|
|
14
15
|
supportTsx: true,
|
|
15
16
|
skipSerializers: true,
|
|
16
|
-
setupFile: 'none',
|
|
17
|
+
setupFile: options.useReactRouter ? 'react-router' : 'none',
|
|
17
18
|
compiler: options.compiler,
|
|
18
19
|
skipFormat: true,
|
|
20
|
+
runtimeTsconfigFileName: 'tsconfig.app.json',
|
|
19
21
|
});
|
|
22
|
+
if (options.useReactRouter) {
|
|
23
|
+
(0, devkit_1.updateJson)(host, (0, node_path_1.join)(options.appProjectRoot, 'tsconfig.spec.json'), (json) => {
|
|
24
|
+
json.include = json.include ?? [];
|
|
25
|
+
const reactRouterTestGlob = options.js
|
|
26
|
+
? [
|
|
27
|
+
'test/**/*.spec.jsx',
|
|
28
|
+
'test/**/*.spec.js',
|
|
29
|
+
'test/**/*.test.jsx',
|
|
30
|
+
'test/**/*.test.js',
|
|
31
|
+
]
|
|
32
|
+
: [
|
|
33
|
+
'test/**/*.spec.tsx',
|
|
34
|
+
'test/**/*.spec.ts',
|
|
35
|
+
'test/**/*.test.tsx',
|
|
36
|
+
'test/**/*.test.ts',
|
|
37
|
+
];
|
|
38
|
+
return {
|
|
39
|
+
...json,
|
|
40
|
+
include: Array.from(new Set([...json.include, ...reactRouterTestGlob])),
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return () => { };
|
|
20
45
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Tree, type GeneratorCallback } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema } from '../schema';
|
|
3
|
+
export declare function addLinting(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function isEslintInstalled(tree: Tree): boolean;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addLinting = addLinting;
|
|
4
|
+
exports.isEslintInstalled = isEslintInstalled;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const eslint_1 = require("@nx/eslint");
|
|
7
|
+
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
|
8
|
+
const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
|
|
9
|
+
const devkit_2 = require("@nx/devkit");
|
|
10
|
+
const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
|
|
11
|
+
const lint_1 = require("../../../utils/lint");
|
|
12
|
+
const versions_1 = require("../../../utils/versions");
|
|
13
|
+
async function addLinting(host, options) {
|
|
14
|
+
const tasks = [];
|
|
15
|
+
if (options.linter === 'eslint') {
|
|
16
|
+
const lintTask = await (0, eslint_1.lintProjectGenerator)(host, {
|
|
17
|
+
linter: options.linter,
|
|
18
|
+
project: options.projectName,
|
|
19
|
+
tsConfigPaths: [
|
|
20
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
21
|
+
],
|
|
22
|
+
unitTestRunner: options.unitTestRunner,
|
|
23
|
+
skipFormat: true,
|
|
24
|
+
rootProject: options.rootProject,
|
|
25
|
+
skipPackageJson: options.skipPackageJson,
|
|
26
|
+
addPlugin: options.addPlugin,
|
|
27
|
+
});
|
|
28
|
+
tasks.push(lintTask);
|
|
29
|
+
if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
30
|
+
if ((0, flat_config_1.useFlatConfig)(host)) {
|
|
31
|
+
(0, eslint_file_1.addPredefinedConfigToFlatLintConfig)(host, options.appProjectRoot, 'flat/react');
|
|
32
|
+
// Add an empty rules object to users know how to add/override rules
|
|
33
|
+
(0, eslint_file_1.addOverrideToLintConfig)(host, options.appProjectRoot, {
|
|
34
|
+
files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
|
|
35
|
+
rules: {},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const addExtendsTask = (0, eslint_file_1.addExtendsToLintConfig)(host, options.appProjectRoot, { name: 'plugin:@nx/react', needCompatFixup: true });
|
|
40
|
+
tasks.push(addExtendsTask);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (!options.skipPackageJson) {
|
|
44
|
+
const installTask = (0, devkit_2.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
|
45
|
+
const addSwcTask = (0, add_swc_dependencies_1.addSwcDependencies)(host);
|
|
46
|
+
tasks.push(installTask, addSwcTask);
|
|
47
|
+
}
|
|
48
|
+
if (options.useReactRouter) {
|
|
49
|
+
await ignoreReactRouterFilesInEslintConfig(host, options.appProjectRoot);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return (0, devkit_2.runTasksInSerial)(...tasks);
|
|
53
|
+
}
|
|
54
|
+
async function ignoreReactRouterFilesInEslintConfig(tree, projectRoot) {
|
|
55
|
+
if (!isEslintInstalled(tree)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
(0, devkit_1.ensurePackage)('@nx/eslint', versions_1.nxVersion);
|
|
59
|
+
const { addIgnoresToLintConfig, isEslintConfigSupported } = await Promise.resolve().then(() => require('@nx/eslint/src/generators/utils/eslint-file'));
|
|
60
|
+
if (!isEslintConfigSupported(tree)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const { useFlatConfig } = await Promise.resolve().then(() => require('@nx/eslint/src/utils/flat-config'));
|
|
64
|
+
const isUsingFlatConfig = useFlatConfig(tree);
|
|
65
|
+
if (!projectRoot && !isUsingFlatConfig) {
|
|
66
|
+
// root eslintrc files ignore all files and the root eslintrc files add
|
|
67
|
+
// back all the project files, so we only add the ignores to the project
|
|
68
|
+
// eslintrc files
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// for flat config, we update the root config file
|
|
72
|
+
const directory = isUsingFlatConfig ? '' : projectRoot ?? '';
|
|
73
|
+
addIgnoresToLintConfig(tree, directory, ['**/build', '**/.react-router']);
|
|
74
|
+
}
|
|
75
|
+
function isEslintInstalled(tree) {
|
|
76
|
+
try {
|
|
77
|
+
require('eslint');
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
catch { }
|
|
81
|
+
// it might not be installed yet, but it might be in the tree pending install
|
|
82
|
+
const { devDependencies, dependencies } = tree.exists('package.json')
|
|
83
|
+
? (0, devkit_1.readJson)(tree, 'package.json')
|
|
84
|
+
: {};
|
|
85
|
+
return !!devDependencies?.['eslint'] || !!dependencies?.['eslint'];
|
|
86
|
+
}
|
|
@@ -4,6 +4,7 @@ exports.addProject = addProject;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
|
|
6
6
|
const maybe_js_1 = require("../../../utils/maybe-js");
|
|
7
|
+
const has_rspack_plugin_1 = require("../../../utils/has-rspack-plugin");
|
|
7
8
|
function addProject(host, options) {
|
|
8
9
|
const project = {
|
|
9
10
|
root: options.appProjectRoot,
|
|
@@ -20,9 +21,112 @@ function addProject(host, options) {
|
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
else if (options.bundler === 'rspack' &&
|
|
25
|
+
(!(0, has_rspack_plugin_1.hasRspackPlugin)(host) || !options.addPlugin)) {
|
|
26
|
+
project.targets = {
|
|
27
|
+
build: createRspackBuildTarget(options),
|
|
28
|
+
serve: createRspackServeTarget(options),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const packageJson = {
|
|
32
|
+
name: options.importPath,
|
|
33
|
+
version: '0.0.1',
|
|
34
|
+
private: true,
|
|
35
|
+
};
|
|
36
|
+
if (!options.useProjectJson) {
|
|
37
|
+
if (options.projectName !== options.importPath) {
|
|
38
|
+
packageJson.nx = { name: options.projectName };
|
|
39
|
+
}
|
|
40
|
+
if (Object.keys(project.targets).length) {
|
|
41
|
+
packageJson.nx ??= {};
|
|
42
|
+
packageJson.nx.targets = project.targets;
|
|
43
|
+
}
|
|
44
|
+
if (options.parsedTags?.length) {
|
|
45
|
+
packageJson.nx ??= {};
|
|
46
|
+
packageJson.nx.tags = options.parsedTags;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
(0, devkit_1.addProjectConfiguration)(host, options.projectName, {
|
|
51
|
+
...project,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
55
|
+
// React Router already adds a package.json to the project root
|
|
56
|
+
if (options.useReactRouter) {
|
|
57
|
+
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), (json) => {
|
|
58
|
+
return {
|
|
59
|
+
name: packageJson.name,
|
|
60
|
+
...json,
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function createRspackBuildTarget(options) {
|
|
70
|
+
return {
|
|
71
|
+
executor: '@nx/rspack:rspack',
|
|
72
|
+
outputs: ['{options.outputPath}'],
|
|
73
|
+
defaultConfiguration: 'production',
|
|
74
|
+
options: {
|
|
75
|
+
outputPath: options.isUsingTsSolutionConfig
|
|
76
|
+
? (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'dist')
|
|
77
|
+
: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot !== '.'
|
|
78
|
+
? options.appProjectRoot
|
|
79
|
+
: options.projectName),
|
|
80
|
+
index: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/index.html'),
|
|
81
|
+
baseHref: '/',
|
|
82
|
+
main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/main.tsx`)),
|
|
83
|
+
tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
84
|
+
assets: [
|
|
85
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/favicon.ico'),
|
|
86
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/assets'),
|
|
87
|
+
],
|
|
88
|
+
rspackConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'rspack.config.js'),
|
|
89
|
+
styles: options.styledModule || !options.hasStyles
|
|
90
|
+
? []
|
|
91
|
+
: [
|
|
92
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/styles.${options.style}`),
|
|
93
|
+
],
|
|
94
|
+
scripts: [],
|
|
95
|
+
configurations: {
|
|
96
|
+
development: {
|
|
97
|
+
mode: 'development',
|
|
98
|
+
},
|
|
99
|
+
production: {
|
|
100
|
+
mode: 'production',
|
|
101
|
+
optimization: true,
|
|
102
|
+
sourceMap: false,
|
|
103
|
+
outputHashing: 'all',
|
|
104
|
+
namedChunks: false,
|
|
105
|
+
extractLicenses: true,
|
|
106
|
+
vendorChunk: false,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function createRspackServeTarget(options) {
|
|
113
|
+
return {
|
|
114
|
+
executor: '@nx/rspack:dev-server',
|
|
115
|
+
defaultConfiguration: 'development',
|
|
116
|
+
options: {
|
|
117
|
+
buildTarget: `${options.projectName}:build`,
|
|
118
|
+
hmr: true,
|
|
119
|
+
},
|
|
120
|
+
configurations: {
|
|
121
|
+
development: {
|
|
122
|
+
buildTarget: `${options.projectName}:build:development`,
|
|
123
|
+
},
|
|
124
|
+
production: {
|
|
125
|
+
buildTarget: `${options.projectName}:build:production`,
|
|
126
|
+
hmr: false,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
};
|
|
26
130
|
}
|
|
27
131
|
function createBuildTarget(options) {
|
|
28
132
|
return {
|
|
@@ -31,9 +135,11 @@ function createBuildTarget(options) {
|
|
|
31
135
|
defaultConfiguration: 'production',
|
|
32
136
|
options: {
|
|
33
137
|
compiler: options.compiler ?? 'babel',
|
|
34
|
-
outputPath:
|
|
35
|
-
? options.appProjectRoot
|
|
36
|
-
:
|
|
138
|
+
outputPath: options.isUsingTsSolutionConfig
|
|
139
|
+
? (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'dist')
|
|
140
|
+
: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot !== '.'
|
|
141
|
+
? options.appProjectRoot
|
|
142
|
+
: options.projectName),
|
|
37
143
|
index: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/index.html'),
|
|
38
144
|
baseHref: '/',
|
|
39
145
|
main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/main.tsx`)),
|
|
@@ -20,7 +20,7 @@ function addRouting(host, options) {
|
|
|
20
20
|
}, `src/app/${options.fileName}.tsx`));
|
|
21
21
|
const appFileContent = host.read(appPath, 'utf-8');
|
|
22
22
|
const appSource = tsModule.createSourceFile(appPath, appFileContent, tsModule.ScriptTarget.Latest, true);
|
|
23
|
-
const changes = (0, devkit_1.applyChangesToString)(appFileContent, (0, ast_utils_1.addInitialRoutes)(appPath, appSource));
|
|
23
|
+
const changes = (0, devkit_1.applyChangesToString)(appFileContent, (0, ast_utils_1.addInitialRoutes)(appPath, appSource, options.inSourceTests));
|
|
24
24
|
host.write(appPath, changes);
|
|
25
25
|
if (!options.skipPackageJson) {
|
|
26
26
|
return (0, devkit_1.addDependenciesToPackageJson)(host, { 'react-router-dom': versions_1.reactRouterDomVersion }, {});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema, Schema } from '../../schema';
|
|
3
|
+
export declare function initRsbuild(tree: Tree, options: NormalizedSchema<Schema>, tasks: any[]): Promise<void>;
|
|
4
|
+
export declare function setupRsbuildConfiguration(tree: Tree, options: NormalizedSchema<Schema>, tasks: any[]): Promise<void>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initRsbuild = initRsbuild;
|
|
4
|
+
exports.setupRsbuildConfiguration = setupRsbuildConfiguration;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const versions_1 = require("../../../../utils/versions");
|
|
7
|
+
const maybe_js_1 = require("../../../../utils/maybe-js");
|
|
8
|
+
async function initRsbuild(tree, options, tasks) {
|
|
9
|
+
(0, devkit_1.ensurePackage)('@nx/rsbuild', versions_1.nxVersion);
|
|
10
|
+
const { initGenerator } = await Promise.resolve().then(() => require('@nx/rsbuild/generators'));
|
|
11
|
+
const initTask = await initGenerator(tree, {
|
|
12
|
+
skipPackageJson: options.skipPackageJson,
|
|
13
|
+
addPlugin: true,
|
|
14
|
+
skipFormat: true,
|
|
15
|
+
});
|
|
16
|
+
tasks.push(initTask);
|
|
17
|
+
}
|
|
18
|
+
async function setupRsbuildConfiguration(tree, options, tasks) {
|
|
19
|
+
(0, devkit_1.ensurePackage)('@nx/rsbuild', versions_1.nxVersion);
|
|
20
|
+
const { configurationGenerator } = await Promise.resolve().then(() => require('@nx/rsbuild/generators'));
|
|
21
|
+
const { addBuildPlugin, addCopyAssets, addHtmlTemplatePath, addExperimentalSwcPlugin, versions, } = await Promise.resolve().then(() => require('@nx/rsbuild/config-utils'));
|
|
22
|
+
const rsbuildTask = await configurationGenerator(tree, {
|
|
23
|
+
project: options.projectName,
|
|
24
|
+
entry: (0, maybe_js_1.maybeJs)({
|
|
25
|
+
js: options.js,
|
|
26
|
+
useJsx: true,
|
|
27
|
+
}, `./src/main.tsx`),
|
|
28
|
+
tsConfig: './tsconfig.app.json',
|
|
29
|
+
target: 'web',
|
|
30
|
+
devServerPort: options.devServerPort ?? 4200,
|
|
31
|
+
});
|
|
32
|
+
tasks.push(rsbuildTask);
|
|
33
|
+
const pathToConfigFile = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'rsbuild.config.ts');
|
|
34
|
+
const deps = { '@rsbuild/plugin-react': versions.rsbuildPluginReactVersion };
|
|
35
|
+
addBuildPlugin(tree, pathToConfigFile, '@rsbuild/plugin-react', 'pluginReact', options.style === '@emotion/styled'
|
|
36
|
+
? `swcReactOptions: {\n\timportSource: '@emotion/react',\n}`
|
|
37
|
+
: undefined);
|
|
38
|
+
if (options.style === 'scss') {
|
|
39
|
+
addBuildPlugin(tree, pathToConfigFile, '@rsbuild/plugin-sass', 'pluginSass');
|
|
40
|
+
deps['@rsbuild/plugin-sass'] = versions.rsbuildPluginSassVersion;
|
|
41
|
+
}
|
|
42
|
+
else if (options.style === 'less') {
|
|
43
|
+
addBuildPlugin(tree, pathToConfigFile, '@rsbuild/plugin-less', 'pluginLess');
|
|
44
|
+
deps['@rsbuild/plugin-less'] = versions.rsbuildPluginLessVersion;
|
|
45
|
+
}
|
|
46
|
+
else if (options.style === '@emotion/styled') {
|
|
47
|
+
deps['@swc/plugin-emotion'] = versions.rsbuildSwcPluginEmotionVersion;
|
|
48
|
+
addExperimentalSwcPlugin(tree, pathToConfigFile, '@swc/plugin-emotion');
|
|
49
|
+
}
|
|
50
|
+
else if (options.style === 'styled-jsx') {
|
|
51
|
+
deps['@swc/plugin-styled-jsx'] = versions.rsbuildSwcPluginStyledJsxVersion;
|
|
52
|
+
addExperimentalSwcPlugin(tree, pathToConfigFile, '@swc/plugin-styled-jsx');
|
|
53
|
+
}
|
|
54
|
+
else if (options.style === 'styled-components') {
|
|
55
|
+
deps['@rsbuild/plugin-styled-components'] =
|
|
56
|
+
versions.rsbuildPluginStyledComponentsVersion;
|
|
57
|
+
addBuildPlugin(tree, pathToConfigFile, '@rsbuild/plugin-styled-components', 'pluginStyledComponents');
|
|
58
|
+
}
|
|
59
|
+
addHtmlTemplatePath(tree, pathToConfigFile, './src/index.html');
|
|
60
|
+
addCopyAssets(tree, pathToConfigFile, './src/assets');
|
|
61
|
+
addCopyAssets(tree, pathToConfigFile, './src/favicon.ico');
|
|
62
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, deps));
|
|
63
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema, Schema } from '../../schema';
|
|
3
|
+
export declare function initRspack(tree: Tree, options: NormalizedSchema<Schema>, tasks: any[]): Promise<void>;
|
|
4
|
+
export declare function handleStyledJsxForRspack(tasks: any[], tree: Tree, options: NormalizedSchema<Schema>): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initRspack = initRspack;
|
|
4
|
+
exports.handleStyledJsxForRspack = handleStyledJsxForRspack;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const pc = require("picocolors");
|
|
7
|
+
const versions_1 = require("../../../../utils/versions");
|
|
8
|
+
async function initRspack(tree, options, tasks) {
|
|
9
|
+
const { rspackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
|
|
10
|
+
const rspackInitTask = await rspackInitGenerator(tree, {
|
|
11
|
+
...options,
|
|
12
|
+
skipFormat: true,
|
|
13
|
+
});
|
|
14
|
+
tasks.push(rspackInitTask);
|
|
15
|
+
}
|
|
16
|
+
function handleStyledJsxForRspack(tasks, tree, options) {
|
|
17
|
+
devkit_1.logger.warn(`${pc.bold('styled-jsx')} is not supported by ${pc.bold('Rspack')}. We've added ${pc.bold('babel-loader')} to your project, but using babel will slow down your build.`);
|
|
18
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, { 'babel-loader': versions_1.babelLoaderVersion }));
|
|
19
|
+
tree.write((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'rspack.config.js'), (0, devkit_1.stripIndents) `
|
|
20
|
+
const { composePlugins, withNx, withReact } = require('@nx/rspack');
|
|
21
|
+
module.exports = composePlugins(withNx(), withReact(), (config) => {
|
|
22
|
+
config.module.rules.push({
|
|
23
|
+
test: /\\.[jt]sx$/i,
|
|
24
|
+
use: [
|
|
25
|
+
{
|
|
26
|
+
loader: 'babel-loader',
|
|
27
|
+
options: {
|
|
28
|
+
presets: ['@babel/preset-typescript'],
|
|
29
|
+
plugins: ['styled-jsx/babel'],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
return config;
|
|
35
|
+
});
|
|
36
|
+
`);
|
|
37
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema, Schema } from '../../schema';
|
|
3
|
+
export declare function setupViteConfiguration(tree: Tree, options: NormalizedSchema<Schema>, tasks: any[]): Promise<void>;
|
|
4
|
+
export declare function setupVitestConfiguration(tree: Tree, options: NormalizedSchema<Schema>, tasks: any[]): Promise<void>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupViteConfiguration = setupViteConfiguration;
|
|
4
|
+
exports.setupVitestConfiguration = setupVitestConfiguration;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const versions_1 = require("../../../../utils/versions");
|
|
7
|
+
async function setupViteConfiguration(tree, options, tasks) {
|
|
8
|
+
const { createOrEditViteConfig, viteConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
9
|
+
// We recommend users use `import.meta.env.MODE` and other variables in their code to differentiate between production and development.
|
|
10
|
+
// See: https://vitejs.dev/guide/env-and-mode.html
|
|
11
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/environments'))) {
|
|
12
|
+
tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/environments'));
|
|
13
|
+
}
|
|
14
|
+
const reactRouterFrameworkConfig = {
|
|
15
|
+
imports: [`import { reactRouter } from '@react-router/dev/vite'`],
|
|
16
|
+
plugins: ['!process.env.VITEST && reactRouter()'],
|
|
17
|
+
};
|
|
18
|
+
const baseReactConfig = {
|
|
19
|
+
imports: [
|
|
20
|
+
options.compiler === 'swc'
|
|
21
|
+
? `import react from '@vitejs/plugin-react-swc'`
|
|
22
|
+
: `import react from '@vitejs/plugin-react'`,
|
|
23
|
+
],
|
|
24
|
+
plugins: ['react()'],
|
|
25
|
+
};
|
|
26
|
+
const viteTask = await viteConfigurationGenerator(tree, {
|
|
27
|
+
uiFramework: 'react',
|
|
28
|
+
project: options.projectName,
|
|
29
|
+
newProject: true,
|
|
30
|
+
includeVitest: options.unitTestRunner === 'vitest',
|
|
31
|
+
inSourceTests: options.inSourceTests,
|
|
32
|
+
compiler: options.compiler,
|
|
33
|
+
skipFormat: true,
|
|
34
|
+
addPlugin: options.addPlugin,
|
|
35
|
+
projectType: 'application',
|
|
36
|
+
});
|
|
37
|
+
tasks.push(viteTask);
|
|
38
|
+
createOrEditViteConfig(tree, {
|
|
39
|
+
project: options.projectName,
|
|
40
|
+
includeLib: false,
|
|
41
|
+
includeVitest: options.unitTestRunner === 'vitest',
|
|
42
|
+
inSourceTests: options.inSourceTests,
|
|
43
|
+
rollupOptionsExternal: ["'react'", "'react-dom'", "'react/jsx-runtime'"],
|
|
44
|
+
...(options.useReactRouter
|
|
45
|
+
? reactRouterFrameworkConfig
|
|
46
|
+
: baseReactConfig),
|
|
47
|
+
}, false);
|
|
48
|
+
}
|
|
49
|
+
async function setupVitestConfiguration(tree, options, tasks) {
|
|
50
|
+
const { createOrEditViteConfig, vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
51
|
+
const vitestTask = await vitestGenerator(tree, {
|
|
52
|
+
uiFramework: 'react',
|
|
53
|
+
coverageProvider: 'v8',
|
|
54
|
+
project: options.projectName,
|
|
55
|
+
inSourceTests: options.inSourceTests,
|
|
56
|
+
skipFormat: true,
|
|
57
|
+
addPlugin: options.addPlugin,
|
|
58
|
+
});
|
|
59
|
+
tasks.push(vitestTask);
|
|
60
|
+
createOrEditViteConfig(tree, {
|
|
61
|
+
project: options.projectName,
|
|
62
|
+
includeLib: false,
|
|
63
|
+
includeVitest: true,
|
|
64
|
+
inSourceTests: options.inSourceTests,
|
|
65
|
+
rollupOptionsExternal: ["'react'", "'react-dom'", "'react/jsx-runtime'"],
|
|
66
|
+
imports: [
|
|
67
|
+
options.compiler === 'swc'
|
|
68
|
+
? `import react from '@vitejs/plugin-react-swc'`
|
|
69
|
+
: `import react from '@vitejs/plugin-react'`,
|
|
70
|
+
],
|
|
71
|
+
plugins: ['react()'],
|
|
72
|
+
}, true);
|
|
73
|
+
if (options.bundler === 'rsbuild') {
|
|
74
|
+
tree.rename((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'vite.config.ts'), (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'vitest.config.ts'));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initWebpack = initWebpack;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("../../../../utils/versions");
|
|
6
|
+
async function initWebpack(tree, options, tasks) {
|
|
7
|
+
const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
|
|
8
|
+
const webpackInitTask = await webpackInitGenerator(tree, {
|
|
9
|
+
skipPackageJson: options.skipPackageJson,
|
|
10
|
+
skipFormat: true,
|
|
11
|
+
addPlugin: options.addPlugin,
|
|
12
|
+
});
|
|
13
|
+
tasks.push(webpackInitTask);
|
|
14
|
+
if (!options.skipPackageJson) {
|
|
15
|
+
const { ensureDependencies } = await Promise.resolve().then(() => require('@nx/webpack/src/utils/ensure-dependencies'));
|
|
16
|
+
tasks.push(ensureDependencies(tree, { uiFramework: 'react' }));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,3 +1,64 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { WithNxOptions } from '@nx/webpack';
|
|
3
|
+
import { WithReactOptions } from '../../../../plugins/with-react';
|
|
2
4
|
import { NormalizedSchema } from '../schema';
|
|
5
|
+
export declare function getDefaultTemplateVariables(host: Tree, options: NormalizedSchema): {
|
|
6
|
+
typesNodeVersion: string;
|
|
7
|
+
typesReactDomVersion: string;
|
|
8
|
+
reactRouterVersion: string;
|
|
9
|
+
typesReactVersion: string;
|
|
10
|
+
reactDomVersion: string;
|
|
11
|
+
reactVersion: string;
|
|
12
|
+
reactRouterIsBotVersion: string;
|
|
13
|
+
js: boolean;
|
|
14
|
+
tmpl: string;
|
|
15
|
+
offsetFromRoot: string;
|
|
16
|
+
appTests: string;
|
|
17
|
+
inSourceVitestTests: string;
|
|
18
|
+
style: "none" | "styled-components" | "@emotion/styled" | "styled-jsx" | "css" | "scss" | "less";
|
|
19
|
+
hasStyleFile: boolean;
|
|
20
|
+
isUsingTsSolutionSetup: boolean;
|
|
21
|
+
projectName: string;
|
|
22
|
+
appProjectRoot: string;
|
|
23
|
+
e2eProjectName: string;
|
|
24
|
+
e2eProjectRoot: string;
|
|
25
|
+
importPath: string;
|
|
26
|
+
parsedTags: string[];
|
|
27
|
+
fileName: string;
|
|
28
|
+
styledModule: null | import("../../../..").SupportedStyles;
|
|
29
|
+
hasStyles: boolean;
|
|
30
|
+
unitTestRunner: "jest" | "vitest" | "none";
|
|
31
|
+
addPlugin?: boolean;
|
|
32
|
+
names: ReturnType<typeof import("@nx/devkit").names>;
|
|
33
|
+
isUsingTsSolutionConfig?: boolean;
|
|
34
|
+
directory: string;
|
|
35
|
+
name: string;
|
|
36
|
+
skipFormat?: boolean;
|
|
37
|
+
tags?: string;
|
|
38
|
+
inSourceTests?: boolean;
|
|
39
|
+
e2eTestRunner: "cypress" | "playwright" | "none";
|
|
40
|
+
linter: import("@nx/eslint").Linter | import("@nx/eslint").LinterType;
|
|
41
|
+
classComponent?: boolean;
|
|
42
|
+
routing?: boolean;
|
|
43
|
+
useReactRouter?: boolean;
|
|
44
|
+
skipNxJson?: boolean;
|
|
45
|
+
globalCss?: boolean;
|
|
46
|
+
strict?: boolean;
|
|
47
|
+
setParserOptionsProject?: boolean;
|
|
48
|
+
compiler?: "babel" | "swc";
|
|
49
|
+
remotes?: string[];
|
|
50
|
+
devServerPort?: number;
|
|
51
|
+
skipPackageJson?: boolean;
|
|
52
|
+
rootProject?: boolean;
|
|
53
|
+
bundler?: "webpack" | "vite" | "rspack" | "rsbuild";
|
|
54
|
+
minimal?: boolean;
|
|
55
|
+
nxCloudToken?: string;
|
|
56
|
+
useTsSolution?: boolean;
|
|
57
|
+
formatter?: "prettier" | "none";
|
|
58
|
+
useProjectJson?: boolean;
|
|
59
|
+
className: string;
|
|
60
|
+
propertyName: string;
|
|
61
|
+
constantName: string;
|
|
62
|
+
};
|
|
63
|
+
export declare function createNxRspackPluginOptions(options: NormalizedSchema, rootOffset: string, tsx?: boolean): WithNxOptions & WithReactOptions;
|
|
3
64
|
export declare function createApplicationFiles(host: Tree, options: NormalizedSchema): Promise<void>;
|