@nx/react 24.0.0-beta.2 → 24.0.0-beta.4
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/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/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 +5 -6
- package/dist/src/generators/application/lib/add-linting.js +0 -1
- 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 -1
- 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 -2
- 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 +0 -1
- 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 -1
- 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.d.ts +0 -1
- package/dist/src/plugins/router-plugin.js +5 -42
- 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/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 +17 -47
- 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/module-federation.d.ts +0 -5
- package/dist/module-federation.js +0 -20
- 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,28 +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 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
|
-
// Server has started
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
server.on('error', console.error);
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { Request, Response } from 'express';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import * as ReactDOMServer from 'react-dom/server';
|
|
4
|
-
import isbot from 'isbot'
|
|
5
|
-
|
|
6
|
-
import App from './<%= appComponentImport %>';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
let indexHtml: null | string = null;
|
|
10
|
-
|
|
11
|
-
export function handleRequest(indexPath: string) {
|
|
12
|
-
return function render(req: Request, res: Response) {
|
|
13
|
-
let didError = false;
|
|
14
|
-
|
|
15
|
-
if (!indexHtml) {
|
|
16
|
-
indexHtml = fs.readFileSync(indexPath).toString();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const [htmlStart, htmlEnd] = indexHtml.split(`<div id="root"></div>`);
|
|
20
|
-
|
|
21
|
-
// For bots (e.g. search engines), the content will not be streamed but render all at once.
|
|
22
|
-
// For users, content should be streamed to the user as they are ready.
|
|
23
|
-
const callbackName = isbot(req.headers['user-agent']) ? 'onAllReady' : 'onShellReady';
|
|
24
|
-
|
|
25
|
-
const stream = ReactDOMServer.renderToPipeableStream(
|
|
26
|
-
<App />,
|
|
27
|
-
{
|
|
28
|
-
[callbackName]() {
|
|
29
|
-
res.statusCode = didError ? 500 : 200;
|
|
30
|
-
res.setHeader('Content-type', 'text/html; charset=utf-8');
|
|
31
|
-
res.write(`${htmlStart}<div id="root">`);
|
|
32
|
-
stream.pipe(res);
|
|
33
|
-
res.write(`</div>${htmlEnd}`);
|
|
34
|
-
},
|
|
35
|
-
onShellError(error) {
|
|
36
|
-
console.error(error);
|
|
37
|
-
res.statusCode = 500;
|
|
38
|
-
res.send('<!doctype html><h1>Server Error</h1>');
|
|
39
|
-
},
|
|
40
|
-
onError(error) {
|
|
41
|
-
didError = true;
|
|
42
|
-
console.error(error);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.app.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../out-tsc/server",
|
|
5
|
-
"target": "es2019",
|
|
6
|
-
"types": [
|
|
7
|
-
"node",
|
|
8
|
-
"@nx/react/typings/cssmodule.d.ts",
|
|
9
|
-
"@nx/react/typings/image.d.ts"
|
|
10
|
-
]
|
|
11
|
-
},
|
|
12
|
-
"include": [
|
|
13
|
-
<%- extraInclude %>
|
|
14
|
-
"src/main.server.tsx",
|
|
15
|
-
"server.ts"
|
|
16
|
-
]
|
|
17
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/schema",
|
|
3
|
-
"$id": "GeneratorReactSSRSetup",
|
|
4
|
-
"cli": "nx",
|
|
5
|
-
"title": "Generate SSR setup for a React app",
|
|
6
|
-
"description": "Create the additional configuration required to enable SSR via Express for a React application.",
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"project": {
|
|
10
|
-
"type": "string",
|
|
11
|
-
"description": "The name of the application to add SSR support to.",
|
|
12
|
-
"$default": {
|
|
13
|
-
"$source": "argv",
|
|
14
|
-
"index": 0
|
|
15
|
-
},
|
|
16
|
-
"x-prompt": "What app would you like to add SSR support to?",
|
|
17
|
-
"x-dropdown": "projects",
|
|
18
|
-
"x-priority": "important"
|
|
19
|
-
},
|
|
20
|
-
"appComponentImportPath": {
|
|
21
|
-
"type": "string",
|
|
22
|
-
"description": "The import path of the <App/ > component, relative to project sourceRoot.",
|
|
23
|
-
"default": "app/app"
|
|
24
|
-
},
|
|
25
|
-
"serverPort": {
|
|
26
|
-
"type": "number",
|
|
27
|
-
"default": 4200,
|
|
28
|
-
"description": "The port for the Express server.",
|
|
29
|
-
"x-priority": "important"
|
|
30
|
-
},
|
|
31
|
-
"skipFormat": {
|
|
32
|
-
"type": "boolean",
|
|
33
|
-
"description": "Skip formatting the workspace after the generator completes.",
|
|
34
|
-
"x-priority": "internal"
|
|
35
|
-
},
|
|
36
|
-
"extraInclude": {
|
|
37
|
-
"type": "array",
|
|
38
|
-
"items": {
|
|
39
|
-
"type": "string"
|
|
40
|
-
},
|
|
41
|
-
"hidden": true,
|
|
42
|
-
"description": "Extra include entries in tsconfig.",
|
|
43
|
-
"default": []
|
|
44
|
-
},
|
|
45
|
-
"bundler": {
|
|
46
|
-
"description": "The bundler to use.",
|
|
47
|
-
"type": "string",
|
|
48
|
-
"enum": ["rspack", "webpack"],
|
|
49
|
-
"default": "webpack"
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"required": ["project"],
|
|
53
|
-
"additionalProperties": false
|
|
54
|
-
}
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupSsrGenerator = setupSsrGenerator;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const internal_1 = require("@nx/devkit/internal");
|
|
6
|
-
const assert_supported_react_version_1 = require("../../utils/assert-supported-react-version");
|
|
7
|
-
const internal_2 = require("@nx/js/internal");
|
|
8
|
-
const path_1 = require("path");
|
|
9
|
-
const ast_utils_1 = require("../../utils/ast-utils");
|
|
10
|
-
const versions_1 = require("../../utils/versions");
|
|
11
|
-
let tsModule;
|
|
12
|
-
function readEntryFile(host, path) {
|
|
13
|
-
if (!tsModule) {
|
|
14
|
-
tsModule = (0, internal_2.ensureTypescript)();
|
|
15
|
-
}
|
|
16
|
-
const content = host.read(path, 'utf-8');
|
|
17
|
-
return {
|
|
18
|
-
content,
|
|
19
|
-
source: tsModule.createSourceFile(path, content, tsModule.ScriptTarget.Latest, true),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
async function getProjectConfig(tree, projectName) {
|
|
23
|
-
let maybeProjectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
24
|
-
if (!maybeProjectConfig.targets?.build) {
|
|
25
|
-
let projectGraph;
|
|
26
|
-
try {
|
|
27
|
-
projectGraph = (0, devkit_1.readCachedProjectGraph)();
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
31
|
-
}
|
|
32
|
-
maybeProjectConfig = projectGraph.nodes[projectName].data;
|
|
33
|
-
}
|
|
34
|
-
return maybeProjectConfig;
|
|
35
|
-
}
|
|
36
|
-
async function setupSsrGenerator(tree, options) {
|
|
37
|
-
(0, assert_supported_react_version_1.assertSupportedReactVersion)(tree);
|
|
38
|
-
const projectConfig = await getProjectConfig(tree, options.project);
|
|
39
|
-
const projectRoot = projectConfig.root;
|
|
40
|
-
const appImportCandidates = [
|
|
41
|
-
options.appComponentImportPath ?? 'app/app',
|
|
42
|
-
'app',
|
|
43
|
-
'App',
|
|
44
|
-
'app/App',
|
|
45
|
-
'App/App',
|
|
46
|
-
].map((importPath) => {
|
|
47
|
-
return {
|
|
48
|
-
importPath,
|
|
49
|
-
filePath: (0, devkit_1.joinPathFragments)((0, internal_2.getProjectSourceRoot)(projectConfig, tree), `${importPath}.tsx`),
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
const appComponentInfo = appImportCandidates.find((candidate) => tree.exists(candidate.filePath));
|
|
53
|
-
if (!appComponentInfo) {
|
|
54
|
-
throw new Error(`Cannot find an import path for <App/> component. Try passing setting --appComponentImportPath option.`);
|
|
55
|
-
}
|
|
56
|
-
if (!projectConfig.targets.build || !projectConfig.targets.serve) {
|
|
57
|
-
throw new Error(`Project ${options.project} does not have build and serve targets`);
|
|
58
|
-
}
|
|
59
|
-
if (projectConfig.targets.server) {
|
|
60
|
-
throw new Error(`Project ${options.project} already has a server target.`);
|
|
61
|
-
}
|
|
62
|
-
const originalOutputPath = projectConfig.targets.build?.options?.outputPath ??
|
|
63
|
-
projectConfig.targets.build?.outputs[0];
|
|
64
|
-
if (!originalOutputPath) {
|
|
65
|
-
throw new Error(`Project ${options.project} does not contain a outputPath for the build target.`);
|
|
66
|
-
}
|
|
67
|
-
// TODO(colum): We need to figure out how to handle this for Crystal
|
|
68
|
-
if (projectConfig.targets.build.options?.outputPath) {
|
|
69
|
-
projectConfig.targets.build.options.outputPath = (0, devkit_1.joinPathFragments)(originalOutputPath, 'browser');
|
|
70
|
-
}
|
|
71
|
-
if (projectConfig.targets.build.executor === '@nx/rspack:rspack') {
|
|
72
|
-
options.bundler = 'rspack';
|
|
73
|
-
}
|
|
74
|
-
else if (projectConfig.targets.build.executor === '@nx/webpack:webpack') {
|
|
75
|
-
options.bundler = 'webpack';
|
|
76
|
-
}
|
|
77
|
-
projectConfig.targets = {
|
|
78
|
-
...projectConfig.targets,
|
|
79
|
-
server: {
|
|
80
|
-
dependsOn: ['build'],
|
|
81
|
-
executor: options.bundler === 'rspack'
|
|
82
|
-
? '@nx/rspack:rspack'
|
|
83
|
-
: '@nx/webpack:webpack',
|
|
84
|
-
outputs: ['{options.outputPath}'],
|
|
85
|
-
defaultConfiguration: 'production',
|
|
86
|
-
options: {
|
|
87
|
-
target: 'node',
|
|
88
|
-
main: `${projectRoot}/server.ts`,
|
|
89
|
-
outputPath: (0, devkit_1.joinPathFragments)(originalOutputPath, 'server'),
|
|
90
|
-
outputFileName: 'server.js',
|
|
91
|
-
tsConfig: `${projectRoot}/tsconfig.server.json`,
|
|
92
|
-
compiler: 'babel',
|
|
93
|
-
externalDependencies: 'all',
|
|
94
|
-
outputHashing: 'none',
|
|
95
|
-
...(options.bundler === 'rspack'
|
|
96
|
-
? { rspackConfig: (0, devkit_1.joinPathFragments)(projectRoot, 'rspack.config.js') }
|
|
97
|
-
: {
|
|
98
|
-
webpackConfig: (0, devkit_1.joinPathFragments)(projectRoot, 'webpack.config.js'),
|
|
99
|
-
}),
|
|
100
|
-
},
|
|
101
|
-
configurations: {
|
|
102
|
-
development: {
|
|
103
|
-
optimization: false,
|
|
104
|
-
sourceMap: true,
|
|
105
|
-
},
|
|
106
|
-
production: {
|
|
107
|
-
fileReplacements: [
|
|
108
|
-
{
|
|
109
|
-
replace: `${projectRoot}/src/environments/environment.ts`,
|
|
110
|
-
with: `${projectRoot}/src/environments/environment.prod.ts`,
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
sourceMap: false,
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
'serve-browser': projectConfig.targets.serve,
|
|
118
|
-
'serve-server': {
|
|
119
|
-
executor: '@nx/js:node',
|
|
120
|
-
defaultConfiguration: 'development',
|
|
121
|
-
options: {
|
|
122
|
-
buildTarget: `${options.project}:server:development`,
|
|
123
|
-
buildTargetOptions: {
|
|
124
|
-
watch: true,
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
configurations: {
|
|
128
|
-
development: {},
|
|
129
|
-
production: {
|
|
130
|
-
buildTarget: `${options.project}:server:production`,
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
serve: {
|
|
135
|
-
executor: options.bundler === 'rspack'
|
|
136
|
-
? '@nx/rspack:ssr-dev-server'
|
|
137
|
-
: '@nx/webpack:ssr-dev-server',
|
|
138
|
-
defaultConfiguration: 'development',
|
|
139
|
-
options: {
|
|
140
|
-
browserTarget: `${options.project}:build:development`,
|
|
141
|
-
serverTarget: `${options.project}:serve-server:development`,
|
|
142
|
-
port: options.serverPort,
|
|
143
|
-
browserTargetOptions: {
|
|
144
|
-
watch: true,
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
configurations: {
|
|
148
|
-
development: {},
|
|
149
|
-
production: {
|
|
150
|
-
browserTarget: `${options.project}:build:production`,
|
|
151
|
-
serverTarget: `${options.project}:serve-server:production`,
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
(0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
|
|
157
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
158
|
-
if (nxJson.tasksRunnerOptions?.default &&
|
|
159
|
-
!nxJson.tasksRunnerOptions?.default.options.cacheableOperations.includes('server')) {
|
|
160
|
-
nxJson.tasksRunnerOptions.default.options.cacheableOperations = [
|
|
161
|
-
...nxJson.tasksRunnerOptions.default.options.cacheableOperations,
|
|
162
|
-
'server',
|
|
163
|
-
];
|
|
164
|
-
}
|
|
165
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), projectRoot, {
|
|
166
|
-
tmpl: '',
|
|
167
|
-
port: Number(options?.serverPort) || 4200,
|
|
168
|
-
extraInclude: options.extraInclude?.length > 0
|
|
169
|
-
? `"${options.extraInclude.join('", "')}",`
|
|
170
|
-
: '',
|
|
171
|
-
appComponentImport: appComponentInfo.importPath,
|
|
172
|
-
browserBuildOutputPath: projectConfig.targets.build?.options?.outputPath ??
|
|
173
|
-
projectConfig.targets.build?.outputs[0],
|
|
174
|
-
});
|
|
175
|
-
// Add <StaticRouter> to server main if needed.
|
|
176
|
-
// TODO: need to read main.server.tsx not main.tsx.
|
|
177
|
-
const appContent = tree.read(appComponentInfo.filePath, 'utf-8');
|
|
178
|
-
const isRouterPresent = appContent.match(/react-router-dom/);
|
|
179
|
-
if (isRouterPresent) {
|
|
180
|
-
const serverEntry = (0, devkit_1.joinPathFragments)(projectRoot, 'src/main.server.tsx');
|
|
181
|
-
const { content, source } = readEntryFile(tree, serverEntry);
|
|
182
|
-
const changes = (0, devkit_1.applyChangesToString)(content, (0, ast_utils_1.addStaticRouter)(serverEntry, source));
|
|
183
|
-
tree.write(serverEntry, changes);
|
|
184
|
-
}
|
|
185
|
-
(0, internal_1.upsertTargetDefault)(tree, nxJson, { target: 'server', cache: true });
|
|
186
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
187
|
-
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
188
|
-
express: versions_1.expressVersion,
|
|
189
|
-
isbot: versions_1.isbotVersion,
|
|
190
|
-
cors: versions_1.corsVersion,
|
|
191
|
-
}, {
|
|
192
|
-
'@types/express': versions_1.typesExpressVersion,
|
|
193
|
-
'@types/cors': versions_1.typesCorsVersion,
|
|
194
|
-
}, undefined, true);
|
|
195
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
196
|
-
return installTask;
|
|
197
|
-
}
|
|
198
|
-
exports.default = setupSsrGenerator;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type * as ts from 'typescript';
|
|
2
|
-
import { StringChange } from '@nx/devkit';
|
|
3
|
-
export declare function addRemoteToConfig(source: ts.SourceFile, app: string): StringChange[];
|
|
4
|
-
export declare function addRemoteDefinition(source: ts.SourceFile, app: string): StringChange[];
|
|
5
|
-
export declare function addRemoteRoute(source: ts.SourceFile, names: {
|
|
6
|
-
fileName: string;
|
|
7
|
-
className: string;
|
|
8
|
-
}): StringChange[];
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addRemoteToConfig = addRemoteToConfig;
|
|
4
|
-
exports.addRemoteDefinition = addRemoteDefinition;
|
|
5
|
-
exports.addRemoteRoute = addRemoteRoute;
|
|
6
|
-
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const js_1 = require("@nx/js");
|
|
8
|
-
const ast_utils_1 = require("../utils/ast-utils");
|
|
9
|
-
const internal_1 = require("@nx/js/internal");
|
|
10
|
-
let tsModule;
|
|
11
|
-
function addRemoteToConfig(source, app) {
|
|
12
|
-
if (!tsModule) {
|
|
13
|
-
tsModule = (0, internal_1.ensureTypescript)();
|
|
14
|
-
}
|
|
15
|
-
const assignments = (0, js_1.findNodes)(source, tsModule.SyntaxKind.PropertyAssignment);
|
|
16
|
-
const remotesAssignment = assignments.find((s) => s.name.getText() === 'remotes');
|
|
17
|
-
if (remotesAssignment) {
|
|
18
|
-
const arrayExpression = remotesAssignment.initializer;
|
|
19
|
-
if (!arrayExpression.elements)
|
|
20
|
-
return [];
|
|
21
|
-
const lastElement = arrayExpression.elements[arrayExpression.elements.length - 1];
|
|
22
|
-
return [
|
|
23
|
-
lastElement && !arrayExpression.elements.hasTrailingComma
|
|
24
|
-
? {
|
|
25
|
-
type: devkit_1.ChangeType.Insert,
|
|
26
|
-
index: lastElement.end,
|
|
27
|
-
text: `,`,
|
|
28
|
-
}
|
|
29
|
-
: null,
|
|
30
|
-
{
|
|
31
|
-
type: devkit_1.ChangeType.Insert,
|
|
32
|
-
index: remotesAssignment.end - 1,
|
|
33
|
-
text: `'${app}',\n`,
|
|
34
|
-
},
|
|
35
|
-
].filter(Boolean);
|
|
36
|
-
}
|
|
37
|
-
const binaryExpressions = (0, js_1.findNodes)(source, tsModule.SyntaxKind.BinaryExpression);
|
|
38
|
-
const exportExpression = binaryExpressions.find((b) => {
|
|
39
|
-
if (b.left.kind === tsModule.SyntaxKind.PropertyAccessExpression) {
|
|
40
|
-
const pae = b.left;
|
|
41
|
-
return (pae.expression.getText() === 'module' &&
|
|
42
|
-
pae.name.getText() === 'exports');
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
if (exportExpression?.right.kind === tsModule.SyntaxKind.ObjectLiteralExpression) {
|
|
46
|
-
const ole = exportExpression.right;
|
|
47
|
-
return [
|
|
48
|
-
{
|
|
49
|
-
type: devkit_1.ChangeType.Insert,
|
|
50
|
-
index: ole.end - 1,
|
|
51
|
-
text: `remotes: ['${app}']\n`,
|
|
52
|
-
},
|
|
53
|
-
];
|
|
54
|
-
}
|
|
55
|
-
return [];
|
|
56
|
-
}
|
|
57
|
-
function addRemoteDefinition(source, app) {
|
|
58
|
-
return [
|
|
59
|
-
{
|
|
60
|
-
type: devkit_1.ChangeType.Insert,
|
|
61
|
-
index: source.end,
|
|
62
|
-
text: `\ndeclare module '${app}/Module';`,
|
|
63
|
-
},
|
|
64
|
-
];
|
|
65
|
-
}
|
|
66
|
-
function addRemoteRoute(source, names) {
|
|
67
|
-
const routes = (0, ast_utils_1.findElements)(source, 'Route');
|
|
68
|
-
const links = (0, ast_utils_1.findElements)(source, 'Link');
|
|
69
|
-
if (routes.length === 0) {
|
|
70
|
-
return [];
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
const changes = [];
|
|
74
|
-
const firstRoute = routes[0];
|
|
75
|
-
const firstLink = links[0];
|
|
76
|
-
changes.push(...(0, ast_utils_1.addImport)(source, `const ${names.className} = React.lazy(() => import('${names.fileName}/Module'));`));
|
|
77
|
-
changes.push({
|
|
78
|
-
type: devkit_1.ChangeType.Insert,
|
|
79
|
-
index: firstRoute.end,
|
|
80
|
-
text: `\n<Route path="/${names.fileName}" element={<${names.className} />} />`,
|
|
81
|
-
});
|
|
82
|
-
if (firstLink) {
|
|
83
|
-
const parentLi = (0, ast_utils_1.findClosestOpening)('li', firstLink);
|
|
84
|
-
if (parentLi) {
|
|
85
|
-
changes.push({
|
|
86
|
-
type: devkit_1.ChangeType.Insert,
|
|
87
|
-
index: parentLi.end,
|
|
88
|
-
text: `\n<li><Link to="/${names.fileName}">${names.className}</Link></li>`,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
changes.push({
|
|
93
|
-
type: devkit_1.ChangeType.Insert,
|
|
94
|
-
index: firstLink.parent.end,
|
|
95
|
-
text: `\n<Link to="/${names.fileName}">${names.className}</Link>`,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return changes;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Tree } from '@nx/devkit';
|
|
2
|
-
export declare function updateModuleFederationProject(host: Tree, options: {
|
|
3
|
-
js?: boolean;
|
|
4
|
-
projectName: string;
|
|
5
|
-
appProjectRoot: string;
|
|
6
|
-
port?: number;
|
|
7
|
-
typescriptConfiguration?: boolean;
|
|
8
|
-
dynamic?: boolean;
|
|
9
|
-
bundler?: 'rspack' | 'webpack';
|
|
10
|
-
ssr?: boolean;
|
|
11
|
-
}, isHost?: boolean): void;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateModuleFederationProject = updateModuleFederationProject;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const maybe_js_1 = require("../utils/maybe-js");
|
|
6
|
-
const internal_1 = require("@nx/js/internal");
|
|
7
|
-
function updateModuleFederationProject(host, options, isHost = false) {
|
|
8
|
-
const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
9
|
-
projectConfig.targets ??= {};
|
|
10
|
-
if (options.bundler !== 'rspack') {
|
|
11
|
-
projectConfig.targets.build.options = {
|
|
12
|
-
...(projectConfig.targets.build.options ?? {}),
|
|
13
|
-
main: (0, maybe_js_1.maybeJs)(options, `${options.appProjectRoot}/src/main.ts`),
|
|
14
|
-
webpackConfig: `${options.appProjectRoot}/webpack.config.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`,
|
|
15
|
-
};
|
|
16
|
-
projectConfig.targets.build.configurations ??= {};
|
|
17
|
-
if (!(0, internal_1.isUsingTsSolutionSetup)(host)) {
|
|
18
|
-
projectConfig.targets.build.configurations.production = {
|
|
19
|
-
...(projectConfig.targets.build.configurations?.production ?? {}),
|
|
20
|
-
webpackConfig: `${options.appProjectRoot}/webpack.config.prod.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
// If host should be configured to use dynamic federation
|
|
25
|
-
if (options.dynamic) {
|
|
26
|
-
if (options.bundler !== 'rspack') {
|
|
27
|
-
const pathToProdWebpackConfig = (0, devkit_1.joinPathFragments)(projectConfig.root, `webpack.prod.config.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`);
|
|
28
|
-
if (host.exists(pathToProdWebpackConfig)) {
|
|
29
|
-
host.delete(pathToProdWebpackConfig);
|
|
30
|
-
}
|
|
31
|
-
delete projectConfig.targets.build.configurations.production
|
|
32
|
-
?.webpackConfig;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
// Must precede the executor assignment below, which dereferences targets.serve:
|
|
36
|
-
// a plugin-driven workspace has no serve target in project.json to inherit.
|
|
37
|
-
projectConfig.targets.serve ??= {};
|
|
38
|
-
projectConfig.targets.serve.options ??= {};
|
|
39
|
-
if (options.bundler !== 'rspack') {
|
|
40
|
-
projectConfig.targets.serve.executor =
|
|
41
|
-
'@nx/react:module-federation-dev-server';
|
|
42
|
-
}
|
|
43
|
-
projectConfig.targets.serve.options.port =
|
|
44
|
-
options.bundler === 'rspack' && options.ssr && isHost ? 4000 : options.port;
|
|
45
|
-
// `serve-static` for remotes that don't need to be in development mode
|
|
46
|
-
if (options.bundler !== 'rspack') {
|
|
47
|
-
const serveStaticExecutor = '@nx/react:module-federation-static-server';
|
|
48
|
-
projectConfig.targets['serve-static'] = {
|
|
49
|
-
executor: serveStaticExecutor,
|
|
50
|
-
defaultConfiguration: 'production',
|
|
51
|
-
options: {
|
|
52
|
-
serveTarget: `${options.projectName}:serve`,
|
|
53
|
-
},
|
|
54
|
-
configurations: {
|
|
55
|
-
development: {
|
|
56
|
-
serveTarget: `${options.projectName}:serve:development`,
|
|
57
|
-
},
|
|
58
|
-
production: {
|
|
59
|
-
serveTarget: `${options.projectName}:serve:production`,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
// Typechecks must be performed first before build and serve to generate remote d.ts files.
|
|
65
|
-
if ((0, internal_1.isUsingTsSolutionSetup)(host)) {
|
|
66
|
-
projectConfig.targets.build ??= {};
|
|
67
|
-
projectConfig.targets.serve ??= {};
|
|
68
|
-
projectConfig.targets.build.dependsOn = ['^build', 'typecheck'];
|
|
69
|
-
projectConfig.targets.serve.dependsOn = ['typecheck'];
|
|
70
|
-
}
|
|
71
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
|
|
72
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addMfEnvToTargetDefaultInputs = addMfEnvToTargetDefaultInputs;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const internal_1 = require("@nx/devkit/internal");
|
|
6
|
-
function addMfEnvToTargetDefaultInputs(tree, bundler) {
|
|
7
|
-
const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
|
|
8
|
-
const executor = bundler === 'rspack' ? '@nx/rspack:rspack' : '@nx/webpack:webpack';
|
|
9
|
-
const mfEnvVar = 'NX_MF_DEV_REMOTES';
|
|
10
|
-
const existing = (0, internal_1.findTargetDefault)(nxJson.targetDefaults, { executor });
|
|
11
|
-
const inputs = [...(existing?.inputs ?? ['production', '^production'])];
|
|
12
|
-
let mfEnvVarExists = false;
|
|
13
|
-
for (const input of inputs) {
|
|
14
|
-
if (typeof input === 'object' && input['env'] === mfEnvVar) {
|
|
15
|
-
mfEnvVarExists = true;
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (!mfEnvVarExists) {
|
|
20
|
-
inputs.push({ env: mfEnvVar });
|
|
21
|
-
}
|
|
22
|
-
(0, internal_1.upsertTargetDefault)(tree, nxJson, {
|
|
23
|
-
executor,
|
|
24
|
-
cache: true,
|
|
25
|
-
inputs,
|
|
26
|
-
dependsOn: existing?.dependsOn ?? ['^build'],
|
|
27
|
-
});
|
|
28
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
29
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const REACT_HOST_GENERATOR_DEPRECATION_MESSAGE = "The `@nx/react:host` generator is deprecated and will be removed in Nx v24. Use `nx g @nx/react:consumer` (dynamic federation, no static-serve orchestration). See https://nx.dev/docs/technologies/module-federation/consumer-and-provider for the v23 migration guide.";
|
|
2
|
-
export declare const REACT_REMOTE_GENERATOR_DEPRECATION_MESSAGE = "The `@nx/react:remote` generator is deprecated and will be removed in Nx v24. Use `nx g @nx/react:provider` instead. See https://nx.dev/docs/technologies/module-federation/consumer-and-provider for the v23 migration guide.";
|
|
3
|
-
export declare const REACT_FEDERATE_MODULE_GENERATOR_DEPRECATION_MESSAGE = "The `@nx/react:federate-module` generator is deprecated and will be removed in Nx v24. The new `@nx/react:provider` generator exposes modules directly. See https://nx.dev/docs/technologies/module-federation/consumer-and-provider for the v23 migration guide.";
|
|
4
|
-
export declare const REACT_MF_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/react:module-federation-dev-server` executor is deprecated and will be removed in Nx v24. Dynamic federation in `@nx/react:consumer` removes the need for host-orchestrated remote serving. See https://nx.dev/docs/technologies/module-federation/consumer-and-provider for the v23 migration guide.";
|
|
5
|
-
export declare const REACT_MF_SSR_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/react:module-federation-ssr-dev-server` executor is deprecated and will be removed in Nx v24. SSR is not first-classed in the new generators; see https://nx.dev/docs/technologies/module-federation/consumer-and-provider for guidance on wiring SSR with `@nx/react:consumer`.";
|
|
6
|
-
export declare const REACT_MF_STATIC_SERVER_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/react:module-federation-static-server` executor is deprecated and will be removed in Nx v24. Use plain `vite preview` / `rsbuild preview` via `nx:run-commands` if a static-serve workflow is still needed. See https://nx.dev/docs/technologies/module-federation/consumer-and-provider for details.";
|
|
7
|
-
export declare function warnReactHostGeneratorDeprecation(): void;
|
|
8
|
-
export declare function warnReactRemoteGeneratorDeprecation(): void;
|
|
9
|
-
export declare function warnReactFederateModuleGeneratorDeprecation(): void;
|
|
10
|
-
export declare function warnReactMfDevServerExecutorDeprecation(): void;
|
|
11
|
-
export declare function warnReactMfSsrDevServerExecutorDeprecation(): void;
|
|
12
|
-
export declare function warnReactMfStaticServerExecutorDeprecation(): void;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REACT_MF_STATIC_SERVER_EXECUTOR_DEPRECATION_MESSAGE = exports.REACT_MF_SSR_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = exports.REACT_MF_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = exports.REACT_FEDERATE_MODULE_GENERATOR_DEPRECATION_MESSAGE = exports.REACT_REMOTE_GENERATOR_DEPRECATION_MESSAGE = exports.REACT_HOST_GENERATOR_DEPRECATION_MESSAGE = void 0;
|
|
4
|
-
exports.warnReactHostGeneratorDeprecation = warnReactHostGeneratorDeprecation;
|
|
5
|
-
exports.warnReactRemoteGeneratorDeprecation = warnReactRemoteGeneratorDeprecation;
|
|
6
|
-
exports.warnReactFederateModuleGeneratorDeprecation = warnReactFederateModuleGeneratorDeprecation;
|
|
7
|
-
exports.warnReactMfDevServerExecutorDeprecation = warnReactMfDevServerExecutorDeprecation;
|
|
8
|
-
exports.warnReactMfSsrDevServerExecutorDeprecation = warnReactMfSsrDevServerExecutorDeprecation;
|
|
9
|
-
exports.warnReactMfStaticServerExecutorDeprecation = warnReactMfStaticServerExecutorDeprecation;
|
|
10
|
-
const devkit_1 = require("@nx/devkit");
|
|
11
|
-
// TODO(v24): Remove these surfaces. Replaced by `@nx/react:consumer`
|
|
12
|
-
// and `@nx/react:provider` (React, dynamic federation, Vite/Rsbuild/Rspack).
|
|
13
|
-
const MIGRATION_URL = 'https://nx.dev/docs/technologies/module-federation/consumer-and-provider';
|
|
14
|
-
exports.REACT_HOST_GENERATOR_DEPRECATION_MESSAGE = `The \`@nx/react:host\` generator is deprecated and will be removed in Nx v24. Use \`nx g @nx/react:consumer\` (dynamic federation, no static-serve orchestration). See ${MIGRATION_URL} for the v23 migration guide.`;
|
|
15
|
-
exports.REACT_REMOTE_GENERATOR_DEPRECATION_MESSAGE = `The \`@nx/react:remote\` generator is deprecated and will be removed in Nx v24. Use \`nx g @nx/react:provider\` instead. See ${MIGRATION_URL} for the v23 migration guide.`;
|
|
16
|
-
exports.REACT_FEDERATE_MODULE_GENERATOR_DEPRECATION_MESSAGE = `The \`@nx/react:federate-module\` generator is deprecated and will be removed in Nx v24. The new \`@nx/react:provider\` generator exposes modules directly. See ${MIGRATION_URL} for the v23 migration guide.`;
|
|
17
|
-
exports.REACT_MF_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = `The \`@nx/react:module-federation-dev-server\` executor is deprecated and will be removed in Nx v24. Dynamic federation in \`@nx/react:consumer\` removes the need for host-orchestrated remote serving. See ${MIGRATION_URL} for the v23 migration guide.`;
|
|
18
|
-
exports.REACT_MF_SSR_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = `The \`@nx/react:module-federation-ssr-dev-server\` executor is deprecated and will be removed in Nx v24. SSR is not first-classed in the new generators; see ${MIGRATION_URL} for guidance on wiring SSR with \`@nx/react:consumer\`.`;
|
|
19
|
-
exports.REACT_MF_STATIC_SERVER_EXECUTOR_DEPRECATION_MESSAGE = `The \`@nx/react:module-federation-static-server\` executor is deprecated and will be removed in Nx v24. Use plain \`vite preview\` / \`rsbuild preview\` via \`nx:run-commands\` if a static-serve workflow is still needed. See ${MIGRATION_URL} for details.`;
|
|
20
|
-
function warnReactHostGeneratorDeprecation() {
|
|
21
|
-
devkit_1.logger.warn(exports.REACT_HOST_GENERATOR_DEPRECATION_MESSAGE);
|
|
22
|
-
}
|
|
23
|
-
function warnReactRemoteGeneratorDeprecation() {
|
|
24
|
-
devkit_1.logger.warn(exports.REACT_REMOTE_GENERATOR_DEPRECATION_MESSAGE);
|
|
25
|
-
}
|
|
26
|
-
function warnReactFederateModuleGeneratorDeprecation() {
|
|
27
|
-
devkit_1.logger.warn(exports.REACT_FEDERATE_MODULE_GENERATOR_DEPRECATION_MESSAGE);
|
|
28
|
-
}
|
|
29
|
-
// Executor warnings fire once per process (dev-server reload loops would
|
|
30
|
-
// otherwise flood the console).
|
|
31
|
-
const executorWarned = new Set();
|
|
32
|
-
function warnOnce(key, message) {
|
|
33
|
-
if (executorWarned.has(key))
|
|
34
|
-
return;
|
|
35
|
-
executorWarned.add(key);
|
|
36
|
-
devkit_1.logger.warn(message);
|
|
37
|
-
}
|
|
38
|
-
function warnReactMfDevServerExecutorDeprecation() {
|
|
39
|
-
warnOnce('react-mf-dev-server', exports.REACT_MF_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE);
|
|
40
|
-
}
|
|
41
|
-
function warnReactMfSsrDevServerExecutorDeprecation() {
|
|
42
|
-
warnOnce('react-mf-ssr-dev-server', exports.REACT_MF_SSR_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE);
|
|
43
|
-
}
|
|
44
|
-
function warnReactMfStaticServerExecutorDeprecation() {
|
|
45
|
-
warnOnce('react-mf-static-server', exports.REACT_MF_STATIC_SERVER_EXECUTOR_DEPRECATION_MESSAGE);
|
|
46
|
-
}
|