@nx/react 24.0.0-canary.20261019-c4bb923 → 24.0.0-canary.20261020-e7ffd79
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/module-federation.d.ts +6 -0
- package/dist/module-federation.js +31 -0
- 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/lib/add-e2e.js +4 -2
- 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/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/plugins/router-plugin-utils.d.ts +4 -0
- package/dist/src/plugins/router-plugin-utils.js +15 -0
- package/dist/src/plugins/router-plugin.js +30 -2
- 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/package.json +32 -16
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type IdentityConfigFn = <T>(config: T, ...rest: unknown[]) => T;
|
|
2
|
+
/** @deprecated Removed in Nx v24. Use `ModuleFederationPlugin` from `@module-federation/enhanced`. This stub will be removed in Nx v25. */
|
|
3
|
+
export declare function withModuleFederation(..._args: unknown[]): Promise<IdentityConfigFn>;
|
|
4
|
+
/** @deprecated Removed in Nx v24. Use `ModuleFederationPlugin` from `@module-federation/enhanced`. This stub will be removed in Nx v25. */
|
|
5
|
+
export declare function withModuleFederationForSSR(..._args: unknown[]): Promise<IdentityConfigFn>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withModuleFederation = withModuleFederation;
|
|
4
|
+
exports.withModuleFederationForSSR = withModuleFederationForSSR;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
// TODO(v25): Delete this subpath. It keeps 23.x configs loading during graph creation so `nx migrate` can run.
|
|
7
|
+
const REMOVED_MESSAGE = 'Nx Module Federation was removed in Nx v24. `@nx/react/module-federation` is a stub that keeps old configs loadable during project graph creation; it does not configure Module Federation. Follow https://nx.dev/docs/kb/migrate-from-nx-module-federation to move to the official Module Federation plugin.';
|
|
8
|
+
let warned = false;
|
|
9
|
+
// Graph creation only reads the config, so it keeps working; a build would silently drop federation.
|
|
10
|
+
function failOutsideGraphCreation() {
|
|
11
|
+
if (!global.NX_GRAPH_CREATION)
|
|
12
|
+
throw new Error(REMOVED_MESSAGE);
|
|
13
|
+
if (warned)
|
|
14
|
+
return;
|
|
15
|
+
warned = true;
|
|
16
|
+
devkit_1.logger.warn(REMOVED_MESSAGE);
|
|
17
|
+
}
|
|
18
|
+
/** @deprecated Removed in Nx v24. Use `ModuleFederationPlugin` from `@module-federation/enhanced`. This stub will be removed in Nx v25. */
|
|
19
|
+
async function withModuleFederation(..._args) {
|
|
20
|
+
failOutsideGraphCreation();
|
|
21
|
+
return (config) => config;
|
|
22
|
+
}
|
|
23
|
+
/** @deprecated Removed in Nx v24. Use `ModuleFederationPlugin` from `@module-federation/enhanced`. This stub will be removed in Nx v25. */
|
|
24
|
+
async function withModuleFederationForSSR(..._args) {
|
|
25
|
+
failOutsideGraphCreation();
|
|
26
|
+
return (config) => config;
|
|
27
|
+
}
|
|
28
|
+
// Older generated configs use `const withModuleFederation = require('@nx/react/module-federation')`.
|
|
29
|
+
module.exports = withModuleFederation;
|
|
30
|
+
module.exports.withModuleFederation = withModuleFederation;
|
|
31
|
+
module.exports.withModuleFederationForSSR = withModuleFederationForSSR;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { waitForReactRouterServe as waitForDevServer } from './src/utils/react-router-serve-ready-check';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.waitForDevServer = void 0;
|
|
4
|
+
var react_router_serve_ready_check_1 = require("./src/utils/react-router-serve-ready-check");
|
|
5
|
+
Object.defineProperty(exports, "waitForDevServer", { enumerable: true, get: function () { return react_router_serve_ready_check_1.waitForReactRouterServe; } });
|
|
@@ -48,6 +48,7 @@ function bundlerDeps(bundler) {
|
|
|
48
48
|
dependencies: {},
|
|
49
49
|
devDependencies: {
|
|
50
50
|
'@module-federation/vite': mfVersions.moduleFederationVitePluginVersion,
|
|
51
|
+
'@nx/vite': versions_2.nxVersion,
|
|
51
52
|
'@vitejs/plugin-react': mfVersions.vitejsPluginReactVersion,
|
|
52
53
|
vite: mfVersions.viteVersion,
|
|
53
54
|
},
|
|
@@ -57,6 +58,7 @@ function bundlerDeps(bundler) {
|
|
|
57
58
|
dependencies: {},
|
|
58
59
|
devDependencies: {
|
|
59
60
|
'@module-federation/rsbuild-plugin': mfVersions.moduleFederationRsbuildPluginVersion,
|
|
61
|
+
'@nx/rsbuild': versions_2.nxVersion,
|
|
60
62
|
'@rsbuild/core': mfVersions.rsbuildCoreVersion,
|
|
61
63
|
'@rsbuild/plugin-react': mfVersions.rsbuildPluginReactVersion,
|
|
62
64
|
},
|
|
@@ -69,6 +71,7 @@ function bundlerDeps(bundler) {
|
|
|
69
71
|
'@module-federation/enhanced': mfVersions.moduleFederationEnhancedVersion,
|
|
70
72
|
},
|
|
71
73
|
devDependencies: {
|
|
74
|
+
'@nx/rspack': versions_2.nxVersion,
|
|
72
75
|
'@rspack/cli': mfVersions.rspackCliVersion,
|
|
73
76
|
'@rspack/core': mfVersions.rspackCoreVersion,
|
|
74
77
|
'@rspack/dev-server': mfVersions.rspackDevServerVersion,
|
|
@@ -138,8 +138,10 @@ async function addE2e(tree, options) {
|
|
|
138
138
|
js: false,
|
|
139
139
|
linter: options.linter,
|
|
140
140
|
enableTypedLinting: (0, internal_1.isTypedLintingEnabled)(options),
|
|
141
|
-
webServerCommand: e2eWebServerInfo.
|
|
142
|
-
webServerAddress: e2eWebServerInfo.
|
|
141
|
+
webServerCommand: e2eWebServerInfo.e2eWebServerCommand,
|
|
142
|
+
webServerAddress: e2eWebServerInfo.e2eWebServerAddress,
|
|
143
|
+
ciWebServerCommand: e2eWebServerInfo.e2eCiWebServerCommand,
|
|
144
|
+
ciWebServerAddress: e2eWebServerInfo.e2eCiBaseUrl,
|
|
143
145
|
rootProject: options.rootProject,
|
|
144
146
|
});
|
|
145
147
|
return e2eTask;
|
|
@@ -66,6 +66,7 @@ async function consumerGenerator(tree, schema) {
|
|
|
66
66
|
command: BUNDLER_DEV_COMMAND[opts.bundler],
|
|
67
67
|
cwd: opts.projectRoot,
|
|
68
68
|
},
|
|
69
|
+
readyWhen: { signal: true },
|
|
69
70
|
},
|
|
70
71
|
build: {
|
|
71
72
|
executor: 'nx:run-commands',
|
|
@@ -118,6 +119,7 @@ async function consumerGenerator(tree, schema) {
|
|
|
118
119
|
remoteType,
|
|
119
120
|
versions: {
|
|
120
121
|
...mfVersions,
|
|
122
|
+
nxVersion: versions_2.nxVersion,
|
|
121
123
|
reactVersion: versions_2.reactVersion,
|
|
122
124
|
reactDomVersion: versions_2.reactDomVersion,
|
|
123
125
|
typesReactVersion: versions_2.typesReactVersion,
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@module-federation/rsbuild-plugin": "<%= versions.moduleFederationRsbuildPluginVersion %>",
|
|
17
|
+
"@nx/rsbuild": "<%= versions.nxVersion %>",
|
|
17
18
|
"@rsbuild/core": "<%= versions.rsbuildCoreVersion %>",
|
|
18
19
|
"@rsbuild/plugin-react": "<%= versions.rsbuildPluginReactVersion %>",
|
|
19
20
|
"@types/react": "<%= versions.typesReactVersion %>",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineConfig } from '@rsbuild/core';
|
|
2
2
|
import { pluginReact } from '@rsbuild/plugin-react';
|
|
3
3
|
import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';
|
|
4
|
+
import { pluginNxReadySignal } from '@nx/rsbuild/ready-signal';
|
|
4
5
|
|
|
5
6
|
const PORT = <%= port %>;
|
|
6
7
|
const NAME = '<%= federationName %>';
|
|
@@ -21,5 +22,6 @@ export default defineConfig({
|
|
|
21
22
|
// at module load time.
|
|
22
23
|
shared: ['react', 'react-dom'],
|
|
23
24
|
}),
|
|
25
|
+
pluginNxReadySignal(),
|
|
24
26
|
],
|
|
25
27
|
});
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"react-dom": "<%= versions.reactDomVersion %>"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
+
"@nx/rspack": "<%= versions.nxVersion %>",
|
|
16
17
|
"@rspack/cli": "<%= versions.rspackCliVersion %>",
|
|
17
18
|
"@rspack/core": "<%= versions.rspackCoreVersion %>",
|
|
18
19
|
"@rspack/dev-server": "<%= versions.rspackDevServerVersion %>",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineConfig } from '@rspack/cli';
|
|
2
2
|
import { rspack } from '@rspack/core';
|
|
3
3
|
import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
|
|
4
|
+
import { NxReadySignalPlugin } from '@nx/rspack/ready-signal';
|
|
4
5
|
import { ReactRefreshRspackPlugin } from '@rspack/plugin-react-refresh';
|
|
5
6
|
import * as path from 'node:path';
|
|
6
7
|
import { fileURLToPath } from 'node:url';
|
|
@@ -58,6 +59,7 @@ export default defineConfig((_env, argv) => {
|
|
|
58
59
|
// src/mf.ts at module load time.
|
|
59
60
|
shared: ['react', 'react-dom'],
|
|
60
61
|
}),
|
|
62
|
+
new NxReadySignalPlugin(),
|
|
61
63
|
].filter(Boolean),
|
|
62
64
|
};
|
|
63
65
|
});
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@module-federation/vite": "<%= versions.moduleFederationVitePluginVersion %>",
|
|
18
|
+
"@nx/vite": "<%= versions.nxVersion %>",
|
|
18
19
|
"@types/react": "<%= versions.typesReactVersion %>",
|
|
19
20
|
"@types/react-dom": "<%= versions.typesReactDomVersion %>",
|
|
20
21
|
"@vitejs/plugin-react": "<%= versions.vitejsPluginReactVersion %>",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineConfig } from 'vite';
|
|
2
2
|
import react from '@vitejs/plugin-react';
|
|
3
3
|
import { federation } from '@module-federation/vite';
|
|
4
|
+
import { nxReadySignal } from '@nx/vite/plugins/nx-ready-signal.plugin';
|
|
4
5
|
|
|
5
6
|
const PORT = <%= port %>;
|
|
6
7
|
|
|
@@ -23,5 +24,6 @@ export default defineConfig({
|
|
|
23
24
|
},
|
|
24
25
|
}),
|
|
25
26
|
react(),
|
|
27
|
+
nxReadySignal(),
|
|
26
28
|
],
|
|
27
29
|
});
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@module-federation/rsbuild-plugin": "<%= versions.moduleFederationRsbuildPluginVersion %>",
|
|
16
|
+
"@nx/rsbuild": "<%= versions.nxVersion %>",
|
|
16
17
|
"@rsbuild/core": "<%= versions.rsbuildCoreVersion %>",
|
|
17
18
|
"@rsbuild/plugin-react": "<%= versions.rsbuildPluginReactVersion %>",
|
|
18
19
|
"@types/react": "<%= versions.typesReactVersion %>",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineConfig } from '@rsbuild/core';
|
|
2
2
|
import { pluginReact } from '@rsbuild/plugin-react';
|
|
3
3
|
import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';
|
|
4
|
+
import { pluginNxReadySignal } from '@nx/rsbuild/ready-signal';
|
|
4
5
|
|
|
5
6
|
const PORT = <%= port %>;
|
|
6
7
|
const NAME = '<%= federationName %>';
|
|
@@ -27,5 +28,6 @@ export default defineConfig({
|
|
|
27
28
|
},
|
|
28
29
|
shared: ['react', 'react-dom'],
|
|
29
30
|
}),
|
|
31
|
+
pluginNxReadySignal(),
|
|
30
32
|
],
|
|
31
33
|
});
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"react-dom": "<%= versions.reactDomVersion %>"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
+
"@nx/rspack": "<%= versions.nxVersion %>",
|
|
15
16
|
"@rspack/cli": "<%= versions.rspackCliVersion %>",
|
|
16
17
|
"@rspack/core": "<%= versions.rspackCoreVersion %>",
|
|
17
18
|
"@rspack/dev-server": "<%= versions.rspackDevServerVersion %>",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineConfig } from '@rspack/cli';
|
|
2
2
|
import { rspack } from '@rspack/core';
|
|
3
3
|
import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
|
|
4
|
+
import { NxReadySignalPlugin } from '@nx/rspack/ready-signal';
|
|
4
5
|
import { ReactRefreshRspackPlugin } from '@rspack/plugin-react-refresh';
|
|
5
6
|
import * as path from 'node:path';
|
|
6
7
|
import { fileURLToPath } from 'node:url';
|
|
@@ -68,6 +69,7 @@ export default defineConfig((_env, argv) => {
|
|
|
68
69
|
},
|
|
69
70
|
shared: ['react', 'react-dom'],
|
|
70
71
|
}),
|
|
72
|
+
new NxReadySignalPlugin(),
|
|
71
73
|
].filter(Boolean),
|
|
72
74
|
};
|
|
73
75
|
});
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@module-federation/vite": "<%= versions.moduleFederationVitePluginVersion %>",
|
|
17
|
+
"@nx/vite": "<%= versions.nxVersion %>",
|
|
17
18
|
"@types/react": "<%= versions.typesReactVersion %>",
|
|
18
19
|
"@types/react-dom": "<%= versions.typesReactDomVersion %>",
|
|
19
20
|
"@vitejs/plugin-react": "<%= versions.vitejsPluginReactVersion %>",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineConfig } from 'vite';
|
|
2
2
|
import react from '@vitejs/plugin-react';
|
|
3
3
|
import { federation } from '@module-federation/vite';
|
|
4
|
+
import { nxReadySignal } from '@nx/vite/plugins/nx-ready-signal.plugin';
|
|
4
5
|
|
|
5
6
|
// Port deliberately avoids 5000 (macOS AirTunes binds it on 0.0.0.0, leading
|
|
6
7
|
// to silent EADDRINUSE on 127.0.0.1). Override `--port` only if 5000+ is free.
|
|
@@ -33,5 +34,6 @@ export default defineConfig({
|
|
|
33
34
|
},
|
|
34
35
|
}),
|
|
35
36
|
react(),
|
|
37
|
+
nxReadySignal(),
|
|
36
38
|
],
|
|
37
39
|
});
|
|
@@ -47,6 +47,7 @@ async function providerGenerator(tree, schema) {
|
|
|
47
47
|
command: BUNDLER_DEV_COMMAND[opts.bundler],
|
|
48
48
|
cwd: opts.projectRoot,
|
|
49
49
|
},
|
|
50
|
+
readyWhen: { signal: true },
|
|
50
51
|
};
|
|
51
52
|
if (schema.consumer) {
|
|
52
53
|
serveTarget.dependsOn = [`${schema.consumer}:serve`];
|
|
@@ -74,6 +75,7 @@ async function providerGenerator(tree, schema) {
|
|
|
74
75
|
componentName,
|
|
75
76
|
versions: {
|
|
76
77
|
...mfVersions,
|
|
78
|
+
nxVersion: versions_2.nxVersion,
|
|
77
79
|
reactVersion: versions_2.reactVersion,
|
|
78
80
|
reactDomVersion: versions_2.reactDomVersion,
|
|
79
81
|
typesReactVersion: versions_2.typesReactVersion,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.canResolve = canResolve;
|
|
4
|
+
/**
|
|
5
|
+
* Whether `request` resolves from `directory`, without loading it.
|
|
6
|
+
*/
|
|
7
|
+
function canResolve(request, directory) {
|
|
8
|
+
try {
|
|
9
|
+
require.resolve(request, { paths: [directory] });
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -7,6 +7,7 @@ const path_1 = require("path");
|
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const js_1 = require("@nx/js");
|
|
9
9
|
const internal_2 = require("@nx/js/internal");
|
|
10
|
+
const router_plugin_utils_1 = require("./router-plugin-utils");
|
|
10
11
|
const reactRouterConfigBlob = '**/react-router.config.{ts,js,cjs,cts,mjs,mts}';
|
|
11
12
|
exports.createNodes = [
|
|
12
13
|
reactRouterConfigBlob,
|
|
@@ -73,7 +74,7 @@ async function buildReactRouterTargets(configFilePath, projectRoot, options, con
|
|
|
73
74
|
const { buildDirectory, serverBuildPath } = await getBuildPaths(reactRouterConfig, isLibMode);
|
|
74
75
|
const targets = {};
|
|
75
76
|
targets[options.buildTargetName] = await getBuildTargetConfig(options.buildTargetName, projectRoot, buildDirectory, serverBuildPath, namedInputs, isUsingTsSolutionSetup);
|
|
76
|
-
targets[options.devTargetName] = await devTarget(projectRoot, namedInputs, isUsingTsSolutionSetup);
|
|
77
|
+
targets[options.devTargetName] = await devTarget(projectRoot, namedInputs, isUsingTsSolutionSetup, getDevReadyWhen(context.workspaceRoot, (0, path_1.join)(context.workspaceRoot, projectRoot)));
|
|
77
78
|
if (serverBuildPath) {
|
|
78
79
|
targets[options.startTargetName] = await startTarget(projectRoot, serverBuildPath, options.buildTargetName, namedInputs, isUsingTsSolutionSetup);
|
|
79
80
|
}
|
|
@@ -128,18 +129,44 @@ function buildInputs(namedInputs) {
|
|
|
128
129
|
{ externalDependencies: ['@react-router/dev'] },
|
|
129
130
|
];
|
|
130
131
|
}
|
|
131
|
-
async function devTarget(projectRoot, namedInputs, isUsingTsSolutionSetup) {
|
|
132
|
+
async function devTarget(projectRoot, namedInputs, isUsingTsSolutionSetup, readyWhen) {
|
|
132
133
|
const devTarget = {
|
|
133
134
|
continuous: true,
|
|
134
135
|
inputs: buildInputs(namedInputs),
|
|
135
136
|
command: 'react-router dev',
|
|
136
137
|
options: { cwd: projectRoot },
|
|
137
138
|
};
|
|
139
|
+
if (readyWhen) {
|
|
140
|
+
devTarget.readyWhen = readyWhen;
|
|
141
|
+
}
|
|
138
142
|
if (isUsingTsSolutionSetup) {
|
|
139
143
|
devTarget.syncGenerators = ['@nx/js:typescript-sync'];
|
|
140
144
|
}
|
|
141
145
|
return devTarget;
|
|
142
146
|
}
|
|
147
|
+
// Vite's lookup order for the config in its root
|
|
148
|
+
const viteConfigFiles = [
|
|
149
|
+
'vite.config.js',
|
|
150
|
+
'vite.config.mjs',
|
|
151
|
+
'vite.config.ts',
|
|
152
|
+
'vite.config.cjs',
|
|
153
|
+
'vite.config.mts',
|
|
154
|
+
'vite.config.cts',
|
|
155
|
+
];
|
|
156
|
+
// The Vite check resolves the config when the task runs, with the task's env
|
|
157
|
+
// and options, and waits for the server's port.
|
|
158
|
+
function getDevReadyWhen(workspaceRoot, absoluteProjectRoot) {
|
|
159
|
+
// `react-router dev` serves with the default Vite config of its cwd.
|
|
160
|
+
const configFile = viteConfigFiles.find((file) => (0, fs_1.existsSync)((0, path_1.join)(absoluteProjectRoot, file)));
|
|
161
|
+
if (!configFile) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
// Nx runs the check from the workspace root, where @nx/vite may be missing
|
|
165
|
+
if (!(0, router_plugin_utils_1.canResolve)('@nx/vite/ready-check', workspaceRoot)) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
return (0, internal_1.getReadyCheckReadyWhen)('@nx/vite/ready-check', configFile, 'react-router-dev');
|
|
169
|
+
}
|
|
143
170
|
async function startTarget(projectRoot, serverBuildPath, buildTargetName, namedInputs, isUsingTsSolutionSetup) {
|
|
144
171
|
const serverPath = serverBuildPath === 'build/server'
|
|
145
172
|
? `${serverBuildPath}/index.js`
|
|
@@ -150,6 +177,7 @@ async function startTarget(projectRoot, serverBuildPath, buildTargetName, namedI
|
|
|
150
177
|
inputs: buildInputs(namedInputs),
|
|
151
178
|
command: `react-router-serve ${serverPath}`,
|
|
152
179
|
options: { cwd: projectRoot },
|
|
180
|
+
readyWhen: (0, internal_1.getReadyCheckReadyWhen)('@nx/react/ready-check'),
|
|
153
181
|
};
|
|
154
182
|
if (isUsingTsSolutionSetup) {
|
|
155
183
|
startTarget.syncGenerators = ['@nx/js:typescript-sync'];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ServerAddress } from '@nx/devkit/internal';
|
|
2
|
+
/**
|
|
3
|
+
* Where `react-router-serve` listens: on PORT and HOST from its env, or on
|
|
4
|
+
* 3000 when PORT is unset and 3000 is free.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getReactRouterServeAddress(env: NodeJS.ProcessEnv): ServerAddress | null;
|
|
7
|
+
/**
|
|
8
|
+
* The readyWhen of the inferred `react-router-serve` target. Runs in the env of
|
|
9
|
+
* the task and waits for the server's port.
|
|
10
|
+
*/
|
|
11
|
+
export declare function waitForReactRouterServe(): Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getReactRouterServeAddress = getReactRouterServeAddress;
|
|
4
|
+
exports.waitForReactRouterServe = waitForReactRouterServe;
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
|
+
/**
|
|
7
|
+
* Where `react-router-serve` listens: on PORT and HOST from its env, or on
|
|
8
|
+
* 3000 when PORT is unset and 3000 is free.
|
|
9
|
+
*/
|
|
10
|
+
function getReactRouterServeAddress(env) {
|
|
11
|
+
// react-router-serve reads PORT with Number() and ignores only NaN, so an
|
|
12
|
+
// empty PORT is port 0, which the server picks
|
|
13
|
+
const port = Number(env.PORT);
|
|
14
|
+
return (0, internal_1.getServerAddress)(Number.isNaN(port) ? 3000 : port, env.HOST);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The readyWhen of the inferred `react-router-serve` target. Runs in the env of
|
|
18
|
+
* the task and waits for the server's port.
|
|
19
|
+
*/
|
|
20
|
+
async function waitForReactRouterServe() {
|
|
21
|
+
await (0, internal_1.runReadyCheck)(async () => {
|
|
22
|
+
const address = getReactRouterServeAddress(process.env);
|
|
23
|
+
return address ? [address] : null;
|
|
24
|
+
});
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "24.0.0-canary.
|
|
3
|
+
"version": "24.0.0-canary.20261020-e7ffd79",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Vitest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
|
|
6
6
|
"repository": {
|
|
@@ -36,12 +36,18 @@
|
|
|
36
36
|
"tailwind": [
|
|
37
37
|
"dist/tailwind.d.ts"
|
|
38
38
|
],
|
|
39
|
+
"module-federation": [
|
|
40
|
+
"dist/module-federation.d.ts"
|
|
41
|
+
],
|
|
39
42
|
"webpack-plugin": [
|
|
40
43
|
"dist/webpack-plugin.d.ts"
|
|
41
44
|
],
|
|
42
45
|
"router-plugin": [
|
|
43
46
|
"dist/router-plugin.d.ts"
|
|
44
47
|
],
|
|
48
|
+
"ready-check": [
|
|
49
|
+
"dist/ready-check.d.ts"
|
|
50
|
+
],
|
|
45
51
|
"ast-utils": [
|
|
46
52
|
"dist/ast-utils.d.ts"
|
|
47
53
|
],
|
|
@@ -99,26 +105,26 @@
|
|
|
99
105
|
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
100
106
|
"minimatch": "10.2.5",
|
|
101
107
|
"tslib": "^2.3.0",
|
|
102
|
-
"@nx/devkit": "24.0.0-canary.
|
|
103
|
-
"@nx/js": "24.0.0-canary.
|
|
104
|
-
"@nx/eslint": "24.0.0-canary.
|
|
105
|
-
"@nx/web": "24.0.0-canary.
|
|
108
|
+
"@nx/devkit": "24.0.0-canary.20261020-e7ffd79",
|
|
109
|
+
"@nx/js": "24.0.0-canary.20261020-e7ffd79",
|
|
110
|
+
"@nx/eslint": "24.0.0-canary.20261020-e7ffd79",
|
|
111
|
+
"@nx/web": "24.0.0-canary.20261020-e7ffd79",
|
|
106
112
|
"semver": "^7.6.3"
|
|
107
113
|
},
|
|
108
114
|
"devDependencies": {
|
|
109
|
-
"@nx/cypress": "24.0.0-canary.
|
|
110
|
-
"@nx/playwright": "24.0.0-canary.
|
|
111
|
-
"@nx/rollup": "24.0.0-canary.
|
|
112
|
-
"@nx/rsbuild": "24.0.0-canary.
|
|
113
|
-
"@nx/rspack": "24.0.0-canary.
|
|
114
|
-
"@nx/vite": "24.0.0-canary.
|
|
115
|
-
"@nx/vitest": "24.0.0-canary.
|
|
116
|
-
"@nx/webpack": "24.0.0-canary.
|
|
117
|
-
"@nx/storybook": "24.0.0-canary.
|
|
118
|
-
"nx": "24.0.0-canary.
|
|
115
|
+
"@nx/cypress": "24.0.0-canary.20261020-e7ffd79",
|
|
116
|
+
"@nx/playwright": "24.0.0-canary.20261020-e7ffd79",
|
|
117
|
+
"@nx/rollup": "24.0.0-canary.20261020-e7ffd79",
|
|
118
|
+
"@nx/rsbuild": "24.0.0-canary.20261020-e7ffd79",
|
|
119
|
+
"@nx/rspack": "24.0.0-canary.20261020-e7ffd79",
|
|
120
|
+
"@nx/vite": "24.0.0-canary.20261020-e7ffd79",
|
|
121
|
+
"@nx/vitest": "24.0.0-canary.20261020-e7ffd79",
|
|
122
|
+
"@nx/webpack": "24.0.0-canary.20261020-e7ffd79",
|
|
123
|
+
"@nx/storybook": "24.0.0-canary.20261020-e7ffd79",
|
|
124
|
+
"nx": "24.0.0-canary.20261020-e7ffd79"
|
|
119
125
|
},
|
|
120
126
|
"optionalDependencies": {
|
|
121
|
-
"@nx/vite": "24.0.0-canary.
|
|
127
|
+
"@nx/vite": "24.0.0-canary.20261020-e7ffd79"
|
|
122
128
|
},
|
|
123
129
|
"publishConfig": {
|
|
124
130
|
"access": "public"
|
|
@@ -143,6 +149,11 @@
|
|
|
143
149
|
"types": "./dist/tailwind.d.ts",
|
|
144
150
|
"default": "./dist/tailwind.js"
|
|
145
151
|
},
|
|
152
|
+
"./module-federation": {
|
|
153
|
+
"@nx/nx-source": "./module-federation.ts",
|
|
154
|
+
"types": "./dist/module-federation.d.ts",
|
|
155
|
+
"default": "./dist/module-federation.js"
|
|
156
|
+
},
|
|
146
157
|
"./webpack-plugin": {
|
|
147
158
|
"@nx/nx-source": "./webpack-plugin.ts",
|
|
148
159
|
"types": "./dist/webpack-plugin.d.ts",
|
|
@@ -153,6 +164,11 @@
|
|
|
153
164
|
"types": "./dist/router-plugin.d.ts",
|
|
154
165
|
"default": "./dist/router-plugin.js"
|
|
155
166
|
},
|
|
167
|
+
"./ready-check": {
|
|
168
|
+
"@nx/nx-source": "./ready-check.ts",
|
|
169
|
+
"types": "./dist/ready-check.d.ts",
|
|
170
|
+
"default": "./dist/ready-check.js"
|
|
171
|
+
},
|
|
156
172
|
"./ast-utils": {
|
|
157
173
|
"@nx/nx-source": "./ast-utils.ts",
|
|
158
174
|
"types": "./dist/ast-utils.d.ts",
|