@nx/react 24.0.0-pr.37405.acdaf31 → 24.0.0-rc.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/dist/index.d.ts +0 -2
- package/dist/index.js +1 -5
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +3 -1
- package/dist/module-federation.d.ts +6 -5
- package/dist/module-federation.js +29 -18
- package/dist/plugins/component-testing/index.js +92 -33
- package/dist/plugins/storybook/index.js +18 -18
- package/dist/plugins/with-react.d.ts +3 -7
- package/dist/plugins/with-react.js +5 -19
- package/dist/ready-check.d.ts +1 -0
- package/dist/ready-check.js +5 -0
- package/dist/src/generators/_utils/mf-dependencies.js +3 -0
- package/dist/src/generators/application/application.js +1 -36
- package/dist/src/generators/application/files/base-rspack/rspack.config.js__tmpl__ +1 -24
- package/dist/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +1 -26
- package/dist/src/generators/application/lib/add-e2e.js +11 -11
- package/dist/src/generators/application/lib/add-linting.js +1 -2
- package/dist/src/generators/application/lib/add-project.js +0 -167
- package/dist/src/generators/application/lib/bundlers/add-rsbuild.js +0 -1
- package/dist/src/generators/application/lib/bundlers/add-vite.js +0 -2
- package/dist/src/generators/application/lib/bundlers/add-webpack.js +0 -1
- package/dist/src/generators/application/lib/create-application-files.d.ts +0 -2
- package/dist/src/generators/application/lib/create-application-files.js +2 -11
- package/dist/src/generators/application/lib/normalize-options.js +0 -4
- package/dist/src/generators/application/schema.d.ts +0 -6
- package/dist/src/generators/application/schema.json +0 -6
- package/dist/src/generators/consumer/consumer.js +2 -0
- package/dist/src/generators/consumer/files/rsbuild/package.json__tmpl__ +1 -0
- package/dist/src/generators/consumer/files/rsbuild/rsbuild.config.ts__tmpl__ +2 -0
- package/dist/src/generators/consumer/files/rspack/package.json__tmpl__ +1 -0
- package/dist/src/generators/consumer/files/rspack/rspack.config.ts__tmpl__ +2 -0
- package/dist/src/generators/consumer/files/vite/package.json__tmpl__ +1 -0
- package/dist/src/generators/consumer/files/vite/vite.config.mts__tmpl__ +2 -0
- package/dist/src/generators/cypress-component-configuration/cypress-component-configuration.js +4 -16
- package/dist/src/generators/cypress-component-configuration/lib/add-files.d.ts +1 -2
- package/dist/src/generators/cypress-component-configuration/lib/add-files.js +4 -2
- package/dist/src/generators/cypress-component-configuration/schema.d.ts +0 -1
- package/dist/src/generators/init/init.js +3 -5
- package/dist/src/generators/init/schema.d.ts +0 -1
- package/dist/src/generators/library/lib/add-linting.js +1 -2
- package/dist/src/generators/library/lib/add-rollup-build-target.js +3 -47
- package/dist/src/generators/library/lib/normalize-options.js +0 -4
- package/dist/src/generators/library/library.js +1 -4
- package/dist/src/generators/library/schema.d.ts +0 -5
- package/dist/src/generators/library/schema.json +0 -6
- package/dist/src/generators/provider/files/rsbuild/package.json__tmpl__ +1 -0
- package/dist/src/generators/provider/files/rsbuild/rsbuild.config.ts__tmpl__ +2 -0
- package/dist/src/generators/provider/files/rspack/package.json__tmpl__ +1 -0
- package/dist/src/generators/provider/files/rspack/rspack.config.ts__tmpl__ +2 -0
- package/dist/src/generators/provider/files/vite/package.json__tmpl__ +1 -0
- package/dist/src/generators/provider/files/vite/vite.config.mts__tmpl__ +2 -0
- package/dist/src/generators/provider/provider.js +2 -0
- package/dist/src/generators/stories/stories.js +0 -5
- package/dist/src/generators/storybook-configuration/configuration.js +1 -9
- package/dist/src/generators/storybook-configuration/schema.d.ts +0 -1
- package/dist/src/migrations/update-23-2-0/add-optional-module-federation-packages.js +2 -1
- package/dist/src/migrations/update-24-0-0/register-typescript-plugin-for-typecheck.d.ts +4 -0
- package/dist/src/migrations/update-24-0-0/register-typescript-plugin-for-typecheck.js +13 -0
- package/dist/src/migrations/update-24-0-0/register-typescript-plugin-for-typecheck.md +40 -0
- package/dist/src/plugins/router-plugin-utils.d.ts +4 -0
- package/dist/src/plugins/router-plugin-utils.js +15 -0
- package/dist/src/plugins/router-plugin.d.ts +0 -1
- package/dist/src/plugins/router-plugin.js +35 -44
- package/dist/src/utils/ast-utils.d.ts +0 -1
- package/dist/src/utils/ast-utils.js +0 -23
- package/dist/src/utils/ct-utils.d.ts +0 -7
- package/dist/src/utils/ct-utils.js +71 -55
- package/dist/src/utils/deprecation.d.ts +1 -1
- package/dist/src/utils/deprecation.js +3 -5
- package/dist/src/utils/framework.js +1 -3
- package/dist/src/utils/react-router-serve-ready-check.d.ts +11 -0
- package/dist/src/utils/react-router-serve-ready-check.js +25 -0
- package/dist/src/utils/versions.d.ts +0 -7
- package/dist/src/utils/versions.js +2 -9
- package/executors.json +1 -17
- package/generators.json +0 -27
- package/migrations.json +6 -0
- package/package.json +25 -39
- package/dist/mf/dynamic-federation.d.ts +0 -69
- package/dist/mf/dynamic-federation.js +0 -141
- package/dist/mf/index.d.ts +0 -1
- package/dist/mf/index.js +0 -8
- package/dist/src/executors/module-federation-dev-server/lib/index.d.ts +0 -2
- package/dist/src/executors/module-federation-dev-server/lib/index.js +0 -5
- package/dist/src/executors/module-federation-dev-server/lib/normalize-options.d.ts +0 -4
- package/dist/src/executors/module-federation-dev-server/lib/normalize-options.js +0 -19
- package/dist/src/executors/module-federation-dev-server/lib/start-remotes.d.ts +0 -5
- package/dist/src/executors/module-federation-dev-server/lib/start-remotes.js +0 -33
- package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +0 -6
- package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +0 -80
- package/dist/src/executors/module-federation-dev-server/schema.d.ts +0 -19
- package/dist/src/executors/module-federation-dev-server/schema.json +0 -142
- package/dist/src/executors/module-federation-ssr-dev-server/lib/index.d.ts +0 -2
- package/dist/src/executors/module-federation-ssr-dev-server/lib/index.js +0 -5
- package/dist/src/executors/module-federation-ssr-dev-server/lib/normalize-options.d.ts +0 -4
- package/dist/src/executors/module-federation-ssr-dev-server/lib/normalize-options.js +0 -23
- package/dist/src/executors/module-federation-ssr-dev-server/lib/start-remotes.d.ts +0 -5
- package/dist/src/executors/module-federation-ssr-dev-server/lib/start-remotes.js +0 -34
- package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +0 -3
- package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +0 -83
- package/dist/src/executors/module-federation-ssr-dev-server/schema.d.ts +0 -29
- package/dist/src/executors/module-federation-ssr-dev-server/schema.json +0 -81
- package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts +0 -12
- package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.js +0 -244
- package/dist/src/executors/module-federation-static-server/schema.d.ts +0 -3
- package/dist/src/executors/module-federation-static-server/schema.json +0 -16
- package/dist/src/generators/federate-module/federate-module.d.ts +0 -4
- package/dist/src/generators/federate-module/federate-module.js +0 -67
- package/dist/src/generators/federate-module/lib/utils.d.ts +0 -23
- package/dist/src/generators/federate-module/lib/utils.js +0 -99
- package/dist/src/generators/federate-module/schema.d.ts +0 -15
- package/dist/src/generators/federate-module/schema.json +0 -89
- package/dist/src/generators/host/files/common/src/app/__fileName__.js__tmpl__ +0 -40
- package/dist/src/generators/host/files/common/src/main.js__tmpl__ +0 -13
- package/dist/src/generators/host/files/common/tsconfig.lint.json__tmpl__ +0 -19
- package/dist/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +0 -41
- package/dist/src/generators/host/files/common-ts/src/main.ts__tmpl__ +0 -13
- package/dist/src/generators/host/files/rspack-common/src/app/__fileName__.jsx__tmpl__ +0 -42
- package/dist/src/generators/host/files/rspack-common/src/main.jsx__tmpl__ +0 -13
- package/dist/src/generators/host/files/rspack-common/tsconfig.lint.json__tmpl__ +0 -19
- package/dist/src/generators/host/files/rspack-module-federation/module-federation.config.js__tmpl__ +0 -24
- package/dist/src/generators/host/files/rspack-module-federation/rspack.config.js__tmpl__ +0 -42
- package/dist/src/generators/host/files/rspack-module-federation/rspack.config.prod.js__tmpl__ +0 -66
- package/dist/src/generators/host/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +0 -27
- package/dist/src/generators/host/files/rspack-module-federation-ssr/rspack.config.js__tmpl__ +0 -68
- package/dist/src/generators/host/files/rspack-module-federation-ssr/server.ts__tmpl__ +0 -28
- package/dist/src/generators/host/files/rspack-module-federation-ssr/src/main.server.tsx__tmpl__ +0 -49
- package/dist/src/generators/host/files/rspack-module-federation-ssr/tsconfig.server.json__tmpl__ +0 -17
- package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +0 -22
- package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +0 -68
- package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/server.ts__tmpl__ +0 -28
- package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/src/main.server.tsx__tmpl__ +0 -49
- package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/tsconfig.server.json__tmpl__ +0 -17
- package/dist/src/generators/host/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +0 -28
- package/dist/src/generators/host/files/rspack-module-federation-ts/rspack.config.prod.ts__tmpl__ +0 -67
- package/dist/src/generators/host/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +0 -42
- package/dist/src/generators/host/files/webpack-module-federation/module-federation.config.js__tmpl__ +0 -24
- package/dist/src/generators/host/files/webpack-module-federation/webpack.config.js__tmpl__ +0 -17
- package/dist/src/generators/host/files/webpack-module-federation/webpack.config.prod.js__tmpl__ +0 -39
- package/dist/src/generators/host/files/webpack-module-federation-ssr/module-federation.server.config.js__tmpl__ +0 -19
- package/dist/src/generators/host/files/webpack-module-federation-ssr/server.ts__tmpl__ +0 -28
- package/dist/src/generators/host/files/webpack-module-federation-ssr/tsconfig.server.json__tmpl__ +0 -17
- package/dist/src/generators/host/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +0 -17
- package/dist/src/generators/host/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +0 -16
- package/dist/src/generators/host/files/webpack-module-federation-ssr-ts/server.ts__tmpl__ +0 -28
- package/dist/src/generators/host/files/webpack-module-federation-ssr-ts/tsconfig.server.json__tmpl__ +0 -17
- package/dist/src/generators/host/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +0 -17
- package/dist/src/generators/host/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +0 -28
- package/dist/src/generators/host/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__ +0 -40
- package/dist/src/generators/host/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +0 -18
- package/dist/src/generators/host/host.d.ts +0 -4
- package/dist/src/generators/host/host.js +0 -174
- package/dist/src/generators/host/lib/add-module-federation-files.d.ts +0 -6
- package/dist/src/generators/host/lib/add-module-federation-files.js +0 -92
- package/dist/src/generators/host/lib/normalize-host-name.d.ts +0 -2
- package/dist/src/generators/host/lib/normalize-host-name.js +0 -12
- package/dist/src/generators/host/lib/setup-ssr-for-host.d.ts +0 -6
- package/dist/src/generators/host/lib/setup-ssr-for-host.js +0 -59
- package/dist/src/generators/host/lib/update-module-federation-e2e-project.d.ts +0 -3
- package/dist/src/generators/host/lib/update-module-federation-e2e-project.js +0 -19
- package/dist/src/generators/host/lib/update-module-federation-tsconfig.d.ts +0 -3
- package/dist/src/generators/host/lib/update-module-federation-tsconfig.js +0 -34
- package/dist/src/generators/host/schema.d.ts +0 -44
- package/dist/src/generators/host/schema.json +0 -173
- package/dist/src/generators/remote/files/common/src/main.js__tmpl__ +0 -1
- package/dist/src/generators/remote/files/common/src/remote-entry.js__tmpl__ +0 -1
- package/dist/src/generators/remote/files/common-ts/src/main.ts__tmpl__ +0 -1
- package/dist/src/generators/remote/files/common-ts/src/remote-entry.ts__tmpl__ +0 -1
- package/dist/src/generators/remote/files/rspack-common/src/main.jsx__tmpl__ +0 -1
- package/dist/src/generators/remote/files/rspack-common/src/remote-entry.js__tmpl__ +0 -1
- package/dist/src/generators/remote/files/rspack-module-federation/module-federation.config.js__tmpl__ +0 -12
- package/dist/src/generators/remote/files/rspack-module-federation/rspack.config.js__tmpl__ +0 -45
- package/dist/src/generators/remote/files/rspack-module-federation/rspack.config.prod.js__tmpl__ +0 -1
- package/dist/src/generators/remote/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +0 -15
- package/dist/src/generators/remote/files/rspack-module-federation-ssr/rspack.config.js__tmpl__ +0 -71
- package/dist/src/generators/remote/files/rspack-module-federation-ssr/server.ts__tmpl__ +0 -45
- package/dist/src/generators/remote/files/rspack-module-federation-ssr/src/main.server.tsx__tmpl__ +0 -45
- package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +0 -19
- package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +0 -71
- package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/server.ts__tmpl__ +0 -45
- package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/src/main.server.tsx__tmpl__ +0 -45
- package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +0 -19
- package/dist/src/generators/remote/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +0 -16
- package/dist/src/generators/remote/files/rspack-module-federation-ts/rspack.config.prod.ts__tmpl__ +0 -1
- package/dist/src/generators/remote/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +0 -45
- package/dist/src/generators/remote/files/rspack-module-federation-ts/tsconfig.lint.json__tmpl__ +0 -19
- package/dist/src/generators/remote/files/webpack-module-federation/module-federation.config.js__tmpl__ +0 -12
- package/dist/src/generators/remote/files/webpack-module-federation/webpack.config.js__tmpl__ +0 -17
- package/dist/src/generators/remote/files/webpack-module-federation/webpack.config.prod.js__tmpl__ +0 -1
- package/dist/src/generators/remote/files/webpack-module-federation-ssr/module-federation.server.config.js__tmpl__ +0 -9
- package/dist/src/generators/remote/files/webpack-module-federation-ssr/server.ts__tmpl__ +0 -45
- package/dist/src/generators/remote/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +0 -17
- package/dist/src/generators/remote/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +0 -13
- package/dist/src/generators/remote/files/webpack-module-federation-ssr-ts/server.ts__tmpl__ +0 -45
- package/dist/src/generators/remote/files/webpack-module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +0 -19
- package/dist/src/generators/remote/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +0 -17
- package/dist/src/generators/remote/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +0 -16
- package/dist/src/generators/remote/files/webpack-module-federation-ts/tsconfig.lint.json__tmpl__ +0 -19
- package/dist/src/generators/remote/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__ +0 -1
- package/dist/src/generators/remote/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +0 -17
- package/dist/src/generators/remote/lib/add-remote-to-dynamic-host.d.ts +0 -2
- package/dist/src/generators/remote/lib/add-remote-to-dynamic-host.js +0 -12
- package/dist/src/generators/remote/lib/setup-package-json-exports-for-remote.d.ts +0 -3
- package/dist/src/generators/remote/lib/setup-package-json-exports-for-remote.js +0 -30
- package/dist/src/generators/remote/lib/setup-ssr-for-remote.d.ts +0 -4
- package/dist/src/generators/remote/lib/setup-ssr-for-remote.js +0 -61
- package/dist/src/generators/remote/lib/setup-tspath-for-remote.d.ts +0 -3
- package/dist/src/generators/remote/lib/setup-tspath-for-remote.js +0 -14
- package/dist/src/generators/remote/lib/update-host-with-remote.d.ts +0 -2
- package/dist/src/generators/remote/lib/update-host-with-remote.js +0 -79
- package/dist/src/generators/remote/remote.d.ts +0 -6
- package/dist/src/generators/remote/remote.js +0 -201
- package/dist/src/generators/remote/schema.d.ts +0 -39
- package/dist/src/generators/remote/schema.json +0 -173
- package/dist/src/generators/setup-ssr/files/server.ts__tmpl__ +0 -28
- package/dist/src/generators/setup-ssr/files/src/main.server.tsx__tmpl__ +0 -47
- package/dist/src/generators/setup-ssr/files/tsconfig.server.json__tmpl__ +0 -17
- package/dist/src/generators/setup-ssr/schema.d.ts +0 -8
- package/dist/src/generators/setup-ssr/schema.json +0 -54
- package/dist/src/generators/setup-ssr/setup-ssr.d.ts +0 -4
- package/dist/src/generators/setup-ssr/setup-ssr.js +0 -198
- package/dist/src/module-federation/ast-utils.d.ts +0 -8
- package/dist/src/module-federation/ast-utils.js +0 -101
- package/dist/src/rules/update-module-federation-project.d.ts +0 -11
- package/dist/src/rules/update-module-federation-project.js +0 -72
- package/dist/src/utils/add-mf-env-to-inputs.d.ts +0 -2
- package/dist/src/utils/add-mf-env-to-inputs.js +0 -29
- package/dist/src/utils/module-federation-deprecation.d.ts +0 -12
- package/dist/src/utils/module-federation-deprecation.js +0 -46
- package/dist/src/utils/normalize-remote.d.ts +0 -8
- package/dist/src/utils/normalize-remote.js +0 -31
|
@@ -1,45 +0,0 @@
|
|
|
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'] || <%= port %>;
|
|
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);
|
package/dist/src/generators/remote/files/webpack-module-federation-ssr-ts/tsconfig.lint.json__tmpl__
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {composePlugins, withNx} from '@nx/webpack';
|
|
2
|
-
import {withReact} from '@nx/react';
|
|
3
|
-
import {withModuleFederationForSSR} from '@nx/module-federation/webpack';
|
|
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
|
-
/**
|
|
13
|
-
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support Module Federation
|
|
14
|
-
* The DTS Plugin can be enabled by setting dts: true
|
|
15
|
-
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
|
|
16
|
-
*/
|
|
17
|
-
export default composePlugins(withNx(), withReact({ssr: true}), withModuleFederationForSSR(defaultConfig, { dts: false }));
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type {ModuleFederationConfig} from '@nx/module-federation';
|
|
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
|
-
/**
|
|
14
|
-
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
|
|
15
|
-
**/
|
|
16
|
-
export default config;
|
package/dist/src/generators/remote/files/webpack-module-federation-ts/tsconfig.lint.json__tmpl__
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/src/generators/remote/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default require('./webpack.config');
|
package/dist/src/generators/remote/files/webpack-module-federation-ts/webpack.config.ts__tmpl__
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {composePlugins, withNx} from '@nx/webpack';
|
|
2
|
-
import {withReact} from '@nx/react';
|
|
3
|
-
import {withModuleFederation} from '@nx/module-federation/webpack';
|
|
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
|
-
/**
|
|
13
|
-
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support Module Federation
|
|
14
|
-
* The DTS Plugin can be enabled by setting dts: true
|
|
15
|
-
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
|
|
16
|
-
*/
|
|
17
|
-
export default composePlugins(withNx(), withReact(), withModuleFederation(config, { dts: false }));
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addRemoteToDynamicHost = addRemoteToDynamicHost;
|
|
4
|
-
function addRemoteToDynamicHost(tree, remoteName, remotePort, pathToMfManifest) {
|
|
5
|
-
if (tree.exists(pathToMfManifest)) {
|
|
6
|
-
const current = tree.read(pathToMfManifest, 'utf8');
|
|
7
|
-
tree.write(pathToMfManifest, JSON.stringify({
|
|
8
|
-
...JSON.parse(current),
|
|
9
|
-
[remoteName]: `http://localhost:${remotePort}`,
|
|
10
|
-
}));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupPackageJsonExportsForRemote = setupPackageJsonExportsForRemote;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const internal_1 = require("@nx/js/internal");
|
|
6
|
-
const maybe_js_1 = require("../../../utils/maybe-js");
|
|
7
|
-
function setupPackageJsonExportsForRemote(tree, options) {
|
|
8
|
-
const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
|
9
|
-
const packageJsonPath = (0, devkit_1.joinPathFragments)(project.root, 'package.json');
|
|
10
|
-
if (!tree.exists(packageJsonPath)) {
|
|
11
|
-
throw new Error(`package.json not found at ${packageJsonPath}. ` +
|
|
12
|
-
`TypeScript solution setup requires package.json for all projects.`);
|
|
13
|
-
}
|
|
14
|
-
const exportPath = (0, maybe_js_1.maybeJs)(options, './src/remote-entry.ts');
|
|
15
|
-
const customCondition = (0, internal_1.getDefinedCustomConditionName)(tree);
|
|
16
|
-
(0, devkit_1.updateJson)(tree, packageJsonPath, (json) => {
|
|
17
|
-
json.exports = {
|
|
18
|
-
...json.exports,
|
|
19
|
-
'./Module': {
|
|
20
|
-
[customCondition]: exportPath,
|
|
21
|
-
types: exportPath,
|
|
22
|
-
import: exportPath,
|
|
23
|
-
default: exportPath,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
// Set types for IDE support (no main needed - this is an app, not a library)
|
|
27
|
-
json.types = exportPath;
|
|
28
|
-
return json;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { 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>;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupSsrForRemote = setupSsrForRemote;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const versions_1 = require("../../../utils/versions");
|
|
6
|
-
const create_application_files_1 = require("../../application/lib/create-application-files");
|
|
7
|
-
async function setupSsrForRemote(tree, options, appName) {
|
|
8
|
-
const tasks = [];
|
|
9
|
-
const project = (0, devkit_1.readProjectConfiguration)(tree, appName);
|
|
10
|
-
const pathToModuleFederationSsrFiles = options.typescriptConfiguration
|
|
11
|
-
? `${options.bundler === 'rspack' ? 'rspack-' : 'webpack-'}module-federation-ssr-ts`
|
|
12
|
-
: `${options.bundler === 'rspack' ? 'rspack-' : 'webpack-'}module-federation-ssr`;
|
|
13
|
-
const templateVariables = options.bundler === 'rspack'
|
|
14
|
-
? {
|
|
15
|
-
...(0, create_application_files_1.getDefaultTemplateVariables)(tree, options),
|
|
16
|
-
rspackPluginOptions: {
|
|
17
|
-
...(0, create_application_files_1.createNxRspackPluginOptions)(options, (0, devkit_1.offsetFromRoot)(options.appProjectRoot), false),
|
|
18
|
-
mainServer: `./server.ts`,
|
|
19
|
-
},
|
|
20
|
-
port: Number(options?.port) || 4200,
|
|
21
|
-
appName,
|
|
22
|
-
}
|
|
23
|
-
: {
|
|
24
|
-
...options,
|
|
25
|
-
port: Number(options?.port) || 4200,
|
|
26
|
-
appName,
|
|
27
|
-
tmpl: '',
|
|
28
|
-
browserBuildOutputPath: project.targets.build?.options?.outputPath,
|
|
29
|
-
serverBuildOutputPath: project.targets.server?.options?.outputPath,
|
|
30
|
-
};
|
|
31
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, `../files/${pathToModuleFederationSsrFiles}`), project.root, templateVariables);
|
|
32
|
-
// For hosts to use when running remotes in static mode.
|
|
33
|
-
const originalOutputPath = (project.targets.build?.options?.outputPath ??
|
|
34
|
-
options.isUsingTsSolutionConfig)
|
|
35
|
-
? 'dist'
|
|
36
|
-
: (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(options.appProjectRoot), 'dist', options.appProjectRoot != '.'
|
|
37
|
-
? options.appProjectRoot
|
|
38
|
-
: options.projectName);
|
|
39
|
-
const serverOptions = project.targets.server?.options;
|
|
40
|
-
const serverOutputPath = serverOptions?.outputPath ??
|
|
41
|
-
(0, devkit_1.joinPathFragments)(originalOutputPath, 'server');
|
|
42
|
-
const serverOutputName = serverOptions?.outputFileName ?? 'main.js';
|
|
43
|
-
project.targets['serve-static'] = {
|
|
44
|
-
dependsOn: ['build', 'server'],
|
|
45
|
-
executor: 'nx:run-commands',
|
|
46
|
-
defaultConfiguration: 'development',
|
|
47
|
-
options: {
|
|
48
|
-
command: `PORT=${options.port ?? 4200} node ${(0, devkit_1.joinPathFragments)(serverOutputPath, serverOutputName)}`,
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
(0, devkit_1.updateProjectConfiguration)(tree, appName, project);
|
|
52
|
-
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
53
|
-
'@module-federation/node': versions_1.moduleFederationNodeVersion,
|
|
54
|
-
cors: versions_1.corsVersion,
|
|
55
|
-
isbot: versions_1.isbotVersion,
|
|
56
|
-
express: versions_1.expressVersion,
|
|
57
|
-
'@types/express': versions_1.typesExpressVersion,
|
|
58
|
-
}, {}, undefined, true);
|
|
59
|
-
tasks.push(installTask);
|
|
60
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
61
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupTspathForRemote = setupTspathForRemote;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const js_1 = require("@nx/js");
|
|
6
|
-
const maybe_js_1 = require("../../../utils/maybe-js");
|
|
7
|
-
const versions_1 = require("../../../utils/versions");
|
|
8
|
-
function setupTspathForRemote(tree, options) {
|
|
9
|
-
const { normalizeProjectName } = (0, devkit_1.ensurePackage)('@nx/module-federation', versions_1.nxVersion);
|
|
10
|
-
const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
|
11
|
-
const exportPath = (0, maybe_js_1.maybeJs)(options, './src/remote-entry.ts');
|
|
12
|
-
const exportName = 'Module';
|
|
13
|
-
(0, js_1.addTsConfigPath)(tree, `${normalizeProjectName(options.projectName)}/${exportName}`, [(0, devkit_1.joinPathFragments)(project.root, exportPath)]);
|
|
14
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateHostWithRemote = updateHostWithRemote;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const internal_1 = require("@nx/js/internal");
|
|
6
|
-
const ast_utils_1 = require("../../../module-federation/ast-utils");
|
|
7
|
-
let tsModule;
|
|
8
|
-
function updateHostWithRemote(host, hostName, remoteName) {
|
|
9
|
-
if (!tsModule) {
|
|
10
|
-
tsModule = (0, internal_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 appComponentPath = findAppComponentPath(host, (0, internal_1.getProjectSourceRoot)(hostConfig, host));
|
|
18
|
-
if (host.exists(moduleFederationConfigPath)) {
|
|
19
|
-
// find the host project path
|
|
20
|
-
// Update remotes inside ${host_path}/src/remotes.d.ts
|
|
21
|
-
let sourceCode = host.read(moduleFederationConfigPath).toString();
|
|
22
|
-
const source = tsModule.createSourceFile(moduleFederationConfigPath, sourceCode, tsModule.ScriptTarget.Latest, true);
|
|
23
|
-
host.write(moduleFederationConfigPath, (0, devkit_1.applyChangesToString)(sourceCode, (0, ast_utils_1.addRemoteToConfig)(source, remoteName)));
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
// TODO(jack): Point to the nx.dev guide when ready.
|
|
27
|
-
devkit_1.logger.warn(`Could not find configuration at ${moduleFederationConfigPath}. Did you generate this project with "@nx/react:host" or "@nx/react:consumer"?`);
|
|
28
|
-
}
|
|
29
|
-
if (host.exists(appComponentPath)) {
|
|
30
|
-
let sourceCode = host.read(appComponentPath).toString();
|
|
31
|
-
const source = tsModule.createSourceFile(moduleFederationConfigPath, sourceCode, tsModule.ScriptTarget.Latest, true, tsModule.ScriptKind.TSX);
|
|
32
|
-
host.write(appComponentPath, (0, devkit_1.applyChangesToString)(sourceCode, (0, ast_utils_1.addRemoteRoute)(source, (0, devkit_1.names)(remoteName))));
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
devkit_1.logger.warn(`Could not find app component at ${appComponentPath}. Did you generate this project with "@nx/react:host" or "@nx/react:consumer"?`);
|
|
36
|
-
}
|
|
37
|
-
// Add remote as devDependency in TS solution setup
|
|
38
|
-
if ((0, internal_1.isUsingTsSolutionSetup)(host)) {
|
|
39
|
-
addRemoteAsHostDependency(host, hostName, remoteName);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function findAppComponentPath(host, sourceRoot) {
|
|
43
|
-
const locations = [
|
|
44
|
-
'app/app.tsx',
|
|
45
|
-
'app/App.tsx',
|
|
46
|
-
'app/app.js',
|
|
47
|
-
'app/app.jsx',
|
|
48
|
-
'app/App.js',
|
|
49
|
-
'app/App.jsx',
|
|
50
|
-
'app.tsx',
|
|
51
|
-
'App.tsx',
|
|
52
|
-
'app.js',
|
|
53
|
-
'App.js',
|
|
54
|
-
'app.jsx',
|
|
55
|
-
'App.jsx',
|
|
56
|
-
];
|
|
57
|
-
for (const loc of locations) {
|
|
58
|
-
if (host.exists((0, devkit_1.joinPathFragments)(sourceRoot, loc))) {
|
|
59
|
-
return (0, devkit_1.joinPathFragments)(sourceRoot, loc);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function addRemoteAsHostDependency(tree, hostName, remoteName) {
|
|
64
|
-
const hostConfig = (0, devkit_1.readProjectConfiguration)(tree, hostName);
|
|
65
|
-
const hostPackageJsonPath = (0, devkit_1.joinPathFragments)(hostConfig.root, 'package.json');
|
|
66
|
-
if (!tree.exists(hostPackageJsonPath)) {
|
|
67
|
-
throw new Error(`Host package.json not found at ${hostPackageJsonPath}. ` +
|
|
68
|
-
`TypeScript solution setup requires package.json for all projects.`);
|
|
69
|
-
}
|
|
70
|
-
const packageManager = (0, devkit_1.detectPackageManager)(tree.root);
|
|
71
|
-
// npm doesn't support workspace: protocol, use * instead
|
|
72
|
-
const versionSpec = packageManager === 'npm' ? '*' : 'workspace:*';
|
|
73
|
-
(0, devkit_1.updateJson)(tree, hostPackageJsonPath, (json) => {
|
|
74
|
-
json.devDependencies ??= {};
|
|
75
|
-
// Use simple remote name directly to match module-federation.config.ts
|
|
76
|
-
json.devDependencies[remoteName] = versionSpec;
|
|
77
|
-
return json;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
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 default remoteGenerator;
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addModuleFederationFiles = addModuleFederationFiles;
|
|
4
|
-
exports.remoteGenerator = remoteGenerator;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const internal_1 = require("@nx/devkit/internal");
|
|
7
|
-
const assert_supported_react_version_1 = require("../../utils/assert-supported-react-version");
|
|
8
|
-
const internal_2 = require("@nx/eslint/internal");
|
|
9
|
-
const devkit_1 = require("@nx/devkit");
|
|
10
|
-
const path_1 = require("path");
|
|
11
|
-
const js_1 = require("@nx/js");
|
|
12
|
-
const internal_3 = require("@nx/js/internal");
|
|
13
|
-
const update_module_federation_project_1 = require("../../rules/update-module-federation-project");
|
|
14
|
-
const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
|
15
|
-
const normalize_remote_1 = require("../../utils/normalize-remote");
|
|
16
|
-
const find_free_port_1 = require("../application/lib/find-free-port");
|
|
17
|
-
const maybe_js_1 = require("../../utils/maybe-js");
|
|
18
|
-
const module_federation_deprecation_1 = require("../../utils/module-federation-deprecation");
|
|
19
|
-
const versions_1 = require("../../utils/versions");
|
|
20
|
-
const application_1 = tslib_1.__importDefault(require("../application/application"));
|
|
21
|
-
const create_application_files_1 = require("../application/lib/create-application-files");
|
|
22
|
-
const normalize_options_1 = require("../application/lib/normalize-options");
|
|
23
|
-
const setup_ssr_1 = tslib_1.__importDefault(require("../setup-ssr/setup-ssr"));
|
|
24
|
-
const add_remote_to_dynamic_host_1 = require("./lib/add-remote-to-dynamic-host");
|
|
25
|
-
const setup_package_json_exports_for_remote_1 = require("./lib/setup-package-json-exports-for-remote");
|
|
26
|
-
const setup_ssr_for_remote_1 = require("./lib/setup-ssr-for-remote");
|
|
27
|
-
const setup_tspath_for_remote_1 = require("./lib/setup-tspath-for-remote");
|
|
28
|
-
const update_host_with_remote_1 = require("./lib/update-host-with-remote");
|
|
29
|
-
function addModuleFederationFiles(host, options) {
|
|
30
|
-
const templateVariables = options.bundler === 'rspack'
|
|
31
|
-
? {
|
|
32
|
-
...(0, create_application_files_1.getDefaultTemplateVariables)(host, options),
|
|
33
|
-
rspackPluginOptions: {
|
|
34
|
-
...(0, create_application_files_1.createNxRspackPluginOptions)(options, (0, devkit_1.offsetFromRoot)(options.appProjectRoot), false),
|
|
35
|
-
mainServer: `./server.ts`,
|
|
36
|
-
},
|
|
37
|
-
}
|
|
38
|
-
: {
|
|
39
|
-
...(0, devkit_1.names)(options.projectName),
|
|
40
|
-
...options,
|
|
41
|
-
tmpl: '',
|
|
42
|
-
};
|
|
43
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, `./files/${options.js
|
|
44
|
-
? options.bundler === 'rspack'
|
|
45
|
-
? 'rspack-common'
|
|
46
|
-
: 'common'
|
|
47
|
-
: 'common-ts'}`), options.appProjectRoot, templateVariables);
|
|
48
|
-
const pathToModuleFederationFiles = options.typescriptConfiguration
|
|
49
|
-
? `${options.bundler === 'rspack' ? 'rspack-' : 'webpack-'}module-federation-ts`
|
|
50
|
-
: `${options.bundler === 'rspack' ? 'rspack-' : 'webpack-'}module-federation`;
|
|
51
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, `./files/${pathToModuleFederationFiles}`), options.appProjectRoot, templateVariables);
|
|
52
|
-
if (options.typescriptConfiguration) {
|
|
53
|
-
const pathToBundlerConfig = (0, devkit_1.joinPathFragments)(options.appProjectRoot, options.bundler === 'rspack' ? 'rspack.config.js' : 'webpack.config.js');
|
|
54
|
-
const pathToWebpackProdConfig = (0, devkit_1.joinPathFragments)(options.appProjectRoot, options.bundler === 'rspack'
|
|
55
|
-
? 'rspack.config.prod.js'
|
|
56
|
-
: 'webpack.config.prod.js');
|
|
57
|
-
if (host.exists(pathToBundlerConfig)) {
|
|
58
|
-
host.delete(pathToBundlerConfig);
|
|
59
|
-
}
|
|
60
|
-
if (host.exists(pathToWebpackProdConfig)) {
|
|
61
|
-
host.delete(pathToWebpackProdConfig);
|
|
62
|
-
}
|
|
63
|
-
// Delete TypeScript prod config in TS solution setup - not needed in Crystal
|
|
64
|
-
if ((0, internal_3.isUsingTsSolutionSetup)(host)) {
|
|
65
|
-
const pathToTsProdConfig = (0, devkit_1.joinPathFragments)(options.appProjectRoot, options.bundler === 'rspack'
|
|
66
|
-
? 'rspack.config.prod.ts'
|
|
67
|
-
: 'webpack.config.prod.ts');
|
|
68
|
-
if (host.exists(pathToTsProdConfig)) {
|
|
69
|
-
host.delete(pathToTsProdConfig);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async function remoteGenerator(host, schema) {
|
|
75
|
-
(0, assert_supported_react_version_1.assertSupportedReactVersion)(host);
|
|
76
|
-
(0, module_federation_deprecation_1.warnReactRemoteGeneratorDeprecation)();
|
|
77
|
-
const tasks = [];
|
|
78
|
-
const name = await (0, normalize_remote_1.normalizeRemoteName)(host, schema.name, schema);
|
|
79
|
-
const options = {
|
|
80
|
-
...(await (0, normalize_options_1.normalizeOptions)(host, {
|
|
81
|
-
...schema,
|
|
82
|
-
name,
|
|
83
|
-
})),
|
|
84
|
-
// when js is set to true, we want to use the js configuration
|
|
85
|
-
js: schema.js ?? false,
|
|
86
|
-
typescriptConfiguration: schema.js
|
|
87
|
-
? false
|
|
88
|
-
: (schema.typescriptConfiguration ?? true),
|
|
89
|
-
dynamic: schema.dynamic ?? false,
|
|
90
|
-
// TODO(colum): remove when Webpack MF works with Crystal
|
|
91
|
-
addPlugin: !schema.bundler || schema.bundler === 'rspack' ? true : false,
|
|
92
|
-
bundler: schema.bundler ?? 'rspack',
|
|
93
|
-
// Unlike a plain app, a remote needs a port of its own: updateModuleFederationProject
|
|
94
|
-
// writes it to the serve target, and a dynamic remote's is also recorded in the host
|
|
95
|
-
// manifest. findFreePort reads the ports already claimed, so remotes step past each other.
|
|
96
|
-
port: schema.port ?? schema.devServerPort ?? (0, find_free_port_1.findFreePort)(host),
|
|
97
|
-
};
|
|
98
|
-
if (options.dynamic) {
|
|
99
|
-
// Dynamic remotes generate with library { type: 'var' } by default.
|
|
100
|
-
// We need to ensure that the remote name is a valid variable name.
|
|
101
|
-
const isValidRemote = (0, js_1.isValidVariable)(options.projectName);
|
|
102
|
-
if (!isValidRemote.isValid) {
|
|
103
|
-
throw new Error(`Invalid remote name provided: ${options.projectName}. ${isValidRemote.message}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
await (0, internal_1.ensureRootProjectName)(options, 'application');
|
|
107
|
-
const isValidRemote = (0, js_1.isValidVariable)(options.projectName);
|
|
108
|
-
if (!isValidRemote.isValid) {
|
|
109
|
-
throw new Error(`Invalid remote name provided: ${options.projectName}. ${isValidRemote.message}`);
|
|
110
|
-
}
|
|
111
|
-
const initAppTask = await (0, application_1.default)(host, {
|
|
112
|
-
...options,
|
|
113
|
-
name: options.projectName,
|
|
114
|
-
skipFormat: true,
|
|
115
|
-
});
|
|
116
|
-
tasks.push(initAppTask);
|
|
117
|
-
// In TS solution setup, update package.json to use simple name instead of scoped name
|
|
118
|
-
if ((0, internal_3.isUsingTsSolutionSetup)(host)) {
|
|
119
|
-
const remotePackageJsonPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json');
|
|
120
|
-
if (host.exists(remotePackageJsonPath)) {
|
|
121
|
-
(0, devkit_1.updateJson)(host, remotePackageJsonPath, (json) => {
|
|
122
|
-
json.name = options.projectName;
|
|
123
|
-
return json;
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (options.host) {
|
|
128
|
-
(0, update_host_with_remote_1.updateHostWithRemote)(host, options.host, options.projectName);
|
|
129
|
-
}
|
|
130
|
-
// Module federation requires bootstrap code to be dynamically imported.
|
|
131
|
-
// Renaming original entry file so we can use `import(./bootstrap)` in
|
|
132
|
-
// new entry file.
|
|
133
|
-
host.rename((0, path_1.join)(options.appProjectRoot, (0, maybe_js_1.maybeJs)({ js: options.js, useJsx: options.bundler === 'rspack' }, 'src/main.tsx')), (0, path_1.join)(options.appProjectRoot, (0, maybe_js_1.maybeJs)({ js: options.js, useJsx: options.bundler === 'rspack' }, 'src/bootstrap.tsx')));
|
|
134
|
-
addModuleFederationFiles(host, options);
|
|
135
|
-
(0, update_module_federation_project_1.updateModuleFederationProject)(host, options);
|
|
136
|
-
// Conditionally setup TS path or package.json exports based on TS solution setup
|
|
137
|
-
if ((0, internal_3.isUsingTsSolutionSetup)(host)) {
|
|
138
|
-
(0, setup_package_json_exports_for_remote_1.setupPackageJsonExportsForRemote)(host, options);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
(0, setup_tspath_for_remote_1.setupTspathForRemote)(host, options);
|
|
142
|
-
}
|
|
143
|
-
if (options.ssr) {
|
|
144
|
-
if (options.bundler !== 'rspack') {
|
|
145
|
-
const setupSsrTask = await (0, setup_ssr_1.default)(host, {
|
|
146
|
-
project: options.projectName,
|
|
147
|
-
serverPort: options.port,
|
|
148
|
-
skipFormat: true,
|
|
149
|
-
bundler: options.bundler,
|
|
150
|
-
});
|
|
151
|
-
tasks.push(setupSsrTask);
|
|
152
|
-
}
|
|
153
|
-
const setupSsrForRemoteTask = await (0, setup_ssr_for_remote_1.setupSsrForRemote)(host, options, options.projectName);
|
|
154
|
-
tasks.push(setupSsrForRemoteTask);
|
|
155
|
-
const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
156
|
-
if (options.bundler !== 'rspack') {
|
|
157
|
-
projectConfig.targets.server.options.webpackConfig = (0, devkit_1.joinPathFragments)(projectConfig.root, `webpack.server.config.${options.typescriptConfiguration ? 'ts' : 'js'}`);
|
|
158
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (!(0, internal_2.isTypedLintingEnabled)(options)) {
|
|
162
|
-
host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.lint.json'));
|
|
163
|
-
}
|
|
164
|
-
if (options.host && options.bundler === 'rspack') {
|
|
165
|
-
const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
166
|
-
projectConfig.targets.serve ??= {};
|
|
167
|
-
projectConfig.targets.serve.dependsOn ??= [];
|
|
168
|
-
projectConfig.targets.serve.dependsOn.push(`${options.host}:serve`);
|
|
169
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
|
|
170
|
-
}
|
|
171
|
-
if (options.host && options.dynamic) {
|
|
172
|
-
const hostConfig = (0, devkit_1.readProjectConfiguration)(host, schema.host);
|
|
173
|
-
const pathToMFManifest = (0, devkit_1.joinPathFragments)((0, internal_3.getProjectSourceRoot)(hostConfig, host), 'assets/module-federation.manifest.json');
|
|
174
|
-
(0, add_remote_to_dynamic_host_1.addRemoteToDynamicHost)(host, options.projectName, options.port, pathToMFManifest);
|
|
175
|
-
}
|
|
176
|
-
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host, options.bundler);
|
|
177
|
-
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
178
|
-
'@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion,
|
|
179
|
-
'@nx/web': versions_1.nxVersion,
|
|
180
|
-
'@nx/module-federation': versions_1.nxVersion,
|
|
181
|
-
// The webpack path also generates a `serve-static` target running the
|
|
182
|
-
// `module-federation-static-server` executor, which proxies via express.
|
|
183
|
-
...(options.bundler !== 'rspack'
|
|
184
|
-
? {
|
|
185
|
-
express: versions_1.expressVersion,
|
|
186
|
-
'http-proxy-middleware': versions_1.httpProxyMiddlewareVersion,
|
|
187
|
-
}
|
|
188
|
-
: {}),
|
|
189
|
-
}, undefined, true);
|
|
190
|
-
tasks.push(installTask);
|
|
191
|
-
// The TS config templates use extensionless relative imports and
|
|
192
|
-
// `__dirname`, which Node's native type stripping cannot load.
|
|
193
|
-
if (options.typescriptConfiguration) {
|
|
194
|
-
tasks.push((0, internal_3.addSwcRegisterDependencies)(host));
|
|
195
|
-
}
|
|
196
|
-
if (!options.skipFormat) {
|
|
197
|
-
await (0, devkit_1.formatFiles)(host);
|
|
198
|
-
}
|
|
199
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
200
|
-
}
|
|
201
|
-
exports.default = remoteGenerator;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { LinterType } from '@nx/js';
|
|
2
|
-
import type { SupportedStyles } from '../../../typings/style';
|
|
3
|
-
import type { NormalizedSchema as ApplicationNormalizedSchema } from '../application/schema';
|
|
4
|
-
|
|
5
|
-
export interface Schema {
|
|
6
|
-
classComponent?: boolean;
|
|
7
|
-
compiler?: 'babel' | 'swc';
|
|
8
|
-
port?: number;
|
|
9
|
-
/** @deprecated Use {@link Schema.port} instead. This option will be removed in Nx v24. */
|
|
10
|
-
devServerPort?: number;
|
|
11
|
-
directory: string;
|
|
12
|
-
e2eTestRunner: 'cypress' | 'playwright' | 'none';
|
|
13
|
-
globalCss?: boolean;
|
|
14
|
-
host?: string;
|
|
15
|
-
js?: boolean;
|
|
16
|
-
linter?: LinterType;
|
|
17
|
-
name?: string;
|
|
18
|
-
routing?: boolean;
|
|
19
|
-
enableTypedLinting?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
|
|
22
|
-
*/
|
|
23
|
-
setParserOptionsProject?: boolean;
|
|
24
|
-
skipFormat: boolean;
|
|
25
|
-
skipNxJson?: boolean;
|
|
26
|
-
skipPackageJson?: boolean;
|
|
27
|
-
ssr?: boolean;
|
|
28
|
-
strict?: boolean;
|
|
29
|
-
style: SupportedStyles;
|
|
30
|
-
tags?: string;
|
|
31
|
-
unitTestRunner: 'jest' | 'vitest' | 'none';
|
|
32
|
-
typescriptConfiguration?: boolean;
|
|
33
|
-
dynamic?: boolean;
|
|
34
|
-
bundler?: 'rspack' | 'webpack';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface NormalizedSchema extends ApplicationNormalizedSchema {
|
|
38
|
-
typescriptConfiguration: boolean;
|
|
39
|
-
}
|