@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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import cors from 'cors';
|
|
4
|
+
|
|
5
|
+
import { handleRequest } from './src/main.server';
|
|
6
|
+
|
|
7
|
+
const port = process.env['PORT'] || 4200;
|
|
8
|
+
const app = express();
|
|
9
|
+
|
|
10
|
+
const browserDist = path.join(process.cwd(), '<%= browserBuildOutputPath %>');
|
|
11
|
+
const indexPath = path.join(browserDist, 'index.html');
|
|
12
|
+
|
|
13
|
+
app.use(cors());
|
|
14
|
+
|
|
15
|
+
app.get(
|
|
16
|
+
'*.*',
|
|
17
|
+
express.static(browserDist, {
|
|
18
|
+
maxAge: '1y',
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
app.use('*', handleRequest(indexPath));
|
|
23
|
+
|
|
24
|
+
const server = app.listen(port, () => {
|
|
25
|
+
console.log(`Express server listening on http://localhost:${port}`);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
server.on('error', console.error);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.app.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../out-tsc/server",
|
|
5
|
+
"target": "es2019",
|
|
6
|
+
"types": [
|
|
7
|
+
"node",
|
|
8
|
+
"@nx/react/typings/cssmodule.d.ts",
|
|
9
|
+
"@nx/react/typings/image.d.ts"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"include": [
|
|
13
|
+
"src/remotes.d.ts",
|
|
14
|
+
"src/main.server.tsx",
|
|
15
|
+
"server.ts"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {composePlugins, withNx} from '@nx/webpack';
|
|
2
|
+
import {withReact} from '@nx/react';
|
|
3
|
+
import {withModuleFederationForSSR} from '@nx/react/module-federation';
|
|
4
|
+
|
|
5
|
+
import baseConfig from './module-federation.config';
|
|
6
|
+
|
|
7
|
+
const defaultConfig = {
|
|
8
|
+
...baseConfig
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Nx plugins for webpack to build config object from Nx options and context.
|
|
12
|
+
export default composePlugins(withNx(), withReact({ssr: true}), withModuleFederationForSSR(defaultConfig));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ModuleFederationConfig } from '@nx/webpack';
|
|
2
|
+
|
|
3
|
+
const config: ModuleFederationConfig = {
|
|
4
|
+
name: '<%= projectName %>',
|
|
5
|
+
/**
|
|
6
|
+
* To use a remote that does not exist in your current Nx Workspace
|
|
7
|
+
* You can use the tuple-syntax to define your remote
|
|
8
|
+
*
|
|
9
|
+
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
|
|
10
|
+
*
|
|
11
|
+
* You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
|
|
12
|
+
* following content:
|
|
13
|
+
*
|
|
14
|
+
* declare module 'my-external-remote';
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
remotes: [
|
|
18
|
+
<% if (static) {
|
|
19
|
+
remotes.forEach(function(r) { %> "<%= r.fileName %>", <% });
|
|
20
|
+
}
|
|
21
|
+
%>
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default config;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { composePlugins, withNx } from '@nx/webpack';
|
|
2
|
+
import { withReact } from '@nx/react';
|
|
3
|
+
import { withModuleFederation } from '@nx/react/module-federation';
|
|
4
|
+
import { ModuleFederationConfig } from '@nx/webpack';
|
|
5
|
+
|
|
6
|
+
import baseConfig from './module-federation.config';
|
|
7
|
+
|
|
8
|
+
const prodConfig: ModuleFederationConfig = {
|
|
9
|
+
...baseConfig,
|
|
10
|
+
/*
|
|
11
|
+
* Remote overrides for production.
|
|
12
|
+
* Each entry is a pair of a unique name and the URL where it is deployed.
|
|
13
|
+
*
|
|
14
|
+
* e.g.
|
|
15
|
+
* remotes: [
|
|
16
|
+
* ['app1', 'http://app1.example.com'],
|
|
17
|
+
* ['app2', 'http://app2.example.com'],
|
|
18
|
+
* ]
|
|
19
|
+
*
|
|
20
|
+
* You can also use a full path to the remoteEntry.js file if desired.
|
|
21
|
+
*
|
|
22
|
+
* remotes: [
|
|
23
|
+
* ['app1', 'http://example.com/path/to/app1/remoteEntry.js'],
|
|
24
|
+
* ['app2', 'http://example.com/path/to/app2/remoteEntry.js'],
|
|
25
|
+
* ]
|
|
26
|
+
*/
|
|
27
|
+
remotes: [
|
|
28
|
+
<% remotes.forEach(function(r) {%>['<%= r.fileName %>', 'http://localhost:<%= r.port %>/'],<% }); %>
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Nx plugins for webpack to build config object from Nx options and context.
|
|
33
|
+
export default composePlugins(withNx(), withReact(), withModuleFederation(prodConfig));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {composePlugins, withNx, ModuleFederationConfig} from '@nx/webpack';
|
|
2
|
+
import {withReact} from '@nx/react';
|
|
3
|
+
import {withModuleFederation} from '@nx/react/module-federation';
|
|
4
|
+
|
|
5
|
+
import baseConfig from './module-federation.config';
|
|
6
|
+
|
|
7
|
+
const config: ModuleFederationConfig = {
|
|
8
|
+
...baseConfig,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Nx plugins for webpack to build config object from Nx options and context.
|
|
12
|
+
export default composePlugins(withNx(), withReact(), withModuleFederation(config));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from './schema';
|
|
3
|
+
export declare function hostGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function hostGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
5
|
+
export default hostGenerator;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hostGeneratorInternal = exports.hostGenerator = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const update_module_federation_project_1 = require("../../rules/update-module-federation-project");
|
|
6
|
+
const application_1 = require("../application/application");
|
|
7
|
+
const normalize_options_1 = require("../application/lib/normalize-options");
|
|
8
|
+
const remote_1 = require("../remote/remote");
|
|
9
|
+
const setup_ssr_1 = require("../setup-ssr/setup-ssr");
|
|
10
|
+
const add_module_federation_files_1 = require("./lib/add-module-federation-files");
|
|
11
|
+
const normalize_remote_1 = require("./lib/normalize-remote");
|
|
12
|
+
const setup_ssr_for_host_1 = require("./lib/setup-ssr-for-host");
|
|
13
|
+
const update_module_federation_e2e_project_1 = require("./lib/update-module-federation-e2e-project");
|
|
14
|
+
const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
|
15
|
+
async function hostGenerator(host, schema) {
|
|
16
|
+
return hostGeneratorInternal(host, {
|
|
17
|
+
projectNameAndRootFormat: 'derived',
|
|
18
|
+
...schema,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.hostGenerator = hostGenerator;
|
|
22
|
+
async function hostGeneratorInternal(host, schema) {
|
|
23
|
+
const tasks = [];
|
|
24
|
+
const options = {
|
|
25
|
+
...(await (0, normalize_options_1.normalizeOptions)(host, schema, '@nx/react:host')),
|
|
26
|
+
js: schema.js ?? false,
|
|
27
|
+
typescriptConfiguration: schema.js
|
|
28
|
+
? false
|
|
29
|
+
: schema.typescriptConfiguration ?? true,
|
|
30
|
+
dynamic: schema.dynamic ?? false,
|
|
31
|
+
// TODO(colum): remove when MF works with Crystal
|
|
32
|
+
addPlugin: false,
|
|
33
|
+
};
|
|
34
|
+
const initTask = await (0, application_1.default)(host, {
|
|
35
|
+
...options,
|
|
36
|
+
// The target use-case is loading remotes as child routes, thus always enable routing.
|
|
37
|
+
routing: true,
|
|
38
|
+
// Only webpack works with module federation for now.
|
|
39
|
+
bundler: 'webpack',
|
|
40
|
+
skipFormat: true,
|
|
41
|
+
});
|
|
42
|
+
tasks.push(initTask);
|
|
43
|
+
const remotesWithPorts = [];
|
|
44
|
+
if (schema.remotes) {
|
|
45
|
+
let remotePort = options.devServerPort + 1;
|
|
46
|
+
for (const remote of schema.remotes) {
|
|
47
|
+
const remoteName = await (0, normalize_remote_1.normalizeRemoteName)(host, remote, options);
|
|
48
|
+
remotesWithPorts.push({ name: remoteName, port: remotePort });
|
|
49
|
+
const remoteTask = await (0, remote_1.default)(host, {
|
|
50
|
+
name: remote,
|
|
51
|
+
directory: (0, normalize_remote_1.normalizeRemoteDirectory)(remote, options),
|
|
52
|
+
style: options.style,
|
|
53
|
+
unitTestRunner: options.unitTestRunner,
|
|
54
|
+
e2eTestRunner: options.e2eTestRunner,
|
|
55
|
+
linter: options.linter,
|
|
56
|
+
devServerPort: remotePort,
|
|
57
|
+
ssr: options.ssr,
|
|
58
|
+
skipFormat: true,
|
|
59
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
60
|
+
typescriptConfiguration: options.typescriptConfiguration,
|
|
61
|
+
js: options.js,
|
|
62
|
+
dynamic: options.dynamic,
|
|
63
|
+
host: options.name,
|
|
64
|
+
});
|
|
65
|
+
tasks.push(remoteTask);
|
|
66
|
+
remotePort++;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
(0, add_module_federation_files_1.addModuleFederationFiles)(host, options, remotesWithPorts);
|
|
70
|
+
(0, update_module_federation_project_1.updateModuleFederationProject)(host, options);
|
|
71
|
+
(0, update_module_federation_e2e_project_1.updateModuleFederationE2eProject)(host, options);
|
|
72
|
+
if (options.ssr) {
|
|
73
|
+
const setupSsrTask = await (0, setup_ssr_1.default)(host, {
|
|
74
|
+
project: options.projectName,
|
|
75
|
+
serverPort: options.devServerPort,
|
|
76
|
+
skipFormat: true,
|
|
77
|
+
});
|
|
78
|
+
tasks.push(setupSsrTask);
|
|
79
|
+
const setupSsrForHostTask = await (0, setup_ssr_for_host_1.setupSsrForHost)(host, options, options.projectName, remotesWithPorts);
|
|
80
|
+
tasks.push(setupSsrForHostTask);
|
|
81
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
82
|
+
projectConfig.targets.server.options.webpackConfig = (0, devkit_1.joinPathFragments)(projectConfig.root, `webpack.server.config.${options.typescriptConfiguration ? 'ts' : 'js'}`);
|
|
83
|
+
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
|
|
84
|
+
}
|
|
85
|
+
if (!options.setParserOptionsProject) {
|
|
86
|
+
host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.lint.json'));
|
|
87
|
+
}
|
|
88
|
+
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host);
|
|
89
|
+
if (!options.skipFormat) {
|
|
90
|
+
await (0, devkit_1.formatFiles)(host);
|
|
91
|
+
}
|
|
92
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
93
|
+
}
|
|
94
|
+
exports.hostGeneratorInternal = hostGeneratorInternal;
|
|
95
|
+
exports.default = hostGenerator;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addModuleFederationFiles = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const maybe_js_1 = require("../../../utils/maybe-js");
|
|
6
|
+
function addModuleFederationFiles(host, options, defaultRemoteManifest) {
|
|
7
|
+
const templateVariables = {
|
|
8
|
+
...(0, devkit_1.names)(options.name),
|
|
9
|
+
...options,
|
|
10
|
+
static: !options?.dynamic,
|
|
11
|
+
tmpl: '',
|
|
12
|
+
remotes: defaultRemoteManifest.map(({ name, port }) => {
|
|
13
|
+
return {
|
|
14
|
+
...(0, devkit_1.names)(name),
|
|
15
|
+
port,
|
|
16
|
+
};
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.name);
|
|
20
|
+
const pathToMFManifest = (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'assets/module-federation.manifest.json');
|
|
21
|
+
// Module federation requires bootstrap code to be dynamically imported.
|
|
22
|
+
// Renaming original entry file so we can use `import(./bootstrap)` in
|
|
23
|
+
// new entry file.
|
|
24
|
+
host.rename((0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, 'src/main.tsx')), (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, 'src/bootstrap.tsx')));
|
|
25
|
+
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, `../files/${options.js ? 'common' : 'common-ts'}`), options.appProjectRoot, templateVariables);
|
|
26
|
+
const pathToModuleFederationFiles = options.typescriptConfiguration
|
|
27
|
+
? 'module-federation-ts'
|
|
28
|
+
: 'module-federation';
|
|
29
|
+
// New entry file is created here.
|
|
30
|
+
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, `../files/${pathToModuleFederationFiles}`), options.appProjectRoot, templateVariables);
|
|
31
|
+
function deleteFileIfExists(host, filePath) {
|
|
32
|
+
if (host.exists(filePath)) {
|
|
33
|
+
host.delete(filePath);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function processWebpackConfig(options, host, fileName) {
|
|
37
|
+
const pathToWebpackConfig = (0, devkit_1.joinPathFragments)(options.appProjectRoot, fileName);
|
|
38
|
+
deleteFileIfExists(host, pathToWebpackConfig);
|
|
39
|
+
}
|
|
40
|
+
if (options.typescriptConfiguration) {
|
|
41
|
+
processWebpackConfig(options, host, 'webpack.config.js');
|
|
42
|
+
processWebpackConfig(options, host, 'webpack.config.prod.js');
|
|
43
|
+
}
|
|
44
|
+
if (options.dynamic) {
|
|
45
|
+
processWebpackConfig(options, host, 'webpack.config.prod.js');
|
|
46
|
+
processWebpackConfig(options, host, 'webpack.config.prod.ts');
|
|
47
|
+
if (!host.exists(pathToMFManifest)) {
|
|
48
|
+
host.write(pathToMFManifest, '{}');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.addModuleFederationFiles = addModuleFederationFiles;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema } from '../schema';
|
|
3
|
+
export declare function normalizeRemoteName(tree: Tree, remote: string, options: NormalizedSchema): Promise<string>;
|
|
4
|
+
export declare function normalizeRemoteDirectory(remote: string, options: NormalizedSchema): string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeRemoteDirectory = exports.normalizeRemoteName = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
|
+
async function normalizeRemoteName(tree, remote, options) {
|
|
7
|
+
const { projectName: remoteName } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
8
|
+
name: remote,
|
|
9
|
+
projectType: 'application',
|
|
10
|
+
directory: options.directory,
|
|
11
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
12
|
+
callingGenerator: '@nx/react:host',
|
|
13
|
+
});
|
|
14
|
+
return remoteName;
|
|
15
|
+
}
|
|
16
|
+
exports.normalizeRemoteName = normalizeRemoteName;
|
|
17
|
+
function normalizeRemoteDirectory(remote, options) {
|
|
18
|
+
if (options.projectNameAndRootFormat === 'derived' || !options.directory) {
|
|
19
|
+
return options.directory;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* With the `as-provided` format, the provided directory would be the root
|
|
23
|
+
* of the host application. Append the remote name to the host parent
|
|
24
|
+
* directory to get the remote directory.
|
|
25
|
+
*/
|
|
26
|
+
return (0, devkit_1.joinPathFragments)(options.directory, '..', remote);
|
|
27
|
+
}
|
|
28
|
+
exports.normalizeRemoteDirectory = normalizeRemoteDirectory;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import type { Schema } from '../schema';
|
|
3
|
+
export declare function setupSsrForHost(tree: Tree, options: Schema, appName: string, defaultRemoteManifest: {
|
|
4
|
+
name: string;
|
|
5
|
+
port: number;
|
|
6
|
+
}[]): Promise<GeneratorCallback>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupSsrForHost = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("../../../utils/versions");
|
|
6
|
+
async function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
|
|
7
|
+
const tasks = [];
|
|
8
|
+
let project = (0, devkit_1.readProjectConfiguration)(tree, appName);
|
|
9
|
+
project.targets.serve.executor = '@nx/react:module-federation-ssr-dev-server';
|
|
10
|
+
(0, devkit_1.updateProjectConfiguration)(tree, appName, project);
|
|
11
|
+
const pathToModuleFederationSsrFiles = options.typescriptConfiguration
|
|
12
|
+
? 'module-federation-ssr-ts'
|
|
13
|
+
: 'module-federation-ssr';
|
|
14
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, `../files/${pathToModuleFederationSsrFiles}`), project.root, {
|
|
15
|
+
...options,
|
|
16
|
+
static: !options?.dynamic,
|
|
17
|
+
remotes: defaultRemoteManifest.map(({ name, port }) => {
|
|
18
|
+
return {
|
|
19
|
+
...(0, devkit_1.names)(name),
|
|
20
|
+
port,
|
|
21
|
+
};
|
|
22
|
+
}),
|
|
23
|
+
appName,
|
|
24
|
+
tmpl: '',
|
|
25
|
+
browserBuildOutputPath: project.targets.build.options.outputPath,
|
|
26
|
+
});
|
|
27
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
28
|
+
'@module-federation/node': versions_1.moduleFederationNodeVersion,
|
|
29
|
+
}, {});
|
|
30
|
+
tasks.push(installTask);
|
|
31
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
32
|
+
}
|
|
33
|
+
exports.setupSsrForHost = setupSsrForHost;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateModuleFederationE2eProject = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function updateModuleFederationE2eProject(host, options) {
|
|
6
|
+
try {
|
|
7
|
+
let projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.e2eProjectName);
|
|
8
|
+
if (projectConfig.targets.e2e.executor !== '@nx/playwright:playwright') {
|
|
9
|
+
projectConfig.targets.e2e.options = {
|
|
10
|
+
...projectConfig.targets.e2e.options,
|
|
11
|
+
baseUrl: `http://localhost:${options.devServerPort}`,
|
|
12
|
+
};
|
|
13
|
+
(0, devkit_1.updateProjectConfiguration)(host, options.e2eProjectName, projectConfig);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// nothing
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.updateModuleFederationE2eProject = updateModuleFederationE2eProject;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
|
+
import type { Linter } from '@nx/eslint';
|
|
3
|
+
import type { SupportedStyles } from '../../../typings/style';
|
|
4
|
+
|
|
5
|
+
export interface Schema {
|
|
6
|
+
classComponent?: boolean;
|
|
7
|
+
compiler?: 'babel' | 'swc';
|
|
8
|
+
devServerPort?: number;
|
|
9
|
+
directory?: string;
|
|
10
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
11
|
+
e2eTestRunner: 'cypress' | 'playwright' | 'none';
|
|
12
|
+
globalCss?: boolean;
|
|
13
|
+
js?: boolean;
|
|
14
|
+
linter: Linter;
|
|
15
|
+
name: string;
|
|
16
|
+
pascalCaseFiles?: boolean;
|
|
17
|
+
remotes?: string[];
|
|
18
|
+
setParserOptionsProject?: boolean;
|
|
19
|
+
skipFormat?: boolean;
|
|
20
|
+
skipNxJson?: boolean;
|
|
21
|
+
ssr?: boolean;
|
|
22
|
+
strict?: boolean;
|
|
23
|
+
style: SupportedStyles;
|
|
24
|
+
tags?: string;
|
|
25
|
+
unitTestRunner: 'jest' | 'vitest' | 'none';
|
|
26
|
+
minimal?: boolean;
|
|
27
|
+
typescriptConfiguration?: boolean;
|
|
28
|
+
dynamic?: boolean;
|
|
29
|
+
addPlugin?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface NormalizedSchema extends Schema {
|
|
33
|
+
appProjectRoot: string;
|
|
34
|
+
e2eProjectName: string;
|
|
35
|
+
projectName: string;
|
|
36
|
+
addPlugin?: boolean;
|
|
37
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "GeneratorReactHost",
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"title": "Generate Module Federation Setup for React Host App",
|
|
6
|
+
"description": "Create Module Federation configuration files for given React Host Application.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The name of the host application to generate the Module Federation configuration",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
|
+
},
|
|
16
|
+
"x-prompt": "What name would you like to use as the host application?",
|
|
17
|
+
"pattern": "^[a-zA-Z][^:]*$",
|
|
18
|
+
"x-priority": "important"
|
|
19
|
+
},
|
|
20
|
+
"directory": {
|
|
21
|
+
"description": "The directory of the new application.",
|
|
22
|
+
"type": "string",
|
|
23
|
+
"alias": "dir",
|
|
24
|
+
"x-priority": "important"
|
|
25
|
+
},
|
|
26
|
+
"projectNameAndRootFormat": {
|
|
27
|
+
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
28
|
+
"type": "string",
|
|
29
|
+
"enum": ["as-provided", "derived"]
|
|
30
|
+
},
|
|
31
|
+
"style": {
|
|
32
|
+
"description": "The file extension to be used for style files.",
|
|
33
|
+
"type": "string",
|
|
34
|
+
"default": "css",
|
|
35
|
+
"alias": "s",
|
|
36
|
+
"x-prompt": {
|
|
37
|
+
"message": "Which stylesheet format would you like to use?",
|
|
38
|
+
"type": "list",
|
|
39
|
+
"items": [
|
|
40
|
+
{
|
|
41
|
+
"value": "css",
|
|
42
|
+
"label": "CSS"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"value": "scss",
|
|
46
|
+
"label": "SASS(.scss) [ https://sass-lang.com ]"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"value": "less",
|
|
50
|
+
"label": "LESS [ https://lesscss.org ]"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"value": "tailwind",
|
|
54
|
+
"label": "tailwind [ https://tailwindcss.com/ ]"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"value": "styled-components",
|
|
58
|
+
"label": "styled-components [ https://styled-components.com ]"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"value": "@emotion/styled",
|
|
62
|
+
"label": "emotion [ https://emotion.sh ]"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"value": "styled-jsx",
|
|
66
|
+
"label": "styled-jsx [ https://www.npmjs.com/package/styled-jsx ]"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"value": "none",
|
|
70
|
+
"label": "None"
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"linter": {
|
|
76
|
+
"description": "The tool to use for running lint checks.",
|
|
77
|
+
"type": "string",
|
|
78
|
+
"enum": ["eslint"],
|
|
79
|
+
"default": "eslint"
|
|
80
|
+
},
|
|
81
|
+
"dynamic": {
|
|
82
|
+
"type": "boolean",
|
|
83
|
+
"description": "Should the host application use dynamic federation?",
|
|
84
|
+
"default": false
|
|
85
|
+
},
|
|
86
|
+
"skipFormat": {
|
|
87
|
+
"description": "Skip formatting files.",
|
|
88
|
+
"type": "boolean",
|
|
89
|
+
"default": false,
|
|
90
|
+
"x-priority": "internal"
|
|
91
|
+
},
|
|
92
|
+
"skipNxJson": {
|
|
93
|
+
"description": "Skip updating workspace.json with default options based on values provided to this app (e.g. babel, style).",
|
|
94
|
+
"type": "boolean",
|
|
95
|
+
"default": false,
|
|
96
|
+
"x-priority": "internal"
|
|
97
|
+
},
|
|
98
|
+
"unitTestRunner": {
|
|
99
|
+
"type": "string",
|
|
100
|
+
"enum": ["jest", "none"],
|
|
101
|
+
"description": "Test runner to use for unit tests.",
|
|
102
|
+
"default": "jest"
|
|
103
|
+
},
|
|
104
|
+
"e2eTestRunner": {
|
|
105
|
+
"type": "string",
|
|
106
|
+
"enum": ["cypress", "playwright", "none"],
|
|
107
|
+
"description": "Test runner to use for end to end (E2E) tests.",
|
|
108
|
+
"x-prompt": "Which E2E test runner would you like to use?",
|
|
109
|
+
"default": "cypress"
|
|
110
|
+
},
|
|
111
|
+
"tags": {
|
|
112
|
+
"type": "string",
|
|
113
|
+
"description": "Add tags to the application (used for linting).",
|
|
114
|
+
"alias": "t"
|
|
115
|
+
},
|
|
116
|
+
"pascalCaseFiles": {
|
|
117
|
+
"type": "boolean",
|
|
118
|
+
"description": "Use pascal case component file name (e.g. App.tsx).",
|
|
119
|
+
"alias": "P",
|
|
120
|
+
"default": false
|
|
121
|
+
},
|
|
122
|
+
"classComponent": {
|
|
123
|
+
"type": "boolean",
|
|
124
|
+
"description": "Use class components instead of functional component.",
|
|
125
|
+
"alias": "C",
|
|
126
|
+
"default": false
|
|
127
|
+
},
|
|
128
|
+
"js": {
|
|
129
|
+
"type": "boolean",
|
|
130
|
+
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
131
|
+
"default": false
|
|
132
|
+
},
|
|
133
|
+
"globalCss": {
|
|
134
|
+
"type": "boolean",
|
|
135
|
+
"description": "Default is false. When true, the component is generated with *.css/*.scss instead of *.module.css/*.module.scss",
|
|
136
|
+
"default": false
|
|
137
|
+
},
|
|
138
|
+
"strict": {
|
|
139
|
+
"type": "boolean",
|
|
140
|
+
"description": "Creates an application with strict mode and strict type checking",
|
|
141
|
+
"default": true
|
|
142
|
+
},
|
|
143
|
+
"setParserOptionsProject": {
|
|
144
|
+
"type": "boolean",
|
|
145
|
+
"description": "Whether or not to configure the ESLint \"parserOptions.project\" option. We do not do this by default for lint performance reasons.",
|
|
146
|
+
"default": false
|
|
147
|
+
},
|
|
148
|
+
"compiler": {
|
|
149
|
+
"type": "string",
|
|
150
|
+
"description": "The compiler to use",
|
|
151
|
+
"enum": ["babel", "swc"],
|
|
152
|
+
"default": "babel"
|
|
153
|
+
},
|
|
154
|
+
"remotes": {
|
|
155
|
+
"type": "array",
|
|
156
|
+
"description": "A list of remote application names that the host application should consume.",
|
|
157
|
+
"default": [],
|
|
158
|
+
"x-priority": "important"
|
|
159
|
+
},
|
|
160
|
+
"devServerPort": {
|
|
161
|
+
"type": "number",
|
|
162
|
+
"description": "The port for the dev server of the remote app.",
|
|
163
|
+
"default": 4200,
|
|
164
|
+
"x-priority": "important"
|
|
165
|
+
},
|
|
166
|
+
"ssr": {
|
|
167
|
+
"description": "Whether to configure SSR for the host application",
|
|
168
|
+
"type": "boolean",
|
|
169
|
+
"default": false
|
|
170
|
+
},
|
|
171
|
+
"minimal": {
|
|
172
|
+
"description": "Generate a React app with a minimal setup. No nx starter template.",
|
|
173
|
+
"type": "boolean",
|
|
174
|
+
"default": false
|
|
175
|
+
},
|
|
176
|
+
"typescriptConfiguration": {
|
|
177
|
+
"type": "boolean",
|
|
178
|
+
"description": "Whether the module federation configuration and webpack configuration files should use TS. When --js is used, this flag is ignored.",
|
|
179
|
+
"default": true
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
"required": ["name"],
|
|
183
|
+
"additionalProperties": false
|
|
184
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reactInitGenerator = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("../../utils/versions");
|
|
6
|
+
async function reactInitGenerator(host, schema) {
|
|
7
|
+
const tasks = [];
|
|
8
|
+
if (!schema.skipPackageJson) {
|
|
9
|
+
tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/react'], []));
|
|
10
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {
|
|
11
|
+
react: versions_1.reactVersion,
|
|
12
|
+
'react-dom': versions_1.reactDomVersion,
|
|
13
|
+
}, {
|
|
14
|
+
'@nx/react': versions_1.nxVersion,
|
|
15
|
+
}, undefined, schema.keepExistingVersions));
|
|
16
|
+
}
|
|
17
|
+
if (!schema.skipFormat) {
|
|
18
|
+
await (0, devkit_1.formatFiles)(host);
|
|
19
|
+
}
|
|
20
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
21
|
+
}
|
|
22
|
+
exports.reactInitGenerator = reactInitGenerator;
|
|
23
|
+
exports.default = reactInitGenerator;
|