@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,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reduxGeneratorInternal = exports.reduxGenerator = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const ast_utils_1 = require("../../utils/ast-utils");
|
|
6
|
+
const versions_1 = require("../../utils/versions");
|
|
7
|
+
const devkit_1 = require("@nx/devkit");
|
|
8
|
+
const js_1 = require("@nx/js");
|
|
9
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
10
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
11
|
+
let tsModule;
|
|
12
|
+
async function reduxGenerator(host, schema) {
|
|
13
|
+
return reduxGeneratorInternal(host, {
|
|
14
|
+
nameAndDirectoryFormat: 'derived',
|
|
15
|
+
...schema,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
exports.reduxGenerator = reduxGenerator;
|
|
19
|
+
async function reduxGeneratorInternal(host, schema) {
|
|
20
|
+
const options = await normalizeOptions(host, schema);
|
|
21
|
+
generateReduxFiles(host, options);
|
|
22
|
+
addExportsToBarrel(host, options);
|
|
23
|
+
const installTask = addReduxPackageDependencies(host);
|
|
24
|
+
addStoreConfiguration(host, options);
|
|
25
|
+
updateReducerConfiguration(host, options);
|
|
26
|
+
await (0, devkit_1.formatFiles)(host);
|
|
27
|
+
return installTask;
|
|
28
|
+
}
|
|
29
|
+
exports.reduxGeneratorInternal = reduxGeneratorInternal;
|
|
30
|
+
function generateReduxFiles(host, options) {
|
|
31
|
+
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files'), options.directory, {
|
|
32
|
+
...options,
|
|
33
|
+
tmpl: '',
|
|
34
|
+
});
|
|
35
|
+
if (options.js) {
|
|
36
|
+
(0, devkit_1.toJS)(host);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function addReduxPackageDependencies(host) {
|
|
40
|
+
return (0, devkit_1.addDependenciesToPackageJson)(host, {
|
|
41
|
+
'@reduxjs/toolkit': versions_1.reduxjsToolkitVersion,
|
|
42
|
+
'react-redux': versions_1.reactReduxVersion,
|
|
43
|
+
}, {});
|
|
44
|
+
}
|
|
45
|
+
function addExportsToBarrel(host, options) {
|
|
46
|
+
if (!tsModule) {
|
|
47
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
48
|
+
}
|
|
49
|
+
const indexFilePath = path.join(options.projectSourcePath, options.js ? 'index.js' : 'index.ts');
|
|
50
|
+
const indexSource = host.read(indexFilePath, 'utf-8');
|
|
51
|
+
if (indexSource !== null) {
|
|
52
|
+
const indexSourceFile = tsModule.createSourceFile(indexFilePath, indexSource, tsModule.ScriptTarget.Latest, true);
|
|
53
|
+
const statePath = options.directory
|
|
54
|
+
? `./lib/${options.directory}/${options.fileName}`
|
|
55
|
+
: `./lib/${options.fileName}`;
|
|
56
|
+
const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, ast_utils_1.addImport)(indexSourceFile, `export * from '${statePath}.slice';`));
|
|
57
|
+
host.write(indexFilePath, changes);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function addStoreConfiguration(host, options) {
|
|
61
|
+
if (!options.appProjectSourcePath) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const mainSource = host.read(options.appMainFilePath, 'utf-8');
|
|
65
|
+
if (!mainSource.includes('redux')) {
|
|
66
|
+
const mainSourceFile = tsModule.createSourceFile(options.appMainFilePath, mainSource, tsModule.ScriptTarget.Latest, true);
|
|
67
|
+
const changes = (0, devkit_1.applyChangesToString)(mainSource, (0, ast_utils_1.addReduxStoreToMain)(options.appMainFilePath, mainSourceFile));
|
|
68
|
+
host.write(options.appMainFilePath, changes);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function updateReducerConfiguration(host, options) {
|
|
72
|
+
if (!tsModule) {
|
|
73
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
74
|
+
}
|
|
75
|
+
if (!options.appProjectSourcePath) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const mainSource = host.read(options.appMainFilePath, 'utf-8');
|
|
79
|
+
const mainSourceFile = tsModule.createSourceFile(options.appMainFilePath, mainSource, tsModule.ScriptTarget.Latest, true);
|
|
80
|
+
const changes = (0, devkit_1.applyChangesToString)(mainSource, (0, ast_utils_1.updateReduxStore)(options.appMainFilePath, mainSourceFile, {
|
|
81
|
+
keyName: `${options.constantName}_FEATURE_KEY`,
|
|
82
|
+
reducerName: `${options.propertyName}Reducer`,
|
|
83
|
+
modulePath: `${options.projectModulePath}`,
|
|
84
|
+
}));
|
|
85
|
+
host.write(options.appMainFilePath, changes);
|
|
86
|
+
}
|
|
87
|
+
async function normalizeOptions(host, options) {
|
|
88
|
+
const { artifactName: name, directory, fileName, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
89
|
+
artifactType: 'slice',
|
|
90
|
+
callingGenerator: '@nx/react:redux',
|
|
91
|
+
name: options.name,
|
|
92
|
+
directory: options.directory,
|
|
93
|
+
derivedDirectory: options.directory,
|
|
94
|
+
flat: true,
|
|
95
|
+
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
96
|
+
project: options.project,
|
|
97
|
+
fileExtension: 'tsx',
|
|
98
|
+
});
|
|
99
|
+
let appProjectSourcePath;
|
|
100
|
+
let appMainFilePath;
|
|
101
|
+
const extraNames = (0, devkit_1.names)(name);
|
|
102
|
+
const projects = (0, devkit_1.getProjects)(host);
|
|
103
|
+
const project = projects.get(projectName);
|
|
104
|
+
const { sourceRoot, projectType } = project;
|
|
105
|
+
const tsConfigJson = (0, devkit_1.readJson)(host, (0, js_1.getRootTsConfigPathInTree)(host));
|
|
106
|
+
const tsPaths = tsConfigJson.compilerOptions
|
|
107
|
+
? tsConfigJson.compilerOptions.paths || {}
|
|
108
|
+
: {};
|
|
109
|
+
const modulePath = projectType === 'application'
|
|
110
|
+
? options.directory
|
|
111
|
+
? `./app/${options.directory}/${extraNames.fileName}.slice`
|
|
112
|
+
: `./app/${extraNames.fileName}.slice`
|
|
113
|
+
: Object.keys(tsPaths).find((k) => tsPaths[k].some((s) => s.includes(sourceRoot)));
|
|
114
|
+
// If --project is set to an app, automatically configure store
|
|
115
|
+
// for it without needing to specify --appProject.
|
|
116
|
+
options.appProject =
|
|
117
|
+
options.appProject ||
|
|
118
|
+
(projectType === 'application' ? projectName : undefined);
|
|
119
|
+
if (options.appProject) {
|
|
120
|
+
const appConfig = projects.get(options.appProject);
|
|
121
|
+
if (appConfig.projectType !== 'application') {
|
|
122
|
+
throw new Error(`Expected ${options.appProject} to be an application but got ${appConfig.projectType}`);
|
|
123
|
+
}
|
|
124
|
+
appProjectSourcePath = appConfig.sourceRoot;
|
|
125
|
+
appMainFilePath = path.join(appProjectSourcePath, options.js ? 'main.js' : 'main.tsx');
|
|
126
|
+
if (!host.exists(appMainFilePath)) {
|
|
127
|
+
throw new Error(`Could not find ${appMainFilePath} during store configuration`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
...options,
|
|
132
|
+
...extraNames,
|
|
133
|
+
fileName,
|
|
134
|
+
constantName: (0, devkit_1.names)(options.name).constantName.toUpperCase(),
|
|
135
|
+
directory,
|
|
136
|
+
projectType,
|
|
137
|
+
projectSourcePath: sourceRoot,
|
|
138
|
+
projectModulePath: modulePath,
|
|
139
|
+
appProjectSourcePath,
|
|
140
|
+
appMainFilePath,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
exports.default = reduxGenerator;
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
directory?: string;
|
|
8
|
+
appProject?: string;
|
|
9
|
+
js?: string;
|
|
10
|
+
nameAndDirectoryFormat?: 'as-provided' | 'derived';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface NormalizedSchema extends Schema {
|
|
14
|
+
projectType: string;
|
|
15
|
+
projectSourcePath: string;
|
|
16
|
+
projectModulePath: string;
|
|
17
|
+
appProjectSourcePath: string;
|
|
18
|
+
appMainFilePath: string;
|
|
19
|
+
className: string;
|
|
20
|
+
constantName: string;
|
|
21
|
+
propertyName: string;
|
|
22
|
+
fileName: string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "redux",
|
|
5
|
+
"title": "Create Redux state",
|
|
6
|
+
"description": "Create a Redux state slice for a React project.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Redux slice name.",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
|
+
},
|
|
16
|
+
"x-priority": "important"
|
|
17
|
+
},
|
|
18
|
+
"project": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "The name of the project to add the slice to. If it is an application, then the store configuration will be updated too.",
|
|
21
|
+
"alias": "p",
|
|
22
|
+
"$default": {
|
|
23
|
+
"$source": "projectName"
|
|
24
|
+
},
|
|
25
|
+
"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."
|
|
26
|
+
},
|
|
27
|
+
"directory": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"alias": "dir",
|
|
30
|
+
"default": "",
|
|
31
|
+
"description": "The directory at which to create the Redux files. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the project root.",
|
|
32
|
+
"x-priority": "important"
|
|
33
|
+
},
|
|
34
|
+
"nameAndDirectoryFormat": {
|
|
35
|
+
"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`).",
|
|
36
|
+
"type": "string",
|
|
37
|
+
"enum": ["as-provided", "derived"]
|
|
38
|
+
},
|
|
39
|
+
"appProject": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "The application project to add the slice to.",
|
|
42
|
+
"alias": "a"
|
|
43
|
+
},
|
|
44
|
+
"js": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
47
|
+
"default": false
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"required": ["name"]
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import('./bootstrap');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './app/app';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import('./bootstrap');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './app/app';
|
|
@@ -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 @@
|
|
|
1
|
+
module.exports = require('./webpack.config');
|
|
@@ -0,0 +1,45 @@
|
|
|
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 serverDist = path.join(process.cwd(), '<%= serverBuildOutputPath %>');
|
|
12
|
+
const indexPath = path.join(browserDist, 'index.html');
|
|
13
|
+
|
|
14
|
+
app.use(cors());
|
|
15
|
+
|
|
16
|
+
// Client-side static bundles
|
|
17
|
+
app.get(
|
|
18
|
+
'*.*',
|
|
19
|
+
express.static(browserDist, {
|
|
20
|
+
maxAge: '1y',
|
|
21
|
+
})
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
// Static bundles for server-side module federation
|
|
25
|
+
app.use('/server',
|
|
26
|
+
express.static(serverDist, {
|
|
27
|
+
maxAge: '1y'
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
app.use('*', handleRequest(indexPath));
|
|
32
|
+
|
|
33
|
+
const server = app.listen(port, () => {
|
|
34
|
+
console.log(`Express server listening on http://localhost:${port}`);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* DO NOT REMOVE IF USING @nx/react:module-federation-dev-ssr executor
|
|
38
|
+
* to serve your Host application with this Remote application.
|
|
39
|
+
* This message allows Nx to determine when the Remote is ready to be
|
|
40
|
+
* consumed by the Host.
|
|
41
|
+
*/
|
|
42
|
+
process.send?.('nx.server.ready');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
server.on('error', console.error);
|
|
@@ -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.server.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,45 @@
|
|
|
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 serverDist = path.join(process.cwd(), '<%= serverBuildOutputPath %>');
|
|
12
|
+
const indexPath = path.join(browserDist, 'index.html');
|
|
13
|
+
|
|
14
|
+
app.use(cors());
|
|
15
|
+
|
|
16
|
+
// Client-side static bundles
|
|
17
|
+
app.get(
|
|
18
|
+
'*.*',
|
|
19
|
+
express.static(browserDist, {
|
|
20
|
+
maxAge: '1y',
|
|
21
|
+
})
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
// Static bundles for server-side module federation
|
|
25
|
+
app.use('/server',
|
|
26
|
+
express.static(serverDist, {
|
|
27
|
+
maxAge: '1y'
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
app.use('*', handleRequest(indexPath));
|
|
32
|
+
|
|
33
|
+
const server = app.listen(port, () => {
|
|
34
|
+
console.log(`Express server listening on http://localhost:${port}`);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* DO NOT REMOVE IF USING @nx/react:module-federation-dev-ssr executor
|
|
38
|
+
* to serve your Host application with this Remote application.
|
|
39
|
+
* This message allows Nx to determine when the Remote is ready to be
|
|
40
|
+
* consumed by the Host.
|
|
41
|
+
*/
|
|
42
|
+
process.send?.('nx.server.ready');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
server.on('error', console.error);
|
|
@@ -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,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.server.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,13 @@
|
|
|
1
|
+
import {ModuleFederationConfig} from '@nx/webpack';
|
|
2
|
+
|
|
3
|
+
const config: ModuleFederationConfig = {
|
|
4
|
+
name: '<%= projectName %>',
|
|
5
|
+
<% if (dynamic) { %>
|
|
6
|
+
library: { type: 'var', name: '<%= projectName %>'},
|
|
7
|
+
<% } %>
|
|
8
|
+
exposes: {
|
|
9
|
+
'./Module': './src/remote-entry.<%= js ? 'js' : 'ts' %>',
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default config;
|
|
@@ -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 @@
|
|
|
1
|
+
export default require('./webpack.config');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {composePlugins, withNx} 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 = {
|
|
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,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addRemoteToDynamicHost = void 0;
|
|
4
|
+
function addRemoteToDynamicHost(tree, remoteName, remotePort, pathToMfManifest) {
|
|
5
|
+
const current = tree.read(pathToMfManifest, 'utf8');
|
|
6
|
+
tree.write(pathToMfManifest, JSON.stringify({
|
|
7
|
+
...JSON.parse(current),
|
|
8
|
+
[remoteName]: `http://localhost:${remotePort}`,
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
exports.addRemoteToDynamicHost = addRemoteToDynamicHost;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema } from '../../application/schema';
|
|
3
|
+
import type { Schema } from '../schema';
|
|
4
|
+
export declare function setupSsrForRemote(tree: Tree, options: NormalizedSchema<Schema>, appName: string): Promise<GeneratorCallback>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupSsrForRemote = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("../../../utils/versions");
|
|
6
|
+
async function setupSsrForRemote(tree, options, appName) {
|
|
7
|
+
const tasks = [];
|
|
8
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, appName);
|
|
9
|
+
const pathToModuleFederationSsrFiles = options.typescriptConfiguration
|
|
10
|
+
? 'module-federation-ssr-ts'
|
|
11
|
+
: 'module-federation-ssr';
|
|
12
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, `../files/${pathToModuleFederationSsrFiles}`), project.root, {
|
|
13
|
+
...options,
|
|
14
|
+
appName,
|
|
15
|
+
tmpl: '',
|
|
16
|
+
browserBuildOutputPath: project.targets.build.options.outputPath,
|
|
17
|
+
serverBuildOutputPath: project.targets.server.options.outputPath,
|
|
18
|
+
});
|
|
19
|
+
// For hosts to use when running remotes in static mode.
|
|
20
|
+
const originalOutputPath = project.targets.build?.options?.outputPath;
|
|
21
|
+
const serverOptions = project.targets.server?.options;
|
|
22
|
+
const serverOutputPath = serverOptions?.outputPath ??
|
|
23
|
+
(0, devkit_1.joinPathFragments)(originalOutputPath, 'server');
|
|
24
|
+
const serverOutputName = serverOptions?.outputFileName ?? 'main.js';
|
|
25
|
+
project.targets['serve-static'] = {
|
|
26
|
+
dependsOn: ['build', 'server'],
|
|
27
|
+
executor: 'nx:run-commands',
|
|
28
|
+
defaultConfiguration: 'development',
|
|
29
|
+
options: {
|
|
30
|
+
command: `PORT=${options.devServerPort ?? 4200} node ${(0, devkit_1.joinPathFragments)(serverOutputPath, serverOutputName)}`,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
(0, devkit_1.updateProjectConfiguration)(tree, appName, project);
|
|
34
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
35
|
+
'@module-federation/node': versions_1.moduleFederationNodeVersion,
|
|
36
|
+
}, {});
|
|
37
|
+
tasks.push(installTask);
|
|
38
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
39
|
+
}
|
|
40
|
+
exports.setupSsrForRemote = setupSsrForRemote;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupTspathForRemote = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const js_1 = require("@nx/js");
|
|
6
|
+
const maybe_js_1 = require("../../../utils/maybe-js");
|
|
7
|
+
function setupTspathForRemote(tree, options) {
|
|
8
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.name);
|
|
9
|
+
const exportPath = (0, maybe_js_1.maybeJs)(options, './src/remote-entry.ts');
|
|
10
|
+
const exportName = 'Module';
|
|
11
|
+
(0, js_1.addTsConfigPath)(tree, `${options.name}/${exportName}`, [
|
|
12
|
+
(0, devkit_1.joinPathFragments)(project.root, exportPath),
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
exports.setupTspathForRemote = setupTspathForRemote;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateHostWithRemote = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const ast_utils_1 = require("../../../module-federation/ast-utils");
|
|
6
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
7
|
+
let tsModule;
|
|
8
|
+
function updateHostWithRemote(host, hostName, remoteName) {
|
|
9
|
+
if (!tsModule) {
|
|
10
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
11
|
+
}
|
|
12
|
+
const hostConfig = (0, devkit_1.readProjectConfiguration)(host, hostName);
|
|
13
|
+
let moduleFederationConfigPath = (0, devkit_1.joinPathFragments)(hostConfig.root, 'module-federation.config.js');
|
|
14
|
+
if (!host.exists(moduleFederationConfigPath)) {
|
|
15
|
+
moduleFederationConfigPath = (0, devkit_1.joinPathFragments)(hostConfig.root, 'module-federation.config.ts');
|
|
16
|
+
}
|
|
17
|
+
const remoteDefsPath = (0, devkit_1.joinPathFragments)(hostConfig.sourceRoot, 'remotes.d.ts');
|
|
18
|
+
const appComponentPath = findAppComponentPath(host, hostConfig.sourceRoot);
|
|
19
|
+
if (host.exists(moduleFederationConfigPath)) {
|
|
20
|
+
// find the host project path
|
|
21
|
+
// Update remotes inside ${host_path}/src/remotes.d.ts
|
|
22
|
+
let sourceCode = host.read(moduleFederationConfigPath).toString();
|
|
23
|
+
const source = tsModule.createSourceFile(moduleFederationConfigPath, sourceCode, tsModule.ScriptTarget.Latest, true);
|
|
24
|
+
host.write(moduleFederationConfigPath, (0, devkit_1.applyChangesToString)(sourceCode, (0, ast_utils_1.addRemoteToConfig)(source, remoteName)));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// TODO(jack): Point to the nx.dev guide when ready.
|
|
28
|
+
devkit_1.logger.warn(`Could not find configuration at ${moduleFederationConfigPath}. Did you generate this project with "@nx/react:host"?`);
|
|
29
|
+
}
|
|
30
|
+
if (host.exists(remoteDefsPath)) {
|
|
31
|
+
let sourceCode = host.read(remoteDefsPath).toString();
|
|
32
|
+
const source = tsModule.createSourceFile(moduleFederationConfigPath, sourceCode, tsModule.ScriptTarget.Latest, true);
|
|
33
|
+
host.write(remoteDefsPath, (0, devkit_1.applyChangesToString)(sourceCode, (0, ast_utils_1.addRemoteDefinition)(source, remoteName)));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
devkit_1.logger.warn(`Could not find remote definitions at ${remoteDefsPath}. Did you generate this project with "@nx/react:host"?`);
|
|
37
|
+
}
|
|
38
|
+
if (host.exists(appComponentPath)) {
|
|
39
|
+
let sourceCode = host.read(appComponentPath).toString();
|
|
40
|
+
const source = tsModule.createSourceFile(moduleFederationConfigPath, sourceCode, tsModule.ScriptTarget.Latest, true);
|
|
41
|
+
host.write(appComponentPath, (0, devkit_1.applyChangesToString)(sourceCode, (0, ast_utils_1.addRemoteRoute)(source, (0, devkit_1.names)(remoteName))));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
devkit_1.logger.warn(`Could not find app component at ${appComponentPath}. Did you generate this project with "@nx/react:host"?`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.updateHostWithRemote = updateHostWithRemote;
|
|
48
|
+
function findAppComponentPath(host, sourceRoot) {
|
|
49
|
+
const locations = [
|
|
50
|
+
'app/app.tsx',
|
|
51
|
+
'app/App.tsx',
|
|
52
|
+
'app/app.js',
|
|
53
|
+
'app/App.js',
|
|
54
|
+
'app.tsx',
|
|
55
|
+
'App.tsx',
|
|
56
|
+
'app.js',
|
|
57
|
+
'App.js',
|
|
58
|
+
];
|
|
59
|
+
for (const loc of locations) {
|
|
60
|
+
if (host.exists((0, devkit_1.joinPathFragments)(sourceRoot, loc))) {
|
|
61
|
+
return (0, devkit_1.joinPathFragments)(sourceRoot, loc);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema } from '../application/schema';
|
|
3
|
+
import { Schema } from './schema';
|
|
4
|
+
export declare function addModuleFederationFiles(host: Tree, options: NormalizedSchema<Schema>): void;
|
|
5
|
+
export declare function remoteGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
6
|
+
export declare function remoteGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
7
|
+
export default remoteGenerator;
|