@nx/react 16.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE +22 -0
- package/README.md +63 -0
- package/ast-utils.d.ts +1 -0
- package/ast-utils.js +12 -0
- package/ast-utils.js.map +1 -0
- package/babel.d.ts +16 -0
- package/babel.js +52 -0
- package/babel.js.map +1 -0
- package/executors.json +26 -0
- package/generators.json +223 -0
- package/index.d.ts +21 -0
- package/index.js +47 -0
- package/index.js.map +1 -0
- package/migrations.json +870 -0
- package/module-federation.d.ts +4 -0
- package/module-federation.js +13 -0
- package/module-federation.js.map +1 -0
- package/package.json +49 -0
- package/plugins/bundle-rollup.d.ts +1 -0
- package/plugins/bundle-rollup.js +42 -0
- package/plugins/bundle-rollup.js.map +1 -0
- package/plugins/component-testing/index.d.ts +38 -0
- package/plugins/component-testing/index.js +122 -0
- package/plugins/component-testing/index.js.map +1 -0
- package/plugins/component-testing/webpack-fallback.d.ts +5 -0
- package/plugins/component-testing/webpack-fallback.js +135 -0
- package/plugins/component-testing/webpack-fallback.js.map +1 -0
- package/plugins/jest.d.ts +1 -0
- package/plugins/jest.js +62 -0
- package/plugins/jest.js.map +1 -0
- package/plugins/storybook/index.d.ts +3 -0
- package/plugins/storybook/index.js +77 -0
- package/plugins/storybook/index.js.map +1 -0
- package/plugins/storybook/merge-plugins.d.ts +3 -0
- package/plugins/storybook/merge-plugins.js +18 -0
- package/plugins/storybook/merge-plugins.js.map +1 -0
- package/plugins/webpack.d.ts +3 -0
- package/plugins/webpack.js +15 -0
- package/plugins/webpack.js.map +1 -0
- package/plugins/with-react.d.ts +12 -0
- package/plugins/with-react.js +82 -0
- package/plugins/with-react.js.map +1 -0
- package/src/executors/module-federation-dev-server/compat.d.ts +2 -0
- package/src/executors/module-federation-dev-server/compat.js +6 -0
- package/src/executors/module-federation-dev-server/compat.js.map +1 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +11 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +55 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js.map +1 -0
- package/src/executors/module-federation-dev-server/schema.json +96 -0
- package/src/executors/module-federation-ssr-dev-server/compat.d.ts +2 -0
- package/src/executors/module-federation-ssr-dev-server/compat.js +6 -0
- package/src/executors/module-federation-ssr-dev-server/compat.js.map +1 -0
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +9 -0
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +71 -0
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js.map +1 -0
- package/src/executors/module-federation-ssr-dev-server/schema.json +48 -0
- package/src/generators/application/application.d.ts +5 -0
- package/src/generators/application/application.js +129 -0
- package/src/generators/application/application.js.map +1 -0
- package/src/generators/application/files/base-vite/index.html__tmpl__ +16 -0
- package/src/generators/application/files/base-vite/public/favicon.ico +0 -0
- package/src/generators/application/files/base-vite/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
- package/src/generators/application/files/base-vite/src/assets/.gitkeep +0 -0
- package/src/generators/application/files/base-vite/src/environments/environment.prod.ts__tmpl__ +3 -0
- package/src/generators/application/files/base-vite/src/environments/environment.ts__tmpl__ +6 -0
- package/src/generators/application/files/base-vite/src/main.tsx__tmpl__ +10 -0
- package/src/generators/application/files/base-vite/tsconfig.app.json__tmpl__ +14 -0
- package/src/generators/application/files/base-webpack/.babelrc__tmpl__ +13 -0
- package/src/generators/application/files/base-webpack/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
- package/src/generators/application/files/base-webpack/src/assets/.gitkeep +0 -0
- package/src/generators/application/files/base-webpack/src/environments/environment.prod.ts__tmpl__ +3 -0
- package/src/generators/application/files/base-webpack/src/environments/environment.ts__tmpl__ +6 -0
- package/src/generators/application/files/base-webpack/src/favicon.ico +0 -0
- package/src/generators/application/files/base-webpack/src/index.html +14 -0
- package/src/generators/application/files/base-webpack/src/main.tsx__tmpl__ +10 -0
- package/src/generators/application/files/base-webpack/tsconfig.app.json__tmpl__ +14 -0
- package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +9 -0
- package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +845 -0
- package/src/generators/application/files/style-css-module/src/app/__fileName__.module.__style__ +1 -0
- package/src/generators/application/files/style-css-module/src/app/__fileName__.tsx__tmpl__ +37 -0
- package/src/generators/application/files/style-css-module/src/styles.__style__ +1 -0
- package/src/generators/application/files/style-global-css/src/app/__fileName__.__style__ +1 -0
- package/src/generators/application/files/style-global-css/src/app/__fileName__.tsx__tmpl__ +36 -0
- package/src/generators/application/files/style-global-css/src/styles.__style__ +1 -0
- package/src/generators/application/files/style-none/src/app/__fileName__.tsx__tmpl__ +35 -0
- package/src/generators/application/files/style-styled-jsx/src/app/__fileName__.tsx__tmpl__ +29 -0
- package/src/generators/application/files/style-styled-module/src/app/__fileName__.tsx__tmpl__ +40 -0
- package/src/generators/application/lib/add-cypress.d.ts +3 -0
- package/src/generators/application/lib/add-cypress.js +22 -0
- package/src/generators/application/lib/add-cypress.js.map +1 -0
- package/src/generators/application/lib/add-jest.d.ts +3 -0
- package/src/generators/application/lib/add-jest.js +17 -0
- package/src/generators/application/lib/add-jest.js.map +1 -0
- package/src/generators/application/lib/add-project.d.ts +2 -0
- package/src/generators/application/lib/add-project.js +98 -0
- package/src/generators/application/lib/add-project.js.map +1 -0
- package/src/generators/application/lib/add-routing.d.ts +3 -0
- package/src/generators/application/lib/add-routing.js +32 -0
- package/src/generators/application/lib/add-routing.js.map +1 -0
- package/src/generators/application/lib/create-application-files.d.ts +3 -0
- package/src/generators/application/lib/create-application-files.js +47 -0
- package/src/generators/application/lib/create-application-files.js.map +1 -0
- package/src/generators/application/lib/find-free-port.d.ts +2 -0
- package/src/generators/application/lib/find-free-port.js +18 -0
- package/src/generators/application/lib/find-free-port.js.map +1 -0
- package/src/generators/application/lib/get-app-tests.d.ts +2 -0
- package/src/generators/application/lib/get-app-tests.js +22 -0
- package/src/generators/application/lib/get-app-tests.js.map +1 -0
- package/src/generators/application/lib/install-common-dependencies.d.ts +3 -0
- package/src/generators/application/lib/install-common-dependencies.js +29 -0
- package/src/generators/application/lib/install-common-dependencies.js.map +1 -0
- package/src/generators/application/lib/normalize-options.d.ts +5 -0
- package/src/generators/application/lib/normalize-options.js +60 -0
- package/src/generators/application/lib/normalize-options.js.map +1 -0
- package/src/generators/application/lib/set-defaults.d.ts +3 -0
- package/src/generators/application/lib/set-defaults.js +23 -0
- package/src/generators/application/lib/set-defaults.js.map +1 -0
- package/src/generators/application/lib/update-jest-config.d.ts +3 -0
- package/src/generators/application/lib/update-jest-config.js +30 -0
- package/src/generators/application/lib/update-jest-config.js.map +1 -0
- package/src/generators/application/schema.d.ts +44 -0
- package/src/generators/application/schema.json +196 -0
- package/src/generators/component/component.d.ts +5 -0
- package/src/generators/component/component.js +141 -0
- package/src/generators/component/component.js.map +1 -0
- package/src/generators/component/files/__fileName__.__style__ +0 -0
- package/src/generators/component/files/__fileName__.module.__style__ +7 -0
- package/src/generators/component/files/__fileName__.spec.tsx__tmpl__ +7 -0
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +71 -0
- package/src/generators/component/get-component-tests.d.ts +2 -0
- package/src/generators/component/get-component-tests.js +13 -0
- package/src/generators/component/get-component-tests.js.map +1 -0
- package/src/generators/component/noramlized-schema.d.ts +8 -0
- package/src/generators/component/noramlized-schema.js +3 -0
- package/src/generators/component/noramlized-schema.js.map +1 -0
- package/src/generators/component/schema.d.ts +20 -0
- package/src/generators/component/schema.json +153 -0
- package/src/generators/component-cypress-spec/component-cypress-spec.d.ts +14 -0
- package/src/generators/component-cypress-spec/component-cypress-spec.js +105 -0
- package/src/generators/component-cypress-spec/component-cypress-spec.js.map +1 -0
- package/src/generators/component-cypress-spec/files/__componentName__.__fileExt__ +13 -0
- package/src/generators/component-cypress-spec/schema.json +44 -0
- package/src/generators/component-story/component-story.d.ts +12 -0
- package/src/generators/component-story/component-story.js +81 -0
- package/src/generators/component-story/component-story.js.map +1 -0
- package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +32 -0
- package/src/generators/component-story/schema.json +36 -0
- package/src/generators/component-test/component-test.d.ts +4 -0
- package/src/generators/component-test/component-test.js +78 -0
- package/src/generators/component-test/component-test.js.map +1 -0
- package/src/generators/component-test/files/__fileName__.cy__ext__ +21 -0
- package/src/generators/component-test/schema.d.ts +4 -0
- package/src/generators/component-test/schema.js +3 -0
- package/src/generators/component-test/schema.js.map +1 -0
- package/src/generators/component-test/schema.json +31 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +9 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +34 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js.map +1 -0
- package/src/generators/cypress-component-configuration/files/cypress/support/commands.ts__tpl__ +42 -0
- package/src/generators/cypress-component-configuration/files/cypress.config.ts__tpl__ +8 -0
- package/src/generators/cypress-component-configuration/lib/add-files.d.ts +4 -0
- package/src/generators/cypress-component-configuration/lib/add-files.js +75 -0
- package/src/generators/cypress-component-configuration/lib/add-files.js.map +1 -0
- package/src/generators/cypress-component-configuration/lib/update-configs.d.ts +7 -0
- package/src/generators/cypress-component-configuration/lib/update-configs.js +30 -0
- package/src/generators/cypress-component-configuration/lib/update-configs.js.map +1 -0
- package/src/generators/cypress-component-configuration/schema.d.ts +7 -0
- package/src/generators/cypress-component-configuration/schema.json +54 -0
- package/src/generators/hook/files/__fileName__.spec.tsx__tmpl__ +18 -0
- package/src/generators/hook/files/__fileName__.ts__tmpl__ +15 -0
- package/src/generators/hook/hook.d.ts +5 -0
- package/src/generators/hook/hook.js +117 -0
- package/src/generators/hook/hook.js.map +1 -0
- package/src/generators/hook/schema.d.ts +11 -0
- package/src/generators/hook/schema.json +77 -0
- package/src/generators/host/files/common/src/app/__fileName__.tsx__tmpl__ +33 -0
- package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +6 -0
- package/src/generators/host/files/module-federation/src/main.ts__tmpl__ +1 -0
- package/src/generators/host/files/module-federation/src/remotes.d.ts__tmpl__ +4 -0
- package/src/generators/host/files/module-federation/webpack.config.js__tmpl__ +12 -0
- package/src/generators/host/files/module-federation/webpack.config.prod.js__tmpl__ +32 -0
- package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +13 -0
- package/src/generators/host/files/module-federation-ssr/server.ts__tmpl__ +28 -0
- package/src/generators/host/files/module-federation-ssr/tsconfig.server.json__tmpl__ +15 -0
- package/src/generators/host/files/module-federation-ssr/webpack.server.config.js__tmpl__ +12 -0
- package/src/generators/host/host.d.ts +4 -0
- package/src/generators/host/host.js +67 -0
- package/src/generators/host/host.js.map +1 -0
- package/src/generators/host/lib/add-module-federation-files.d.ts +5 -0
- package/src/generators/host/lib/add-module-federation-files.js +21 -0
- package/src/generators/host/lib/add-module-federation-files.js.map +1 -0
- package/src/generators/host/lib/setup-ssr-for-host.d.ts +6 -0
- package/src/generators/host/lib/setup-ssr-for-host.js +27 -0
- package/src/generators/host/lib/setup-ssr-for-host.js.map +1 -0
- package/src/generators/host/lib/update-module-federation-e2e-project.d.ts +3 -0
- package/src/generators/host/lib/update-module-federation-e2e-project.js +16 -0
- package/src/generators/host/lib/update-module-federation-e2e-project.js.map +1 -0
- package/src/generators/host/schema.d.ts +31 -0
- package/src/generators/host/schema.json +168 -0
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +80 -0
- package/src/generators/init/init.js.map +1 -0
- package/src/generators/init/schema.d.ts +11 -0
- package/src/generators/init/schema.json +49 -0
- package/src/generators/library/files/common/.babelrc__tmpl__ +16 -0
- package/src/generators/library/files/common/README.md +7 -0
- package/src/generators/library/files/common/package.json__tmpl__ +4 -0
- package/src/generators/library/files/common/src/index.ts__tmpl__ +0 -0
- package/src/generators/library/files/common/tsconfig.lib.json__tmpl__ +14 -0
- package/src/generators/library/files/vite/README.md +7 -0
- package/src/generators/library/files/vite/package.json__tmpl__ +12 -0
- package/src/generators/library/files/vite/tsconfig.lib.json__tmpl__ +14 -0
- package/src/generators/library/lib/add-linting.d.ts +3 -0
- package/src/generators/library/lib/add-linting.js +38 -0
- package/src/generators/library/lib/add-linting.js.map +1 -0
- package/src/generators/library/lib/add-rollup-build-target.d.ts +3 -0
- package/src/generators/library/lib/add-rollup-build-target.js +59 -0
- package/src/generators/library/lib/add-rollup-build-target.js.map +1 -0
- package/src/generators/library/lib/create-files.d.ts +3 -0
- package/src/generators/library/lib/create-files.js +26 -0
- package/src/generators/library/lib/create-files.js.map +1 -0
- package/src/generators/library/lib/install-common-dependencies.d.ts +3 -0
- package/src/generators/library/lib/install-common-dependencies.js +30 -0
- package/src/generators/library/lib/install-common-dependencies.js.map +1 -0
- package/src/generators/library/lib/maybe-js.d.ts +2 -0
- package/src/generators/library/lib/maybe-js.js +10 -0
- package/src/generators/library/lib/maybe-js.js.map +1 -0
- package/src/generators/library/lib/normalize-options.d.ts +3 -0
- package/src/generators/library/lib/normalize-options.js +57 -0
- package/src/generators/library/lib/normalize-options.js.map +1 -0
- package/src/generators/library/lib/set-defaults.d.ts +3 -0
- package/src/generators/library/lib/set-defaults.js +16 -0
- package/src/generators/library/lib/set-defaults.js.map +1 -0
- package/src/generators/library/lib/update-app-routes.d.ts +3 -0
- package/src/generators/library/lib/update-app-routes.js +63 -0
- package/src/generators/library/lib/update-app-routes.js.map +1 -0
- package/src/generators/library/library.d.ts +5 -0
- package/src/generators/library/library.js +128 -0
- package/src/generators/library/library.js.map +1 -0
- package/src/generators/library/schema.d.ts +43 -0
- package/src/generators/library/schema.json +192 -0
- package/src/generators/redux/files/__directory__/__fileName__.slice.spec.ts__tmpl__ +53 -0
- package/src/generators/redux/files/__directory__/__fileName__.slice.ts__tmpl__ +129 -0
- package/src/generators/redux/redux.d.ts +5 -0
- package/src/generators/redux/redux.js +117 -0
- package/src/generators/redux/redux.js.map +1 -0
- package/src/generators/redux/schema.d.ts +20 -0
- package/src/generators/redux/schema.json +47 -0
- package/src/generators/remote/files/module-federation/module-federation.config.js__tmpl__ +6 -0
- package/src/generators/remote/files/module-federation/src/main.ts__tmpl__ +1 -0
- package/src/generators/remote/files/module-federation/src/remote-entry.ts__tmpl__ +1 -0
- package/src/generators/remote/files/module-federation/webpack.config.js__tmpl__ +12 -0
- package/src/generators/remote/files/module-federation/webpack.config.prod.js__tmpl__ +1 -0
- package/src/generators/remote/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +6 -0
- package/src/generators/remote/files/module-federation-ssr/server.ts__tmpl__ +45 -0
- package/src/generators/remote/files/module-federation-ssr/webpack.server.config.js__tmpl__ +12 -0
- package/src/generators/remote/lib/setup-ssr-for-remote.d.ts +4 -0
- package/src/generators/remote/lib/setup-ssr-for-remote.js +32 -0
- package/src/generators/remote/lib/setup-ssr-for-remote.js.map +1 -0
- package/src/generators/remote/lib/update-host-with-remote.d.ts +2 -0
- package/src/generators/remote/lib/update-host-with-remote.js +53 -0
- package/src/generators/remote/lib/update-host-with-remote.js.map +1 -0
- package/src/generators/remote/remote.d.ts +6 -0
- package/src/generators/remote/remote.js +56 -0
- package/src/generators/remote/remote.js.map +1 -0
- package/src/generators/remote/schema.d.ts +26 -0
- package/src/generators/remote/schema.json +167 -0
- package/src/generators/setup-ssr/files/server.ts__tmpl__ +28 -0
- package/src/generators/setup-ssr/files/src/main.server.tsx__tmpl__ +47 -0
- package/src/generators/setup-ssr/files/tsconfig.server.json__tmpl__ +15 -0
- package/src/generators/setup-ssr/schema.d.ts +7 -0
- package/src/generators/setup-ssr/schema.json +48 -0
- package/src/generators/setup-ssr/setup-ssr.d.ts +5 -0
- package/src/generators/setup-ssr/setup-ssr.js +162 -0
- package/src/generators/setup-ssr/setup-ssr.js.map +1 -0
- package/src/generators/setup-tailwind/files/postcss.config.js__tmpl__ +15 -0
- package/src/generators/setup-tailwind/files/tailwind.config.js__tmpl__ +17 -0
- package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.d.ts +3 -0
- package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +36 -0
- package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js.map +1 -0
- package/src/generators/setup-tailwind/lib/update-project.d.ts +3 -0
- package/src/generators/setup-tailwind/lib/update-project.js +15 -0
- package/src/generators/setup-tailwind/lib/update-project.js.map +1 -0
- package/src/generators/setup-tailwind/schema.d.ts +6 -0
- package/src/generators/setup-tailwind/schema.js +3 -0
- package/src/generators/setup-tailwind/schema.js.map +1 -0
- package/src/generators/setup-tailwind/schema.json +47 -0
- package/src/generators/setup-tailwind/setup-tailwind.d.ts +5 -0
- package/src/generators/setup-tailwind/setup-tailwind.js +39 -0
- package/src/generators/setup-tailwind/setup-tailwind.js.map +1 -0
- package/src/generators/stories/schema.json +59 -0
- package/src/generators/stories/stories.d.ts +15 -0
- package/src/generators/stories/stories.js +118 -0
- package/src/generators/stories/stories.js.map +1 -0
- package/src/generators/storybook-configuration/configuration.d.ts +5 -0
- package/src/generators/storybook-configuration/configuration.js +64 -0
- package/src/generators/storybook-configuration/configuration.js.map +1 -0
- package/src/generators/storybook-configuration/schema.d.ts +17 -0
- package/src/generators/storybook-configuration/schema.json +103 -0
- package/src/migrations/update-12-0-0/remove-react-redux-types-package.d.ts +3 -0
- package/src/migrations/update-12-0-0/remove-react-redux-types-package.js +13 -0
- package/src/migrations/update-12-0-0/remove-react-redux-types-package.js.map +1 -0
- package/src/migrations/update-12-0-0/update-emotion-setup.d.ts +3 -0
- package/src/migrations/update-12-0-0/update-emotion-setup.js +67 -0
- package/src/migrations/update-12-0-0/update-emotion-setup.js.map +1 -0
- package/src/migrations/update-12-0-0/use-react-jsx-in-tsconfig.d.ts +3 -0
- package/src/migrations/update-12-0-0/use-react-jsx-in-tsconfig.js +27 -0
- package/src/migrations/update-12-0-0/use-react-jsx-in-tsconfig.js.map +1 -0
- package/src/migrations/update-12-8-0/update-12-8-0.d.ts +3 -0
- package/src/migrations/update-12-8-0/update-12-8-0.js +15 -0
- package/src/migrations/update-12-8-0/update-12-8-0.js.map +1 -0
- package/src/migrations/update-13-0-0/migrate-storybook-to-webpack-5.d.ts +3 -0
- package/src/migrations/update-13-0-0/migrate-storybook-to-webpack-5.js +38 -0
- package/src/migrations/update-13-0-0/migrate-storybook-to-webpack-5.js.map +1 -0
- package/src/migrations/update-13-0-0/update-emotion-setup.d.ts +3 -0
- package/src/migrations/update-13-0-0/update-emotion-setup.js +39 -0
- package/src/migrations/update-13-0-0/update-emotion-setup.js.map +1 -0
- package/src/migrations/update-13-0-0/webpack5-changes-utils.d.ts +11 -0
- package/src/migrations/update-13-0-0/webpack5-changes-utils.js +269 -0
- package/src/migrations/update-13-0-0/webpack5-changes-utils.js.map +1 -0
- package/src/migrations/update-13-10-0/update-13-10-0.d.ts +3 -0
- package/src/migrations/update-13-10-0/update-13-10-0.js +29 -0
- package/src/migrations/update-13-10-0/update-13-10-0.js.map +1 -0
- package/src/migrations/update-14-0-0/add-default-development-configurations.d.ts +3 -0
- package/src/migrations/update-14-0-0/add-default-development-configurations.js +40 -0
- package/src/migrations/update-14-0-0/add-default-development-configurations.js.map +1 -0
- package/src/migrations/update-14-0-0/replace-testing-library-react-hook.d.ts +3 -0
- package/src/migrations/update-14-0-0/replace-testing-library-react-hook.js +27 -0
- package/src/migrations/update-14-0-0/replace-testing-library-react-hook.js.map +1 -0
- package/src/migrations/update-14-0-0/update-react-dom-render-for-v18.d.ts +5 -0
- package/src/migrations/update-14-0-0/update-react-dom-render-for-v18.js +69 -0
- package/src/migrations/update-14-0-0/update-react-dom-render-for-v18.js.map +1 -0
- package/src/migrations/update-14-1-0/update-external-emotion-jsx-runtime.d.ts +3 -0
- package/src/migrations/update-14-1-0/update-external-emotion-jsx-runtime.js +38 -0
- package/src/migrations/update-14-1-0/update-external-emotion-jsx-runtime.js.map +1 -0
- package/src/migrations/update-14-6-0/add-preset-jest-config.d.ts +3 -0
- package/src/migrations/update-14-6-0/add-preset-jest-config.js +40 -0
- package/src/migrations/update-14-6-0/add-preset-jest-config.js.map +1 -0
- package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.d.ts +3 -0
- package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js +39 -0
- package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js.map +1 -0
- package/src/migrations/update-15-3-0/update-rollup-executor.d.ts +3 -0
- package/src/migrations/update-15-3-0/update-rollup-executor.js +17 -0
- package/src/migrations/update-15-3-0/update-rollup-executor.js.map +1 -0
- package/src/migrations/update-15-6-3/webpack-config-setup.d.ts +2 -0
- package/src/migrations/update-15-6-3/webpack-config-setup.js +108 -0
- package/src/migrations/update-15-6-3/webpack-config-setup.js.map +1 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
- package/src/module-federation/ast-utils.d.ts +8 -0
- package/src/module-federation/ast-utils.js +103 -0
- package/src/module-federation/ast-utils.js.map +1 -0
- package/src/module-federation/load-config.d.ts +3 -0
- package/src/module-federation/load-config.js +17 -0
- package/src/module-federation/load-config.js.map +1 -0
- package/src/module-federation/models.d.ts +24 -0
- package/src/module-federation/models.js +3 -0
- package/src/module-federation/models.js.map +1 -0
- package/src/module-federation/package-json.d.ts +8 -0
- package/src/module-federation/package-json.js +14 -0
- package/src/module-federation/package-json.js.map +1 -0
- package/src/module-federation/utils.d.ts +10 -0
- package/src/module-federation/utils.js +38 -0
- package/src/module-federation/utils.js.map +1 -0
- package/src/module-federation/with-module-federation-ssr.d.ts +2 -0
- package/src/module-federation/with-module-federation-ssr.js +48 -0
- package/src/module-federation/with-module-federation-ssr.js.map +1 -0
- package/src/module-federation/with-module-federation.d.ts +7 -0
- package/src/module-federation/with-module-federation.js +50 -0
- package/src/module-federation/with-module-federation.js.map +1 -0
- package/src/rules/add-styled-dependencies.d.ts +2 -0
- package/src/rules/add-styled-dependencies.js +16 -0
- package/src/rules/add-styled-dependencies.js.map +1 -0
- package/src/rules/update-module-federation-project.d.ts +6 -0
- package/src/rules/update-module-federation-project.js +34 -0
- package/src/rules/update-module-federation-project.js.map +1 -0
- package/src/utils/assertion.d.ts +1 -0
- package/src/utils/assertion.js +20 -0
- package/src/utils/assertion.js.map +1 -0
- package/src/utils/ast-utils.d.ts +29 -0
- package/src/utils/ast-utils.js +526 -0
- package/src/utils/ast-utils.js.map +1 -0
- package/src/utils/component-props.d.ts +15 -0
- package/src/utils/component-props.js +61 -0
- package/src/utils/component-props.js.map +1 -0
- package/src/utils/create-ts-config.d.ts +9 -0
- package/src/utils/create-ts-config.js +64 -0
- package/src/utils/create-ts-config.js.map +1 -0
- package/src/utils/dependencies.d.ts +7 -0
- package/src/utils/dependencies.js +3 -0
- package/src/utils/dependencies.js.map +1 -0
- package/src/utils/format-file.d.ts +1 -0
- package/src/utils/format-file.js +13 -0
- package/src/utils/format-file.js.map +1 -0
- package/src/utils/get-in-source-vitest-tests-template.d.ts +1 -0
- package/src/utils/get-in-source-vitest-tests-template.js +22 -0
- package/src/utils/get-in-source-vitest-tests-template.js.map +1 -0
- package/src/utils/jest-utils.d.ts +1 -0
- package/src/utils/jest-utils.js +10 -0
- package/src/utils/jest-utils.js.map +1 -0
- package/src/utils/lint.d.ts +37 -0
- package/src/utils/lint.js +68 -0
- package/src/utils/lint.js.map +1 -0
- package/src/utils/styled.d.ts +4 -0
- package/src/utils/styled.js +33 -0
- package/src/utils/styled.js.map +1 -0
- package/src/utils/testing-generators.d.ts +3 -0
- package/src/utils/testing-generators.js +35 -0
- package/src/utils/testing-generators.js.map +1 -0
- package/src/utils/versions.d.ts +43 -0
- package/src/utils/versions.js +51 -0
- package/src/utils/versions.js.map +1 -0
- package/tailwind.d.ts +6 -0
- package/tailwind.js +30 -0
- package/tailwind.js.map +1 -0
- package/typings/cssmodule.d.ts +24 -0
- package/typings/image.d.ts +48 -0
- package/typings/style.d.ts +9 -0
- package/typings/styled-jsx.d.ts +8 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.librarySchematic = exports.libraryGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const js_1 = require("@nx/js");
|
|
7
|
+
const versions_1 = require("../../utils/versions");
|
|
8
|
+
const component_1 = require("../component/component");
|
|
9
|
+
const init_1 = require("../init/init");
|
|
10
|
+
const jest_utils_1 = require("../../utils/jest-utils");
|
|
11
|
+
const normalize_options_1 = require("./lib/normalize-options");
|
|
12
|
+
const add_rollup_build_target_1 = require("./lib/add-rollup-build-target");
|
|
13
|
+
const add_linting_1 = require("./lib/add-linting");
|
|
14
|
+
const update_app_routes_1 = require("./lib/update-app-routes");
|
|
15
|
+
const create_files_1 = require("./lib/create-files");
|
|
16
|
+
const create_ts_config_1 = require("../../utils/create-ts-config");
|
|
17
|
+
const install_common_dependencies_1 = require("./lib/install-common-dependencies");
|
|
18
|
+
const set_defaults_1 = require("./lib/set-defaults");
|
|
19
|
+
function libraryGenerator(host, schema) {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const tasks = [];
|
|
22
|
+
const options = (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
23
|
+
if (options.publishable === true && !schema.importPath) {
|
|
24
|
+
throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
|
|
25
|
+
}
|
|
26
|
+
if (!options.component) {
|
|
27
|
+
options.style = 'none';
|
|
28
|
+
}
|
|
29
|
+
const initTask = yield (0, init_1.default)(host, Object.assign(Object.assign({}, options), { e2eTestRunner: 'none', skipFormat: true, skipBabelConfig: options.bundler === 'vite', skipHelperLibs: options.bundler === 'vite' }));
|
|
30
|
+
tasks.push(initTask);
|
|
31
|
+
(0, devkit_1.addProjectConfiguration)(host, options.name, {
|
|
32
|
+
root: options.projectRoot,
|
|
33
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
|
|
34
|
+
projectType: 'library',
|
|
35
|
+
tags: options.parsedTags,
|
|
36
|
+
targets: {},
|
|
37
|
+
});
|
|
38
|
+
const lintTask = yield (0, add_linting_1.addLinting)(host, options);
|
|
39
|
+
tasks.push(lintTask);
|
|
40
|
+
(0, create_files_1.createFiles)(host, options);
|
|
41
|
+
// Set up build target
|
|
42
|
+
if (options.buildable && options.bundler === 'vite') {
|
|
43
|
+
const { viteConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
44
|
+
const viteTask = yield viteConfigurationGenerator(host, {
|
|
45
|
+
uiFramework: 'react',
|
|
46
|
+
project: options.name,
|
|
47
|
+
newProject: true,
|
|
48
|
+
includeLib: true,
|
|
49
|
+
inSourceTests: options.inSourceTests,
|
|
50
|
+
includeVitest: options.unitTestRunner === 'vitest',
|
|
51
|
+
skipFormat: true,
|
|
52
|
+
});
|
|
53
|
+
tasks.push(viteTask);
|
|
54
|
+
}
|
|
55
|
+
else if (options.buildable && options.bundler === 'rollup') {
|
|
56
|
+
const rollupTask = yield (0, add_rollup_build_target_1.addRollupBuildTarget)(host, options);
|
|
57
|
+
tasks.push(rollupTask);
|
|
58
|
+
}
|
|
59
|
+
// Set up test target
|
|
60
|
+
if (options.unitTestRunner === 'jest') {
|
|
61
|
+
const { jestProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
|
|
62
|
+
const jestTask = yield jestProjectGenerator(host, Object.assign(Object.assign({}, options), { project: options.name, setupFile: 'none', supportTsx: true, skipSerializers: true, compiler: options.compiler, skipFormat: true }));
|
|
63
|
+
tasks.push(jestTask);
|
|
64
|
+
const jestConfigPath = (0, devkit_1.joinPathFragments)(options.projectRoot, options.js ? 'jest.config.js' : 'jest.config.ts');
|
|
65
|
+
if (options.compiler === 'babel' && host.exists(jestConfigPath)) {
|
|
66
|
+
const updatedContent = (0, jest_utils_1.updateJestConfigContent)(host.read(jestConfigPath, 'utf-8'));
|
|
67
|
+
host.write(jestConfigPath, updatedContent);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (options.unitTestRunner === 'vitest' &&
|
|
71
|
+
options.bundler !== 'vite' // tests are already configured if bundler is vite
|
|
72
|
+
) {
|
|
73
|
+
const { vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
74
|
+
const vitestTask = yield vitestGenerator(host, {
|
|
75
|
+
uiFramework: 'react',
|
|
76
|
+
project: options.name,
|
|
77
|
+
coverageProvider: 'c8',
|
|
78
|
+
inSourceTests: options.inSourceTests,
|
|
79
|
+
skipFormat: true,
|
|
80
|
+
});
|
|
81
|
+
tasks.push(vitestTask);
|
|
82
|
+
}
|
|
83
|
+
if (options.component) {
|
|
84
|
+
const componentTask = yield (0, component_1.default)(host, {
|
|
85
|
+
name: options.name,
|
|
86
|
+
project: options.name,
|
|
87
|
+
flat: true,
|
|
88
|
+
style: options.style,
|
|
89
|
+
skipTests: options.unitTestRunner === 'none' ||
|
|
90
|
+
(options.unitTestRunner === 'vitest' && options.inSourceTests == true),
|
|
91
|
+
export: true,
|
|
92
|
+
routing: options.routing,
|
|
93
|
+
js: options.js,
|
|
94
|
+
pascalCaseFiles: options.pascalCaseFiles,
|
|
95
|
+
inSourceTests: options.inSourceTests,
|
|
96
|
+
skipFormat: true,
|
|
97
|
+
});
|
|
98
|
+
tasks.push(componentTask);
|
|
99
|
+
}
|
|
100
|
+
if (options.publishable || options.buildable) {
|
|
101
|
+
(0, devkit_1.updateJson)(host, `${options.projectRoot}/package.json`, (json) => {
|
|
102
|
+
json.name = options.importPath;
|
|
103
|
+
return json;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (!options.skipPackageJson) {
|
|
107
|
+
const installReactTask = yield (0, install_common_dependencies_1.installCommonDependencies)(host, options);
|
|
108
|
+
tasks.push(installReactTask);
|
|
109
|
+
}
|
|
110
|
+
const routeTask = (0, update_app_routes_1.updateAppRoutes)(host, options);
|
|
111
|
+
tasks.push(routeTask);
|
|
112
|
+
(0, set_defaults_1.setDefaults)(host, options);
|
|
113
|
+
(0, create_ts_config_1.extractTsConfigBase)(host);
|
|
114
|
+
if (!options.skipTsConfig) {
|
|
115
|
+
(0, js_1.addTsConfigPath)(host, options.importPath, [
|
|
116
|
+
(0, devkit_1.joinPathFragments)(options.projectRoot, './src', 'index.' + (options.js ? 'js' : 'ts')),
|
|
117
|
+
]);
|
|
118
|
+
}
|
|
119
|
+
if (!options.skipFormat) {
|
|
120
|
+
yield (0, devkit_1.formatFiles)(host);
|
|
121
|
+
}
|
|
122
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
exports.libraryGenerator = libraryGenerator;
|
|
126
|
+
exports.default = libraryGenerator;
|
|
127
|
+
exports.librarySchematic = (0, devkit_1.convertNxGenerator)(libraryGenerator);
|
|
128
|
+
//# sourceMappingURL=library.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/library/library.ts"],"names":[],"mappings":";;;;AAAA,uCAUoB;AAEpB,+BAAyC;AAEzC,mDAAiD;AACjD,sDAAwD;AACxD,uCAAyC;AAEzC,uDAAiE;AACjE,+DAA2D;AAC3D,2EAAqE;AACrE,mDAA+C;AAC/C,+DAA0D;AAC1D,qDAAiD;AACjD,mEAAmE;AACnE,mFAA8E;AAC9E,qDAAiD;AAEjD,SAAsB,gBAAgB,CAAC,IAAU,EAAE,MAAc;;QAC/D,MAAM,KAAK,GAAwB,EAAE,CAAC;QAEtC,MAAM,OAAO,GAAG,IAAA,oCAAgB,EAAC,IAAI,EAAE,MA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
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Linter } from '@nx/linter';
|
|
2
|
+
import { SupportedStyles } from '../../../typings/style';
|
|
3
|
+
|
|
4
|
+
export interface Schema {
|
|
5
|
+
appProject?: string;
|
|
6
|
+
buildable?: boolean;
|
|
7
|
+
bundler?: 'none' | 'rollup' | 'vite';
|
|
8
|
+
compiler?: 'babel' | 'swc';
|
|
9
|
+
component?: boolean;
|
|
10
|
+
directory?: string;
|
|
11
|
+
globalCss?: boolean;
|
|
12
|
+
importPath?: string;
|
|
13
|
+
inSourceTests?: boolean;
|
|
14
|
+
js?: boolean;
|
|
15
|
+
linter: Linter;
|
|
16
|
+
name: string;
|
|
17
|
+
pascalCaseFiles?: boolean;
|
|
18
|
+
publishable?: boolean;
|
|
19
|
+
routing?: boolean;
|
|
20
|
+
setParserOptionsProject?: boolean;
|
|
21
|
+
skipFormat?: boolean;
|
|
22
|
+
skipPackageJson?: boolean;
|
|
23
|
+
skipTsConfig?: boolean;
|
|
24
|
+
strict?: boolean;
|
|
25
|
+
style: SupportedStyles;
|
|
26
|
+
tags?: string;
|
|
27
|
+
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
28
|
+
minimal?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface NormalizedSchema extends Schema {
|
|
32
|
+
js: boolean;
|
|
33
|
+
name: string;
|
|
34
|
+
fileName: string;
|
|
35
|
+
projectRoot: string;
|
|
36
|
+
routePath: string;
|
|
37
|
+
projectDirectory: string;
|
|
38
|
+
parsedTags: string[];
|
|
39
|
+
appMain?: string;
|
|
40
|
+
appSourceRoot?: string;
|
|
41
|
+
libsDir?: string;
|
|
42
|
+
unitTestRunner: 'jest' | 'vitest' | 'none';
|
|
43
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxReactLibrary",
|
|
5
|
+
"title": "Create a React Library",
|
|
6
|
+
"description": "Create a React Library for an Nx workspace.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"examples": [
|
|
9
|
+
{
|
|
10
|
+
"command": "nx g lib mylib --directory=myapp",
|
|
11
|
+
"description": "Generate `libs/myapp/mylib`"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"command": "nx g lib mylib --appProject=myapp",
|
|
15
|
+
"description": "Generate a library with routes and add them to `myapp`"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"properties": {
|
|
19
|
+
"name": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "Library name",
|
|
22
|
+
"$default": {
|
|
23
|
+
"$source": "argv",
|
|
24
|
+
"index": 0
|
|
25
|
+
},
|
|
26
|
+
"x-prompt": "What name would you like to use for the library?",
|
|
27
|
+
"pattern": "^[a-zA-Z].*$",
|
|
28
|
+
"x-priority": "important"
|
|
29
|
+
},
|
|
30
|
+
"directory": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "A directory where the lib is placed.",
|
|
33
|
+
"alias": "dir",
|
|
34
|
+
"x-priority": "important"
|
|
35
|
+
},
|
|
36
|
+
"style": {
|
|
37
|
+
"description": "The file extension to be used for style files.",
|
|
38
|
+
"type": "string",
|
|
39
|
+
"default": "css",
|
|
40
|
+
"alias": "s",
|
|
41
|
+
"x-prompt": {
|
|
42
|
+
"message": "Which stylesheet format would you like to use?",
|
|
43
|
+
"type": "list",
|
|
44
|
+
"items": [
|
|
45
|
+
{ "value": "css", "label": "CSS" },
|
|
46
|
+
{
|
|
47
|
+
"value": "scss",
|
|
48
|
+
"label": "SASS(.scss) [ http://sass-lang.com ]"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"value": "less",
|
|
52
|
+
"label": "LESS [ http://lesscss.org ]"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"value": "styled-components",
|
|
56
|
+
"label": "styled-components [ https://styled-components.com ]"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"value": "@emotion/styled",
|
|
60
|
+
"label": "emotion [ https://emotion.sh ]"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"value": "styled-jsx",
|
|
64
|
+
"label": "styled-jsx [ https://www.npmjs.com/package/styled-jsx ]"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"value": "none",
|
|
68
|
+
"label": "None"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"value": "styl",
|
|
72
|
+
"label": "Stylus(.styl) [ http://stylus-lang.com ] (DEPRECATED)"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"linter": {
|
|
78
|
+
"description": "The tool to use for running lint checks.",
|
|
79
|
+
"type": "string",
|
|
80
|
+
"enum": ["eslint", "none"],
|
|
81
|
+
"default": "eslint"
|
|
82
|
+
},
|
|
83
|
+
"unitTestRunner": {
|
|
84
|
+
"type": "string",
|
|
85
|
+
"enum": ["jest", "vitest", "none"],
|
|
86
|
+
"description": "Test runner to use for unit tests.",
|
|
87
|
+
"x-prompt": "What unit test runner should be used?"
|
|
88
|
+
},
|
|
89
|
+
"inSourceTests": {
|
|
90
|
+
"type": "boolean",
|
|
91
|
+
"default": false,
|
|
92
|
+
"description": "When using Vitest, separate spec files will not be generated and instead will be included within the source files."
|
|
93
|
+
},
|
|
94
|
+
"tags": {
|
|
95
|
+
"type": "string",
|
|
96
|
+
"description": "Add tags to the library (used for linting).",
|
|
97
|
+
"alias": "t"
|
|
98
|
+
},
|
|
99
|
+
"skipFormat": {
|
|
100
|
+
"description": "Skip formatting files.",
|
|
101
|
+
"type": "boolean",
|
|
102
|
+
"default": false,
|
|
103
|
+
"x-priority": "internal"
|
|
104
|
+
},
|
|
105
|
+
"skipTsConfig": {
|
|
106
|
+
"type": "boolean",
|
|
107
|
+
"default": false,
|
|
108
|
+
"description": "Do not update `tsconfig.json` for development experience.",
|
|
109
|
+
"x-priority": "internal"
|
|
110
|
+
},
|
|
111
|
+
"pascalCaseFiles": {
|
|
112
|
+
"type": "boolean",
|
|
113
|
+
"description": "Use pascal case component file name (e.g. `App.tsx`).",
|
|
114
|
+
"alias": "P",
|
|
115
|
+
"default": false
|
|
116
|
+
},
|
|
117
|
+
"routing": {
|
|
118
|
+
"type": "boolean",
|
|
119
|
+
"description": "Generate library with routes."
|
|
120
|
+
},
|
|
121
|
+
"appProject": {
|
|
122
|
+
"type": "string",
|
|
123
|
+
"description": "The application project to add the library route to.",
|
|
124
|
+
"alias": "a"
|
|
125
|
+
},
|
|
126
|
+
"publishable": {
|
|
127
|
+
"type": "boolean",
|
|
128
|
+
"description": "Create a publishable library."
|
|
129
|
+
},
|
|
130
|
+
"buildable": {
|
|
131
|
+
"type": "boolean",
|
|
132
|
+
"default": false,
|
|
133
|
+
"description": "Generate a buildable library that uses rollup to bundle.",
|
|
134
|
+
"x-deprecated": "Use the `bundler` option for greater control (none, vite, rollup)."
|
|
135
|
+
},
|
|
136
|
+
"importPath": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"description": "The library name used to import it, like `@myorg/my-awesome-lib`."
|
|
139
|
+
},
|
|
140
|
+
"component": {
|
|
141
|
+
"type": "boolean",
|
|
142
|
+
"description": "Generate a default component.",
|
|
143
|
+
"default": true
|
|
144
|
+
},
|
|
145
|
+
"js": {
|
|
146
|
+
"type": "boolean",
|
|
147
|
+
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
148
|
+
"default": false
|
|
149
|
+
},
|
|
150
|
+
"globalCss": {
|
|
151
|
+
"type": "boolean",
|
|
152
|
+
"description": "When `true`, the stylesheet is generated using global CSS instead of CSS modules (e.g. file is `*.css` rather than `*.module.css`).",
|
|
153
|
+
"default": false
|
|
154
|
+
},
|
|
155
|
+
"strict": {
|
|
156
|
+
"type": "boolean",
|
|
157
|
+
"description": "Whether to enable tsconfig strict mode or not.",
|
|
158
|
+
"default": true
|
|
159
|
+
},
|
|
160
|
+
"setParserOptionsProject": {
|
|
161
|
+
"type": "boolean",
|
|
162
|
+
"description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
|
|
163
|
+
"default": false
|
|
164
|
+
},
|
|
165
|
+
"bundler": {
|
|
166
|
+
"type": "string",
|
|
167
|
+
"description": "The bundler to use. Choosing 'none' means this library is not buildable.",
|
|
168
|
+
"enum": ["none", "vite", "rollup"],
|
|
169
|
+
"default": "none",
|
|
170
|
+
"x-prompt": "Which bundler would you like to use to build the library? Choose 'none' to skip build setup.",
|
|
171
|
+
"x-priority": "important"
|
|
172
|
+
},
|
|
173
|
+
"compiler": {
|
|
174
|
+
"type": "string",
|
|
175
|
+
"enum": ["babel", "swc"],
|
|
176
|
+
"default": "babel",
|
|
177
|
+
"description": "Which compiler to use. Only applies to `bundler: 'rollup'`."
|
|
178
|
+
},
|
|
179
|
+
"skipPackageJson": {
|
|
180
|
+
"description": "Do not add dependencies to `package.json`.",
|
|
181
|
+
"type": "boolean",
|
|
182
|
+
"default": false,
|
|
183
|
+
"x-priority": "internal"
|
|
184
|
+
},
|
|
185
|
+
"minimal": {
|
|
186
|
+
"description": "Create a React library with a minimal setup, no separate test files.",
|
|
187
|
+
"type": "boolean",
|
|
188
|
+
"default": false
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"required": ["name"]
|
|
192
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { fetch<%= className %>, <%= propertyName %>Adapter, <%= propertyName %>Reducer } from './<%= fileName %>.slice';
|
|
2
|
+
|
|
3
|
+
describe('<%= propertyName %> reducer', () => {
|
|
4
|
+
it('should handle initial state', () => {
|
|
5
|
+
const expected = <%= propertyName %>Adapter.getInitialState({
|
|
6
|
+
loadingStatus: 'not loaded',
|
|
7
|
+
error: null
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
expect(<%= propertyName %>Reducer(undefined, { type: '' })).toEqual(expected);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should handle fetch<%= className %>s', () => {
|
|
14
|
+
let state = <%= propertyName %>Reducer(
|
|
15
|
+
undefined,
|
|
16
|
+
fetch<%= className %>.pending(null, null)
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
expect(state).toEqual(
|
|
20
|
+
expect.objectContaining({
|
|
21
|
+
loadingStatus: 'loading',
|
|
22
|
+
error: null,
|
|
23
|
+
entities: {}
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
state = <%= propertyName %>Reducer(
|
|
28
|
+
state,
|
|
29
|
+
fetch<%= className %>.fulfilled([{ id: 1 }], null, null)
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
expect(state).toEqual(
|
|
33
|
+
expect.objectContaining({
|
|
34
|
+
loadingStatus: 'loaded',
|
|
35
|
+
error: null,
|
|
36
|
+
entities: { 1: { id: 1 } }
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
state = <%= propertyName %>Reducer(
|
|
41
|
+
state,
|
|
42
|
+
fetch<%= className %>.rejected(new Error('Uh oh'), null, null)
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
expect(state).toEqual(
|
|
46
|
+
expect.objectContaining({
|
|
47
|
+
loadingStatus: 'error',
|
|
48
|
+
error: 'Uh oh',
|
|
49
|
+
entities: { 1: { id: 1 } }
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAsyncThunk,
|
|
3
|
+
createEntityAdapter,
|
|
4
|
+
createSelector,
|
|
5
|
+
createSlice,
|
|
6
|
+
EntityState,
|
|
7
|
+
PayloadAction
|
|
8
|
+
} from '@reduxjs/toolkit';
|
|
9
|
+
|
|
10
|
+
export const <%= constantName %>_FEATURE_KEY = '<%= propertyName %>';
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Update these interfaces according to your requirements.
|
|
14
|
+
*/
|
|
15
|
+
export interface <%= className %>Entity {
|
|
16
|
+
id: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface <%= className %>State extends EntityState<<%= className %>Entity> {
|
|
20
|
+
loadingStatus: 'not loaded' | 'loading' | 'loaded' | 'error';
|
|
21
|
+
error: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const <%= propertyName %>Adapter = createEntityAdapter<<%= className %>Entity>();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Export an effect using createAsyncThunk from
|
|
28
|
+
* the Redux Toolkit: https://redux-toolkit.js.org/api/createAsyncThunk
|
|
29
|
+
*
|
|
30
|
+
* e.g.
|
|
31
|
+
* ```
|
|
32
|
+
* import React, { useEffect } from 'react';
|
|
33
|
+
* import { useDispatch } from 'react-redux';
|
|
34
|
+
*
|
|
35
|
+
* // ...
|
|
36
|
+
*
|
|
37
|
+
* const dispatch = useDispatch();
|
|
38
|
+
* useEffect(() => {
|
|
39
|
+
* dispatch(fetch<%= className %>())
|
|
40
|
+
* }, [dispatch]);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export const fetch<%= className %> = createAsyncThunk(
|
|
44
|
+
'<%= propertyName %>/fetchStatus',
|
|
45
|
+
async (_, thunkAPI) => {
|
|
46
|
+
/**
|
|
47
|
+
* Replace this with your custom fetch call.
|
|
48
|
+
* For example, `return myApi.get<%= className %>s()`;
|
|
49
|
+
* Right now we just return an empty array.
|
|
50
|
+
*/
|
|
51
|
+
return Promise.resolve([]);
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
export const initial<%= className %>State: <%= className %>State = <%= propertyName %>Adapter.getInitialState({
|
|
56
|
+
loadingStatus: 'not loaded',
|
|
57
|
+
error: null
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export const <%= propertyName %>Slice = createSlice({
|
|
61
|
+
name: <%= constantName %>_FEATURE_KEY,
|
|
62
|
+
initialState: initial<%= className %>State,
|
|
63
|
+
reducers: {
|
|
64
|
+
add: <%= propertyName %>Adapter.addOne,
|
|
65
|
+
remove: <%= propertyName %>Adapter.removeOne
|
|
66
|
+
// ...
|
|
67
|
+
},
|
|
68
|
+
extraReducers: builder => {
|
|
69
|
+
builder
|
|
70
|
+
.addCase(fetch<%= className %>.pending, (state: <%= className %>State) => {
|
|
71
|
+
state.loadingStatus = 'loading';
|
|
72
|
+
})
|
|
73
|
+
.addCase(fetch<%= className %>.fulfilled, (state: <%= className %>State, action: PayloadAction<<%= className %>Entity[]>) => {
|
|
74
|
+
<%= propertyName %>Adapter.setAll(state, action.payload);
|
|
75
|
+
state.loadingStatus = 'loaded';
|
|
76
|
+
})
|
|
77
|
+
.addCase(fetch<%= className %>.rejected, (state: <%= className %>State, action) => {
|
|
78
|
+
state.loadingStatus = 'error';
|
|
79
|
+
state.error = action.error.message;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
/*
|
|
85
|
+
* Export reducer for store configuration.
|
|
86
|
+
*/
|
|
87
|
+
export const <%= propertyName %>Reducer = <%= propertyName %>Slice.reducer;
|
|
88
|
+
|
|
89
|
+
/*
|
|
90
|
+
* Export action creators to be dispatched. For use with the `useDispatch` hook.
|
|
91
|
+
*
|
|
92
|
+
* e.g.
|
|
93
|
+
* ```
|
|
94
|
+
* import React, { useEffect } from 'react';
|
|
95
|
+
* import { useDispatch } from 'react-redux';
|
|
96
|
+
*
|
|
97
|
+
* // ...
|
|
98
|
+
*
|
|
99
|
+
* const dispatch = useDispatch();
|
|
100
|
+
* useEffect(() => {
|
|
101
|
+
* dispatch(<%= propertyName %>Actions.add({ id: 1 }))
|
|
102
|
+
* }, [dispatch]);
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* See: https://react-redux.js.org/next/api/hooks#usedispatch
|
|
106
|
+
*/
|
|
107
|
+
export const <%= propertyName %>Actions = <%= propertyName %>Slice.actions;
|
|
108
|
+
|
|
109
|
+
/*
|
|
110
|
+
* Export selectors to query state. For use with the `useSelector` hook.
|
|
111
|
+
*
|
|
112
|
+
* e.g.
|
|
113
|
+
* ```
|
|
114
|
+
* import { useSelector } from 'react-redux';
|
|
115
|
+
*
|
|
116
|
+
* // ...
|
|
117
|
+
*
|
|
118
|
+
* const entities = useSelector(selectAll<%= className %>);
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* See: https://react-redux.js.org/next/api/hooks#useselector
|
|
122
|
+
*/
|
|
123
|
+
const { selectAll, selectEntities } = <%= propertyName %>Adapter.getSelectors();
|
|
124
|
+
|
|
125
|
+
export const get<%= className %>State = (rootState: unknown): <%= className %>State => rootState[<%= constantName %>_FEATURE_KEY];
|
|
126
|
+
|
|
127
|
+
export const selectAll<%= className %> = createSelector(get<%= className %>State, selectAll);
|
|
128
|
+
|
|
129
|
+
export const select<%= className %>Entities = createSelector(get<%= className %>State, selectEntities);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Schema } from './schema';
|
|
2
|
+
import { Tree } from '@nx/devkit';
|
|
3
|
+
export declare function reduxGenerator(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
4
|
+
export default reduxGenerator;
|
|
5
|
+
export declare const reduxSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reduxSchematic = exports.reduxGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const ast_utils_1 = require("../../utils/ast-utils");
|
|
7
|
+
const versions_1 = require("../../utils/versions");
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const js_1 = require("@nx/js");
|
|
10
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
11
|
+
let tsModule;
|
|
12
|
+
function reduxGenerator(host, schema) {
|
|
13
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
const options = normalizeOptions(host, schema);
|
|
15
|
+
generateReduxFiles(host, options);
|
|
16
|
+
addExportsToBarrel(host, options);
|
|
17
|
+
const installTask = addReduxPackageDependencies(host);
|
|
18
|
+
addStoreConfiguration(host, options);
|
|
19
|
+
updateReducerConfiguration(host, options);
|
|
20
|
+
yield (0, devkit_1.formatFiles)(host);
|
|
21
|
+
return installTask;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.reduxGenerator = reduxGenerator;
|
|
25
|
+
function generateReduxFiles(host, options) {
|
|
26
|
+
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files'), options.filesPath, Object.assign(Object.assign({}, options), { tmpl: '' }));
|
|
27
|
+
if (options.js) {
|
|
28
|
+
(0, devkit_1.toJS)(host);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function addReduxPackageDependencies(host) {
|
|
32
|
+
return (0, devkit_1.addDependenciesToPackageJson)(host, {
|
|
33
|
+
'@reduxjs/toolkit': versions_1.reduxjsToolkitVersion,
|
|
34
|
+
'react-redux': versions_1.reactReduxVersion,
|
|
35
|
+
}, {});
|
|
36
|
+
}
|
|
37
|
+
function addExportsToBarrel(host, options) {
|
|
38
|
+
if (!tsModule) {
|
|
39
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
40
|
+
}
|
|
41
|
+
const indexFilePath = path.join(options.projectSourcePath, options.js ? 'index.js' : 'index.ts');
|
|
42
|
+
const indexSource = host.read(indexFilePath, 'utf-8');
|
|
43
|
+
if (indexSource !== null) {
|
|
44
|
+
const indexSourceFile = tsModule.createSourceFile(indexFilePath, indexSource, tsModule.ScriptTarget.Latest, true);
|
|
45
|
+
const statePath = options.directory
|
|
46
|
+
? `./lib/${options.directory}/${options.fileName}`
|
|
47
|
+
: `./lib/${options.fileName}`;
|
|
48
|
+
const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, ast_utils_1.addImport)(indexSourceFile, `export * from '${statePath}.slice';`));
|
|
49
|
+
host.write(indexFilePath, changes);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function addStoreConfiguration(host, options) {
|
|
53
|
+
if (!options.appProjectSourcePath) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const mainSource = host.read(options.appMainFilePath, 'utf-8');
|
|
57
|
+
if (!mainSource.includes('redux')) {
|
|
58
|
+
const mainSourceFile = tsModule.createSourceFile(options.appMainFilePath, mainSource, tsModule.ScriptTarget.Latest, true);
|
|
59
|
+
const changes = (0, devkit_1.applyChangesToString)(mainSource, (0, ast_utils_1.addReduxStoreToMain)(options.appMainFilePath, mainSourceFile));
|
|
60
|
+
host.write(options.appMainFilePath, changes);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function updateReducerConfiguration(host, options) {
|
|
64
|
+
if (!tsModule) {
|
|
65
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
66
|
+
}
|
|
67
|
+
if (!options.appProjectSourcePath) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const mainSource = host.read(options.appMainFilePath, 'utf-8');
|
|
71
|
+
const mainSourceFile = tsModule.createSourceFile(options.appMainFilePath, mainSource, tsModule.ScriptTarget.Latest, true);
|
|
72
|
+
const changes = (0, devkit_1.applyChangesToString)(mainSource, (0, ast_utils_1.updateReduxStore)(options.appMainFilePath, mainSourceFile, {
|
|
73
|
+
keyName: `${options.constantName}_FEATURE_KEY`,
|
|
74
|
+
reducerName: `${options.propertyName}Reducer`,
|
|
75
|
+
modulePath: `${options.projectModulePath}`,
|
|
76
|
+
}));
|
|
77
|
+
host.write(options.appMainFilePath, changes);
|
|
78
|
+
}
|
|
79
|
+
function normalizeOptions(host, options) {
|
|
80
|
+
var _a;
|
|
81
|
+
let appProjectSourcePath;
|
|
82
|
+
let appMainFilePath;
|
|
83
|
+
const extraNames = (0, devkit_1.names)(options.name);
|
|
84
|
+
const projects = (0, devkit_1.getProjects)(host);
|
|
85
|
+
const project = projects.get(options.project);
|
|
86
|
+
const { sourceRoot, projectType } = project;
|
|
87
|
+
const tsConfigJson = (0, devkit_1.readJson)(host, (0, js_1.getRootTsConfigPathInTree)(host));
|
|
88
|
+
const tsPaths = tsConfigJson.compilerOptions
|
|
89
|
+
? tsConfigJson.compilerOptions.paths || {}
|
|
90
|
+
: {};
|
|
91
|
+
const modulePath = projectType === 'application'
|
|
92
|
+
? options.directory
|
|
93
|
+
? `./app/${options.directory}/${extraNames.fileName}.slice`
|
|
94
|
+
: `./app/${extraNames.fileName}.slice`
|
|
95
|
+
: Object.keys(tsPaths).find((k) => tsPaths[k].some((s) => s.includes(sourceRoot)));
|
|
96
|
+
// If --project is set to an app, automatically configure store
|
|
97
|
+
// for it without needing to specify --appProject.
|
|
98
|
+
options.appProject =
|
|
99
|
+
options.appProject ||
|
|
100
|
+
(projectType === 'application' ? options.project : undefined);
|
|
101
|
+
if (options.appProject) {
|
|
102
|
+
const appConfig = projects.get(options.appProject);
|
|
103
|
+
if (appConfig.projectType !== 'application') {
|
|
104
|
+
throw new Error(`Expected ${options.appProject} to be an application but got ${appConfig.projectType}`);
|
|
105
|
+
}
|
|
106
|
+
appProjectSourcePath = appConfig.sourceRoot;
|
|
107
|
+
appMainFilePath = path.join(appProjectSourcePath, options.js ? 'main.js' : 'main.tsx');
|
|
108
|
+
if (!host.exists(appMainFilePath)) {
|
|
109
|
+
throw new Error(`Could not find ${appMainFilePath} during store configuration`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return Object.assign(Object.assign(Object.assign({}, options), extraNames), { constantName: (0, devkit_1.names)(options.name).constantName.toUpperCase(), directory: (0, devkit_1.names)((_a = options.directory) !== null && _a !== void 0 ? _a : '').fileName, projectType, projectSourcePath: sourceRoot, projectModulePath: modulePath, appProjectSourcePath,
|
|
113
|
+
appMainFilePath, filesPath: (0, devkit_1.joinPathFragments)(sourceRoot, projectType === 'application' ? 'app' : 'lib') });
|
|
114
|
+
}
|
|
115
|
+
exports.default = reduxGenerator;
|
|
116
|
+
exports.reduxSchematic = (0, devkit_1.convertNxGenerator)(reduxGenerator);
|
|
117
|
+
//# sourceMappingURL=redux.js.map
|