@nx/react 0.0.0-pr-22179-271588f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +68 -0
- package/ast-utils.d.ts +1 -0
- package/ast-utils.js +11 -0
- package/babel.d.ts +20 -0
- package/babel.js +50 -0
- package/executors.json +14 -0
- package/generators.json +112 -0
- package/index.d.ts +22 -0
- package/index.js +47 -0
- package/mf/dynamic-federation.d.ts +4 -0
- package/mf/dynamic-federation.js +75 -0
- package/mf/index.d.ts +1 -0
- package/mf/index.js +7 -0
- package/migrations.json +310 -0
- package/module-federation.d.ts +4 -0
- package/module-federation.js +12 -0
- package/package.json +49 -0
- package/plugins/bundle-rollup.d.ts +1 -0
- package/plugins/bundle-rollup.js +47 -0
- package/plugins/component-testing/index.d.ts +37 -0
- package/plugins/component-testing/index.js +222 -0
- package/plugins/component-testing/webpack-fallback.d.ts +5 -0
- package/plugins/component-testing/webpack-fallback.js +125 -0
- package/plugins/jest.d.ts +1 -0
- package/plugins/jest.js +59 -0
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.d.ts +4 -0
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +60 -0
- package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.d.ts +8 -0
- package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.js +13 -0
- package/plugins/storybook/index.d.ts +3 -0
- package/plugins/storybook/index.js +174 -0
- package/plugins/storybook/merge-plugins.d.ts +3 -0
- package/plugins/storybook/merge-plugins.js +17 -0
- package/plugins/webpack.d.ts +1 -0
- package/plugins/webpack.js +6 -0
- package/plugins/with-react.d.ts +10 -0
- package/plugins/with-react.js +22 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +25 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +211 -0
- package/src/executors/module-federation-dev-server/schema.json +114 -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 +106 -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 +232 -0
- package/src/generators/application/files/base-rspack/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
- package/src/generators/application/files/base-rspack/src/assets/.gitkeep +0 -0
- package/src/generators/application/files/base-rspack/src/favicon.ico +0 -0
- package/src/generators/application/files/base-rspack/src/index.html +14 -0
- package/src/generators/application/files/base-rspack/src/main.tsx__tmpl__ +10 -0
- package/src/generators/application/files/base-rspack/tsconfig.app.json__tmpl__ +14 -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/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/favicon.ico +0 -0
- package/src/generators/application/files/base-webpack/src/index.html +12 -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__ +50 -0
- package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +886 -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__ +36 -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__ +35 -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__ +34 -0
- package/src/generators/application/files/style-styled-jsx/src/app/__fileName__.tsx__tmpl__ +37 -0
- package/src/generators/application/files/style-styled-module/src/app/__fileName__.tsx__tmpl__ +40 -0
- package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +33 -0
- package/src/generators/application/files/style-tailwind/src/styles.css +1 -0
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +79 -0
- package/src/generators/application/lib/add-jest.d.ts +3 -0
- package/src/generators/application/lib/add-jest.js +21 -0
- package/src/generators/application/lib/add-project.d.ts +3 -0
- package/src/generators/application/lib/add-project.js +96 -0
- package/src/generators/application/lib/add-routing.d.ts +3 -0
- package/src/generators/application/lib/add-routing.js +27 -0
- package/src/generators/application/lib/create-application-files.d.ts +3 -0
- package/src/generators/application/lib/create-application-files.js +143 -0
- package/src/generators/application/lib/find-free-port.d.ts +2 -0
- package/src/generators/application/lib/find-free-port.js +16 -0
- package/src/generators/application/lib/get-app-tests.d.ts +2 -0
- package/src/generators/application/lib/get-app-tests.js +21 -0
- package/src/generators/application/lib/install-common-dependencies.d.ts +3 -0
- package/src/generators/application/lib/install-common-dependencies.js +47 -0
- package/src/generators/application/lib/normalize-options.d.ts +5 -0
- package/src/generators/application/lib/normalize-options.js +72 -0
- package/src/generators/application/lib/set-defaults.d.ts +3 -0
- package/src/generators/application/lib/set-defaults.js +43 -0
- package/src/generators/application/lib/show-possible-warnings.d.ts +3 -0
- package/src/generators/application/lib/show-possible-warnings.js +11 -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/schema.d.ts +45 -0
- package/src/generators/application/schema.json +201 -0
- package/src/generators/component/component.d.ts +5 -0
- package/src/generators/component/component.js +93 -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__ +88 -0
- package/src/generators/component/lib/get-component-tests.d.ts +2 -0
- package/src/generators/component/lib/get-component-tests.js +12 -0
- package/src/generators/component/lib/normalize-options.d.ts +3 -0
- package/src/generators/component/lib/normalize-options.js +50 -0
- package/src/generators/component/schema.d.ts +48 -0
- package/src/generators/component/schema.json +150 -0
- package/src/generators/component-cypress-spec/component-cypress-spec.d.ts +13 -0
- package/src/generators/component-cypress-spec/component-cypress-spec.js +100 -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 +72 -0
- package/src/generators/component-story/files/jsx/__componentFileName__.stories.jsx__tmpl__ +29 -0
- package/src/generators/component-story/files/tsx/__componentFileName__.stories.tsx__tmpl__ +36 -0
- package/src/generators/component-story/schema.json +42 -0
- package/src/generators/component-test/component-test.d.ts +4 -0
- package/src/generators/component-test/component-test.js +76 -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 +2 -0
- package/src/generators/component-test/schema.json +31 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +10 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +51 -0
- package/src/generators/cypress-component-configuration/lib/add-files.d.ts +4 -0
- package/src/generators/cypress-component-configuration/lib/add-files.js +45 -0
- package/src/generators/cypress-component-configuration/schema.d.ts +8 -0
- package/src/generators/cypress-component-configuration/schema.json +54 -0
- package/src/generators/federate-module/federate-module.d.ts +4 -0
- package/src/generators/federate-module/federate-module.js +70 -0
- package/src/generators/federate-module/lib/utils.d.ts +23 -0
- package/src/generators/federate-module/lib/utils.js +100 -0
- package/src/generators/federate-module/schema.d.ts +13 -0
- package/src/generators/federate-module/schema.json +83 -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 +131 -0
- package/src/generators/hook/schema.d.ts +24 -0
- package/src/generators/hook/schema.json +84 -0
- package/src/generators/host/files/common/src/app/__fileName__.js__tmpl__ +33 -0
- package/src/generators/host/files/common/src/main.js__tmpl__ +10 -0
- package/src/generators/host/files/common/tsconfig.lint.json__tmpl__ +19 -0
- package/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +41 -0
- package/src/generators/host/files/common-ts/src/main.ts__tmpl__ +10 -0
- package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +21 -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__ +16 -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__ +17 -0
- package/src/generators/host/files/module-federation-ssr/webpack.server.config.js__tmpl__ +12 -0
- package/src/generators/host/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +13 -0
- package/src/generators/host/files/module-federation-ssr-ts/server.ts__tmpl__ +28 -0
- package/src/generators/host/files/module-federation-ssr-ts/tsconfig.server.json__tmpl__ +17 -0
- package/src/generators/host/files/module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +12 -0
- package/src/generators/host/files/module-federation-ts/module-federation.config.ts__tmpl__ +25 -0
- package/src/generators/host/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +33 -0
- package/src/generators/host/files/module-federation-ts/webpack.config.ts__tmpl__ +12 -0
- package/src/generators/host/host.d.ts +5 -0
- package/src/generators/host/host.js +95 -0
- package/src/generators/host/lib/add-module-federation-files.d.ts +6 -0
- package/src/generators/host/lib/add-module-federation-files.js +52 -0
- package/src/generators/host/lib/normalize-remote.d.ts +4 -0
- package/src/generators/host/lib/normalize-remote.js +28 -0
- package/src/generators/host/lib/setup-ssr-for-host.d.ts +6 -0
- package/src/generators/host/lib/setup-ssr-for-host.js +33 -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 +20 -0
- package/src/generators/host/schema.d.ts +37 -0
- package/src/generators/host/schema.json +184 -0
- package/src/generators/init/init.d.ts +4 -0
- package/src/generators/init/init.js +23 -0
- package/src/generators/init/schema.d.ts +5 -0
- package/src/generators/init/schema.json +27 -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 +36 -0
- package/src/generators/library/lib/add-rollup-build-target.d.ts +4 -0
- package/src/generators/library/lib/add-rollup-build-target.js +59 -0
- package/src/generators/library/lib/create-files.d.ts +3 -0
- package/src/generators/library/lib/create-files.js +53 -0
- package/src/generators/library/lib/install-common-dependencies.d.ts +3 -0
- package/src/generators/library/lib/install-common-dependencies.js +47 -0
- package/src/generators/library/lib/normalize-options.d.ts +3 -0
- package/src/generators/library/lib/normalize-options.js +92 -0
- package/src/generators/library/lib/set-defaults.d.ts +3 -0
- package/src/generators/library/lib/set-defaults.js +23 -0
- package/src/generators/library/lib/update-app-routes.d.ts +3 -0
- package/src/generators/library/lib/update-app-routes.js +62 -0
- package/src/generators/library/library.d.ts +5 -0
- package/src/generators/library/library.js +193 -0
- package/src/generators/library/schema.d.ts +45 -0
- package/src/generators/library/schema.json +198 -0
- package/src/generators/redux/files/__fileName__.slice.spec.ts__tmpl__ +56 -0
- package/src/generators/redux/files/__fileName__.slice.ts__tmpl__ +129 -0
- package/src/generators/redux/redux.d.ts +5 -0
- package/src/generators/redux/redux.js +143 -0
- package/src/generators/redux/schema.d.ts +23 -0
- package/src/generators/redux/schema.json +51 -0
- package/src/generators/remote/files/common/src/main.js__tmpl__ +1 -0
- package/src/generators/remote/files/common/src/remote-entry.js__tmpl__ +1 -0
- package/src/generators/remote/files/common-ts/src/main.ts__tmpl__ +1 -0
- package/src/generators/remote/files/common-ts/src/remote-entry.ts__tmpl__ +1 -0
- package/src/generators/remote/files/module-federation/module-federation.config.js__tmpl__ +9 -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/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +10 -0
- package/src/generators/remote/files/module-federation-ssr-ts/server.ts__tmpl__ +45 -0
- package/src/generators/remote/files/module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +19 -0
- package/src/generators/remote/files/module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +12 -0
- package/src/generators/remote/files/module-federation-ts/module-federation.config.ts__tmpl__ +13 -0
- package/src/generators/remote/files/module-federation-ts/tsconfig.lint.json__tmpl__ +19 -0
- package/src/generators/remote/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +1 -0
- package/src/generators/remote/files/module-federation-ts/webpack.config.ts__tmpl__ +12 -0
- package/src/generators/remote/lib/add-remote-to-dynamic-host.d.ts +2 -0
- package/src/generators/remote/lib/add-remote-to-dynamic-host.js +11 -0
- package/src/generators/remote/lib/setup-ssr-for-remote.d.ts +4 -0
- package/src/generators/remote/lib/setup-ssr-for-remote.js +40 -0
- package/src/generators/remote/lib/setup-tspath-for-remote.d.ts +3 -0
- package/src/generators/remote/lib/setup-tspath-for-remote.js +15 -0
- package/src/generators/remote/lib/update-host-with-remote.d.ts +2 -0
- package/src/generators/remote/lib/update-host-with-remote.js +64 -0
- package/src/generators/remote/remote.d.ts +7 -0
- package/src/generators/remote/remote.js +104 -0
- package/src/generators/remote/schema.d.ts +34 -0
- package/src/generators/remote/schema.json +183 -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__ +17 -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 +4 -0
- package/src/generators/setup-ssr/setup-ssr.js +183 -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/update-project.d.ts +3 -0
- package/src/generators/setup-tailwind/lib/update-project.js +13 -0
- package/src/generators/setup-tailwind/schema.d.ts +6 -0
- package/src/generators/setup-tailwind/schema.js +2 -0
- package/src/generators/setup-tailwind/schema.json +47 -0
- package/src/generators/setup-tailwind/setup-tailwind.d.ts +4 -0
- package/src/generators/setup-tailwind/setup-tailwind.js +35 -0
- package/src/generators/stories/schema.json +67 -0
- package/src/generators/stories/stories.d.ts +15 -0
- package/src/generators/stories/stories.js +130 -0
- package/src/generators/storybook-configuration/configuration.d.ts +6 -0
- package/src/generators/storybook-configuration/configuration.js +74 -0
- package/src/generators/storybook-configuration/schema.d.ts +16 -0
- package/src/generators/storybook-configuration/schema.json +95 -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 +37 -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 +15 -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 +103 -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 +9 -0
- package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.d.ts +2 -0
- package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.js +8 -0
- package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.d.ts +2 -0
- package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.js +8 -0
- package/src/migrations/update-16-7-0/add-babel-core.d.ts +2 -0
- package/src/migrations/update-16-7-0/add-babel-core.js +14 -0
- package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.d.ts +2 -0
- package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.js +57 -0
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.d.ts +2 -0
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +26 -0
- package/src/module-federation/ast-utils.d.ts +8 -0
- package/src/module-federation/ast-utils.js +102 -0
- package/src/module-federation/load-config.d.ts +3 -0
- package/src/module-federation/load-config.js +16 -0
- package/src/module-federation/models.d.ts +24 -0
- package/src/module-federation/models.js +2 -0
- package/src/module-federation/package-json.d.ts +8 -0
- package/src/module-federation/package-json.js +13 -0
- package/src/module-federation/utils.d.ts +12 -0
- package/src/module-federation/utils.js +76 -0
- package/src/module-federation/with-module-federation-ssr.d.ts +2 -0
- package/src/module-federation/with-module-federation-ssr.js +34 -0
- package/src/module-federation/with-module-federation.d.ts +7 -0
- package/src/module-federation/with-module-federation.js +50 -0
- package/src/rules/add-styled-dependencies.d.ts +5 -0
- package/src/rules/add-styled-dependencies.js +17 -0
- package/src/rules/update-module-federation-project.d.ts +9 -0
- package/src/rules/update-module-federation-project.js +50 -0
- package/src/utils/add-mf-env-to-inputs.d.ts +2 -0
- package/src/utils/add-mf-env-to-inputs.js +24 -0
- package/src/utils/assertion.d.ts +1 -0
- package/src/utils/assertion.js +19 -0
- package/src/utils/ast-utils.d.ts +29 -0
- package/src/utils/ast-utils.js +522 -0
- package/src/utils/component-props.d.ts +15 -0
- package/src/utils/component-props.js +60 -0
- package/src/utils/create-ts-config.d.ts +9 -0
- package/src/utils/create-ts-config.js +65 -0
- package/src/utils/ct-utils.d.ts +14 -0
- package/src/utils/ct-utils.js +94 -0
- package/src/utils/dependencies.d.ts +7 -0
- package/src/utils/dependencies.js +2 -0
- package/src/utils/format-file.d.ts +1 -0
- package/src/utils/format-file.js +12 -0
- package/src/utils/get-in-source-vitest-tests-template.d.ts +1 -0
- package/src/utils/get-in-source-vitest-tests-template.js +21 -0
- package/src/utils/has-vite-plugin.d.ts +2 -0
- package/src/utils/has-vite-plugin.js +11 -0
- package/src/utils/has-webpack-plugin.d.ts +2 -0
- package/src/utils/has-webpack-plugin.js +11 -0
- package/src/utils/jest-utils.d.ts +1 -0
- package/src/utils/jest-utils.js +9 -0
- package/src/utils/lint.d.ts +36 -0
- package/src/utils/lint.js +24 -0
- package/src/utils/maybe-js.d.ts +3 -0
- package/src/utils/maybe-js.js +9 -0
- package/src/utils/styled.d.ts +3 -0
- package/src/utils/styled.js +62 -0
- package/src/utils/testing-generators.d.ts +3 -0
- package/src/utils/testing-generators.js +30 -0
- package/src/utils/versions.d.ts +46 -0
- package/src/utils/versions.js +54 -0
- package/tailwind.d.ts +6 -0
- package/tailwind.js +29 -0
- package/typings/cssmodule.d.ts +19 -0
- package/typings/image.d.ts +48 -0
- package/typings/style.d.ts +9 -0
- package/typings/styled-jsx.d.ts +8 -0
package/migrations.json
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generators": {
|
|
3
|
+
"update-rollup-executor": {
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"version": "15.3.0-beta.0",
|
|
6
|
+
"description": "Update projects using @nrwl/web:rollup to @nrwl/rollup:rollup for build.",
|
|
7
|
+
"factory": "./src/migrations/update-15-3-0/update-rollup-executor"
|
|
8
|
+
},
|
|
9
|
+
"install-webpack-rollup-dependencies": {
|
|
10
|
+
"cli": "nx",
|
|
11
|
+
"version": "15.3.0-beta.0",
|
|
12
|
+
"description": "Install new dependencies for React projects using Webpack or Rollup.",
|
|
13
|
+
"factory": "./src/migrations/update-15-3-0/install-webpack-rollup-dependencies"
|
|
14
|
+
},
|
|
15
|
+
"react-webpack-config-setup": {
|
|
16
|
+
"cli": "nx",
|
|
17
|
+
"version": "15.6.3-beta.0",
|
|
18
|
+
"description": "Creates or updates webpack.config.js file with the new options for webpack.",
|
|
19
|
+
"factory": "./src/migrations/update-15-6-3/webpack-config-setup"
|
|
20
|
+
},
|
|
21
|
+
"update-16-0-0-add-nx-packages": {
|
|
22
|
+
"cli": "nx",
|
|
23
|
+
"version": "16.0.0-beta.1",
|
|
24
|
+
"description": "Replace @nrwl/react with @nx/react",
|
|
25
|
+
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
26
|
+
},
|
|
27
|
+
"update-16-2-0-remove-package": {
|
|
28
|
+
"cli": "nx",
|
|
29
|
+
"version": "16.2.0-beta.0",
|
|
30
|
+
"description": "Remove react-test-renderer from package.json",
|
|
31
|
+
"implementation": "./src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package"
|
|
32
|
+
},
|
|
33
|
+
"remove-types-react-router-dom": {
|
|
34
|
+
"cli": "nx",
|
|
35
|
+
"version": "16.3.0-beta.2",
|
|
36
|
+
"description": "Remove @types/react-router-dom from package.json",
|
|
37
|
+
"implementation": "./src/migrations/update-16-3-0/remove-types-react-router-dom-package"
|
|
38
|
+
},
|
|
39
|
+
"add-babel-core": {
|
|
40
|
+
"cli": "nx",
|
|
41
|
+
"version": "16.7.0-beta.2",
|
|
42
|
+
"description": "Add @babel/core to package.json if @babel/preset-react is present",
|
|
43
|
+
"implementation": "./src/migrations/update-16-7-0/add-babel-core"
|
|
44
|
+
},
|
|
45
|
+
"update-16-7-0-add-typings": {
|
|
46
|
+
"cli": "nx",
|
|
47
|
+
"version": "16.7.0-beta.2",
|
|
48
|
+
"description": "Add @nx/react types to tsconfig types array",
|
|
49
|
+
"implementation": "./src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings"
|
|
50
|
+
},
|
|
51
|
+
"add-module-federation-env-var-to-target-defaults": {
|
|
52
|
+
"cli": "nx",
|
|
53
|
+
"version": "18.0.0-beta.0",
|
|
54
|
+
"description": "Add NX_MF_DEV_SERVER_STATIC_REMOTES to inputs for task hashing when '@nx/webpack:webpack' is used for Module Federation.",
|
|
55
|
+
"factory": "./src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"packageJsonUpdates": {
|
|
59
|
+
"15.2.2-beta.0": {
|
|
60
|
+
"version": "15.2.2-beta.0",
|
|
61
|
+
"packages": {
|
|
62
|
+
"@types/react": {
|
|
63
|
+
"version": "18.0.25",
|
|
64
|
+
"alwaysAddToPackageJson": false
|
|
65
|
+
},
|
|
66
|
+
"@types/react-dom": {
|
|
67
|
+
"version": "18.0.9",
|
|
68
|
+
"alwaysAddToPackageJson": false
|
|
69
|
+
},
|
|
70
|
+
"@types/node": {
|
|
71
|
+
"version": "18.11.9",
|
|
72
|
+
"alwaysAddToPackageJson": false
|
|
73
|
+
},
|
|
74
|
+
"styled-components": {
|
|
75
|
+
"version": "5.3.6",
|
|
76
|
+
"alwaysAddToPackageJson": false
|
|
77
|
+
},
|
|
78
|
+
"@emotion/styled": {
|
|
79
|
+
"version": "11.10.5",
|
|
80
|
+
"alwaysAddToPackageJson": false
|
|
81
|
+
},
|
|
82
|
+
"@emotion/react": {
|
|
83
|
+
"version": "11.10.5",
|
|
84
|
+
"alwaysAddToPackageJson": false
|
|
85
|
+
},
|
|
86
|
+
"@emotion/babel-plugin": {
|
|
87
|
+
"version": "11.10.5",
|
|
88
|
+
"alwaysAddToPackageJson": false
|
|
89
|
+
},
|
|
90
|
+
"styled-jsx": {
|
|
91
|
+
"version": "5.1.0",
|
|
92
|
+
"alwaysAddToPackageJson": false
|
|
93
|
+
},
|
|
94
|
+
"react-router-dom": {
|
|
95
|
+
"version": "6.4.3",
|
|
96
|
+
"alwaysAddToPackageJson": false
|
|
97
|
+
},
|
|
98
|
+
"@reduxjs/toolkit": {
|
|
99
|
+
"version": "1.9.0",
|
|
100
|
+
"alwaysAddToPackageJson": false
|
|
101
|
+
},
|
|
102
|
+
"react-redux": {
|
|
103
|
+
"version": "8.0.5",
|
|
104
|
+
"alwaysAddToPackageJson": false
|
|
105
|
+
},
|
|
106
|
+
"eslint-plugin-react": {
|
|
107
|
+
"version": "7.31.11",
|
|
108
|
+
"alwaysAddToPackageJson": false
|
|
109
|
+
},
|
|
110
|
+
"postcss": {
|
|
111
|
+
"version": "8.4.19",
|
|
112
|
+
"alwaysAddToPackageJson": false
|
|
113
|
+
},
|
|
114
|
+
"tailwindcss": {
|
|
115
|
+
"version": "3.2.4",
|
|
116
|
+
"alwaysAddToPackageJson": false
|
|
117
|
+
},
|
|
118
|
+
"autoprefixer": {
|
|
119
|
+
"version": "10.4.13",
|
|
120
|
+
"alwaysAddToPackageJson": false
|
|
121
|
+
},
|
|
122
|
+
"@types/express": {
|
|
123
|
+
"version": "4.17.14",
|
|
124
|
+
"alwaysAddToPackageJson": false
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"15.8.0": {
|
|
129
|
+
"version": "15.8.0-beta.0",
|
|
130
|
+
"packages": {
|
|
131
|
+
"@types/react": {
|
|
132
|
+
"version": "18.0.28",
|
|
133
|
+
"alwaysAddToPackageJson": false
|
|
134
|
+
},
|
|
135
|
+
"@types/react-dom": {
|
|
136
|
+
"version": "18.0.11",
|
|
137
|
+
"alwaysAddToPackageJson": false
|
|
138
|
+
},
|
|
139
|
+
"@types/node": {
|
|
140
|
+
"version": "18.14.2",
|
|
141
|
+
"alwaysAddToPackageJson": false
|
|
142
|
+
},
|
|
143
|
+
"@emotion/styled": {
|
|
144
|
+
"version": "11.10.6",
|
|
145
|
+
"alwaysAddToPackageJson": false
|
|
146
|
+
},
|
|
147
|
+
"@emotion/react": {
|
|
148
|
+
"version": "11.10.6",
|
|
149
|
+
"alwaysAddToPackageJson": false
|
|
150
|
+
},
|
|
151
|
+
"@emotion/babel-plugin": {
|
|
152
|
+
"version": "11.10.6",
|
|
153
|
+
"alwaysAddToPackageJson": false
|
|
154
|
+
},
|
|
155
|
+
"styled-jsx": {
|
|
156
|
+
"version": "5.1.2",
|
|
157
|
+
"alwaysAddToPackageJson": false
|
|
158
|
+
},
|
|
159
|
+
"react-router-dom": {
|
|
160
|
+
"version": "6.8.1",
|
|
161
|
+
"alwaysAddToPackageJson": false
|
|
162
|
+
},
|
|
163
|
+
"@testing-library/react": {
|
|
164
|
+
"version": "14.0.0",
|
|
165
|
+
"alwaysAddToPackageJson": false
|
|
166
|
+
},
|
|
167
|
+
"@reduxjs/toolkit": {
|
|
168
|
+
"version": "1.9.3",
|
|
169
|
+
"alwaysAddToPackageJson": false
|
|
170
|
+
},
|
|
171
|
+
"eslint-plugin-import": {
|
|
172
|
+
"version": "2.27.5",
|
|
173
|
+
"alwaysAddToPackageJson": false
|
|
174
|
+
},
|
|
175
|
+
"eslint-plugin-jsx-a11y": {
|
|
176
|
+
"version": "6.7.1",
|
|
177
|
+
"alwaysAddToPackageJson": false
|
|
178
|
+
},
|
|
179
|
+
"eslint-plugin-react": {
|
|
180
|
+
"version": "7.32.2",
|
|
181
|
+
"alwaysAddToPackageJson": false
|
|
182
|
+
},
|
|
183
|
+
"postcss": {
|
|
184
|
+
"version": "8.4.21",
|
|
185
|
+
"alwaysAddToPackageJson": false
|
|
186
|
+
},
|
|
187
|
+
"tailwindcss": {
|
|
188
|
+
"version": "3.2.7",
|
|
189
|
+
"alwaysAddToPackageJson": false
|
|
190
|
+
},
|
|
191
|
+
"@types/express": {
|
|
192
|
+
"version": "4.17.17",
|
|
193
|
+
"alwaysAddToPackageJson": false
|
|
194
|
+
},
|
|
195
|
+
"less": {
|
|
196
|
+
"version": "4.1.3",
|
|
197
|
+
"alwaysAddToPackageJson": false
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"16.3.0": {
|
|
202
|
+
"version": "16.3.0-beta.2",
|
|
203
|
+
"packages": {
|
|
204
|
+
"react-router-dom": {
|
|
205
|
+
"version": "6.11.2",
|
|
206
|
+
"alwaysAddToPackageJson": false
|
|
207
|
+
},
|
|
208
|
+
"@svgr/rollup": {
|
|
209
|
+
"version": "^8.0.1",
|
|
210
|
+
"alwaysAddToPackageJson": false
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
"16.4.0-beta.4": {
|
|
215
|
+
"version": "16.4.0-beta.4",
|
|
216
|
+
"packages": {
|
|
217
|
+
"stylus": {
|
|
218
|
+
"version": "^0.59.0",
|
|
219
|
+
"alwaysAddToPackageJson": false
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
"16.4.0-beta.7": {
|
|
224
|
+
"version": "16.4.0-beta.7",
|
|
225
|
+
"packages": {
|
|
226
|
+
"@types/react": {
|
|
227
|
+
"version": "18.2.12",
|
|
228
|
+
"alwaysAddToPackageJson": false
|
|
229
|
+
},
|
|
230
|
+
"@types/react-dom": {
|
|
231
|
+
"version": "18.2.5",
|
|
232
|
+
"alwaysAddToPackageJson": false
|
|
233
|
+
},
|
|
234
|
+
"@types/react-is": {
|
|
235
|
+
"version": "18.2.0",
|
|
236
|
+
"alwaysAddToPackageJson": false
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
"16.4.0-beta.8": {
|
|
241
|
+
"version": "16.4.0-beta.8",
|
|
242
|
+
"packages": {
|
|
243
|
+
"@emotion/styled": {
|
|
244
|
+
"version": "11.11.0",
|
|
245
|
+
"alwaysAddToPackageJson": false
|
|
246
|
+
},
|
|
247
|
+
"@emotion/react": {
|
|
248
|
+
"version": "11.11.1",
|
|
249
|
+
"alwaysAddToPackageJson": false
|
|
250
|
+
},
|
|
251
|
+
"@emotion/babel-plugin": {
|
|
252
|
+
"version": "11.11.0",
|
|
253
|
+
"alwaysAddToPackageJson": false
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
"16.4.0-beta.11": {
|
|
258
|
+
"version": "16.4.0-beta.11",
|
|
259
|
+
"packages": {
|
|
260
|
+
"@types/react": {
|
|
261
|
+
"version": "18.2.13",
|
|
262
|
+
"alwaysAddToPackageJson": false
|
|
263
|
+
},
|
|
264
|
+
"@types/react-dom": {
|
|
265
|
+
"version": "18.2.6",
|
|
266
|
+
"alwaysAddToPackageJson": false
|
|
267
|
+
},
|
|
268
|
+
"@types/react-is": {
|
|
269
|
+
"version": "18.2.1",
|
|
270
|
+
"alwaysAddToPackageJson": false
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
"16.5.0-beta.4": {
|
|
275
|
+
"version": "16.5.0-beta.4",
|
|
276
|
+
"packages": {
|
|
277
|
+
"@types/react": {
|
|
278
|
+
"version": "18.2.14",
|
|
279
|
+
"alwaysAddToPackageJson": false
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
"17.0.0-beta.0": {
|
|
284
|
+
"version": "17.0.0-beta.0",
|
|
285
|
+
"packages": {
|
|
286
|
+
"@types/react": {
|
|
287
|
+
"version": "18.2.24",
|
|
288
|
+
"alwaysAddToPackageJson": false
|
|
289
|
+
},
|
|
290
|
+
"@types/react-dom": {
|
|
291
|
+
"version": "18.2.9",
|
|
292
|
+
"alwaysAddToPackageJson": false
|
|
293
|
+
},
|
|
294
|
+
"@types/react-is": {
|
|
295
|
+
"version": "18.2.2",
|
|
296
|
+
"alwaysAddToPackageJson": false
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
"17.3.0": {
|
|
301
|
+
"version": "17.3.0-beta.3",
|
|
302
|
+
"packages": {
|
|
303
|
+
"@types/node": {
|
|
304
|
+
"version": "18.16.9",
|
|
305
|
+
"alwaysAddToPackageJson": false
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withModuleFederationForSSR = exports.withModuleFederation = void 0;
|
|
4
|
+
const with_module_federation_1 = require("./src/module-federation/with-module-federation");
|
|
5
|
+
Object.defineProperty(exports, "withModuleFederation", { enumerable: true, get: function () { return with_module_federation_1.withModuleFederation; } });
|
|
6
|
+
const with_module_federation_ssr_1 = require("./src/module-federation/with-module-federation-ssr");
|
|
7
|
+
Object.defineProperty(exports, "withModuleFederationForSSR", { enumerable: true, get: function () { return with_module_federation_ssr_1.withModuleFederationForSSR; } });
|
|
8
|
+
// Support for older generated code: `const withModuleFederation = require('@nx/react/module-federation')`
|
|
9
|
+
module.exports = with_module_federation_1.withModuleFederation;
|
|
10
|
+
// Allow newer generated code to work: `const { withModuleFederation } = require(...)`;
|
|
11
|
+
module.exports.withModuleFederation = with_module_federation_1.withModuleFederation;
|
|
12
|
+
module.exports.withModuleFederationForSSR = with_module_federation_ssr_1.withModuleFederationForSSR;
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nx/react",
|
|
3
|
+
"version": "0.0.0-pr-22179-271588f",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/nrwl/nx.git",
|
|
9
|
+
"directory": "packages/react"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"Monorepo",
|
|
13
|
+
"React",
|
|
14
|
+
"Web",
|
|
15
|
+
"Jest",
|
|
16
|
+
"Cypress",
|
|
17
|
+
"CLI"
|
|
18
|
+
],
|
|
19
|
+
"main": "./index.js",
|
|
20
|
+
"typings": "./index.d.ts",
|
|
21
|
+
"author": "Victor Savkin",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/nrwl/nx/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://nx.dev",
|
|
27
|
+
"executors": "./executors.json",
|
|
28
|
+
"generators": "./generators.json",
|
|
29
|
+
"ng-update": {
|
|
30
|
+
"requirements": {},
|
|
31
|
+
"migrations": "./migrations.json"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
|
+
"@svgr/webpack": "^8.0.1",
|
|
36
|
+
"chalk": "^4.1.0",
|
|
37
|
+
"minimatch": "9.0.3",
|
|
38
|
+
"tslib": "^2.3.0",
|
|
39
|
+
"@nx/devkit": "0.0.0-pr-22179-271588f",
|
|
40
|
+
"@nx/js": "0.0.0-pr-22179-271588f",
|
|
41
|
+
"@nx/eslint": "0.0.0-pr-22179-271588f",
|
|
42
|
+
"@nx/web": "0.0.0-pr-22179-271588f",
|
|
43
|
+
"@nrwl/react": "0.0.0-pr-22179-271588f"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"type": "commonjs"
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function getRollupOptions(options) {
|
|
4
|
+
const extraGlobals = {
|
|
5
|
+
react: 'React',
|
|
6
|
+
'react-dom': 'ReactDOM',
|
|
7
|
+
'styled-components': 'styled',
|
|
8
|
+
'@emotion/react': 'emotionReact',
|
|
9
|
+
'@emotion/styled': 'emotionStyled',
|
|
10
|
+
};
|
|
11
|
+
if (Array.isArray(options.output)) {
|
|
12
|
+
options.output.forEach((o) => {
|
|
13
|
+
o.globals = { ...o.globals, ...extraGlobals };
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
options.output = {
|
|
18
|
+
...options.output,
|
|
19
|
+
globals: {
|
|
20
|
+
...options.output.globals,
|
|
21
|
+
...extraGlobals,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// React buildable libs support SVGR, but not for React Native.
|
|
26
|
+
// If imports fail, ignore it.
|
|
27
|
+
try {
|
|
28
|
+
const url = require('@rollup/plugin-url');
|
|
29
|
+
const svg = require('@svgr/rollup');
|
|
30
|
+
options.plugins = [
|
|
31
|
+
svg({
|
|
32
|
+
svgo: false,
|
|
33
|
+
titleProp: true,
|
|
34
|
+
ref: true,
|
|
35
|
+
}),
|
|
36
|
+
url({
|
|
37
|
+
limit: 10000, // 10kB
|
|
38
|
+
}),
|
|
39
|
+
...options.plugins,
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Ignored for React Native
|
|
44
|
+
}
|
|
45
|
+
return options;
|
|
46
|
+
}
|
|
47
|
+
module.exports = getRollupOptions;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { NxComponentTestingOptions } from '@nx/cypress/plugins/cypress-preset';
|
|
2
|
+
type ViteDevServer = {
|
|
3
|
+
framework: 'react';
|
|
4
|
+
bundler: 'vite';
|
|
5
|
+
viteConfig?: any;
|
|
6
|
+
};
|
|
7
|
+
type WebpackDevServer = {
|
|
8
|
+
framework: 'react';
|
|
9
|
+
bundler: 'webpack';
|
|
10
|
+
webpackConfig?: any;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* React nx preset for Cypress Component Testing
|
|
14
|
+
*
|
|
15
|
+
* This preset contains the base configuration
|
|
16
|
+
* for your component tests that nx recommends.
|
|
17
|
+
* including a devServer that supports nx workspaces.
|
|
18
|
+
* you can easily extend this within your cypress config via spreading the preset
|
|
19
|
+
* @example
|
|
20
|
+
* export default defineConfig({
|
|
21
|
+
* component: {
|
|
22
|
+
* ...nxComponentTestingPreset(__dirname)
|
|
23
|
+
* // add your own config here
|
|
24
|
+
* }
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* @param pathToConfig will be used for loading project options and to construct the output paths for videos and screenshots
|
|
28
|
+
* @param options override options
|
|
29
|
+
*/
|
|
30
|
+
export declare function nxComponentTestingPreset(pathToConfig: string, options?: NxComponentTestingOptions): {
|
|
31
|
+
specPattern: string;
|
|
32
|
+
devServer: ViteDevServer | WebpackDevServer;
|
|
33
|
+
videosFolder: string;
|
|
34
|
+
screenshotsFolder: string;
|
|
35
|
+
chromeWebSecurity: boolean;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nxComponentTestingPreset = void 0;
|
|
4
|
+
const cypress_preset_1 = require("@nx/cypress/plugins/cypress-preset");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const ct_helpers_1 = require("@nx/cypress/src/utils/ct-helpers");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
/**
|
|
10
|
+
* React nx preset for Cypress Component Testing
|
|
11
|
+
*
|
|
12
|
+
* This preset contains the base configuration
|
|
13
|
+
* for your component tests that nx recommends.
|
|
14
|
+
* including a devServer that supports nx workspaces.
|
|
15
|
+
* you can easily extend this within your cypress config via spreading the preset
|
|
16
|
+
* @example
|
|
17
|
+
* export default defineConfig({
|
|
18
|
+
* component: {
|
|
19
|
+
* ...nxComponentTestingPreset(__dirname)
|
|
20
|
+
* // add your own config here
|
|
21
|
+
* }
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* @param pathToConfig will be used for loading project options and to construct the output paths for videos and screenshots
|
|
25
|
+
* @param options override options
|
|
26
|
+
*/
|
|
27
|
+
function nxComponentTestingPreset(pathToConfig, options) {
|
|
28
|
+
const basePresetSettings = (0, cypress_preset_1.nxBaseCypressPreset)(pathToConfig, {
|
|
29
|
+
testingType: 'component',
|
|
30
|
+
});
|
|
31
|
+
if (global.NX_GRAPH_CREATION || global.NX_CYPRESS_INIT_GENERATOR_RUNNING) {
|
|
32
|
+
// this is only used by plugins, so we don't need the component testing
|
|
33
|
+
// options, cast to any to avoid type errors
|
|
34
|
+
return basePresetSettings;
|
|
35
|
+
}
|
|
36
|
+
const normalizedProjectRootPath = ['.ts', '.js'].some((ext) => pathToConfig.endsWith(ext))
|
|
37
|
+
? pathToConfig
|
|
38
|
+
: (0, path_1.dirname)(pathToConfig);
|
|
39
|
+
if (options?.bundler === 'vite') {
|
|
40
|
+
return {
|
|
41
|
+
...basePresetSettings,
|
|
42
|
+
specPattern: 'src/**/*.cy.{js,jsx,ts,tsx}',
|
|
43
|
+
devServer: {
|
|
44
|
+
...{ framework: 'react', bundler: 'vite' },
|
|
45
|
+
viteConfig: async () => {
|
|
46
|
+
const viteConfigPath = findViteConfig(normalizedProjectRootPath);
|
|
47
|
+
const { mergeConfig, loadConfigFromFile, searchForWorkspaceRoot } = await Function('return import("vite")')();
|
|
48
|
+
const resolved = await loadConfigFromFile({
|
|
49
|
+
mode: 'watch',
|
|
50
|
+
command: 'serve',
|
|
51
|
+
}, viteConfigPath);
|
|
52
|
+
return mergeConfig(resolved.config, {
|
|
53
|
+
server: {
|
|
54
|
+
fs: {
|
|
55
|
+
allow: [
|
|
56
|
+
searchForWorkspaceRoot(normalizedProjectRootPath),
|
|
57
|
+
devkit_1.workspaceRoot,
|
|
58
|
+
(0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, 'node_modules/vite'),
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
let webpackConfig;
|
|
68
|
+
try {
|
|
69
|
+
const graph = (0, devkit_1.readCachedProjectGraph)();
|
|
70
|
+
const { targets: ctTargets, name: ctProjectName } = (0, ct_helpers_1.getProjectConfigByPath)(graph, pathToConfig);
|
|
71
|
+
const ctTargetName = options?.ctTargetName || 'component-test';
|
|
72
|
+
const ctConfigurationName = process.env.NX_CYPRESS_TARGET_CONFIGURATION;
|
|
73
|
+
const ctExecutorContext = (0, ct_helpers_1.createExecutorContext)(graph, ctTargets, ctProjectName, ctTargetName, ctConfigurationName);
|
|
74
|
+
let buildTarget = options?.buildTarget;
|
|
75
|
+
if (!buildTarget) {
|
|
76
|
+
const ctExecutorOptions = (0, devkit_1.readTargetOptions)({
|
|
77
|
+
project: ctProjectName,
|
|
78
|
+
target: ctTargetName,
|
|
79
|
+
configuration: ctConfigurationName,
|
|
80
|
+
}, ctExecutorContext);
|
|
81
|
+
buildTarget = ctExecutorOptions.devServerTarget;
|
|
82
|
+
}
|
|
83
|
+
if (!buildTarget) {
|
|
84
|
+
throw new Error(`Unable to find the 'devServerTarget' executor option in the '${ctTargetName}' target of the '${ctProjectName}' project`);
|
|
85
|
+
}
|
|
86
|
+
webpackConfig = buildTargetWebpack(ctExecutorContext, buildTarget, ctProjectName);
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
if (e instanceof InvalidExecutorError) {
|
|
90
|
+
throw e;
|
|
91
|
+
}
|
|
92
|
+
devkit_1.logger.warn((0, devkit_1.stripIndents) `Unable to build a webpack config with the project graph.
|
|
93
|
+
Falling back to default webpack config.`);
|
|
94
|
+
devkit_1.logger.warn(e);
|
|
95
|
+
const { buildBaseWebpackConfig } = require('./webpack-fallback');
|
|
96
|
+
webpackConfig = buildBaseWebpackConfig({
|
|
97
|
+
tsConfigPath: findTsConfig(normalizedProjectRootPath),
|
|
98
|
+
compiler: options?.compiler || 'babel',
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
...basePresetSettings,
|
|
103
|
+
specPattern: 'src/**/*.cy.{js,jsx,ts,tsx}',
|
|
104
|
+
devServer: {
|
|
105
|
+
// cypress uses string union type,
|
|
106
|
+
// need to use const to prevent typing to string
|
|
107
|
+
// but don't want to use as const on webpackConfig
|
|
108
|
+
// so it is still user modifiable
|
|
109
|
+
...{ framework: 'react', bundler: 'webpack' },
|
|
110
|
+
webpackConfig,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
exports.nxComponentTestingPreset = nxComponentTestingPreset;
|
|
115
|
+
/**
|
|
116
|
+
* apply the schema.json defaults from the @nx/web:webpack executor to the target options
|
|
117
|
+
*/
|
|
118
|
+
function withSchemaDefaults(target, context) {
|
|
119
|
+
const options = (0, devkit_1.readTargetOptions)(target, context);
|
|
120
|
+
options.compiler ??= 'babel';
|
|
121
|
+
options.deleteOutputPath ??= true;
|
|
122
|
+
options.vendorChunk ??= true;
|
|
123
|
+
options.commonChunk ??= true;
|
|
124
|
+
options.runtimeChunk ??= true;
|
|
125
|
+
options.sourceMap ??= true;
|
|
126
|
+
options.assets ??= [];
|
|
127
|
+
options.scripts ??= [];
|
|
128
|
+
options.styles ??= [];
|
|
129
|
+
options.budgets ??= [];
|
|
130
|
+
options.namedChunks ??= true;
|
|
131
|
+
options.outputHashing ??= 'none';
|
|
132
|
+
options.extractCss ??= true;
|
|
133
|
+
options.memoryLimit ??= 2048;
|
|
134
|
+
options.maxWorkers ??= 2;
|
|
135
|
+
options.fileReplacements ??= [];
|
|
136
|
+
options.buildLibsFromSource ??= true;
|
|
137
|
+
return options;
|
|
138
|
+
}
|
|
139
|
+
function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
|
|
140
|
+
const graph = ctx.projectGraph;
|
|
141
|
+
const parsed = (0, devkit_1.parseTargetString)(buildTarget, graph);
|
|
142
|
+
const buildableProjectConfig = graph.nodes[parsed.project]?.data;
|
|
143
|
+
const ctProjectConfig = graph.nodes[componentTestingProjectName]?.data;
|
|
144
|
+
if (!buildableProjectConfig || !ctProjectConfig) {
|
|
145
|
+
throw new Error((0, devkit_1.stripIndents) `Unable to load project configs from graph.
|
|
146
|
+
Using build target '${buildTarget}'
|
|
147
|
+
Has build config? ${!!buildableProjectConfig}
|
|
148
|
+
Has component config? ${!!ctProjectConfig}
|
|
149
|
+
`);
|
|
150
|
+
}
|
|
151
|
+
if (buildableProjectConfig.targets[parsed.target].executor !==
|
|
152
|
+
'@nx/webpack:webpack') {
|
|
153
|
+
throw new InvalidExecutorError(`The '${parsed.target}' target of the '${parsed.project}' project is not using the '@nx/webpack:webpack' executor. ` +
|
|
154
|
+
`Please make sure to use '@nx/webpack:webpack' executor in that target to use Cypress Component Testing.`);
|
|
155
|
+
}
|
|
156
|
+
const context = (0, ct_helpers_1.createExecutorContext)(graph, buildableProjectConfig.targets, parsed.project, parsed.target, parsed.target);
|
|
157
|
+
const { normalizeOptions, } = require('@nx/webpack/src/executors/webpack/lib/normalize-options');
|
|
158
|
+
const { resolveUserDefinedWebpackConfig, } = require('@nx/webpack/src/utils/webpack/resolve-user-defined-webpack-config');
|
|
159
|
+
const { composePluginsSync } = require('@nx/webpack/src/utils/config');
|
|
160
|
+
const { withNx } = require('@nx/webpack/src/utils/with-nx');
|
|
161
|
+
const { withWeb } = require('@nx/webpack/src/utils/with-web');
|
|
162
|
+
const options = normalizeOptions(withSchemaDefaults(parsed, context), devkit_1.workspaceRoot, buildableProjectConfig.root, buildableProjectConfig.sourceRoot);
|
|
163
|
+
let customWebpack;
|
|
164
|
+
if (options.webpackConfig) {
|
|
165
|
+
customWebpack = resolveUserDefinedWebpackConfig(options.webpackConfig, options.tsConfig.startsWith(context.root)
|
|
166
|
+
? options.tsConfig
|
|
167
|
+
: (0, path_1.join)(context.root, options.tsConfig));
|
|
168
|
+
}
|
|
169
|
+
return async () => {
|
|
170
|
+
customWebpack = await customWebpack;
|
|
171
|
+
// TODO(v19): Once webpackConfig is always set in @nx/webpack:webpack and isolatedConfig is removed, we no longer need this default.
|
|
172
|
+
const configure = composePluginsSync(withNx(), withWeb());
|
|
173
|
+
const defaultWebpack = configure({}, {
|
|
174
|
+
options: {
|
|
175
|
+
...options,
|
|
176
|
+
// cypress will generate its own index.html from component-index.html
|
|
177
|
+
generateIndexHtml: false,
|
|
178
|
+
// causes issues with buildable libraries with ENOENT: no such file or directory, scandir error
|
|
179
|
+
extractLicenses: false,
|
|
180
|
+
root: devkit_1.workspaceRoot,
|
|
181
|
+
projectRoot: ctProjectConfig.root,
|
|
182
|
+
sourceRoot: ctProjectConfig.sourceRoot,
|
|
183
|
+
},
|
|
184
|
+
context,
|
|
185
|
+
});
|
|
186
|
+
if (customWebpack) {
|
|
187
|
+
return await customWebpack(defaultWebpack, {
|
|
188
|
+
options,
|
|
189
|
+
context,
|
|
190
|
+
configuration: parsed.configuration,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
return defaultWebpack;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function findViteConfig(projectRootFullPath) {
|
|
197
|
+
const allowsExt = ['js', 'mjs', 'ts', 'cjs', 'mts', 'cts'];
|
|
198
|
+
for (const ext of allowsExt) {
|
|
199
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(projectRootFullPath, `vite.config.${ext}`))) {
|
|
200
|
+
return (0, path_1.join)(projectRootFullPath, `vite.config.${ext}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function findTsConfig(projectRoot) {
|
|
205
|
+
const potentialConfigs = [
|
|
206
|
+
'cypress/tsconfig.json',
|
|
207
|
+
'cypress/tsconfig.cy.json',
|
|
208
|
+
'tsconfig.cy.json',
|
|
209
|
+
];
|
|
210
|
+
for (const config of potentialConfigs) {
|
|
211
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(projectRoot, config))) {
|
|
212
|
+
return config;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
class InvalidExecutorError extends Error {
|
|
217
|
+
constructor(message) {
|
|
218
|
+
super(message);
|
|
219
|
+
this.message = message;
|
|
220
|
+
this.name = 'InvalidExecutorError';
|
|
221
|
+
}
|
|
222
|
+
}
|