@nrwl/react 14.8.8 → 14.9.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/LICENSE +22 -22
- package/README.md +5 -26
- package/babel.d.ts +16 -1
- package/babel.js +4 -3
- package/babel.js.map +1 -1
- package/executors.json +10 -0
- package/generators.json +14 -0
- package/index.d.ts +4 -1
- package/index.js +8 -1
- package/index.js.map +1 -1
- package/migrations.json +160 -0
- package/module-federation.d.ts +2 -2
- package/module-federation.js +4 -4
- package/module-federation.js.map +1 -1
- package/package.json +9 -26
- package/plugins/bundle-rollup.js +20 -0
- package/plugins/bundle-rollup.js.map +1 -1
- package/plugins/component-testing/index.d.ts +13 -5
- package/plugins/component-testing/index.js +31 -44
- package/plugins/component-testing/index.js.map +1 -1
- package/plugins/component-testing/webpack-fallback.js +2 -2
- package/plugins/component-testing/webpack-fallback.js.map +1 -1
- package/plugins/jest.js +10 -6
- package/plugins/jest.js.map +1 -1
- package/plugins/storybook/index.d.ts +0 -4
- package/plugins/storybook/index.js +24 -74
- package/plugins/storybook/index.js.map +1 -1
- package/plugins/storybook/merge-plugins.d.ts +2 -2
- package/plugins/storybook/merge-plugins.js.map +1 -1
- package/plugins/webpack.d.ts +3 -2
- package/plugins/webpack.js +10 -72
- package/plugins/webpack.js.map +1 -1
- package/plugins/with-react.d.ts +12 -0
- package/plugins/with-react.js +82 -0
- package/plugins/with-react.js.map +1 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +6 -2
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +11 -7
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js.map +1 -1
- package/src/executors/module-federation-dev-server/schema.json +18 -4
- package/src/executors/module-federation-ssr-dev-server/compat.d.ts +2 -0
- package/src/executors/module-federation-ssr-dev-server/compat.js +6 -0
- package/src/executors/module-federation-ssr-dev-server/compat.js.map +1 -0
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +9 -0
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +71 -0
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js.map +1 -0
- package/src/executors/module-federation-ssr-dev-server/schema.json +48 -0
- package/src/generators/application/application.js +85 -25
- package/src/generators/application/application.js.map +1 -1
- package/src/generators/application/files/base-vite/index.html__tmpl__ +16 -0
- package/src/generators/application/files/base-vite/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
- package/src/generators/application/files/{common → base-vite}/tsconfig.app.json__tmpl__ +2 -2
- package/src/generators/application/files/base-webpack/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
- package/src/generators/application/files/base-webpack/src/environments/environment.prod.ts__tmpl__ +3 -0
- package/src/generators/application/files/base-webpack/src/environments/environment.ts__tmpl__ +6 -0
- package/src/generators/application/files/base-webpack/src/favicon.ico +0 -0
- package/src/generators/application/files/base-webpack/src/main.tsx__tmpl__ +10 -0
- package/src/generators/application/files/base-webpack/tsconfig.app.json__tmpl__ +14 -0
- package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +9 -0
- package/src/generators/application/files/{common → nx-welcome}/src/app/nx-welcome.tsx +30 -8
- package/src/generators/application/files/{css-module → style-css-module}/src/app/__fileName__.tsx__tmpl__ +11 -0
- package/src/generators/application/files/{global-css → style-global-css}/src/app/__fileName__.tsx__tmpl__ +11 -0
- package/src/generators/application/files/{none → style-none}/src/app/__fileName__.tsx__tmpl__ +11 -0
- package/src/generators/application/files/{styled-jsx → style-styled-jsx}/src/app/__fileName__.tsx__tmpl__ +4 -1
- package/src/generators/application/files/{styled-module → style-styled-module}/src/app/__fileName__.tsx__tmpl__ +11 -0
- package/src/generators/application/lib/add-cypress.d.ts +1 -1
- package/src/generators/application/lib/add-cypress.js +4 -2
- package/src/generators/application/lib/add-cypress.js.map +1 -1
- package/src/generators/application/lib/add-jest.d.ts +2 -2
- package/src/generators/application/lib/add-jest.js +4 -2
- package/src/generators/application/lib/add-jest.js.map +1 -1
- package/src/generators/application/lib/add-project.js +13 -8
- package/src/generators/application/lib/add-project.js.map +1 -1
- package/src/generators/application/lib/add-routing.js +10 -3
- package/src/generators/application/lib/add-routing.js.map +1 -1
- package/src/generators/application/lib/create-application-files.d.ts +1 -1
- package/src/generators/application/lib/create-application-files.js +21 -18
- package/src/generators/application/lib/create-application-files.js.map +1 -1
- package/src/generators/application/lib/get-app-tests.d.ts +2 -0
- package/src/generators/application/lib/get-app-tests.js +22 -0
- package/src/generators/application/lib/get-app-tests.js.map +1 -0
- package/src/generators/application/lib/install-common-dependencies.d.ts +3 -0
- package/src/generators/application/lib/install-common-dependencies.js +29 -0
- package/src/generators/application/lib/install-common-dependencies.js.map +1 -0
- package/src/generators/application/lib/normalize-options.d.ts +1 -1
- package/src/generators/application/lib/normalize-options.js +28 -14
- package/src/generators/application/lib/normalize-options.js.map +1 -1
- package/src/generators/application/lib/set-defaults.js +11 -9
- package/src/generators/application/lib/set-defaults.js.map +1 -1
- package/src/generators/application/lib/update-jest-config.d.ts +1 -1
- package/src/generators/application/lib/update-jest-config.js +7 -4
- package/src/generators/application/lib/update-jest-config.js.map +1 -1
- package/src/generators/application/schema.d.ts +9 -4
- package/src/generators/application/schema.json +42 -10
- package/src/generators/component/component.js +15 -7
- package/src/generators/component/component.js.map +1 -1
- package/src/generators/component/files/__fileName__.spec.tsx__tmpl__ +1 -4
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +4 -2
- package/src/generators/component/get-component-tests.d.ts +2 -0
- package/src/generators/component/get-component-tests.js +13 -0
- package/src/generators/component/get-component-tests.js.map +1 -0
- package/src/generators/component/noramlized-schema.d.ts +8 -0
- package/src/generators/component/noramlized-schema.js +3 -0
- package/src/generators/component/noramlized-schema.js.map +1 -0
- package/src/generators/component/schema.d.ts +1 -0
- package/src/generators/component/schema.json +13 -4
- package/src/generators/component-cypress-spec/component-cypress-spec.d.ts +1 -1
- package/src/generators/component-cypress-spec/component-cypress-spec.js +12 -5
- package/src/generators/component-cypress-spec/component-cypress-spec.js.map +1 -1
- package/src/generators/component-cypress-spec/schema.json +4 -2
- package/src/generators/component-story/component-story.d.ts +1 -1
- package/src/generators/component-story/component-story.js +6 -2
- package/src/generators/component-story/component-story.js.map +1 -1
- package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +6 -7
- package/src/generators/component-story/schema.json +4 -2
- package/src/generators/component-test/component-test.d.ts +1 -1
- package/src/generators/component-test/component-test.js +21 -12
- package/src/generators/component-test/component-test.js.map +1 -1
- package/src/generators/component-test/files/__fileName__.cy__ext__ +2 -3
- package/src/generators/component-test/schema.json +6 -3
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +5 -4
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js.map +1 -1
- package/src/generators/cypress-component-configuration/files/cypress/support/commands.ts__tpl__ +42 -0
- package/src/generators/cypress-component-configuration/files/cypress.config.ts__tpl__ +3 -1
- package/src/generators/cypress-component-configuration/lib/add-files.d.ts +2 -1
- package/src/generators/cypress-component-configuration/lib/add-files.js +52 -16
- package/src/generators/cypress-component-configuration/lib/add-files.js.map +1 -1
- package/src/generators/cypress-component-configuration/lib/update-configs.d.ts +6 -2
- package/src/generators/cypress-component-configuration/lib/update-configs.js +8 -4
- package/src/generators/cypress-component-configuration/lib/update-configs.js.map +1 -1
- package/src/generators/cypress-component-configuration/schema.d.ts +1 -0
- package/src/generators/cypress-component-configuration/schema.json +15 -4
- package/src/generators/hook/hook.js +6 -2
- package/src/generators/hook/hook.js.map +1 -1
- package/src/generators/hook/schema.json +7 -4
- package/src/generators/host/files/common/src/app/__fileName__.tsx__tmpl__ +4 -0
- package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +5 -12
- package/src/generators/host/files/module-federation/webpack.config.js__tmpl__ +7 -8
- package/src/generators/host/files/module-federation/webpack.config.prod.js__tmpl__ +11 -12
- package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +13 -0
- package/src/generators/host/files/module-federation-ssr/server.ts__tmpl__ +28 -0
- package/src/generators/host/files/module-federation-ssr/tsconfig.server.json__tmpl__ +15 -0
- package/src/generators/host/files/module-federation-ssr/webpack.server.config.js__tmpl__ +12 -0
- package/src/generators/host/host.d.ts +2 -2
- package/src/generators/host/host.js +21 -2
- package/src/generators/host/host.js.map +1 -1
- package/src/generators/host/lib/add-module-federation-files.js +1 -1
- package/src/generators/host/lib/add-module-federation-files.js.map +1 -1
- package/src/generators/host/lib/setup-ssr-for-host.d.ts +6 -0
- package/src/generators/host/lib/setup-ssr-for-host.js +27 -0
- package/src/generators/host/lib/setup-ssr-for-host.js.map +1 -0
- package/src/generators/host/schema.d.ts +16 -14
- package/src/generators/host/schema.json +27 -8
- package/src/generators/init/init.js +45 -22
- package/src/generators/init/init.js.map +1 -1
- package/src/generators/init/schema.d.ts +6 -1
- package/src/generators/init/schema.json +16 -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/{lib → vite}/tsconfig.lib.json__tmpl__ +1 -1
- package/src/generators/library/lib/add-linting.d.ts +3 -0
- package/src/generators/library/lib/add-linting.js +37 -0
- package/src/generators/library/lib/add-linting.js.map +1 -0
- package/src/generators/library/lib/add-rollup-build-target.d.ts +3 -0
- package/src/generators/library/lib/add-rollup-build-target.js +59 -0
- package/src/generators/library/lib/add-rollup-build-target.js.map +1 -0
- package/src/generators/library/lib/create-files.d.ts +3 -0
- package/src/generators/library/lib/create-files.js +26 -0
- package/src/generators/library/lib/create-files.js.map +1 -0
- package/src/generators/library/lib/install-common-dependencies.d.ts +3 -0
- package/src/generators/library/lib/install-common-dependencies.js +30 -0
- package/src/generators/library/lib/install-common-dependencies.js.map +1 -0
- package/src/generators/library/lib/maybe-js.d.ts +2 -0
- package/src/generators/library/lib/maybe-js.js +10 -0
- package/src/generators/library/lib/maybe-js.js.map +1 -0
- package/src/generators/library/lib/normalize-options.d.ts +3 -0
- package/src/generators/library/lib/normalize-options.js +57 -0
- package/src/generators/library/lib/normalize-options.js.map +1 -0
- package/src/generators/library/lib/set-defaults.d.ts +3 -0
- package/src/generators/library/lib/set-defaults.js +16 -0
- package/src/generators/library/lib/set-defaults.js.map +1 -0
- package/src/generators/library/lib/update-app-routes.d.ts +3 -0
- package/src/generators/library/lib/update-app-routes.js +63 -0
- package/src/generators/library/lib/update-app-routes.js.map +1 -0
- package/src/generators/library/library.d.ts +0 -10
- package/src/generators/library/library.js +76 -214
- package/src/generators/library/library.js.map +1 -1
- package/src/generators/library/schema.d.ts +34 -16
- package/src/generators/library/schema.json +41 -10
- package/src/generators/redux/redux.js +13 -6
- package/src/generators/redux/redux.js.map +1 -1
- package/src/generators/redux/schema.json +6 -3
- package/src/generators/remote/files/module-federation/module-federation.config.js__tmpl__ +1 -8
- package/src/generators/remote/files/module-federation/webpack.config.js__tmpl__ +7 -8
- package/src/generators/remote/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +6 -0
- package/src/generators/remote/files/module-federation-ssr/server.ts__tmpl__ +45 -0
- package/src/generators/remote/files/module-federation-ssr/webpack.server.config.js__tmpl__ +12 -0
- package/src/generators/remote/lib/setup-ssr-for-remote.d.ts +4 -0
- package/src/generators/remote/lib/setup-ssr-for-remote.js +32 -0
- package/src/generators/remote/lib/setup-ssr-for-remote.js.map +1 -0
- package/src/generators/remote/lib/update-host-with-remote.js +8 -4
- package/src/generators/remote/lib/update-host-with-remote.js.map +1 -1
- package/src/generators/remote/remote.d.ts +2 -2
- package/src/generators/remote/remote.js +20 -3
- package/src/generators/remote/remote.js.map +1 -1
- package/src/generators/remote/schema.d.ts +14 -13
- package/src/generators/remote/schema.json +22 -8
- package/src/generators/setup-ssr/files/server.ts__tmpl__ +28 -0
- package/src/generators/setup-ssr/files/src/main.server.tsx__tmpl__ +47 -0
- package/src/generators/setup-ssr/files/tsconfig.server.json__tmpl__ +15 -0
- package/src/generators/setup-ssr/schema.d.ts +7 -0
- package/src/generators/setup-ssr/schema.json +48 -0
- package/src/generators/setup-ssr/setup-ssr.d.ts +5 -0
- package/src/generators/setup-ssr/setup-ssr.js +162 -0
- package/src/generators/setup-ssr/setup-ssr.js.map +1 -0
- package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +2 -2
- package/src/generators/setup-tailwind/schema.json +8 -4
- package/src/generators/setup-tailwind/setup-tailwind.js +1 -2
- package/src/generators/setup-tailwind/setup-tailwind.js.map +1 -1
- package/src/generators/stories/schema.json +4 -2
- package/src/generators/stories/stories.d.ts +1 -1
- package/src/generators/stories/stories.js +29 -21
- package/src/generators/stories/stories.js.map +1 -1
- package/src/generators/storybook-configuration/configuration.d.ts +1 -1
- package/src/generators/storybook-configuration/configuration.js +24 -6
- package/src/generators/storybook-configuration/configuration.js.map +1 -1
- package/src/generators/storybook-configuration/schema.d.ts +2 -0
- package/src/generators/storybook-configuration/schema.json +25 -8
- package/src/migrations/update-13-0-0/webpack5-changes-utils.js +3 -3
- package/src/migrations/update-13-0-0/webpack5-changes-utils.js.map +1 -1
- package/src/migrations/update-14-0-0/update-react-dom-render-for-v18.js +3 -3
- package/src/migrations/update-14-0-0/update-react-dom-render-for-v18.js.map +1 -1
- package/src/migrations/update-14-1-0/update-external-emotion-jsx-runtime.js +1 -1
- package/src/migrations/update-14-1-0/update-external-emotion-jsx-runtime.js.map +1 -1
- package/src/migrations/update-14-6-0/add-preset-jest-config.js +1 -1
- package/src/migrations/update-14-6-0/add-preset-jest-config.js.map +1 -1
- package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.d.ts +3 -0
- package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js +39 -0
- package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js.map +1 -0
- package/src/migrations/update-15-3-0/update-rollup-executor.d.ts +3 -0
- package/src/migrations/update-15-3-0/update-rollup-executor.js +17 -0
- package/src/migrations/update-15-3-0/update-rollup-executor.js.map +1 -0
- package/src/migrations/update-15-6-3/webpack-config-setup.d.ts +2 -0
- package/src/migrations/update-15-6-3/webpack-config-setup.js +108 -0
- package/src/migrations/update-15-6-3/webpack-config-setup.js.map +1 -0
- package/src/module-federation/ast-utils.d.ts +1 -1
- package/src/module-federation/ast-utils.js +10 -6
- package/src/module-federation/ast-utils.js.map +1 -1
- package/src/module-federation/load-config.js +1 -1
- package/src/module-federation/load-config.js.map +1 -1
- package/src/module-federation/models.d.ts +4 -4
- package/src/module-federation/utils.d.ts +10 -0
- package/src/module-federation/utils.js +38 -0
- package/src/module-federation/utils.js.map +1 -0
- package/src/module-federation/with-module-federation-ssr.d.ts +2 -0
- package/src/module-federation/with-module-federation-ssr.js +48 -0
- package/src/module-federation/with-module-federation-ssr.js.map +1 -0
- package/src/module-federation/with-module-federation.d.ts +7 -2
- package/src/module-federation/with-module-federation.js +15 -158
- package/src/module-federation/with-module-federation.js.map +1 -1
- package/src/rules/update-module-federation-project.d.ts +2 -2
- package/src/rules/update-module-federation-project.js +2 -0
- package/src/rules/update-module-federation-project.js.map +1 -1
- package/src/utils/ast-utils.d.ts +2 -1
- package/src/utils/ast-utils.js +132 -65
- package/src/utils/ast-utils.js.map +1 -1
- package/src/utils/component-props.d.ts +1 -1
- package/src/utils/component-props.js +13 -6
- package/src/utils/component-props.js.map +1 -1
- package/src/utils/create-ts-config.d.ts +9 -0
- package/src/utils/create-ts-config.js +64 -0
- package/src/utils/create-ts-config.js.map +1 -0
- package/src/utils/get-in-source-vitest-tests-template.d.ts +1 -0
- package/src/utils/get-in-source-vitest-tests-template.js +22 -0
- package/src/utils/get-in-source-vitest-tests-template.js.map +1 -0
- package/src/utils/lint.d.ts +26 -0
- package/src/utils/lint.js +10 -1
- package/src/utils/lint.js.map +1 -1
- package/src/utils/versions.d.ts +32 -18
- package/src/utils/versions.js +36 -19
- package/src/utils/versions.js.map +1 -1
- package/tailwind.js +1 -1
- package/tailwind.js.map +1 -1
- package/src/generators/application/files/common/.browserslistrc__tmpl__ +0 -16
- package/src/generators/application/files/common/src/app/__fileName__.spec.tsx__tmpl__ +0 -26
- package/src/generators/application/files/common/src/polyfills.ts__tmpl__ +0 -7
- package/src/generators/application/files/common/tsconfig.json__tmpl__ +0 -17
- package/src/generators/library/files/lib/tsconfig.json__tmpl__ +0 -17
- package/src/migrations/utils/rules.d.ts +0 -2
- package/src/migrations/utils/rules.js +0 -15
- package/src/migrations/utils/rules.js.map +0 -1
- package/src/migrations/utils/testing.d.ts +0 -6
- package/src/migrations/utils/testing.js +0 -76
- package/src/migrations/utils/testing.js.map +0 -1
- package/src/module-federation/webpack-utils.d.ts +0 -9
- package/src/module-federation/webpack-utils.js +0 -76
- package/src/module-federation/webpack-utils.js.map +0 -1
- package/src/utils/async-iterator.d.ts +0 -5
- package/src/utils/async-iterator.js +0 -76
- package/src/utils/async-iterator.js.map +0 -1
- /package/src/generators/application/files/{common/src → base-vite/public}/favicon.ico +0 -0
- /package/src/generators/application/files/{common → base-vite}/src/assets/.gitkeep +0 -0
- /package/src/generators/application/files/{common → base-vite}/src/environments/environment.prod.ts__tmpl__ +0 -0
- /package/src/generators/application/files/{common → base-vite}/src/environments/environment.ts__tmpl__ +0 -0
- /package/src/generators/application/files/{common → base-vite}/src/main.tsx__tmpl__ +0 -0
- /package/src/generators/application/files/{common → base-webpack}/.babelrc__tmpl__ +0 -0
- /package/src/generators/{library/files/lib/src/index.ts__tmpl__ → application/files/base-webpack/src/assets/.gitkeep} +0 -0
- /package/src/generators/application/files/{common → base-webpack}/src/index.html +0 -0
- /package/src/generators/application/files/{css-module → style-css-module}/src/app/__fileName__.module.__style__ +0 -0
- /package/src/generators/application/files/{css-module → style-css-module}/src/styles.__style__ +0 -0
- /package/src/generators/application/files/{global-css → style-global-css}/src/app/__fileName__.__style__ +0 -0
- /package/src/generators/application/files/{global-css → style-global-css}/src/styles.__style__ +0 -0
- /package/src/generators/library/files/{lib → common}/.babelrc__tmpl__ +0 -0
- /package/src/generators/library/files/{lib → common}/README.md +0 -0
- /package/src/generators/library/files/{lib → common}/package.json__tmpl__ +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
<% if (!minimal) { %>
|
|
2
3
|
import NxWelcome from "./nx-welcome";
|
|
4
|
+
<% } %>
|
|
3
5
|
import { Link, Route, Routes } from 'react-router-dom';
|
|
4
6
|
|
|
5
7
|
<% if (remotes.length > 0) { %>
|
|
@@ -17,7 +19,9 @@ export function App() {
|
|
|
17
19
|
<% }); %>
|
|
18
20
|
</ul>
|
|
19
21
|
<Routes>
|
|
22
|
+
<% if (!minimal) { %>
|
|
20
23
|
<Route path="/" element={<NxWelcome title="<%= projectName %>"/>} />
|
|
24
|
+
<% } %>
|
|
21
25
|
<% remotes.forEach(function(r) { %>
|
|
22
26
|
<Route path="/<%=r.fileName%>" element={<<%= r.className %>/>} />
|
|
23
27
|
<% }); %>
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const moduleFederationConfig = {
|
|
7
|
-
name: '<%= projectName %>',
|
|
8
|
-
remotes: [
|
|
9
|
-
<% remotes.forEach(function(r) {%> "<%= r.fileName %>", <% }); %>
|
|
10
|
-
],
|
|
1
|
+
module.exports = {
|
|
2
|
+
name: '<%= projectName %>',
|
|
3
|
+
remotes: [
|
|
4
|
+
<% remotes.forEach(function(r) {%> "<%= r.fileName %>", <% }); %>
|
|
5
|
+
],
|
|
11
6
|
};
|
|
12
|
-
|
|
13
|
-
module.exports = moduleFederationConfig;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const { composePlugins, withNx } = require('@nrwl/webpack');
|
|
2
|
+
const { withReact } = require('@nrwl/react');
|
|
3
3
|
const { withModuleFederation } = require('@nrwl/react/module-federation');
|
|
4
|
+
|
|
4
5
|
const baseConfig = require('./module-federation.config');
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
**/
|
|
9
|
-
const defaultConfig = {
|
|
10
|
-
...baseConfig,
|
|
7
|
+
const config = {
|
|
8
|
+
...baseConfig,
|
|
11
9
|
};
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
// Nx plugins for webpack to build config object from Nx options and context.
|
|
12
|
+
module.exports = composePlugins(withNx(), withReact(), withModuleFederation(config));
|
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const { composePlugins, withNx } = require('@nrwl/webpack');
|
|
2
|
+
const { withReact } = require('@nrwl/react');
|
|
3
3
|
const { withModuleFederation } = require('@nrwl/react/module-federation');
|
|
4
|
+
|
|
4
5
|
const baseConfig = require('./module-federation.config');
|
|
5
6
|
|
|
6
|
-
/**
|
|
7
|
-
* @type {import('@nrwl/react/module-federation').ModuleFederationConfig}
|
|
8
|
-
**/
|
|
9
7
|
const prodConfig = {
|
|
10
8
|
...baseConfig,
|
|
11
9
|
/*
|
|
12
10
|
* Remote overrides for production.
|
|
13
|
-
* Each entry is a pair of
|
|
11
|
+
* Each entry is a pair of a unique name and the URL where it is deployed.
|
|
14
12
|
*
|
|
15
13
|
* e.g.
|
|
16
14
|
* remotes: [
|
|
17
|
-
* ['app1', '
|
|
18
|
-
* ['app2', '
|
|
15
|
+
* ['app1', 'http://app1.example.com'],
|
|
16
|
+
* ['app2', 'http://app2.example.com'],
|
|
19
17
|
* ]
|
|
20
18
|
*
|
|
21
19
|
* You can also use a full path to the remoteEntry.js file if desired.
|
|
22
20
|
*
|
|
23
21
|
* remotes: [
|
|
24
|
-
* ['app1', '
|
|
25
|
-
* ['app2', '
|
|
22
|
+
* ['app1', 'http://example.com/path/to/app1/remoteEntry.js'],
|
|
23
|
+
* ['app2', 'http://example.com/path/to/app2/remoteEntry.js'],
|
|
26
24
|
* ]
|
|
27
25
|
*/
|
|
28
26
|
remotes: [
|
|
29
|
-
<% remotes.forEach(function(r) {%>['<%= r.fileName %>', '
|
|
27
|
+
<% remotes.forEach(function(r) {%>['<%= r.fileName %>', 'http://localhost:<%= r.port %>/'],<% }); %>
|
|
30
28
|
],
|
|
31
29
|
};
|
|
32
30
|
|
|
33
|
-
|
|
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,13 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @type {import('@nrwl/devkit').ModuleFederationConfig}
|
|
5
|
+
**/
|
|
6
|
+
const moduleFederationConfig = {
|
|
7
|
+
name: '<%= projectName %>',
|
|
8
|
+
remotes: [
|
|
9
|
+
<% remotes.forEach(function(r) {%> "<%= r.fileName %>", <% }); %>
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
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,12 @@
|
|
|
1
|
+
const { composePlugins, withNx } = require('@nrwl/webpack');
|
|
2
|
+
const { withReact } = require('@nrwl/react');
|
|
3
|
+
const { withModuleFederationForSSR } = require('@nrwl/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(), withModuleFederationForSSR(defaultConfig));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Tree } from '@nrwl/devkit';
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nrwl/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
|
-
export declare function hostGenerator(host: Tree, schema: Schema): Promise<
|
|
3
|
+
export declare function hostGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
4
|
export default hostGenerator;
|
|
@@ -9,12 +9,18 @@ const update_module_federation_project_1 = require("../../rules/update-module-fe
|
|
|
9
9
|
const add_module_federation_files_1 = require("./lib/add-module-federation-files");
|
|
10
10
|
const update_module_federation_e2e_project_1 = require("./lib/update-module-federation-e2e-project");
|
|
11
11
|
const remote_1 = require("../remote/remote");
|
|
12
|
+
const setup_ssr_1 = require("../setup-ssr/setup-ssr");
|
|
13
|
+
const setup_ssr_for_host_1 = require("./lib/setup-ssr-for-host");
|
|
12
14
|
function hostGenerator(host, schema) {
|
|
13
15
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const tasks = [];
|
|
14
17
|
const options = (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
15
18
|
const initTask = yield (0, application_1.default)(host, Object.assign(Object.assign({}, options), {
|
|
16
19
|
// The target use-case is loading remotes as child routes, thus always enable routing.
|
|
17
|
-
routing: true
|
|
20
|
+
routing: true,
|
|
21
|
+
// Only webpack works with module federation for now.
|
|
22
|
+
bundler: 'webpack' }));
|
|
23
|
+
tasks.push(initTask);
|
|
18
24
|
const remotesWithPorts = [];
|
|
19
25
|
if (schema.remotes) {
|
|
20
26
|
let remotePort = options.devServerPort + 1;
|
|
@@ -29,6 +35,7 @@ function hostGenerator(host, schema) {
|
|
|
29
35
|
e2eTestRunner: options.e2eTestRunner,
|
|
30
36
|
linter: options.linter,
|
|
31
37
|
devServerPort: remotePort,
|
|
38
|
+
ssr: options.ssr,
|
|
32
39
|
});
|
|
33
40
|
remotePort++;
|
|
34
41
|
}
|
|
@@ -36,10 +43,22 @@ function hostGenerator(host, schema) {
|
|
|
36
43
|
(0, add_module_federation_files_1.addModuleFederationFiles)(host, options, remotesWithPorts);
|
|
37
44
|
(0, update_module_federation_project_1.updateModuleFederationProject)(host, options);
|
|
38
45
|
(0, update_module_federation_e2e_project_1.updateModuleFederationE2eProject)(host, options);
|
|
46
|
+
if (options.ssr) {
|
|
47
|
+
const setupSsrTask = yield (0, setup_ssr_1.default)(host, {
|
|
48
|
+
project: options.projectName,
|
|
49
|
+
serverPort: options.devServerPort,
|
|
50
|
+
});
|
|
51
|
+
tasks.push(setupSsrTask);
|
|
52
|
+
const setupSsrForHostTask = yield (0, setup_ssr_for_host_1.setupSsrForHost)(host, options, options.projectName, remotesWithPorts);
|
|
53
|
+
tasks.push(setupSsrForHostTask);
|
|
54
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
55
|
+
projectConfig.targets.server.options.webpackConfig = (0, devkit_1.joinPathFragments)(projectConfig.root, 'webpack.server.config.js');
|
|
56
|
+
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
|
|
57
|
+
}
|
|
39
58
|
if (!options.skipFormat) {
|
|
40
59
|
yield (0, devkit_1.formatFiles)(host);
|
|
41
60
|
}
|
|
42
|
-
return
|
|
61
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
43
62
|
});
|
|
44
63
|
}
|
|
45
64
|
exports.hostGenerator = hostGenerator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/host/host.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/host/host.ts"],"names":[],"mappings":";;;;AAAA,yCAQsB;AAEtB,4DAA8D;AAC9D,4EAAwE;AACxE,mGAA6F;AAC7F,mFAA6E;AAC7E,qGAA8F;AAG9F,6CAA+C;AAE/C,sDAAuD;AACvD,iEAA2D;AAE3D,SAAsB,aAAa,CAAC,IAAU,EAAE,MAAc;;QAC5D,MAAM,KAAK,GAAwB,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,IAAA,oCAAgB,EAAS,IAAI,EAAE,MAAM,CAAC,CAAC;QAEvD,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAoB,EAAC,IAAI,kCAC3C,OAAO;YACV,sFAAsF;YACtF,OAAO,EAAE,IAAI;YACb,qDAAqD;YACrD,OAAO,EAAE,SAAS,IAClB,CAAC;QACH,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAErB,MAAM,gBAAgB,GAAqC,EAAE,CAAC;QAE9D,IAAI,MAAM,CAAC,OAAO,EAAE;YAClB,IAAI,UAAU,GAAG,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC;YAC3C,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;gBACnC,gBAAgB,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;gBAC1D,MAAM,IAAA,gBAAe,EAAC,IAAI,EAAE;oBAC1B,IAAI,EAAE,MAAM;oBACZ,SAAS,EAAE,OAA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CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;QAED,OAAO,IAAA,yBAAgB,EAAC,GAAG,KAAK,CAAC,CAAC;IACpC,CAAC;CAAA;AAlED,sCAkEC;AAED,kBAAe,aAAa,CAAC"}
|
|
@@ -13,9 +13,9 @@ function addModuleFederationFiles(host, options, defaultRemoteManifest) {
|
|
|
13
13
|
// Renaming original entry file so we can use `import(./bootstrap)` in
|
|
14
14
|
// new entry file.
|
|
15
15
|
host.rename((0, path_1.join)(options.appProjectRoot, 'src/main.tsx'), (0, path_1.join)(options.appProjectRoot, 'src/bootstrap.tsx'));
|
|
16
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, `../files/common`), options.appProjectRoot, templateVariables);
|
|
16
17
|
// New entry file is created here.
|
|
17
18
|
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, `../files/module-federation`), options.appProjectRoot, templateVariables);
|
|
18
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, `../files/common`), options.appProjectRoot, templateVariables);
|
|
19
19
|
}
|
|
20
20
|
exports.addModuleFederationFiles = addModuleFederationFiles;
|
|
21
21
|
//# sourceMappingURL=add-module-federation-files.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-module-federation-files.js","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/host/lib/add-module-federation-files.ts"],"names":[],"mappings":";;;AACA,yCAAoD;AACpD,+BAA4B;AAC5B,+EAA+E;AAE/E,SAAgB,wBAAwB,CACtC,IAAI,EACJ,OAAyB,EACzB,qBAAuD;IAEvD,MAAM,iBAAiB,iDAClB,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,GACnB,OAAO,KACV,IAAI,EAAE,EAAE,EACR,OAAO,EAAE,qBAAqB,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;YACpD,MAAM,MAAM,GAAG,IAAA,wCAAoB,kCAAM,OAAO,KAAE,IAAI,IAAG,CAAC;YAC1D,uCACK,IAAA,cAAK,EAAC,MAAM,CAAC,KAChB,IAAI,IACJ;QACJ,CAAC,CAAC,GACH,CAAC;IAEF,wEAAwE;IACxE,sEAAsE;IACtE,kBAAkB;IAClB,IAAI,CAAC,MAAM,CACT,IAAA,WAAI,EAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAC5C,IAAA,WAAI,EAAC,OAAO,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAClD,CAAC;IAEF,
|
|
1
|
+
{"version":3,"file":"add-module-federation-files.js","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/host/lib/add-module-federation-files.ts"],"names":[],"mappings":";;;AACA,yCAAoD;AACpD,+BAA4B;AAC5B,+EAA+E;AAE/E,SAAgB,wBAAwB,CACtC,IAAI,EACJ,OAAyB,EACzB,qBAAuD;IAEvD,MAAM,iBAAiB,iDAClB,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,GACnB,OAAO,KACV,IAAI,EAAE,EAAE,EACR,OAAO,EAAE,qBAAqB,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;YACpD,MAAM,MAAM,GAAG,IAAA,wCAAoB,kCAAM,OAAO,KAAE,IAAI,IAAG,CAAC;YAC1D,uCACK,IAAA,cAAK,EAAC,MAAM,CAAC,KAChB,IAAI,IACJ;QACJ,CAAC,CAAC,GACH,CAAC;IAEF,wEAAwE;IACxE,sEAAsE;IACtE,kBAAkB;IAClB,IAAI,CAAC,MAAM,CACT,IAAA,WAAI,EAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAC5C,IAAA,WAAI,EAAC,OAAO,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAClD,CAAC;IAEF,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,WAAI,EAAC,SAAS,EAAE,iBAAiB,CAAC,EAClC,OAAO,CAAC,cAAc,EACtB,iBAAiB,CAClB,CAAC;IAEF,kCAAkC;IAClC,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,WAAI,EAAC,SAAS,EAAE,4BAA4B,CAAC,EAC7C,OAAO,CAAC,cAAc,EACtB,iBAAiB,CAClB,CAAC;AACJ,CAAC;AAxCD,4DAwCC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GeneratorCallback, Tree } from '@nrwl/devkit';
|
|
2
|
+
import type { Schema } from '../schema';
|
|
3
|
+
export declare function setupSsrForHost(tree: Tree, options: Schema, appName: string, defaultRemoteManifest: {
|
|
4
|
+
name: string;
|
|
5
|
+
port: number;
|
|
6
|
+
}[]): Promise<GeneratorCallback>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupSsrForHost = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
+
const versions_1 = require("../../../utils/versions");
|
|
7
|
+
const normalize_options_1 = require("../../application/lib/normalize-options");
|
|
8
|
+
function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
|
|
9
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
|
+
const tasks = [];
|
|
11
|
+
let project = (0, devkit_1.readProjectConfiguration)(tree, appName);
|
|
12
|
+
project.targets.serve.executor =
|
|
13
|
+
'@nrwl/react:module-federation-ssr-dev-server';
|
|
14
|
+
(0, devkit_1.updateProjectConfiguration)(tree, appName, project);
|
|
15
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/module-federation-ssr'), project.root, Object.assign(Object.assign({}, options), { remotes: defaultRemoteManifest.map(({ name, port }) => {
|
|
16
|
+
const remote = (0, normalize_options_1.normalizeProjectName)(Object.assign(Object.assign({}, options), { name }));
|
|
17
|
+
return Object.assign(Object.assign({}, (0, devkit_1.names)(remote)), { port });
|
|
18
|
+
}), appName, tmpl: '', browserBuildOutputPath: project.targets.build.options.outputPath }));
|
|
19
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
20
|
+
'@module-federation/node': versions_1.moduleFederationNodeVersion,
|
|
21
|
+
}, {});
|
|
22
|
+
tasks.push(installTask);
|
|
23
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.setupSsrForHost = setupSsrForHost;
|
|
27
|
+
//# sourceMappingURL=setup-ssr-for-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-ssr-for-host.js","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/host/lib/setup-ssr-for-host.ts"],"names":[],"mappings":";;;;AACA,yCAQsB;AAGtB,sDAAsE;AACtE,+EAA+E;AAE/E,SAAsB,eAAe,CACnC,IAAU,EACV,OAAe,EACf,OAAe,EACf,qBAAuD;;QAEvD,MAAM,KAAK,GAAwB,EAAE,CAAC;QACtC,IAAI,OAAO,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACtD,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ;YAC5B,8CAA8C,CAAC;QACjD,IAAA,mCAA0B,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAEnD,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EAAC,SAAS,EAAE,gCAAgC,CAAC,EAC9D,OAAO,CAAC,IAAI,kCAEP,OAAO,KACV,OAAO,EAAE,qBAAqB,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;gBACpD,MAAM,MAAM,GAAG,IAAA,wCAAoB,kCAAM,OAAO,KAAE,IAAI,IAAG,CAAC;gBAC1D,uCACK,IAAA,cAAK,EAAC,MAAM,CAAC,KAChB,IAAI,IACJ;YACJ,CAAC,CAAC,EACF,OAAO,EACP,IAAI,EAAE,EAAE,EACR,sBAAsB,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,IAEnE,CAAC;QAEF,MAAM,WAAW,GAAG,IAAA,qCAA4B,EAC9C,IAAI,EACJ;YACE,yBAAyB,EAAE,sCAA2B;SACvD,EACD,EAAE,CACH,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAExB,OAAO,IAAA,yBAAgB,EAAC,GAAG,KAAK,CAAC,CAAC;IACpC,CAAC;CAAA;AAzCD,0CAyCC"}
|
|
@@ -2,29 +2,31 @@ import { Linter } from '@nrwl/linter';
|
|
|
2
2
|
import { SupportedStyles } from '../../../typings';
|
|
3
3
|
|
|
4
4
|
export interface Schema {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
classComponent?: boolean;
|
|
6
|
+
compiler?: 'babel' | 'swc';
|
|
7
|
+
devServerPort?: number;
|
|
8
8
|
directory?: string;
|
|
9
|
-
tags?: string;
|
|
10
|
-
unitTestRunner: 'jest' | 'none';
|
|
11
9
|
e2eTestRunner: 'cypress' | 'none';
|
|
10
|
+
globalCss?: boolean;
|
|
11
|
+
js?: boolean;
|
|
12
12
|
linter: Linter;
|
|
13
|
+
name: string;
|
|
13
14
|
pascalCaseFiles?: boolean;
|
|
14
|
-
|
|
15
|
-
skipWorkspaceJson?: boolean;
|
|
16
|
-
js?: boolean;
|
|
17
|
-
globalCss?: boolean;
|
|
18
|
-
strict?: boolean;
|
|
15
|
+
remotes?: string[];
|
|
19
16
|
setParserOptionsProject?: boolean;
|
|
17
|
+
skipFormat?: boolean;
|
|
18
|
+
skipWorkspaceJson?: boolean;
|
|
19
|
+
ssr?: boolean;
|
|
20
20
|
standaloneConfig?: boolean;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
strict?: boolean;
|
|
22
|
+
style: SupportedStyles;
|
|
23
|
+
tags?: string;
|
|
24
|
+
unitTestRunner: 'jest' | 'vitest' | 'none';
|
|
25
|
+
minimal?: boolean;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export interface NormalizedSchema extends Schema {
|
|
27
|
-
projectName: string;
|
|
28
29
|
appProjectRoot: string;
|
|
29
30
|
e2eProjectName: string;
|
|
31
|
+
projectName: string;
|
|
30
32
|
}
|
|
@@ -14,12 +14,14 @@
|
|
|
14
14
|
"index": 0
|
|
15
15
|
},
|
|
16
16
|
"x-prompt": "What name would you like to use as the host application?",
|
|
17
|
-
"pattern": "^[a-zA-Z].*$"
|
|
17
|
+
"pattern": "^[a-zA-Z].*$",
|
|
18
|
+
"x-priority": "important"
|
|
18
19
|
},
|
|
19
20
|
"directory": {
|
|
20
21
|
"description": "The directory of the new application.",
|
|
21
22
|
"type": "string",
|
|
22
|
-
"alias": "dir"
|
|
23
|
+
"alias": "dir",
|
|
24
|
+
"x-priority": "important"
|
|
23
25
|
},
|
|
24
26
|
"style": {
|
|
25
27
|
"description": "The file extension to be used for style files.",
|
|
@@ -68,18 +70,20 @@
|
|
|
68
70
|
"linter": {
|
|
69
71
|
"description": "The tool to use for running lint checks.",
|
|
70
72
|
"type": "string",
|
|
71
|
-
"enum": ["eslint"
|
|
73
|
+
"enum": ["eslint"],
|
|
72
74
|
"default": "eslint"
|
|
73
75
|
},
|
|
74
76
|
"skipFormat": {
|
|
75
77
|
"description": "Skip formatting files.",
|
|
76
78
|
"type": "boolean",
|
|
77
|
-
"default": false
|
|
79
|
+
"default": false,
|
|
80
|
+
"x-priority": "internal"
|
|
78
81
|
},
|
|
79
82
|
"skipWorkspaceJson": {
|
|
80
83
|
"description": "Skip updating workspace.json with default options based on values provided to this app (e.g. babel, style).",
|
|
81
84
|
"type": "boolean",
|
|
82
|
-
"default": false
|
|
85
|
+
"default": false,
|
|
86
|
+
"x-priority": "internal"
|
|
83
87
|
},
|
|
84
88
|
"unitTestRunner": {
|
|
85
89
|
"type": "string",
|
|
@@ -132,7 +136,9 @@
|
|
|
132
136
|
},
|
|
133
137
|
"standaloneConfig": {
|
|
134
138
|
"description": "Split the project configuration into <projectRoot>/project.json rather than including it inside workspace.json",
|
|
135
|
-
"type": "boolean"
|
|
139
|
+
"type": "boolean",
|
|
140
|
+
"default": true,
|
|
141
|
+
"x-deprecated": "Nx only supports standaloneConfig"
|
|
136
142
|
},
|
|
137
143
|
"compiler": {
|
|
138
144
|
"type": "string",
|
|
@@ -143,11 +149,24 @@
|
|
|
143
149
|
"remotes": {
|
|
144
150
|
"type": "array",
|
|
145
151
|
"description": "A list of remote application names that the host application should consume.",
|
|
146
|
-
"default": []
|
|
152
|
+
"default": [],
|
|
153
|
+
"x-priority": "important"
|
|
147
154
|
},
|
|
148
155
|
"devServerPort": {
|
|
149
156
|
"type": "number",
|
|
150
|
-
"description": "The port for the dev server of the remote app."
|
|
157
|
+
"description": "The port for the dev server of the remote app.",
|
|
158
|
+
"default": 4200,
|
|
159
|
+
"x-priority": "important"
|
|
160
|
+
},
|
|
161
|
+
"ssr": {
|
|
162
|
+
"description": "Whether to configure SSR for the host application",
|
|
163
|
+
"type": "boolean",
|
|
164
|
+
"default": false
|
|
165
|
+
},
|
|
166
|
+
"minimal": {
|
|
167
|
+
"description": "Generate a React app with a minimal setup. No nx starter template.",
|
|
168
|
+
"type": "boolean",
|
|
169
|
+
"default": false
|
|
151
170
|
}
|
|
152
171
|
},
|
|
153
172
|
"required": ["name"],
|
|
@@ -2,28 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reactInitSchematic = exports.reactInitGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const cypress_1 = require("@nrwl/cypress");
|
|
6
5
|
const devkit_1 = require("@nrwl/devkit");
|
|
7
|
-
const
|
|
8
|
-
const web_1 = require("@nrwl/web");
|
|
9
|
-
const run_tasks_in_serial_1 = require("@nrwl/workspace/src/utilities/run-tasks-in-serial");
|
|
6
|
+
const js_1 = require("@nrwl/js");
|
|
10
7
|
const versions_1 = require("../../utils/versions");
|
|
11
8
|
function setDefault(host) {
|
|
12
|
-
const workspace = (0, devkit_1.
|
|
9
|
+
const workspace = (0, devkit_1.readNxJson)(host);
|
|
13
10
|
workspace.generators = workspace.generators || {};
|
|
14
11
|
const reactGenerators = workspace.generators['@nrwl/react'] || {};
|
|
15
12
|
const generators = Object.assign(Object.assign({}, workspace.generators), { '@nrwl/react': Object.assign(Object.assign({}, reactGenerators), { application: Object.assign(Object.assign({}, reactGenerators.application), { babel: true }) }) });
|
|
16
|
-
(0, devkit_1.
|
|
13
|
+
(0, devkit_1.updateNxJson)(host, Object.assign(Object.assign({}, workspace), { generators }));
|
|
17
14
|
}
|
|
18
|
-
function updateDependencies(host) {
|
|
15
|
+
function updateDependencies(host, schema) {
|
|
19
16
|
(0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nrwl/react'], []);
|
|
20
|
-
|
|
21
|
-
'core-js': '^3.6.5',
|
|
17
|
+
const dependencies = {
|
|
22
18
|
react: versions_1.reactVersion,
|
|
23
19
|
'react-dom': versions_1.reactDomVersion,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
};
|
|
21
|
+
if (!schema.skipHelperLibs) {
|
|
22
|
+
dependencies['tslib'] = versions_1.tsLibVersion;
|
|
23
|
+
}
|
|
24
|
+
return (0, devkit_1.addDependenciesToPackageJson)(host, dependencies, {
|
|
27
25
|
'@nrwl/react': versions_1.nxVersion,
|
|
28
26
|
'@types/node': versions_1.typesNodeVersion,
|
|
29
27
|
'@types/react': versions_1.typesReactVersion,
|
|
@@ -32,23 +30,48 @@ function updateDependencies(host) {
|
|
|
32
30
|
'react-test-renderer': versions_1.reactTestRendererVersion,
|
|
33
31
|
});
|
|
34
32
|
}
|
|
33
|
+
function initRootBabelConfig(tree, schema) {
|
|
34
|
+
var _a;
|
|
35
|
+
if (tree.exists('/babel.config.json') || tree.exists('/babel.config.js')) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (!schema.skipBabelConfig) {
|
|
39
|
+
(0, devkit_1.writeJson)(tree, '/babel.config.json', {
|
|
40
|
+
babelrcRoots: ['*'], // Make sure .babelrc files other than root can be loaded in a monorepo
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
44
|
+
if ((_a = nxJson.namedInputs) === null || _a === void 0 ? void 0 : _a.sharedGlobals) {
|
|
45
|
+
nxJson.namedInputs.sharedGlobals.push('{workspaceRoot}/babel.config.json');
|
|
46
|
+
}
|
|
47
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
48
|
+
}
|
|
35
49
|
function reactInitGenerator(host, schema) {
|
|
36
50
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
51
|
const tasks = [];
|
|
52
|
+
const jsInitTask = yield (0, js_1.initGenerator)(host, Object.assign(Object.assign({}, schema), { tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json', skipFormat: true }));
|
|
53
|
+
tasks.push(jsInitTask);
|
|
38
54
|
setDefault(host);
|
|
39
|
-
if (!schema.unitTestRunner || schema.unitTestRunner === 'jest') {
|
|
40
|
-
const jestTask = (0, jest_1.jestInitGenerator)(host, schema);
|
|
41
|
-
tasks.push(jestTask);
|
|
42
|
-
}
|
|
43
55
|
if (!schema.e2eTestRunner || schema.e2eTestRunner === 'cypress') {
|
|
44
|
-
|
|
56
|
+
(0, devkit_1.ensurePackage)('@nrwl/cypress', versions_1.nxVersion);
|
|
57
|
+
const { cypressInitGenerator } = yield Promise.resolve().then(() => require('@nrwl/cypress/src/generators/init/init'));
|
|
58
|
+
const cypressTask = yield cypressInitGenerator(host, {});
|
|
45
59
|
tasks.push(cypressTask);
|
|
46
60
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
if (!schema.skipPackageJson && !schema.skipBabelConfig) {
|
|
62
|
+
const installBabelTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
63
|
+
'@babel/preset-react': versions_1.babelPresetReactVersion,
|
|
64
|
+
});
|
|
65
|
+
tasks.push(installBabelTask);
|
|
66
|
+
}
|
|
67
|
+
if (!schema.skipBabelConfig) {
|
|
68
|
+
initRootBabelConfig(host, schema);
|
|
69
|
+
}
|
|
70
|
+
if (!schema.skipPackageJson) {
|
|
71
|
+
const installTask = updateDependencies(host, schema);
|
|
72
|
+
tasks.push(installTask);
|
|
73
|
+
}
|
|
74
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
52
75
|
});
|
|
53
76
|
}
|
|
54
77
|
exports.reactInitGenerator = reactInitGenerator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/init/init.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/init/init.ts"],"names":[],"mappings":";;;;AAAA,yCAWsB;AAEtB,iCAA4D;AAC5D,mDAW8B;AAG9B,SAAS,UAAU,CAAC,IAAU;IAC5B,MAAM,SAAS,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,CAAC;IAEnC,SAAS,CAAC,UAAU,GAAG,SAAS,CAAC,UAAU,IAAI,EAAE,CAAC;IAClD,MAAM,eAAe,GAAG,SAAS,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IAClE,MAAM,UAAU,mCACX,SAAS,CAAC,UAAU,KACvB,aAAa,kCACR,eAAe,KAClB,WAAW,kCACN,eAAe,CAAC,WAAW,KAC9B,KAAK,EAAE,IAAI,SAGhB,CAAC;IAEF,IAAA,qBAAY,EAAC,IAAI,kCAAO,SAAS,KAAE,UAAU,IAAG,CAAC;AACnD,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAU,EAA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,GAAG,IAAA,2BAAkB,EAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export interface InitSchema {
|
|
2
|
-
unitTestRunner?: 'jest' | 'none';
|
|
2
|
+
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
3
3
|
e2eTestRunner?: 'cypress' | 'none';
|
|
4
|
+
skipBabelConfig?: boolean;
|
|
4
5
|
skipFormat?: boolean;
|
|
6
|
+
skipPackageJson?: boolean;
|
|
7
|
+
skipHelperLibs?: boolean;
|
|
5
8
|
js?: boolean;
|
|
9
|
+
|
|
10
|
+
rootProject?: boolean;
|
|
6
11
|
}
|
|
@@ -23,6 +23,22 @@
|
|
|
23
23
|
"type": "boolean",
|
|
24
24
|
"default": false
|
|
25
25
|
},
|
|
26
|
+
"skipPackageJson": {
|
|
27
|
+
"description": "Do not add dependencies to `package.json`.",
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"default": false
|
|
30
|
+
},
|
|
31
|
+
"skipBabelConfig": {
|
|
32
|
+
"description": "Do not generate a root babel.config.json (if babel is not needed).",
|
|
33
|
+
"type": "boolean",
|
|
34
|
+
"default": false
|
|
35
|
+
},
|
|
36
|
+
"skipHelperLibs": {
|
|
37
|
+
"description": "Do not install tslib.",
|
|
38
|
+
"type": "boolean",
|
|
39
|
+
"default": false,
|
|
40
|
+
"hidden": true
|
|
41
|
+
},
|
|
26
42
|
"js": {
|
|
27
43
|
"type": "boolean",
|
|
28
44
|
"default": false,
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
|
5
|
+
"types": ["node"]
|
|
6
|
+
},
|
|
7
|
+
"files": [<% if (style === 'styled-jsx') { %>
|
|
8
|
+
"<%= offsetFromRoot %>node_modules/@nrwl/react/typings/styled-jsx.d.ts",<% } %>
|
|
9
|
+
"<%= offsetFromRoot %>node_modules/@nrwl/react/typings/cssmodule.d.ts",
|
|
10
|
+
"<%= offsetFromRoot %>node_modules/@nrwl/react/typings/image.d.ts"
|
|
11
|
+
],
|
|
12
|
+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
|
|
13
|
+
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
|
14
|
+
}
|