@nx/react 20.2.0-beta.2 → 20.2.0-beta.3
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/migrations.json +33 -0
- package/module-federation.d.ts +6 -4
- package/module-federation.js +16 -7
- package/package.json +6 -6
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +5 -7
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +5 -7
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts +1 -1
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.js +4 -5
- package/src/generators/application/application.js +9 -18
- package/src/generators/application/files/base-rspack/rspack.config.js__tmpl__ +53 -0
- package/src/generators/application/lib/add-e2e.js +2 -0
- package/src/generators/application/lib/add-project.js +66 -0
- package/src/generators/application/lib/create-application-files.js +28 -1
- package/src/generators/host/files/rspack-module-federation/rspack.config.js__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation/rspack.config.prod.js__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ts/rspack.config.prod.ts__tmpl__ +2 -1
- package/src/generators/host/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +2 -1
- package/src/generators/host/files/webpack-module-federation/webpack.config.js__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation/webpack.config.prod.js__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation-ssr/module-federation.server.config.js__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__ +2 -2
- package/src/generators/host/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +3 -2
- package/src/generators/remote/files/rspack-module-federation/rspack.config.js__tmpl__ +1 -1
- package/src/generators/remote/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__ +1 -1
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation/webpack.config.js__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +1 -1
- package/src/migrations/update-20-2-0/migrate-mf-imports-to-new-package.d.ts +2 -0
- package/src/migrations/update-20-2-0/migrate-mf-imports-to-new-package.js +63 -0
- package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.d.ts +2 -0
- package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.js +35 -0
- package/src/rules/update-module-federation-project.js +6 -4
- package/src/utils/has-rspack-plugin.d.ts +2 -0
- package/src/utils/has-rspack-plugin.js +10 -0
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +2 -2
- package/src/generators/application/lib/add-project-root-to-rspack-plugin-excludes.d.ts +0 -2
- package/src/generators/application/lib/add-project-root-to-rspack-plugin-excludes.js +0 -31
- package/src/module-federation/load-config.d.ts +0 -3
- package/src/module-federation/load-config.js +0 -15
- package/src/module-federation/models.d.ts +0 -24
- package/src/module-federation/models.js +0 -2
- package/src/module-federation/package-json.d.ts +0 -8
- package/src/module-federation/package-json.js +0 -12
- package/src/module-federation/utils.d.ts +0 -12
- package/src/module-federation/utils.js +0 -75
- package/src/module-federation/with-module-federation-ssr.d.ts +0 -2
- package/src/module-federation/with-module-federation-ssr.js +0 -50
- package/src/module-federation/with-module-federation.d.ts +0 -7
- package/src/module-federation/with-module-federation.js +0 -63
package/migrations.json
CHANGED
@@ -29,6 +29,18 @@
|
|
29
29
|
"version": "19.6.1-beta.0",
|
30
30
|
"description": "Ensure Target Defaults are set correctly for Module Federation.",
|
31
31
|
"factory": "./src/migrations/update-19-6-1/ensure-depends-on-for-mf"
|
32
|
+
},
|
33
|
+
"update-20-2-0-update-module-federation-config-import": {
|
34
|
+
"cli": "nx",
|
35
|
+
"version": "20.2.0-beta.2",
|
36
|
+
"description": "Update the ModuleFederationConfig import use @nx/module-federation.",
|
37
|
+
"factory": "./src/migrations/update-20-2-0/migrate-mf-imports-to-new-package"
|
38
|
+
},
|
39
|
+
"update-20-2-0-update-with-module-federation-import": {
|
40
|
+
"cli": "nx",
|
41
|
+
"version": "20.2.0-beta.2",
|
42
|
+
"description": "Update the withModuleFederation import use @nx/module-federation/webpack.",
|
43
|
+
"factory": "./src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package"
|
32
44
|
}
|
33
45
|
},
|
34
46
|
"packageJsonUpdates": {
|
@@ -152,6 +164,27 @@
|
|
152
164
|
"alwaysAddToPackageJson": false
|
153
165
|
}
|
154
166
|
}
|
167
|
+
},
|
168
|
+
"20.2.0": {
|
169
|
+
"version": "20.2.0-beta.3",
|
170
|
+
"packages": {
|
171
|
+
"@module-federation/enhanced": {
|
172
|
+
"version": "0.7.6",
|
173
|
+
"alwaysAddToPackageJson": false
|
174
|
+
},
|
175
|
+
"@module-federation/runtime": {
|
176
|
+
"version": "0.7.6",
|
177
|
+
"alwaysAddToPackageJson": false
|
178
|
+
},
|
179
|
+
"@module-federation/sdk": {
|
180
|
+
"version": "0.7.6",
|
181
|
+
"alwaysAddToPackageJson": false
|
182
|
+
},
|
183
|
+
"@module-federation/node": {
|
184
|
+
"version": "2.6.11",
|
185
|
+
"alwaysAddToPackageJson": false
|
186
|
+
}
|
187
|
+
}
|
155
188
|
}
|
156
189
|
}
|
157
190
|
}
|
package/module-federation.d.ts
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
import { withModuleFederation } from '
|
2
|
-
import { withModuleFederationForSSR } from '
|
3
|
-
|
4
|
-
|
1
|
+
import { withModuleFederation } from '@nx/module-federation/webpack';
|
2
|
+
import { withModuleFederationForSSR } from '@nx/module-federation/webpack';
|
3
|
+
/**
|
4
|
+
* @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
|
5
|
+
*/
|
6
|
+
export { withModuleFederation, withModuleFederationForSSR };
|
package/module-federation.js
CHANGED
@@ -1,12 +1,21 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.withModuleFederationForSSR = exports.withModuleFederation = void 0;
|
4
|
-
const
|
5
|
-
Object.defineProperty(exports, "withModuleFederation", { enumerable: true, get: function () { return
|
6
|
-
const
|
7
|
-
Object.defineProperty(exports, "withModuleFederationForSSR", { enumerable: true, get: function () { return
|
4
|
+
const webpack_1 = require("@nx/module-federation/webpack");
|
5
|
+
Object.defineProperty(exports, "withModuleFederation", { enumerable: true, get: function () { return webpack_1.withModuleFederation; } });
|
6
|
+
const webpack_2 = require("@nx/module-federation/webpack");
|
7
|
+
Object.defineProperty(exports, "withModuleFederationForSSR", { enumerable: true, get: function () { return webpack_2.withModuleFederationForSSR; } });
|
8
8
|
// Support for older generated code: `const withModuleFederation = require('@nx/react/module-federation')`
|
9
|
-
|
9
|
+
/**
|
10
|
+
* @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
|
11
|
+
*/
|
12
|
+
module.exports = webpack_1.withModuleFederation;
|
10
13
|
// Allow newer generated code to work: `const { withModuleFederation } = require(...)`;
|
11
|
-
|
12
|
-
module.
|
14
|
+
/**
|
15
|
+
* @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
|
16
|
+
*/
|
17
|
+
module.exports.withModuleFederation = webpack_1.withModuleFederation;
|
18
|
+
/**
|
19
|
+
* @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
|
20
|
+
*/
|
21
|
+
module.exports.withModuleFederationForSSR = webpack_2.withModuleFederationForSSR;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/react",
|
3
|
-
"version": "20.2.0-beta.
|
3
|
+
"version": "20.2.0-beta.3",
|
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": {
|
@@ -38,11 +38,11 @@
|
|
38
38
|
"minimatch": "9.0.3",
|
39
39
|
"picocolors": "^1.1.0",
|
40
40
|
"tslib": "^2.3.0",
|
41
|
-
"@
|
42
|
-
"@nx/
|
43
|
-
"@nx/
|
44
|
-
"@nx/
|
45
|
-
"@nx/
|
41
|
+
"@nx/devkit": "20.2.0-beta.3",
|
42
|
+
"@nx/js": "20.2.0-beta.3",
|
43
|
+
"@nx/eslint": "20.2.0-beta.3",
|
44
|
+
"@nx/web": "20.2.0-beta.3",
|
45
|
+
"@nx/module-federation": "20.2.0-beta.3",
|
46
46
|
"express": "^4.19.2",
|
47
47
|
"http-proxy-middleware": "^3.0.3"
|
48
48
|
},
|
@@ -4,13 +4,11 @@ exports.default = moduleFederationDevServer;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
5
|
const dev_server_impl_1 = require("@nx/webpack/src/executors/dev-server/dev-server.impl");
|
6
6
|
const file_server_impl_1 = require("@nx/web/src/executors/file-server/file-server.impl");
|
7
|
-
const
|
7
|
+
const utils_1 = require("@nx/module-federation/src/utils");
|
8
8
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
9
9
|
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
10
10
|
const fs_1 = require("fs");
|
11
11
|
const path_1 = require("path");
|
12
|
-
const start_remote_proxies_1 = require("@nx/webpack/src/utils/module-federation/start-remote-proxies");
|
13
|
-
const parse_static_remotes_config_1 = require("@nx/webpack/src/utils/module-federation/parse-static-remotes-config");
|
14
12
|
const build_static_remotes_1 = require("../../utils/build-static.remotes");
|
15
13
|
function getBuildOptions(buildTarget, context) {
|
16
14
|
const target = (0, devkit_1.parseTargetString)(buildTarget, context);
|
@@ -120,9 +118,9 @@ async function* moduleFederationDevServer(options, context) {
|
|
120
118
|
if (!options.isInitialHost) {
|
121
119
|
return yield* currIter;
|
122
120
|
}
|
123
|
-
const moduleFederationConfig = (0,
|
121
|
+
const moduleFederationConfig = (0, utils_1.getModuleFederationConfig)(buildOptions.tsConfig, context.root, p.root, 'react');
|
124
122
|
const remoteNames = options.devRemotes?.map((r) => typeof r === 'string' ? r : r.remoteName);
|
125
|
-
const remotes = (0,
|
123
|
+
const remotes = (0, utils_1.getRemotes)(remoteNames, options.skipRemotes, moduleFederationConfig, {
|
126
124
|
projectName: context.projectName,
|
127
125
|
projectGraph: context.projectGraph,
|
128
126
|
root: context.root,
|
@@ -133,11 +131,11 @@ async function* moduleFederationDevServer(options, context) {
|
|
133
131
|
...(remotes.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName) ?? []).map((r) => r.replace(/-/g, '_')),
|
134
132
|
p.name.replace(/-/g, '_'),
|
135
133
|
]);
|
136
|
-
const staticRemotesConfig = (0,
|
134
|
+
const staticRemotesConfig = (0, utils_1.parseStaticRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
|
137
135
|
const mappedLocationsOfStaticRemotes = await (0, build_static_remotes_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options);
|
138
136
|
const devRemoteIters = await startRemotes(remotes.devRemotes, context, options, 'serve');
|
139
137
|
const staticRemotesIter = startStaticRemotesFileServer(staticRemotesConfig, context, options);
|
140
|
-
(0,
|
138
|
+
(0, utils_1.startRemoteProxies)(staticRemotesConfig, mappedLocationsOfStaticRemotes, options.ssl
|
141
139
|
? {
|
142
140
|
pathToCert: (0, path_1.join)(devkit_1.workspaceRoot, options.sslCert),
|
143
141
|
pathToKey: (0, path_1.join)(devkit_1.workspaceRoot, options.sslKey),
|
package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js
CHANGED
@@ -4,14 +4,12 @@ exports.default = moduleFederationSsrDevServer;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
5
|
const ssr_dev_server_impl_1 = require("@nx/webpack/src/executors/ssr-dev-server/ssr-dev-server.impl");
|
6
6
|
const path_1 = require("path");
|
7
|
-
const
|
7
|
+
const utils_1 = require("@nx/module-federation/src/utils");
|
8
8
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
9
9
|
const child_process_1 = require("child_process");
|
10
10
|
const fs_1 = require("fs");
|
11
|
-
const parse_static_remotes_config_1 = require("@nx/webpack/src/utils/module-federation/parse-static-remotes-config");
|
12
11
|
const file_server_impl_1 = require("@nx/web/src/executors/file-server/file-server.impl");
|
13
12
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
14
|
-
const start_ssr_remote_proxies_1 = require("@nx/webpack/src/utils/module-federation/start-ssr-remote-proxies");
|
15
13
|
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
16
14
|
function normalizeOptions(options) {
|
17
15
|
return {
|
@@ -155,9 +153,9 @@ async function* moduleFederationSsrDevServer(ssrDevServerOptions, context) {
|
|
155
153
|
if (!options.isInitialHost) {
|
156
154
|
return yield* iter;
|
157
155
|
}
|
158
|
-
const moduleFederationConfig = (0,
|
156
|
+
const moduleFederationConfig = (0, utils_1.getModuleFederationConfig)(buildOptions.tsConfig, context.root, projectConfig.root, 'react');
|
159
157
|
const remoteNames = options.devRemotes?.map((remote) => typeof remote === 'string' ? remote : remote.remoteName);
|
160
|
-
const remotes = (0,
|
158
|
+
const remotes = (0, utils_1.getRemotes)(remoteNames, options.skipRemotes, moduleFederationConfig, {
|
161
159
|
projectName: context.projectName,
|
162
160
|
projectGraph: context.projectGraph,
|
163
161
|
root: context.root,
|
@@ -167,11 +165,11 @@ async function* moduleFederationSsrDevServer(ssrDevServerOptions, context) {
|
|
167
165
|
...(remotes.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName) ?? []).map((r) => r.replace(/-/g, '_')),
|
168
166
|
projectConfig.name.replace(/-/g, '_'),
|
169
167
|
]);
|
170
|
-
const staticRemotesConfig = (0,
|
168
|
+
const staticRemotesConfig = (0, utils_1.parseStaticSsrRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
|
171
169
|
const mappedLocationsOfStaticRemotes = await buildSsrStaticRemotes(staticRemotesConfig, nxBin, context, options);
|
172
170
|
const devRemoteIters = await startRemotes(remotes.devRemotes, context, options);
|
173
171
|
const staticRemotesIter = startSsrStaticRemotesFileServer(staticRemotesConfig, context, options);
|
174
|
-
(0,
|
172
|
+
(0, utils_1.startSsrRemoteProxies)(staticRemotesConfig, mappedLocationsOfStaticRemotes, options.ssl
|
175
173
|
? {
|
176
174
|
pathToCert: options.sslCert,
|
177
175
|
pathToKey: options.sslKey,
|
package/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ModuleFederationStaticServerSchema } from './schema';
|
2
2
|
import { ModuleFederationDevServerOptions } from '../module-federation-dev-server/schema';
|
3
3
|
import { ExecutorContext } from 'nx/src/config/misc-interfaces';
|
4
|
-
import { StaticRemotesConfig } from '@nx/
|
4
|
+
import { StaticRemotesConfig } from '@nx/module-federation/src/utils';
|
5
5
|
export declare function startProxies(staticRemotesConfig: StaticRemotesConfig, hostServeOptions: ModuleFederationDevServerOptions, mappedLocationOfHost: string, mappedLocationsOfRemotes: Record<string, string>, sslOptions?: {
|
6
6
|
pathToCert: string;
|
7
7
|
pathToKey: string;
|
package/src/executors/module-federation-static-server/module-federation-static-server.impl.js
CHANGED
@@ -5,8 +5,7 @@ exports.default = moduleFederationStaticServer;
|
|
5
5
|
const path_1 = require("path");
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
7
7
|
const fs_1 = require("fs");
|
8
|
-
const
|
9
|
-
const parse_static_remotes_config_1 = require("@nx/webpack/src/utils/module-federation/parse-static-remotes-config");
|
8
|
+
const utils_1 = require("@nx/module-federation/src/utils");
|
10
9
|
const build_static_remotes_1 = require("../../utils/build-static.remotes");
|
11
10
|
const child_process_1 = require("child_process");
|
12
11
|
const process = require("node:process");
|
@@ -164,13 +163,13 @@ async function* moduleFederationStaticServer(schema, context) {
|
|
164
163
|
// Get the remotes from the module federation config
|
165
164
|
const p = context.projectsConfigurations.projects[context.projectName];
|
166
165
|
const options = getBuildAndServeOptionsFromServeTarget(schema.serveTarget, context);
|
167
|
-
const moduleFederationConfig = (0,
|
168
|
-
const remotes = (0,
|
166
|
+
const moduleFederationConfig = (0, utils_1.getModuleFederationConfig)(options.buildOptions.tsConfig, context.root, p.root, 'react');
|
167
|
+
const remotes = (0, utils_1.getRemotes)([], options.serveOptions.skipRemotes, moduleFederationConfig, {
|
169
168
|
projectName: context.projectName,
|
170
169
|
projectGraph: context.projectGraph,
|
171
170
|
root: context.root,
|
172
171
|
}, options.pathToManifestFile);
|
173
|
-
const staticRemotesConfig = (0,
|
172
|
+
const staticRemotesConfig = (0, utils_1.parseStaticRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
|
174
173
|
options.serveOptions.staticRemotesPort ??= remotes.staticRemotePort;
|
175
174
|
const mappedLocationsOfStaticRemotes = await (0, build_static_remotes_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options.serveOptions);
|
176
175
|
// Build the host
|
@@ -15,7 +15,6 @@ const devkit_1 = require("@nx/devkit");
|
|
15
15
|
const init_1 = require("../init/init");
|
16
16
|
const eslint_1 = require("@nx/eslint");
|
17
17
|
const versions_1 = require("../../utils/versions");
|
18
|
-
const maybe_js_1 = require("../../utils/maybe-js");
|
19
18
|
const install_common_dependencies_1 = require("./lib/install-common-dependencies");
|
20
19
|
const create_ts_config_1 = require("../../utils/create-ts-config");
|
21
20
|
const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
|
@@ -28,7 +27,6 @@ const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-projec
|
|
28
27
|
const setup_tailwind_1 = require("../setup-tailwind/setup-tailwind");
|
29
28
|
const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
|
30
29
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
31
|
-
const add_project_root_to_rspack_plugin_excludes_1 = require("./lib/add-project-root-to-rspack-plugin-excludes");
|
32
30
|
async function addLinting(host, options) {
|
33
31
|
const tasks = [];
|
34
32
|
if (options.linter === eslint_1.Linter.EsLint) {
|
@@ -116,6 +114,15 @@ async function applicationGeneratorInternal(host, schema) {
|
|
116
114
|
tasks.push(ensureDependencies(host, { uiFramework: 'react' }));
|
117
115
|
}
|
118
116
|
}
|
117
|
+
else if (options.bundler === 'rspack') {
|
118
|
+
const { rspackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxRspackVersion);
|
119
|
+
const rspackInitTask = await rspackInitGenerator(host, {
|
120
|
+
...options,
|
121
|
+
addPlugin: false,
|
122
|
+
skipFormat: true,
|
123
|
+
});
|
124
|
+
tasks.push(rspackInitTask);
|
125
|
+
}
|
119
126
|
if (!options.rootProject) {
|
120
127
|
(0, create_ts_config_1.extractTsConfigBase)(host);
|
121
128
|
}
|
@@ -163,22 +170,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
163
170
|
plugins: ['react()'],
|
164
171
|
}, false);
|
165
172
|
}
|
166
|
-
else if (options.bundler === 'rspack') {
|
167
|
-
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxRspackVersion);
|
168
|
-
const rspackTask = await configurationGenerator(host, {
|
169
|
-
project: options.projectName,
|
170
|
-
main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)({
|
171
|
-
js: options.js,
|
172
|
-
useJsx: true,
|
173
|
-
}, `src/main.tsx`)),
|
174
|
-
tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
175
|
-
target: 'web',
|
176
|
-
newProject: true,
|
177
|
-
framework: 'react',
|
178
|
-
});
|
179
|
-
tasks.push(rspackTask);
|
180
|
-
(0, add_project_root_to_rspack_plugin_excludes_1.addProjectRootToRspackPluginExcludesIfExists)(host, options.appProjectRoot);
|
181
|
-
}
|
182
173
|
if (options.bundler !== 'vite' && options.unitTestRunner === 'vitest') {
|
183
174
|
const { createOrEditViteConfig, vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
184
175
|
const vitestTask = await vitestGenerator(host, {
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<%_ if (rspackPluginOptions) { _%>
|
2
|
+
const { NxAppRspackPlugin } = require('@nx/rspack/app-plugin');
|
3
|
+
const { NxReactRspackPlugin } = require('@nx/rspack/react-plugin');
|
4
|
+
const { join } = require('path');
|
5
|
+
|
6
|
+
module.exports = {
|
7
|
+
output: {
|
8
|
+
path: join(__dirname, '<%= offsetFromRoot %><%= rspackPluginOptions.outputPath %>'),
|
9
|
+
},
|
10
|
+
devServer: {
|
11
|
+
port: 4200,
|
12
|
+
historyApiFallback: {
|
13
|
+
index: '/index.html',
|
14
|
+
disableDotRule: true,
|
15
|
+
htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
|
16
|
+
},
|
17
|
+
},
|
18
|
+
plugins: [
|
19
|
+
new NxAppRspackPlugin({
|
20
|
+
tsConfig: '<%= rspackPluginOptions.tsConfig %>',
|
21
|
+
main: '<%= rspackPluginOptions.main %>',
|
22
|
+
index: '<%= rspackPluginOptions.index %>',
|
23
|
+
baseHref: '<%= rspackPluginOptions.baseHref %>',
|
24
|
+
assets: <%- JSON.stringify(rspackPluginOptions.assets) %>,
|
25
|
+
styles: <%- JSON.stringify(rspackPluginOptions.styles) %>,
|
26
|
+
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
|
27
|
+
optimization: process.env['NODE_ENV'] === 'production',
|
28
|
+
}),
|
29
|
+
new NxReactRspackPlugin({
|
30
|
+
// Uncomment this line if you don't want to use SVGR
|
31
|
+
// See: https://react-svgr.com/
|
32
|
+
// svgr: false
|
33
|
+
}),
|
34
|
+
],
|
35
|
+
};
|
36
|
+
<%_ } else { _%>
|
37
|
+
const { composePlugins, withNx, withReact } = require('@nx/rspack');
|
38
|
+
|
39
|
+
// Nx plugins for rspack.
|
40
|
+
module.exports = composePlugins(
|
41
|
+
withNx(),
|
42
|
+
withReact({
|
43
|
+
// Uncomment this line if you don't want to use SVGR
|
44
|
+
// See: https://react-svgr.com/
|
45
|
+
// svgr: false
|
46
|
+
}),
|
47
|
+
(config) => {
|
48
|
+
// Update the rspack config as needed here.
|
49
|
+
// e.g. `config.plugins.push(new MyPlugin())`
|
50
|
+
return config;
|
51
|
+
}
|
52
|
+
);
|
53
|
+
<%_ } _%>
|
@@ -6,10 +6,12 @@ const web_1 = require("@nx/web");
|
|
6
6
|
const versions_1 = require("../../../utils/versions");
|
7
7
|
const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
|
8
8
|
const has_vite_plugin_1 = require("../../../utils/has-vite-plugin");
|
9
|
+
const has_rspack_plugin_1 = require("../../../utils/has-rspack-plugin");
|
9
10
|
const find_plugin_for_config_file_1 = require("@nx/devkit/src/utils/find-plugin-for-config-file");
|
10
11
|
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
11
12
|
async function addE2e(tree, options) {
|
12
13
|
const hasNxBuildPlugin = (options.bundler === 'webpack' && (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)) ||
|
14
|
+
(options.bundler === 'rspack' && (0, has_rspack_plugin_1.hasRspackPlugin)(tree)) ||
|
13
15
|
(options.bundler === 'vite' && (0, has_vite_plugin_1.hasVitePlugin)(tree));
|
14
16
|
let e2eWebServerInfo = {
|
15
17
|
e2eWebServerAddress: `http://localhost:${options.devServerPort ?? 4200}`,
|
@@ -4,6 +4,7 @@ exports.addProject = addProject;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
5
|
const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
|
6
6
|
const maybe_js_1 = require("../../../utils/maybe-js");
|
7
|
+
const has_rspack_plugin_1 = require("../../../utils/has-rspack-plugin");
|
7
8
|
function addProject(host, options) {
|
8
9
|
const project = {
|
9
10
|
root: options.appProjectRoot,
|
@@ -20,10 +21,75 @@ function addProject(host, options) {
|
|
20
21
|
};
|
21
22
|
}
|
22
23
|
}
|
24
|
+
else if (options.bundler === 'rspack' &&
|
25
|
+
(!(0, has_rspack_plugin_1.hasRspackPlugin)(host) || !options.addPlugin)) {
|
26
|
+
project.targets = {
|
27
|
+
build: createRspackBuildTarget(options),
|
28
|
+
serve: createRspackServeTarget(options),
|
29
|
+
};
|
30
|
+
}
|
23
31
|
(0, devkit_1.addProjectConfiguration)(host, options.projectName, {
|
24
32
|
...project,
|
25
33
|
});
|
26
34
|
}
|
35
|
+
function createRspackBuildTarget(options) {
|
36
|
+
return {
|
37
|
+
executor: '@nx/rspack:rspack',
|
38
|
+
outputs: ['{options.outputPath}'],
|
39
|
+
defaultConfiguration: 'production',
|
40
|
+
options: {
|
41
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot),
|
42
|
+
index: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/index.html'),
|
43
|
+
baseHref: '/',
|
44
|
+
main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/main.tsx`)),
|
45
|
+
tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
46
|
+
assets: [
|
47
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/favicon.ico'),
|
48
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/assets'),
|
49
|
+
],
|
50
|
+
rspackConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'rspack.config.js'),
|
51
|
+
styles: options.styledModule || !options.hasStyles
|
52
|
+
? []
|
53
|
+
: [
|
54
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/styles.${options.style}`),
|
55
|
+
],
|
56
|
+
scripts: [],
|
57
|
+
configurations: {
|
58
|
+
development: {
|
59
|
+
mode: 'development',
|
60
|
+
},
|
61
|
+
production: {
|
62
|
+
mode: 'production',
|
63
|
+
optimization: true,
|
64
|
+
sourceMap: false,
|
65
|
+
outputHashing: 'all',
|
66
|
+
namedChunks: false,
|
67
|
+
extractLicenses: true,
|
68
|
+
vendorChunk: false,
|
69
|
+
},
|
70
|
+
},
|
71
|
+
},
|
72
|
+
};
|
73
|
+
}
|
74
|
+
function createRspackServeTarget(options) {
|
75
|
+
return {
|
76
|
+
executor: '@nx/rspack:dev-server',
|
77
|
+
defaultConfiguration: 'development',
|
78
|
+
options: {
|
79
|
+
buildTarget: `${options.projectName}:build`,
|
80
|
+
hmr: true,
|
81
|
+
},
|
82
|
+
configurations: {
|
83
|
+
development: {
|
84
|
+
buildTarget: `${options.projectName}:build:development`,
|
85
|
+
},
|
86
|
+
production: {
|
87
|
+
buildTarget: `${options.projectName}:build:production`,
|
88
|
+
hmr: false,
|
89
|
+
},
|
90
|
+
},
|
91
|
+
};
|
92
|
+
}
|
27
93
|
function createBuildTarget(options) {
|
28
94
|
return {
|
29
95
|
executor: '@nx/webpack:webpack',
|
@@ -10,6 +10,7 @@ const maybe_js_1 = require("../../../utils/maybe-js");
|
|
10
10
|
const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
|
11
11
|
const get_app_tests_1 = require("./get-app-tests");
|
12
12
|
const onboarding_1 = require("nx/src/nx-cloud/utilities/onboarding");
|
13
|
+
const has_rspack_plugin_1 = require("../../../utils/has-rspack-plugin");
|
13
14
|
async function createApplicationFiles(host, options) {
|
14
15
|
let styleSolutionSpecificAppFiles;
|
15
16
|
if (options.styledModule && options.style !== 'styled-jsx') {
|
@@ -114,7 +115,12 @@ async function createApplicationFiles(host, options) {
|
|
114
115
|
}
|
115
116
|
}
|
116
117
|
else if (options.bundler === 'rspack') {
|
117
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-rspack'), options.appProjectRoot,
|
118
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-rspack'), options.appProjectRoot, {
|
119
|
+
...templateVariables,
|
120
|
+
rspackPluginOptions: (0, has_rspack_plugin_1.hasRspackPlugin)(host)
|
121
|
+
? createNxRspackPluginOptions(options)
|
122
|
+
: null,
|
123
|
+
});
|
118
124
|
}
|
119
125
|
if (options.unitTestRunner === 'none' ||
|
120
126
|
(options.unitTestRunner === 'vitest' && options.inSourceTests == true)) {
|
@@ -156,3 +162,24 @@ function createNxWebpackPluginOptions(options) {
|
|
156
162
|
],
|
157
163
|
};
|
158
164
|
}
|
165
|
+
function createNxRspackPluginOptions(options) {
|
166
|
+
return {
|
167
|
+
target: 'web',
|
168
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot != '.'
|
169
|
+
? options.appProjectRoot
|
170
|
+
: options.projectName),
|
171
|
+
index: './src/index.html',
|
172
|
+
baseHref: '/',
|
173
|
+
main: (0, maybe_js_1.maybeJs)({
|
174
|
+
js: options.js,
|
175
|
+
useJsx: true,
|
176
|
+
}, `./src/main.tsx`),
|
177
|
+
tsConfig: './tsconfig.app.json',
|
178
|
+
assets: ['./src/favicon.ico', './src/assets'],
|
179
|
+
styles: options.styledModule || !options.hasStyles
|
180
|
+
? []
|
181
|
+
: [
|
182
|
+
`./src/styles.${options.style !== 'tailwind' ? options.style : 'css'}`,
|
183
|
+
],
|
184
|
+
};
|
185
|
+
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
const { composePlugins, withNx, withReact } = require('@nx/rspack');
|
2
|
-
const { withModuleFederation } = require('@nx/
|
2
|
+
const { withModuleFederation } = require('@nx/module-federation/rspack');
|
3
3
|
|
4
4
|
const baseConfig = require('./module-federation.config');
|
5
5
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
const { composePlugins, withNx, withReact } = require('@nx/rspack');
|
2
|
-
const { withModuleFederation } = require('@nx/
|
2
|
+
const { withModuleFederation } = require('@nx/module-federation/rspack');
|
3
3
|
|
4
4
|
const baseConfig = require('./module-federation.config');
|
5
5
|
|
package/src/generators/host/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
const {composePlugins, withNx, withReact} = require('@nx/rspack');
|
2
|
-
const {withModuleFederationForSSR} = require('@nx/
|
2
|
+
const {withModuleFederationForSSR} = require('@nx/module-federation/rspack');
|
3
3
|
|
4
4
|
const baseConfig = require('./module-federation.config');
|
5
5
|
|
package/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import {composePlugins, withNx, withReact} from '@nx/rspack';
|
2
|
-
import {withModuleFederationForSSR} from '@nx/
|
2
|
+
import {withModuleFederationForSSR} from '@nx/module-federation/rspack';
|
3
3
|
|
4
4
|
import baseConfig from './module-federation.config';
|
5
5
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { composePlugins, withNx, withReact } from '@nx/rspack';
|
2
|
-
import { withModuleFederation
|
2
|
+
import { withModuleFederation } from '@nx/module-federation/rspack';
|
3
|
+
import { ModuleFederationConfig } from '@nx/module-federation';
|
3
4
|
|
4
5
|
import baseConfig from './module-federation.config';
|
5
6
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import {composePlugins, withNx, withReact} from '@nx/rspack';
|
2
|
-
import {withModuleFederation
|
2
|
+
import { withModuleFederation } from '@nx/module-federation/rspack';
|
3
|
+
import { ModuleFederationConfig } from '@nx/module-federation';
|
3
4
|
|
4
5
|
import baseConfig from './module-federation.config';
|
5
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
const { composePlugins, withNx } = require('@nx/webpack');
|
2
2
|
const { withReact } = require('@nx/react');
|
3
|
-
const { withModuleFederation } = require('@nx/
|
3
|
+
const { withModuleFederation } = require('@nx/module-federation/webpack');
|
4
4
|
|
5
5
|
const baseConfig = require('./module-federation.config');
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
const { composePlugins, withNx } = require('@nx/webpack');
|
2
2
|
const { withReact } = require('@nx/react');
|
3
|
-
const { withModuleFederation } = require('@nx/
|
3
|
+
const { withModuleFederation } = require('@nx/module-federation/webpack');
|
4
4
|
|
5
5
|
const baseConfig = require('./module-federation.config');
|
6
6
|
|
package/src/generators/host/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
const {composePlugins, withNx} = require('@nx/webpack');
|
2
2
|
const {withReact} = require('@nx/react');
|
3
|
-
const {withModuleFederationForSSR} = require('@nx/
|
3
|
+
const {withModuleFederationForSSR} = require('@nx/module-federation/webpack');
|
4
4
|
|
5
5
|
const baseConfig = require('./module-federation.config');
|
6
6
|
|
package/src/generators/host/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import {composePlugins, withNx} from '@nx/webpack';
|
2
2
|
import {withReact} from '@nx/react';
|
3
|
-
import {withModuleFederationForSSR} from '@nx/
|
3
|
+
import {withModuleFederationForSSR} from '@nx/module-federation/webpack';
|
4
4
|
|
5
5
|
import baseConfig from './module-federation.config';
|
6
6
|
|