@nx/react 20.5.0-beta.3 → 20.5.0-canary.20250128-e0c49d3
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 +6 -6
- package/src/generators/application/application.js +5 -2
- package/src/generators/application/files/base-rspack/rspack.config.js__tmpl__ +1 -1
- package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +1 -1
- package/src/generators/application/lib/add-project.js +9 -19
- package/src/generators/application/lib/bundlers/add-rspack.d.ts +1 -0
- package/src/generators/application/lib/bundlers/add-rspack.js +18 -0
- package/src/generators/application/lib/create-application-files.js +10 -14
- package/src/generators/application/lib/get-app-tests.js +3 -3
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/react",
|
3
|
-
"version": "20.5.0-
|
3
|
+
"version": "20.5.0-canary.20250128-e0c49d3",
|
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
|
-
"@nx/devkit": "20.5.0-
|
42
|
-
"@nx/js": "20.5.0-
|
43
|
-
"@nx/eslint": "20.5.0-
|
44
|
-
"@nx/web": "20.5.0-
|
45
|
-
"@nx/module-federation": "20.5.0-
|
41
|
+
"@nx/devkit": "20.5.0-canary.20250128-e0c49d3",
|
42
|
+
"@nx/js": "20.5.0-canary.20250128-e0c49d3",
|
43
|
+
"@nx/eslint": "20.5.0-canary.20250128-e0c49d3",
|
44
|
+
"@nx/web": "20.5.0-canary.20250128-e0c49d3",
|
45
|
+
"@nx/module-federation": "20.5.0-canary.20250128-e0c49d3",
|
46
46
|
"express": "^4.21.2",
|
47
47
|
"http-proxy-middleware": "^3.0.3",
|
48
48
|
"semver": "^7.6.3"
|
@@ -89,11 +89,12 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
89
89
|
});
|
90
90
|
tasks.push(twTask);
|
91
91
|
}
|
92
|
-
const lintTask = await (0, add_linting_1.addLinting)(tree, options);
|
93
|
-
tasks.push(lintTask);
|
94
92
|
if (options.bundler === 'vite') {
|
95
93
|
await (0, add_vite_1.setupViteConfiguration)(tree, options, tasks);
|
96
94
|
}
|
95
|
+
else if (options.bundler === 'rspack') {
|
96
|
+
await (0, add_rspack_1.setupRspackConfiguration)(tree, options, tasks);
|
97
|
+
}
|
97
98
|
else if (options.bundler === 'rsbuild') {
|
98
99
|
await (0, add_rsbuild_1.setupRsbuildConfiguration)(tree, options, tasks);
|
99
100
|
}
|
@@ -104,6 +105,8 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
104
105
|
options.inSourceTests) {
|
105
106
|
tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/app/${options.fileName}.spec.tsx`));
|
106
107
|
}
|
108
|
+
const lintTask = await (0, add_linting_1.addLinting)(tree, options);
|
109
|
+
tasks.push(lintTask);
|
107
110
|
const e2eTask = await (0, add_e2e_1.addE2e)(tree, options);
|
108
111
|
tasks.push(e2eTask);
|
109
112
|
if (options.unitTestRunner === 'jest') {
|
@@ -33,6 +33,11 @@ function addProject(host, options) {
|
|
33
33
|
name: options.projectName,
|
34
34
|
version: '0.0.1',
|
35
35
|
private: true,
|
36
|
+
nx: options.parsedTags?.length
|
37
|
+
? {
|
38
|
+
tags: options.parsedTags,
|
39
|
+
}
|
40
|
+
: undefined,
|
36
41
|
});
|
37
42
|
}
|
38
43
|
if (!options.isUsingTsSolutionConfig || options.alwaysGenerateProjectJson) {
|
@@ -40,15 +45,6 @@ function addProject(host, options) {
|
|
40
45
|
...project,
|
41
46
|
});
|
42
47
|
}
|
43
|
-
else if (options.parsedTags?.length ||
|
44
|
-
Object.keys(project.targets).length) {
|
45
|
-
const updatedProject = {
|
46
|
-
root: options.appProjectRoot,
|
47
|
-
targets: project.targets,
|
48
|
-
tags: options.parsedTags?.length ? options.parsedTags : undefined,
|
49
|
-
};
|
50
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, updatedProject);
|
51
|
-
}
|
52
48
|
}
|
53
49
|
function createRspackBuildTarget(options) {
|
54
50
|
return {
|
@@ -56,11 +52,7 @@ function createRspackBuildTarget(options) {
|
|
56
52
|
outputs: ['{options.outputPath}'],
|
57
53
|
defaultConfiguration: 'production',
|
58
54
|
options: {
|
59
|
-
outputPath: options.
|
60
|
-
? (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'dist')
|
61
|
-
: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot !== '.'
|
62
|
-
? options.appProjectRoot
|
63
|
-
: options.projectName),
|
55
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot),
|
64
56
|
index: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/index.html'),
|
65
57
|
baseHref: '/',
|
66
58
|
main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/main.tsx`)),
|
@@ -119,11 +111,9 @@ function createBuildTarget(options) {
|
|
119
111
|
defaultConfiguration: 'production',
|
120
112
|
options: {
|
121
113
|
compiler: options.compiler ?? 'babel',
|
122
|
-
outputPath: options.
|
123
|
-
?
|
124
|
-
:
|
125
|
-
? options.appProjectRoot
|
126
|
-
: options.projectName),
|
114
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot != '.'
|
115
|
+
? options.appProjectRoot
|
116
|
+
: options.projectName),
|
127
117
|
index: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/index.html'),
|
128
118
|
baseHref: '/',
|
129
119
|
main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/main.tsx`)),
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { type Tree } from '@nx/devkit';
|
2
2
|
import { NormalizedSchema, Schema } from '../../schema';
|
3
3
|
export declare function initRspack(tree: Tree, options: NormalizedSchema<Schema>, tasks: any[]): Promise<void>;
|
4
|
+
export declare function setupRspackConfiguration(tree: Tree, options: NormalizedSchema<Schema>, tasks: any[]): Promise<void>;
|
4
5
|
export declare function handleStyledJsxForRspack(tasks: any[], tree: Tree, options: NormalizedSchema<Schema>): void;
|
@@ -1,18 +1,36 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.initRspack = initRspack;
|
4
|
+
exports.setupRspackConfiguration = setupRspackConfiguration;
|
4
5
|
exports.handleStyledJsxForRspack = handleStyledJsxForRspack;
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
6
7
|
const pc = require("picocolors");
|
7
8
|
const versions_1 = require("../../../../utils/versions");
|
9
|
+
const maybe_js_1 = require("../../../../utils/maybe-js");
|
8
10
|
async function initRspack(tree, options, tasks) {
|
9
11
|
const { rspackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
|
10
12
|
const rspackInitTask = await rspackInitGenerator(tree, {
|
11
13
|
...options,
|
14
|
+
addPlugin: false,
|
12
15
|
skipFormat: true,
|
13
16
|
});
|
14
17
|
tasks.push(rspackInitTask);
|
15
18
|
}
|
19
|
+
async function setupRspackConfiguration(tree, options, tasks) {
|
20
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
|
21
|
+
const rspackTask = await configurationGenerator(tree, {
|
22
|
+
project: options.projectName,
|
23
|
+
main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)({
|
24
|
+
js: options.js,
|
25
|
+
useJsx: true,
|
26
|
+
}, `src/main.tsx`)),
|
27
|
+
tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
28
|
+
target: 'web',
|
29
|
+
newProject: true,
|
30
|
+
framework: 'react',
|
31
|
+
});
|
32
|
+
tasks.push(rspackTask);
|
33
|
+
}
|
16
34
|
function handleStyledJsxForRspack(tasks, tree, options) {
|
17
35
|
devkit_1.logger.warn(`${pc.bold('styled-jsx')} is not supported by ${pc.bold('Rspack')}. We've added ${pc.bold('babel-loader')} to your project, but using babel will slow down your build.`);
|
18
36
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, { 'babel-loader': versions_1.babelLoaderVersion }));
|
@@ -57,7 +57,7 @@ async function createApplicationFiles(host, options) {
|
|
57
57
|
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-webpack'), options.appProjectRoot, {
|
58
58
|
...templateVariables,
|
59
59
|
webpackPluginOptions: (0, has_webpack_plugin_1.hasWebpackPlugin)(host)
|
60
|
-
? createNxWebpackPluginOptions(options
|
60
|
+
? createNxWebpackPluginOptions(options)
|
61
61
|
: null,
|
62
62
|
});
|
63
63
|
if (options.compiler === 'babel') {
|
@@ -120,7 +120,7 @@ async function createApplicationFiles(host, options) {
|
|
120
120
|
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-rspack'), options.appProjectRoot, {
|
121
121
|
...templateVariables,
|
122
122
|
rspackPluginOptions: (0, has_rspack_plugin_1.hasRspackPlugin)(host)
|
123
|
-
? createNxRspackPluginOptions(options
|
123
|
+
? createNxRspackPluginOptions(options)
|
124
124
|
: null,
|
125
125
|
});
|
126
126
|
}
|
@@ -147,15 +147,13 @@ async function createApplicationFiles(host, options) {
|
|
147
147
|
}
|
148
148
|
(0, create_ts_config_1.createTsConfig)(host, options.appProjectRoot, 'app', options, relativePathToRootTsConfig);
|
149
149
|
}
|
150
|
-
function createNxWebpackPluginOptions(options
|
150
|
+
function createNxWebpackPluginOptions(options) {
|
151
151
|
return {
|
152
152
|
target: 'web',
|
153
153
|
compiler: options.compiler ?? 'babel',
|
154
|
-
outputPath: options.
|
155
|
-
?
|
156
|
-
:
|
157
|
-
? options.appProjectRoot
|
158
|
-
: options.projectName),
|
154
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot != '.'
|
155
|
+
? options.appProjectRoot
|
156
|
+
: options.projectName),
|
159
157
|
index: './src/index.html',
|
160
158
|
baseHref: '/',
|
161
159
|
main: (0, maybe_js_1.maybeJs)({
|
@@ -171,14 +169,12 @@ function createNxWebpackPluginOptions(options, rootOffset) {
|
|
171
169
|
],
|
172
170
|
};
|
173
171
|
}
|
174
|
-
function createNxRspackPluginOptions(options
|
172
|
+
function createNxRspackPluginOptions(options) {
|
175
173
|
return {
|
176
174
|
target: 'web',
|
177
|
-
outputPath: options.
|
178
|
-
?
|
179
|
-
:
|
180
|
-
? options.appProjectRoot
|
181
|
-
: options.projectName),
|
175
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot != '.'
|
176
|
+
? options.appProjectRoot
|
177
|
+
: options.projectName),
|
182
178
|
index: './src/index.html',
|
183
179
|
baseHref: '/',
|
184
180
|
main: (0, maybe_js_1.maybeJs)({
|
@@ -11,9 +11,9 @@ function getAppTests(options) {
|
|
11
11
|
|
12
12
|
it('should have a greeting as the title', () => {
|
13
13
|
${options.routing
|
14
|
-
? 'const {
|
15
|
-
: 'const {
|
16
|
-
expect(
|
14
|
+
? 'const { getByText } = render(<BrowserRouter><App /></BrowserRouter>);'
|
15
|
+
: 'const { getByText } = render(<App />);'}
|
16
|
+
expect(getByText(new RegExp('Welcome ${options.projectName}', 'gi'))).toBeTruthy();
|
17
17
|
});
|
18
18
|
`;
|
19
19
|
}
|