@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,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxReactFederateModule",
|
|
5
|
+
"title": "Federate Module",
|
|
6
|
+
"description": "Create a federated module, which can be loaded by a remote host.",
|
|
7
|
+
"examples": [
|
|
8
|
+
{
|
|
9
|
+
"command": "nx g federate-module MyModule --path=./src/component/my-cmp.ts --remote=my-remote-app --remoteDirectory=apps/my-remote-app",
|
|
10
|
+
"description": "Create a federated module from my-remote-app, that exposes my-cmp from ./src/component/my-cmp.ts as MyModule."
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": {
|
|
15
|
+
"path": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"$default": {
|
|
18
|
+
"$source": "argv",
|
|
19
|
+
"index": 0
|
|
20
|
+
},
|
|
21
|
+
"description": "The path to locate the federated module. This path should be relative to the workspace root and the file should exist.",
|
|
22
|
+
"x-prompt": "What is the path to the module to be federated?"
|
|
23
|
+
},
|
|
24
|
+
"name": {
|
|
25
|
+
"description": "The name of the module.",
|
|
26
|
+
"type": "string",
|
|
27
|
+
"x-prompt": "What name would you like to use for the module?",
|
|
28
|
+
"pattern": "^[a-zA-Z][^:]*$",
|
|
29
|
+
"x-priority": "important"
|
|
30
|
+
},
|
|
31
|
+
"remote": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "The name of the remote.",
|
|
34
|
+
"x-prompt": "What is/should the remote be named?"
|
|
35
|
+
},
|
|
36
|
+
"remoteDirectory": {
|
|
37
|
+
"description": "The directory of the new remote application if one needs to be created.",
|
|
38
|
+
"type": "string"
|
|
39
|
+
},
|
|
40
|
+
"projectNameAndRootFormat": {
|
|
41
|
+
"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`).",
|
|
42
|
+
"type": "string",
|
|
43
|
+
"enum": ["as-provided", "derived"]
|
|
44
|
+
},
|
|
45
|
+
"style": {
|
|
46
|
+
"description": "The file extension to be used for style files.",
|
|
47
|
+
"type": "string",
|
|
48
|
+
"default": "none",
|
|
49
|
+
"alias": "s"
|
|
50
|
+
},
|
|
51
|
+
"linter": {
|
|
52
|
+
"description": "The tool to use for running lint checks.",
|
|
53
|
+
"type": "string",
|
|
54
|
+
"enum": ["eslint"],
|
|
55
|
+
"default": "eslint"
|
|
56
|
+
},
|
|
57
|
+
"skipFormat": {
|
|
58
|
+
"description": "Skip formatting files.",
|
|
59
|
+
"type": "boolean",
|
|
60
|
+
"default": false,
|
|
61
|
+
"x-priority": "internal"
|
|
62
|
+
},
|
|
63
|
+
"unitTestRunner": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"enum": ["jest", "none"],
|
|
66
|
+
"description": "Test runner to use for unit tests.",
|
|
67
|
+
"default": "jest"
|
|
68
|
+
},
|
|
69
|
+
"e2eTestRunner": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"enum": ["cypress", "playwright", "none"],
|
|
72
|
+
"description": "Test runner to use for end to end (E2E) tests.",
|
|
73
|
+
"x-prompt": "Which E2E test runner would you like to use?",
|
|
74
|
+
"default": "cypress"
|
|
75
|
+
},
|
|
76
|
+
"host": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "The host / shell application for this remote."
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"required": ["name", "path", "remote"],
|
|
82
|
+
"additionalProperties": false
|
|
83
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { act, renderHook } from '@testing-library/react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import <%= hookName %> from './<%= fileName %>';
|
|
5
|
+
|
|
6
|
+
describe('<%= hookName %>', () => {
|
|
7
|
+
it('should render successfully', () => {
|
|
8
|
+
const { result } = renderHook(() => <%= hookName %>());
|
|
9
|
+
|
|
10
|
+
expect(result.current.count).toBe(0);
|
|
11
|
+
|
|
12
|
+
act(() => {
|
|
13
|
+
result.current.increment()
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
expect(result.current.count).toBe(1);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react'
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
4
|
+
export interface <%= hookTypeName %> {
|
|
5
|
+
count: number;
|
|
6
|
+
increment: () => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function <%= hookName %>(): <%= hookTypeName %> {
|
|
10
|
+
const [count, setCount] = useState(0)
|
|
11
|
+
const increment = useCallback(() => setCount((x) => x + 1), [])
|
|
12
|
+
return { count, increment }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default <%= hookName %>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from './schema';
|
|
3
|
+
export declare function hookGenerator(host: Tree, schema: Schema): Promise<void>;
|
|
4
|
+
export declare function hookGeneratorInternal(host: Tree, schema: Schema): Promise<void>;
|
|
5
|
+
export default hookGenerator;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hookGeneratorInternal = exports.hookGenerator = void 0;
|
|
4
|
+
// TODO(jack): Remove inline renderHook function when RTL releases with its own version
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const ast_utils_1 = require("../../utils/ast-utils");
|
|
7
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
10
|
+
async function hookGenerator(host, schema) {
|
|
11
|
+
return hookGeneratorInternal(host, {
|
|
12
|
+
nameAndDirectoryFormat: 'derived',
|
|
13
|
+
...schema,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.hookGenerator = hookGenerator;
|
|
17
|
+
async function hookGeneratorInternal(host, schema) {
|
|
18
|
+
const options = await normalizeOptions(host, schema);
|
|
19
|
+
createFiles(host, options);
|
|
20
|
+
addExportsToBarrel(host, options);
|
|
21
|
+
return await (0, devkit_1.formatFiles)(host);
|
|
22
|
+
}
|
|
23
|
+
exports.hookGeneratorInternal = hookGeneratorInternal;
|
|
24
|
+
function createFiles(host, options) {
|
|
25
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), options.directory, {
|
|
26
|
+
...options,
|
|
27
|
+
tmpl: '',
|
|
28
|
+
});
|
|
29
|
+
for (const c of host.listChanges()) {
|
|
30
|
+
let deleteFile = false;
|
|
31
|
+
if (options.skipTests && /.*spec.ts/.test(c.path)) {
|
|
32
|
+
deleteFile = true;
|
|
33
|
+
}
|
|
34
|
+
if (deleteFile) {
|
|
35
|
+
host.delete(c.path);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (options.js) {
|
|
39
|
+
(0, devkit_1.toJS)(host);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
let tsModule;
|
|
43
|
+
function addExportsToBarrel(host, options) {
|
|
44
|
+
if (!tsModule) {
|
|
45
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
46
|
+
}
|
|
47
|
+
const workspace = (0, devkit_1.getProjects)(host);
|
|
48
|
+
const isApp = workspace.get(options.projectName).projectType === 'application';
|
|
49
|
+
if (options.export && !isApp) {
|
|
50
|
+
const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts');
|
|
51
|
+
const indexSource = host.read(indexFilePath, 'utf-8');
|
|
52
|
+
if (indexSource !== null) {
|
|
53
|
+
const indexSourceFile = tsModule.createSourceFile(indexFilePath, indexSource, tsModule.ScriptTarget.Latest, true);
|
|
54
|
+
const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, ast_utils_1.addImport)(indexSourceFile, `export * from './${options.directory}/${options.fileName}';`));
|
|
55
|
+
host.write(indexFilePath, changes);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function normalizeOptions(host, options) {
|
|
60
|
+
assertValidOptions(options);
|
|
61
|
+
const { artifactName: name, directory: _directory, fileName: _fileName, nameAndDirectoryFormat, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
62
|
+
artifactType: 'hook',
|
|
63
|
+
callingGenerator: '@nx/react:hook',
|
|
64
|
+
name: options.name,
|
|
65
|
+
directory: options.directory,
|
|
66
|
+
derivedDirectory: options.directory,
|
|
67
|
+
flat: options.flat,
|
|
68
|
+
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
69
|
+
project: options.project,
|
|
70
|
+
fileExtension: 'tsx',
|
|
71
|
+
pascalCaseFile: options.pascalCaseFiles,
|
|
72
|
+
pascalCaseDirectory: options.pascalCaseDirectory,
|
|
73
|
+
});
|
|
74
|
+
let base = _fileName;
|
|
75
|
+
if (base.startsWith('use-')) {
|
|
76
|
+
base = base.substring(4);
|
|
77
|
+
}
|
|
78
|
+
else if (base.startsWith('use')) {
|
|
79
|
+
base = base.substring(3);
|
|
80
|
+
}
|
|
81
|
+
const { className, fileName } = (0, devkit_1.names)(base);
|
|
82
|
+
// If using `as-provided` file and directory, then don't normalize.
|
|
83
|
+
// Otherwise, support legacy behavior of prefixing filename with `use-`.
|
|
84
|
+
const hookFilename = nameAndDirectoryFormat === 'as-provided'
|
|
85
|
+
? fileName
|
|
86
|
+
: options.pascalCaseFiles
|
|
87
|
+
? 'use'.concat(className)
|
|
88
|
+
: 'use-'.concat(fileName);
|
|
89
|
+
const hookName = 'use'.concat(className);
|
|
90
|
+
const hookTypeName = 'Use'.concat(className);
|
|
91
|
+
const project = (0, devkit_1.getProjects)(host).get(projectName);
|
|
92
|
+
const { sourceRoot: projectSourceRoot, projectType } = project;
|
|
93
|
+
if (options.export && projectType === 'application') {
|
|
94
|
+
devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
|
|
95
|
+
}
|
|
96
|
+
// Support legacy behavior of derived directory to prefix with `use-`.
|
|
97
|
+
let directory = _directory;
|
|
98
|
+
if (nameAndDirectoryFormat === 'derived') {
|
|
99
|
+
const parts = directory.split('/');
|
|
100
|
+
parts.pop();
|
|
101
|
+
if (!options.flat) {
|
|
102
|
+
parts.push(options.pascalCaseDirectory
|
|
103
|
+
? 'use'.concat(className)
|
|
104
|
+
: 'use-'.concat(fileName));
|
|
105
|
+
}
|
|
106
|
+
directory = parts.join('/');
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
...options,
|
|
110
|
+
directory,
|
|
111
|
+
hookName,
|
|
112
|
+
hookTypeName,
|
|
113
|
+
fileName: hookFilename,
|
|
114
|
+
projectSourceRoot,
|
|
115
|
+
projectName,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function assertValidOptions(options) {
|
|
119
|
+
const slashes = ['/', '\\'];
|
|
120
|
+
slashes.forEach((s) => {
|
|
121
|
+
if (options.name.indexOf(s) !== -1) {
|
|
122
|
+
const [name, ...rest] = options.name.split(s).reverse();
|
|
123
|
+
let suggestion = rest.map((x) => x.toLowerCase()).join(s);
|
|
124
|
+
if (options.directory) {
|
|
125
|
+
suggestion = `${options.directory}${s}${suggestion}`;
|
|
126
|
+
}
|
|
127
|
+
throw new Error(`Found "${s}" in the hook name. Did you mean to use the --directory option (e.g. \`nx g c ${name} --directory ${suggestion}\`)?`);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
exports.default = hookGenerator;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface Schema {
|
|
2
|
+
name: string;
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
5
|
+
*/
|
|
6
|
+
project: string;
|
|
7
|
+
skipTests?: boolean;
|
|
8
|
+
directory?: string;
|
|
9
|
+
export?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Provide the `name` option instead and use the `as-provided` format. This option will be removed in Nx v19.
|
|
12
|
+
*/
|
|
13
|
+
pascalCaseFiles?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
|
|
16
|
+
*/
|
|
17
|
+
pascalCaseDirectory?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
|
|
20
|
+
*/
|
|
21
|
+
flat?: boolean;
|
|
22
|
+
js?: boolean;
|
|
23
|
+
nameAndDirectoryFormat?: 'as-provided' | 'derived';
|
|
24
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxReactHook",
|
|
5
|
+
"title": "Create a React Hook for Nx",
|
|
6
|
+
"description": "Create a React component using Hooks in a dedicated React project.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"examples": [
|
|
9
|
+
{
|
|
10
|
+
"command": "nx g hook my-hook --project=mylib",
|
|
11
|
+
"description": "Generate a hook in the `mylib` library"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"properties": {
|
|
15
|
+
"project": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "The name of the project.",
|
|
18
|
+
"alias": "p",
|
|
19
|
+
"$default": {
|
|
20
|
+
"$source": "projectName"
|
|
21
|
+
},
|
|
22
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
|
|
23
|
+
},
|
|
24
|
+
"name": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "The name of the hook.",
|
|
27
|
+
"$default": {
|
|
28
|
+
"$source": "argv",
|
|
29
|
+
"index": 0
|
|
30
|
+
},
|
|
31
|
+
"x-prompt": "What name would you like to use for the hook?",
|
|
32
|
+
"x-priority": "important"
|
|
33
|
+
},
|
|
34
|
+
"js": {
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
37
|
+
"default": false
|
|
38
|
+
},
|
|
39
|
+
"skipTests": {
|
|
40
|
+
"type": "boolean",
|
|
41
|
+
"description": "When true, does not create `spec.ts` test files for the new hook.",
|
|
42
|
+
"default": false,
|
|
43
|
+
"x-priority": "internal"
|
|
44
|
+
},
|
|
45
|
+
"directory": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "The directory at which to create the hook file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the project root.",
|
|
48
|
+
"x-priority": "important"
|
|
49
|
+
},
|
|
50
|
+
"nameAndDirectoryFormat": {
|
|
51
|
+
"description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
|
|
52
|
+
"type": "string",
|
|
53
|
+
"enum": ["as-provided", "derived"]
|
|
54
|
+
},
|
|
55
|
+
"flat": {
|
|
56
|
+
"type": "boolean",
|
|
57
|
+
"description": "Create hook at the source root rather than its own directory.",
|
|
58
|
+
"default": false,
|
|
59
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19."
|
|
60
|
+
},
|
|
61
|
+
"export": {
|
|
62
|
+
"type": "boolean",
|
|
63
|
+
"description": "When true, the hook is exported from the project `index.ts` (if it exists).",
|
|
64
|
+
"alias": "e",
|
|
65
|
+
"default": false,
|
|
66
|
+
"x-prompt": "Should this hook be exported in the project?"
|
|
67
|
+
},
|
|
68
|
+
"pascalCaseFiles": {
|
|
69
|
+
"type": "boolean",
|
|
70
|
+
"description": "Use pascal case hook file name (e.g. `useHook.ts`).",
|
|
71
|
+
"alias": "P",
|
|
72
|
+
"default": false,
|
|
73
|
+
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
|
|
74
|
+
},
|
|
75
|
+
"pascalCaseDirectory": {
|
|
76
|
+
"type": "boolean",
|
|
77
|
+
"description": "Use pascal case directory name (e.g. `useHook/useHook.ts`).",
|
|
78
|
+
"alias": "R",
|
|
79
|
+
"default": false,
|
|
80
|
+
"x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"required": ["name"]
|
|
84
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
<% if (!minimal) { %>
|
|
3
|
+
import NxWelcome from "./nx-welcome";
|
|
4
|
+
<% } %>
|
|
5
|
+
import { Link, Route, Routes } from 'react-router-dom';
|
|
6
|
+
|
|
7
|
+
<% if (remotes.length > 0) { %>
|
|
8
|
+
<% remotes.forEach(function(r) { %>
|
|
9
|
+
const <%= r.className %> = React.lazy(() => import('<%= r.fileName %>/Module'));
|
|
10
|
+
<% }); %>
|
|
11
|
+
<% } %>
|
|
12
|
+
export function App() {
|
|
13
|
+
return (
|
|
14
|
+
<React.Suspense fallback={null}>
|
|
15
|
+
<ul>
|
|
16
|
+
<li><Link to="/">Home</Link></li>
|
|
17
|
+
<% remotes.forEach(function(r) { %>
|
|
18
|
+
<li><Link to="/<%=r.fileName%>"><%=r.className%></Link></li>
|
|
19
|
+
<% }); %>
|
|
20
|
+
</ul>
|
|
21
|
+
<Routes>
|
|
22
|
+
<% if (!minimal) { %>
|
|
23
|
+
<Route path="/" element={<NxWelcome title="<%= projectName %>"/>} />
|
|
24
|
+
<% } %>
|
|
25
|
+
<% remotes.forEach(function(r) { %>
|
|
26
|
+
<Route path="/<%=r.fileName%>" element={<<%= r.className %>/>} />
|
|
27
|
+
<% }); %>
|
|
28
|
+
</Routes>
|
|
29
|
+
</React.Suspense>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default App;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<% if (dynamic) { %>
|
|
2
|
+
import { setRemoteDefinitions } from '@nx/react/mf';
|
|
3
|
+
|
|
4
|
+
fetch('/assets/module-federation.manifest.json')
|
|
5
|
+
.then((res) => res.json())
|
|
6
|
+
.then(definitions => setRemoteDefinitions(definitions))
|
|
7
|
+
.then(() => import('./bootstrap').catch(err => console.error(err)));
|
|
8
|
+
<% } else { %>
|
|
9
|
+
import('./bootstrap').catch(err => console.error(err));
|
|
10
|
+
<% } %>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"types": [
|
|
6
|
+
"node",
|
|
7
|
+
"@nx/react/typings/cssmodule.d.ts",
|
|
8
|
+
"@nx/react/typings/image.d.ts"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
"include": [
|
|
12
|
+
"src/**/*.js",
|
|
13
|
+
"src/**/*.jsx",
|
|
14
|
+
"src/**/*.ts",
|
|
15
|
+
"src/**/*.tsx",
|
|
16
|
+
"webpack.config.ts",
|
|
17
|
+
"webpack.prod.config.ts"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
<% if (!minimal) { %>
|
|
3
|
+
import NxWelcome from "./nx-welcome";
|
|
4
|
+
<% } %>
|
|
5
|
+
import { Link, Route, Routes } from 'react-router-dom';
|
|
6
|
+
<% if (dynamic) { %>
|
|
7
|
+
import { loadRemoteModule } from '@nx/react/mf';
|
|
8
|
+
<% } %>
|
|
9
|
+
|
|
10
|
+
<% if (remotes.length > 0) { %>
|
|
11
|
+
<% remotes.forEach(function(r) { %>
|
|
12
|
+
<% if (dynamic) { %>
|
|
13
|
+
const <%= r.className %> = React.lazy(() => loadRemoteModule('<%= r.fileName %>', './Module'))
|
|
14
|
+
<% } else { %>
|
|
15
|
+
const <%= r.className %> = React.lazy(() => import('<%= r.fileName %>/Module'));
|
|
16
|
+
<% } %>
|
|
17
|
+
<% }); %>
|
|
18
|
+
<% } %>
|
|
19
|
+
|
|
20
|
+
export function App() {
|
|
21
|
+
return (
|
|
22
|
+
<React.Suspense fallback={null}>
|
|
23
|
+
<ul>
|
|
24
|
+
<li><Link to="/">Home</Link></li>
|
|
25
|
+
<% remotes.forEach(function(r) { %>
|
|
26
|
+
<li><Link to="/<%=r.fileName%>"><%=r.className%></Link></li>
|
|
27
|
+
<% }); %>
|
|
28
|
+
</ul>
|
|
29
|
+
<Routes>
|
|
30
|
+
<% if (!minimal) { %>
|
|
31
|
+
<Route path="/" element={<NxWelcome title="<%= projectName %>"/>} />
|
|
32
|
+
<% } %>
|
|
33
|
+
<% remotes.forEach(function(r) { %>
|
|
34
|
+
<Route path="/<%=r.fileName%>" element={<<%= r.className %>/>} />
|
|
35
|
+
<% }); %>
|
|
36
|
+
</Routes>
|
|
37
|
+
</React.Suspense>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default App;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<% if (dynamic) { %>
|
|
2
|
+
import { setRemoteDefinitions } from '@nx/react/mf';
|
|
3
|
+
|
|
4
|
+
fetch('/assets/module-federation.manifest.json')
|
|
5
|
+
.then((res) => res.json())
|
|
6
|
+
.then(definitions => setRemoteDefinitions(definitions))
|
|
7
|
+
.then(() => import('./bootstrap').catch(err => console.error(err)));
|
|
8
|
+
<% } else { %>
|
|
9
|
+
import('./bootstrap').catch(err => console.error(err));
|
|
10
|
+
<% } %>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
name: '<%= projectName %>',
|
|
3
|
+
/**
|
|
4
|
+
* To use a remote that does not exist in your current Nx Workspace
|
|
5
|
+
* You can use the tuple-syntax to define your remote
|
|
6
|
+
*
|
|
7
|
+
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
|
|
8
|
+
*
|
|
9
|
+
* You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
|
|
10
|
+
* following content:
|
|
11
|
+
*
|
|
12
|
+
* declare module 'my-external-remote';
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
remotes: [
|
|
16
|
+
<% if (static) {
|
|
17
|
+
remotes.forEach(function(r) { %> "<%= r.fileName %>", <% });
|
|
18
|
+
}
|
|
19
|
+
%>
|
|
20
|
+
],
|
|
21
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const { composePlugins, withNx } = require('@nx/webpack');
|
|
2
|
+
const { withReact } = require('@nx/react');
|
|
3
|
+
const { withModuleFederation } = require('@nx/react/module-federation');
|
|
4
|
+
|
|
5
|
+
const baseConfig = require('./module-federation.config');
|
|
6
|
+
|
|
7
|
+
const config = {
|
|
8
|
+
...baseConfig,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Nx plugins for webpack to build config object from Nx options and context.
|
|
12
|
+
module.exports = composePlugins(withNx(), withReact(), withModuleFederation(config));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const { composePlugins, withNx } = require('@nx/webpack');
|
|
2
|
+
const { withReact } = require('@nx/react');
|
|
3
|
+
const { withModuleFederation } = require('@nx/react/module-federation');
|
|
4
|
+
|
|
5
|
+
const baseConfig = require('./module-federation.config');
|
|
6
|
+
|
|
7
|
+
const prodConfig = {
|
|
8
|
+
...baseConfig,
|
|
9
|
+
/*
|
|
10
|
+
* Remote overrides for production.
|
|
11
|
+
* Each entry is a pair of a unique name and the URL where it is deployed.
|
|
12
|
+
*
|
|
13
|
+
* e.g.
|
|
14
|
+
* remotes: [
|
|
15
|
+
* ['app1', 'http://app1.example.com'],
|
|
16
|
+
* ['app2', 'http://app2.example.com'],
|
|
17
|
+
* ]
|
|
18
|
+
*
|
|
19
|
+
* You can also use a full path to the remoteEntry.js file if desired.
|
|
20
|
+
*
|
|
21
|
+
* remotes: [
|
|
22
|
+
* ['app1', 'http://example.com/path/to/app1/remoteEntry.js'],
|
|
23
|
+
* ['app2', 'http://example.com/path/to/app2/remoteEntry.js'],
|
|
24
|
+
* ]
|
|
25
|
+
*/
|
|
26
|
+
remotes: [
|
|
27
|
+
<% remotes.forEach(function(r) {%>['<%= r.fileName %>', 'http://localhost:<%= r.port %>/'],<% }); %>
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Nx plugins for webpack to build config object from Nx options and context.
|
|
32
|
+
module.exports = composePlugins(withNx(), withReact(), withModuleFederation(prodConfig));
|
package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @type {import('@nx/webpack').ModuleFederationConfig}
|
|
5
|
+
**/
|
|
6
|
+
const moduleFederationConfig = {
|
|
7
|
+
name: '<%= projectName %>',
|
|
8
|
+
remotes: [
|
|
9
|
+
<% if (static) {
|
|
10
|
+
remotes.forEach(function(r) { %> "<%= r.fileName %>", <% });
|
|
11
|
+
}
|
|
12
|
+
%>
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = moduleFederationConfig;
|
|
@@ -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
|
+
const {composePlugins, withNx} = require('@nx/webpack');
|
|
2
|
+
const {withReact} = require('@nx/react');
|
|
3
|
+
const {withModuleFederationForSSR} = require('@nx/react/module-federation');
|
|
4
|
+
|
|
5
|
+
const baseConfig = require('./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
|
+
module.exports = composePlugins(withNx(), withReact({ssr: true}), withModuleFederationForSSR(defaultConfig));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModuleFederationConfig } from '@nx/webpack';
|
|
2
|
+
|
|
3
|
+
const config: ModuleFederationConfig = {
|
|
4
|
+
name: '<%= projectName %>',
|
|
5
|
+
remotes: [
|
|
6
|
+
<% if (static) {
|
|
7
|
+
remotes.forEach(function(r) { %> "<%= r.fileName %>", <% });
|
|
8
|
+
}
|
|
9
|
+
%>
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default config;
|