@nx/react 18.0.3 → 18.1.0-beta.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "18.0.
|
|
3
|
+
"version": "18.1.0-beta.0",
|
|
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, 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,11 +36,11 @@
|
|
|
36
36
|
"chalk": "^4.1.0",
|
|
37
37
|
"minimatch": "9.0.3",
|
|
38
38
|
"tslib": "^2.3.0",
|
|
39
|
-
"@nx/devkit": "18.0.
|
|
40
|
-
"@nx/js": "18.0.
|
|
41
|
-
"@nx/eslint": "18.0.
|
|
42
|
-
"@nx/web": "18.0.
|
|
43
|
-
"@nrwl/react": "18.0.
|
|
39
|
+
"@nx/devkit": "18.1.0-beta.0",
|
|
40
|
+
"@nx/js": "18.1.0-beta.0",
|
|
41
|
+
"@nx/eslint": "18.1.0-beta.0",
|
|
42
|
+
"@nx/web": "18.1.0-beta.0",
|
|
43
|
+
"@nrwl/react": "18.1.0-beta.0"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
@@ -8,6 +8,16 @@ type ModuleFederationDevServerOptions = WebDevServerOptions & {
|
|
|
8
8
|
parallel?: number;
|
|
9
9
|
staticRemotesPort?: number;
|
|
10
10
|
};
|
|
11
|
+
type StaticRemoteConfig = {
|
|
12
|
+
basePath: string;
|
|
13
|
+
outputPath: string;
|
|
14
|
+
urlSegment: string;
|
|
15
|
+
};
|
|
16
|
+
type StaticRemotesConfig = {
|
|
17
|
+
remotes: string[];
|
|
18
|
+
config: Record<string, StaticRemoteConfig> | undefined;
|
|
19
|
+
};
|
|
20
|
+
export declare function parseStaticRemotesConfig(staticRemotes: string[] | undefined, context: ExecutorContext): StaticRemotesConfig;
|
|
11
21
|
export default function moduleFederationDevServer(options: ModuleFederationDevServerOptions, context: ExecutorContext): AsyncIterableIterator<{
|
|
12
22
|
success: boolean;
|
|
13
23
|
baseUrl?: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseStaticRemotesConfig = void 0;
|
|
3
4
|
const devkit_1 = require("@nx/devkit");
|
|
4
5
|
const dev_server_impl_1 = require("@nx/webpack/src/executors/dev-server/dev-server.impl");
|
|
5
6
|
const file_server_impl_1 = require("@nx/web/src/executors/file-server/file-server.impl");
|
|
@@ -16,26 +17,24 @@ function getBuildOptions(buildTarget, context) {
|
|
|
16
17
|
...buildOptions,
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
|
-
function startStaticRemotesFileServer(
|
|
20
|
+
function startStaticRemotesFileServer(staticRemotesConfig, context, options) {
|
|
20
21
|
let shouldMoveToCommonLocation = false;
|
|
21
22
|
let commonOutputDirectory;
|
|
22
|
-
for (const app of remotes
|
|
23
|
-
const
|
|
24
|
-
const directoryOfOutputPath = (0, path_1.dirname)(outputPath);
|
|
23
|
+
for (const app of staticRemotesConfig.remotes) {
|
|
24
|
+
const remoteBasePath = staticRemotesConfig.config[app].basePath;
|
|
25
25
|
if (!commonOutputDirectory) {
|
|
26
|
-
commonOutputDirectory =
|
|
26
|
+
commonOutputDirectory = remoteBasePath;
|
|
27
27
|
}
|
|
28
|
-
else if (commonOutputDirectory !==
|
|
29
|
-
!outputPath.endsWith(app)) {
|
|
28
|
+
else if (commonOutputDirectory !== remoteBasePath) {
|
|
30
29
|
shouldMoveToCommonLocation = true;
|
|
30
|
+
break;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
if (shouldMoveToCommonLocation) {
|
|
34
34
|
commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
|
|
35
|
-
for (const app of remotes
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
(0, fs_1.cpSync)(outputPath, (0, path_1.join)(commonOutputDirectory, app), {
|
|
35
|
+
for (const app of staticRemotesConfig.remotes) {
|
|
36
|
+
const remoteConfig = staticRemotesConfig.config[app];
|
|
37
|
+
(0, fs_1.cpSync)(remoteConfig.outputPath, (0, path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
|
|
39
38
|
force: true,
|
|
40
39
|
recursive: true,
|
|
41
40
|
});
|
|
@@ -74,21 +73,21 @@ async function startDevRemotes(remotes, context) {
|
|
|
74
73
|
}
|
|
75
74
|
return devRemoteIters;
|
|
76
75
|
}
|
|
77
|
-
async function buildStaticRemotes(
|
|
78
|
-
if (!remotes.
|
|
76
|
+
async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options) {
|
|
77
|
+
if (!staticRemotesConfig.remotes.length) {
|
|
79
78
|
return;
|
|
80
79
|
}
|
|
81
|
-
devkit_1.logger.info(`NX Building ${remotes.
|
|
80
|
+
devkit_1.logger.info(`NX Building ${staticRemotesConfig.remotes.length} static remotes...`);
|
|
82
81
|
const mappedLocationOfRemotes = {};
|
|
83
|
-
for (const app of remotes
|
|
84
|
-
mappedLocationOfRemotes[app] = `http${options.ssl ? 's' : ''}://${options.host}:${options.staticRemotesPort}/${app}`;
|
|
82
|
+
for (const app of staticRemotesConfig.remotes) {
|
|
83
|
+
mappedLocationOfRemotes[app] = `http${options.ssl ? 's' : ''}://${options.host}:${options.staticRemotesPort}/${staticRemotesConfig.config[app].urlSegment}`;
|
|
85
84
|
}
|
|
86
85
|
process.env.NX_MF_DEV_SERVER_STATIC_REMOTES = JSON.stringify(mappedLocationOfRemotes);
|
|
87
86
|
await new Promise((res) => {
|
|
88
87
|
const staticProcess = (0, child_process_1.fork)(nxBin, [
|
|
89
88
|
'run-many',
|
|
90
89
|
`--target=build`,
|
|
91
|
-
`--projects=${remotes.
|
|
90
|
+
`--projects=${staticRemotesConfig.remotes.join(',')}`,
|
|
92
91
|
...(context.configurationName
|
|
93
92
|
? [`--configuration=${context.configurationName}`]
|
|
94
93
|
: []),
|
|
@@ -102,7 +101,7 @@ async function buildStaticRemotes(remotes, nxBin, context, options) {
|
|
|
102
101
|
const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
|
|
103
102
|
if (stdoutString.includes('Successfully ran target build')) {
|
|
104
103
|
staticProcess.stdout.removeAllListeners('data');
|
|
105
|
-
devkit_1.logger.info(`NX Built ${remotes.
|
|
104
|
+
devkit_1.logger.info(`NX Built ${staticRemotesConfig.remotes.length} static remotes`);
|
|
106
105
|
res();
|
|
107
106
|
}
|
|
108
107
|
});
|
|
@@ -116,6 +115,20 @@ async function buildStaticRemotes(remotes, nxBin, context, options) {
|
|
|
116
115
|
process.on('exit', () => staticProcess.kill('SIGTERM'));
|
|
117
116
|
});
|
|
118
117
|
}
|
|
118
|
+
function parseStaticRemotesConfig(staticRemotes, context) {
|
|
119
|
+
if (!staticRemotes?.length) {
|
|
120
|
+
return { remotes: [], config: undefined };
|
|
121
|
+
}
|
|
122
|
+
const config = {};
|
|
123
|
+
for (const app of staticRemotes) {
|
|
124
|
+
const outputPath = context.projectGraph.nodes[app].data.targets['build'].options.outputPath;
|
|
125
|
+
const basePath = (0, path_1.dirname)(outputPath);
|
|
126
|
+
const urlSegment = (0, path_1.basename)(outputPath);
|
|
127
|
+
config[app] = { basePath, outputPath, urlSegment };
|
|
128
|
+
}
|
|
129
|
+
return { remotes: staticRemotes, config };
|
|
130
|
+
}
|
|
131
|
+
exports.parseStaticRemotesConfig = parseStaticRemotesConfig;
|
|
119
132
|
async function* moduleFederationDevServer(options, context) {
|
|
120
133
|
const initialStaticRemotesPorts = options.staticRemotesPort;
|
|
121
134
|
options.staticRemotesPort ??= options.port + 1;
|
|
@@ -152,10 +165,11 @@ async function* moduleFederationDevServer(options, context) {
|
|
|
152
165
|
}
|
|
153
166
|
}, options.staticRemotesPort);
|
|
154
167
|
}
|
|
155
|
-
|
|
168
|
+
const staticRemotesConfig = parseStaticRemotesConfig(remotes.staticRemotes, context);
|
|
169
|
+
await buildStaticRemotes(staticRemotesConfig, nxBin, context, options);
|
|
156
170
|
const devRemoteIters = await startDevRemotes(remotes, context);
|
|
157
171
|
const staticRemotesIter = remotes.staticRemotes.length > 0
|
|
158
|
-
? startStaticRemotesFileServer(
|
|
172
|
+
? startStaticRemotesFileServer(staticRemotesConfig, context, options)
|
|
159
173
|
: undefined;
|
|
160
174
|
return yield* (0, async_iterable_1.combineAsyncIterables)(currIter, ...devRemoteIters, ...(staticRemotesIter ? [staticRemotesIter] : []), (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
|
|
161
175
|
if (!options.isInitialHost) {
|