@nx/react 20.2.0-beta.2 → 20.2.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/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 +20 -6
- package/src/generators/application/files/base-rspack/rspack.config.js__tmpl__ +53 -0
- package/src/generators/application/files/base-rspack/tsconfig.app.json__tmpl__ +21 -4
- package/src/generators/application/files/base-vite/tsconfig.app.json__tmpl__ +19 -2
- package/src/generators/application/files/base-webpack/tsconfig.app.json__tmpl__ +20 -3
- package/src/generators/application/files/style-css-module/src/app/__fileName__.tsx__tmpl__ +2 -2
- package/src/generators/application/lib/add-e2e.d.ts +1 -1
- package/src/generators/application/lib/add-e2e.js +45 -15
- package/src/generators/application/lib/add-jest.js +1 -0
- package/src/generators/application/lib/add-project.js +85 -3
- package/src/generators/application/lib/create-application-files.js +30 -1
- package/src/generators/application/lib/normalize-options.js +2 -0
- package/src/generators/application/lib/update-jest-config.js +5 -0
- package/src/generators/application/schema.d.ts +5 -0
- package/src/generators/application/schema.json +19 -15
- package/src/generators/component/component.js +3 -1
- package/src/generators/component/lib/normalize-options.js +2 -1
- package/src/generators/component/schema.d.ts +1 -1
- package/src/generators/component/schema.json +3 -5
- package/src/generators/hook/hook.js +10 -25
- package/src/generators/hook/schema.d.ts +0 -2
- package/src/generators/hook/schema.json +10 -18
- 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/host/host.js +3 -2
- package/src/generators/host/lib/update-module-federation-tsconfig.d.ts +3 -0
- package/src/generators/host/lib/update-module-federation-tsconfig.js +39 -0
- package/src/generators/init/init.js +0 -2
- package/src/generators/library/lib/create-files.d.ts +1 -1
- package/src/generators/library/lib/create-files.js +22 -2
- package/src/generators/library/lib/normalize-options.js +3 -0
- package/src/generators/library/library.js +46 -16
- package/src/generators/library/schema.d.ts +1 -0
- package/src/generators/library/schema.json +14 -11
- package/src/generators/redux/schema.json +13 -4
- 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/generators/remote/remote.js +1 -2
- 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 +66 -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 +12 -4
- package/src/utils/build-static.remotes.d.ts +1 -1
- package/src/utils/create-ts-config.js +57 -7
- 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 -3
- package/src/utils/versions.js +3 -5
- 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/generators/library/files/common/package.json__tmpl__ +0 -4
- package/src/generators/library/files/vite/package.json__tmpl__ +0 -12
- 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.4",
|
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.4",
|
42
|
+
"@nx/js": "20.2.0-beta.4",
|
43
|
+
"@nx/eslint": "20.2.0-beta.4",
|
44
|
+
"@nx/web": "20.2.0-beta.4",
|
45
|
+
"@nx/module-federation": "20.2.0-beta.4",
|
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
|
@@ -28,7 +28,6 @@ const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-projec
|
|
28
28
|
const setup_tailwind_1 = require("../setup-tailwind/setup-tailwind");
|
29
29
|
const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
|
30
30
|
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
31
|
async function addLinting(host, options) {
|
33
32
|
const tasks = [];
|
34
33
|
if (options.linter === eslint_1.Linter.EsLint) {
|
@@ -74,16 +73,17 @@ async function applicationGenerator(host, schema) {
|
|
74
73
|
});
|
75
74
|
}
|
76
75
|
async function applicationGeneratorInternal(host, schema) {
|
77
|
-
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'application');
|
78
76
|
const tasks = [];
|
79
|
-
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
80
|
-
(0, show_possible_warnings_1.showPossibleWarnings)(host, options);
|
81
77
|
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
82
78
|
...schema,
|
83
79
|
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
84
80
|
skipFormat: true,
|
81
|
+
addTsPlugin: schema.useTsSolution,
|
82
|
+
formatter: schema.formatter,
|
85
83
|
});
|
86
84
|
tasks.push(jsInitTask);
|
85
|
+
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
86
|
+
(0, show_possible_warnings_1.showPossibleWarnings)(host, options);
|
87
87
|
const initTask = await (0, init_1.default)(host, {
|
88
88
|
...options,
|
89
89
|
skipFormat: true,
|
@@ -116,6 +116,15 @@ async function applicationGeneratorInternal(host, schema) {
|
|
116
116
|
tasks.push(ensureDependencies(host, { uiFramework: 'react' }));
|
117
117
|
}
|
118
118
|
}
|
119
|
+
else if (options.bundler === 'rspack') {
|
120
|
+
const { rspackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
|
121
|
+
const rspackInitTask = await rspackInitGenerator(host, {
|
122
|
+
...options,
|
123
|
+
addPlugin: false,
|
124
|
+
skipFormat: true,
|
125
|
+
});
|
126
|
+
tasks.push(rspackInitTask);
|
127
|
+
}
|
119
128
|
if (!options.rootProject) {
|
120
129
|
(0, create_ts_config_1.extractTsConfigBase)(host);
|
121
130
|
}
|
@@ -143,6 +152,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
143
152
|
compiler: options.compiler,
|
144
153
|
skipFormat: true,
|
145
154
|
addPlugin: options.addPlugin,
|
155
|
+
projectType: 'application',
|
146
156
|
});
|
147
157
|
tasks.push(viteTask);
|
148
158
|
createOrEditViteConfig(host, {
|
@@ -164,7 +174,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
164
174
|
}, false);
|
165
175
|
}
|
166
176
|
else if (options.bundler === 'rspack') {
|
167
|
-
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.
|
177
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
|
168
178
|
const rspackTask = await configurationGenerator(host, {
|
169
179
|
project: options.projectName,
|
170
180
|
main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)({
|
@@ -177,7 +187,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
177
187
|
framework: 'react',
|
178
188
|
});
|
179
189
|
tasks.push(rspackTask);
|
180
|
-
(0, add_project_root_to_rspack_plugin_excludes_1.addProjectRootToRspackPluginExcludesIfExists)(host, options.appProjectRoot);
|
181
190
|
}
|
182
191
|
if (options.bundler !== 'vite' && options.unitTestRunner === 'vitest') {
|
183
192
|
const { createOrEditViteConfig, vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
@@ -251,6 +260,11 @@ async function applicationGeneratorInternal(host, schema) {
|
|
251
260
|
});
|
252
261
|
`);
|
253
262
|
}
|
263
|
+
(0, ts_solution_setup_1.updateTsconfigFiles)(host, options.appProjectRoot, 'tsconfig.app.json', {
|
264
|
+
jsx: 'react-jsx',
|
265
|
+
module: 'esnext',
|
266
|
+
moduleResolution: 'bundler',
|
267
|
+
});
|
254
268
|
if (!options.skipFormat) {
|
255
269
|
await (0, devkit_1.formatFiles)(host);
|
256
270
|
}
|
@@ -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
|
+
<%_ } _%>
|
@@ -1,14 +1,31 @@
|
|
1
|
-
{
|
1
|
+
<%_ if (isUsingTsSolutionSetup) { _%>{
|
2
|
+
"extends": "<%= offsetFromRoot%>tsconfig.base.json",
|
3
|
+
"compilerOptions": {
|
4
|
+
"outDir": "dist",
|
5
|
+
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
6
|
+
"jsx": "react-jsx",
|
7
|
+
"lib": ["dom"],
|
8
|
+
"types": [
|
9
|
+
"node",
|
10
|
+
<%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
|
11
|
+
"@nx/react/typings/cssmodule.d.ts",
|
12
|
+
"@nx/react/typings/image.d.ts"
|
13
|
+
]
|
14
|
+
},
|
15
|
+
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
|
16
|
+
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
17
|
+
}<% } else { %>{
|
2
18
|
"extends": "./tsconfig.json",
|
3
19
|
"compilerOptions": {
|
4
20
|
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
5
21
|
"types": [
|
6
22
|
"node",
|
7
|
-
<%_ if (style === 'styled-jsx') { %>"@nx/react/typings/styled-jsx.d.ts",<% } _%>
|
23
|
+
<%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
|
8
24
|
"@nx/react/typings/cssmodule.d.ts",
|
9
25
|
"@nx/react/typings/image.d.ts"
|
10
|
-
|
26
|
+
]
|
11
27
|
},
|
12
|
-
"exclude": ["
|
28
|
+
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
|
13
29
|
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
14
30
|
}
|
31
|
+
<% } %>
|
@@ -1,4 +1,20 @@
|
|
1
|
-
{
|
1
|
+
<%_ if (isUsingTsSolutionSetup) { _%>{
|
2
|
+
"extends": "<%= offsetFromRoot%>tsconfig.base.json",
|
3
|
+
"compilerOptions": {
|
4
|
+
"outDir": "dist",
|
5
|
+
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
6
|
+
"jsx": "react-jsx",
|
7
|
+
"lib": ["dom"],
|
8
|
+
"types": [
|
9
|
+
"node",
|
10
|
+
<%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
|
11
|
+
"@nx/react/typings/cssmodule.d.ts",
|
12
|
+
"@nx/react/typings/image.d.ts"
|
13
|
+
]
|
14
|
+
},
|
15
|
+
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
|
16
|
+
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
17
|
+
}<% } else { %>{
|
2
18
|
"extends": "./tsconfig.json",
|
3
19
|
"compilerOptions": {
|
4
20
|
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
@@ -7,8 +23,9 @@
|
|
7
23
|
<%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
|
8
24
|
"@nx/react/typings/cssmodule.d.ts",
|
9
25
|
"@nx/react/typings/image.d.ts"
|
10
|
-
|
26
|
+
]
|
11
27
|
},
|
12
28
|
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
|
13
29
|
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
14
30
|
}
|
31
|
+
<% } %>
|
@@ -1,4 +1,20 @@
|
|
1
|
-
{
|
1
|
+
<%_ if (isUsingTsSolutionSetup) { _%>{
|
2
|
+
"extends": "<%= offsetFromRoot%>tsconfig.base.json",
|
3
|
+
"compilerOptions": {
|
4
|
+
"outDir": "dist",
|
5
|
+
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
6
|
+
"jsx": "react-jsx",
|
7
|
+
"lib": ["dom"],
|
8
|
+
"types": [
|
9
|
+
"node",
|
10
|
+
<%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
|
11
|
+
"@nx/react/typings/cssmodule.d.ts",
|
12
|
+
"@nx/react/typings/image.d.ts"
|
13
|
+
]
|
14
|
+
},
|
15
|
+
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
|
16
|
+
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
17
|
+
}<% } else { %>{
|
2
18
|
"extends": "./tsconfig.json",
|
3
19
|
"compilerOptions": {
|
4
20
|
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
@@ -7,8 +23,9 @@
|
|
7
23
|
<%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
|
8
24
|
"@nx/react/typings/cssmodule.d.ts",
|
9
25
|
"@nx/react/typings/image.d.ts"
|
10
|
-
|
26
|
+
]
|
11
27
|
},
|
12
|
-
"exclude": ["
|
28
|
+
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
|
13
29
|
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
14
30
|
}
|
31
|
+
<% } %>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<% if (classComponent) { %>
|
2
2
|
import { Component } from 'react';
|
3
3
|
<%_ } _%>
|
4
|
-
//
|
5
|
-
import styles from './<%= fileName %>.module.<%= style %>';
|
4
|
+
// Uncomment this line to use CSS modules
|
5
|
+
// import styles from './<%= fileName %>.module.<%= style %>';
|
6
6
|
<%_ if (!minimal) { _%>
|
7
7
|
import NxWelcome from "./nx-welcome";
|
8
8
|
<%_ } _%>
|
@@ -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}`,
|
@@ -36,14 +38,28 @@ async function addE2e(tree, options) {
|
|
36
38
|
switch (options.e2eTestRunner) {
|
37
39
|
case 'cypress': {
|
38
40
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
if (options.isUsingTsSolutionConfig) {
|
42
|
+
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
|
43
|
+
name: options.e2eProjectName,
|
44
|
+
version: '0.0.1',
|
45
|
+
private: true,
|
46
|
+
nx: {
|
47
|
+
projectType: 'application',
|
48
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
49
|
+
implicitDependencies: [options.projectName],
|
50
|
+
},
|
51
|
+
});
|
52
|
+
}
|
53
|
+
else {
|
54
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
55
|
+
projectType: 'application',
|
56
|
+
root: options.e2eProjectRoot,
|
57
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
58
|
+
targets: {},
|
59
|
+
implicitDependencies: [options.projectName],
|
60
|
+
tags: [],
|
61
|
+
});
|
62
|
+
}
|
47
63
|
const e2eTask = await configurationGenerator(tree, {
|
48
64
|
...options,
|
49
65
|
project: options.e2eProjectName,
|
@@ -88,13 +104,27 @@ async function addE2e(tree, options) {
|
|
88
104
|
}
|
89
105
|
case 'playwright': {
|
90
106
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
107
|
+
if (options.isUsingTsSolutionConfig) {
|
108
|
+
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
|
109
|
+
name: options.e2eProjectName,
|
110
|
+
version: '0.0.1',
|
111
|
+
private: true,
|
112
|
+
nx: {
|
113
|
+
projectType: 'application',
|
114
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
115
|
+
implicitDependencies: [options.projectName],
|
116
|
+
},
|
117
|
+
});
|
118
|
+
}
|
119
|
+
else {
|
120
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
121
|
+
projectType: 'application',
|
122
|
+
root: options.e2eProjectRoot,
|
123
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
124
|
+
targets: {},
|
125
|
+
implicitDependencies: [options.projectName],
|
126
|
+
});
|
127
|
+
}
|
98
128
|
const e2eTask = await configurationGenerator(tree, {
|
99
129
|
project: options.e2eProjectName,
|
100
130
|
skipFormat: true,
|