@nx/react 23.0.0-rc.3 → 23.0.0-rc.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.
|
@@ -6,9 +6,8 @@ const tslib_1 = require("tslib");
|
|
|
6
6
|
const internal_1 = require("@nx/devkit/internal");
|
|
7
7
|
const assert_supported_react_version_1 = require("../../utils/assert-supported-react-version");
|
|
8
8
|
const devkit_1 = require("@nx/devkit");
|
|
9
|
-
const internal_2 = require("@nx/devkit/internal");
|
|
10
9
|
const js_1 = require("@nx/js");
|
|
11
|
-
const
|
|
10
|
+
const internal_2 = require("@nx/js/internal");
|
|
12
11
|
const create_ts_config_1 = require("../../utils/create-ts-config");
|
|
13
12
|
const init_1 = tslib_1.__importDefault(require("../init/init"));
|
|
14
13
|
const create_application_files_1 = require("./lib/create-application-files");
|
|
@@ -35,7 +34,7 @@ async function applicationGenerator(tree, schema) {
|
|
|
35
34
|
async function applicationGeneratorInternal(tree, schema) {
|
|
36
35
|
(0, assert_supported_react_version_1.assertSupportedReactVersion)(tree);
|
|
37
36
|
const tasks = [];
|
|
38
|
-
const addTsPlugin = (0,
|
|
37
|
+
const addTsPlugin = (0, internal_2.shouldConfigureTsSolutionSetup)(tree, schema.addPlugin, schema.useTsSolution);
|
|
39
38
|
const jsInitTask = await (0, js_1.initGenerator)(tree, {
|
|
40
39
|
...schema,
|
|
41
40
|
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
@@ -73,23 +72,18 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
73
72
|
});
|
|
74
73
|
tasks.push(initTask);
|
|
75
74
|
if (!options.addPlugin) {
|
|
76
|
-
const nxJson = (0, devkit_1.readNxJson)(tree)
|
|
77
|
-
|
|
78
|
-
if (!
|
|
79
|
-
|
|
80
|
-
target: 'build',
|
|
75
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
76
|
+
nxJson.targetDefaults ??= {};
|
|
77
|
+
if (!Object.keys(nxJson.targetDefaults).includes('build')) {
|
|
78
|
+
nxJson.targetDefaults.build = {
|
|
81
79
|
cache: true,
|
|
82
80
|
dependsOn: ['^build'],
|
|
83
|
-
}
|
|
84
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
81
|
+
};
|
|
85
82
|
}
|
|
86
|
-
else if (!
|
|
87
|
-
|
|
88
|
-
target: 'build',
|
|
89
|
-
dependsOn: ['^build'],
|
|
90
|
-
});
|
|
91
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
83
|
+
else if (!nxJson.targetDefaults.build.dependsOn) {
|
|
84
|
+
nxJson.targetDefaults.build.dependsOn = ['^build'];
|
|
92
85
|
}
|
|
86
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
93
87
|
}
|
|
94
88
|
if (options.bundler === 'webpack') {
|
|
95
89
|
await (0, add_webpack_1.initWebpack)(tree, options, tasks);
|
|
@@ -108,7 +102,7 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
108
102
|
// If we are using the new TS solution
|
|
109
103
|
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
110
104
|
if (options.isUsingTsSolutionConfig) {
|
|
111
|
-
await (0,
|
|
105
|
+
await (0, internal_2.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
|
|
112
106
|
}
|
|
113
107
|
const lintTask = await (0, add_linting_1.addLinting)(tree, options);
|
|
114
108
|
tasks.push(lintTask);
|
|
@@ -157,14 +151,14 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
157
151
|
});
|
|
158
152
|
}
|
|
159
153
|
// Only for the new TS solution
|
|
160
|
-
(0,
|
|
154
|
+
(0, internal_2.updateTsconfigFiles)(tree, options.appProjectRoot, 'tsconfig.app.json', {
|
|
161
155
|
jsx: 'react-jsx',
|
|
162
156
|
module: 'esnext',
|
|
163
157
|
moduleResolution: 'bundler',
|
|
164
158
|
}, options.linter === 'eslint'
|
|
165
159
|
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
166
160
|
: undefined, options.useReactRouter ? 'app' : 'src');
|
|
167
|
-
(0,
|
|
161
|
+
(0, internal_2.sortPackageJsonFields)(tree, options.appProjectRoot);
|
|
168
162
|
if (!options.skipFormat) {
|
|
169
163
|
await (0, devkit_1.formatFiles)(tree);
|
|
170
164
|
}
|
|
@@ -173,14 +167,4 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
173
167
|
});
|
|
174
168
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
175
169
|
}
|
|
176
|
-
function findBuildDefault(td) {
|
|
177
|
-
if (!td)
|
|
178
|
-
return undefined;
|
|
179
|
-
if (Array.isArray(td)) {
|
|
180
|
-
return td.find((e) => e.target === 'build' &&
|
|
181
|
-
e.projects === undefined &&
|
|
182
|
-
e.plugin === undefined);
|
|
183
|
-
}
|
|
184
|
-
return td['build'];
|
|
185
|
-
}
|
|
186
170
|
exports.default = applicationGenerator;
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setupSsrGenerator = setupSsrGenerator;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const internal_1 = require("@nx/devkit/internal");
|
|
6
5
|
const assert_supported_react_version_1 = require("../../utils/assert-supported-react-version");
|
|
7
|
-
const
|
|
6
|
+
const internal_1 = require("@nx/js/internal");
|
|
8
7
|
const path_1 = require("path");
|
|
9
8
|
const ast_utils_1 = require("../../utils/ast-utils");
|
|
10
9
|
const versions_1 = require("../../utils/versions");
|
|
11
10
|
let tsModule;
|
|
12
11
|
function readEntryFile(host, path) {
|
|
13
12
|
if (!tsModule) {
|
|
14
|
-
tsModule = (0,
|
|
13
|
+
tsModule = (0, internal_1.ensureTypescript)();
|
|
15
14
|
}
|
|
16
15
|
const content = host.read(path, 'utf-8');
|
|
17
16
|
return {
|
|
@@ -46,7 +45,7 @@ async function setupSsrGenerator(tree, options) {
|
|
|
46
45
|
].map((importPath) => {
|
|
47
46
|
return {
|
|
48
47
|
importPath,
|
|
49
|
-
filePath: (0, devkit_1.joinPathFragments)((0,
|
|
48
|
+
filePath: (0, devkit_1.joinPathFragments)((0, internal_1.getProjectSourceRoot)(projectConfig, tree), `${importPath}.tsx`),
|
|
50
49
|
};
|
|
51
50
|
});
|
|
52
51
|
const appComponentInfo = appImportCandidates.find((candidate) => tree.exists(candidate.filePath));
|
|
@@ -162,6 +161,9 @@ async function setupSsrGenerator(tree, options) {
|
|
|
162
161
|
'server',
|
|
163
162
|
];
|
|
164
163
|
}
|
|
164
|
+
nxJson.targetDefaults ??= {};
|
|
165
|
+
nxJson.targetDefaults['server'] ??= {};
|
|
166
|
+
nxJson.targetDefaults.server.cache = true;
|
|
165
167
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), projectRoot, {
|
|
166
168
|
tmpl: '',
|
|
167
169
|
port: Number(options?.serverPort) || 4200,
|
|
@@ -182,7 +184,6 @@ async function setupSsrGenerator(tree, options) {
|
|
|
182
184
|
const changes = (0, devkit_1.applyChangesToString)(content, (0, ast_utils_1.addStaticRouter)(serverEntry, source));
|
|
183
185
|
tree.write(serverEntry, changes);
|
|
184
186
|
}
|
|
185
|
-
(0, internal_1.upsertTargetDefault)(tree, nxJson, { target: 'server', cache: true });
|
|
186
187
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
187
188
|
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
188
189
|
express: versions_1.expressVersion,
|
|
@@ -2,31 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addMfEnvToTargetDefaultInputs = addMfEnvToTargetDefaultInputs;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const internal_1 = require("@nx/devkit/internal");
|
|
6
5
|
function addMfEnvToTargetDefaultInputs(tree, bundler) {
|
|
7
|
-
const nxJson = (0, devkit_1.readNxJson)(tree)
|
|
6
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
8
7
|
const executor = bundler === 'rspack' ? '@nx/rspack:rspack' : '@nx/webpack:webpack';
|
|
9
8
|
const mfEnvVar = 'NX_MF_DEV_REMOTES';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const inputs = [...(existing?.inputs ?? ['production', '^production'])];
|
|
9
|
+
nxJson.targetDefaults ??= {};
|
|
10
|
+
nxJson.targetDefaults[executor] ??= {};
|
|
11
|
+
nxJson.targetDefaults[executor].inputs ??= ['production', '^production'];
|
|
12
|
+
nxJson.targetDefaults[executor].dependsOn ??= ['^build'];
|
|
15
13
|
let mfEnvVarExists = false;
|
|
16
|
-
for (const input of inputs) {
|
|
14
|
+
for (const input of nxJson.targetDefaults[executor].inputs) {
|
|
17
15
|
if (typeof input === 'object' && input['env'] === mfEnvVar) {
|
|
18
16
|
mfEnvVarExists = true;
|
|
19
17
|
break;
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
20
|
if (!mfEnvVarExists) {
|
|
23
|
-
inputs.push({ env: mfEnvVar });
|
|
21
|
+
nxJson.targetDefaults[executor].inputs.push({ env: mfEnvVar });
|
|
24
22
|
}
|
|
25
|
-
|
|
26
|
-
executor,
|
|
27
|
-
cache: true,
|
|
28
|
-
inputs,
|
|
29
|
-
dependsOn: existing?.dependsOn ?? ['^build'],
|
|
30
|
-
});
|
|
23
|
+
nxJson.targetDefaults[executor].cache = true;
|
|
31
24
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
32
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "23.0.0-rc.
|
|
3
|
+
"version": "23.0.0-rc.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": {
|
|
@@ -108,25 +108,25 @@
|
|
|
108
108
|
"express": "^4.21.2",
|
|
109
109
|
"http-proxy-middleware": "^3.0.5",
|
|
110
110
|
"semver": "^7.6.3",
|
|
111
|
-
"@nx/devkit": "23.0.0-rc.
|
|
112
|
-
"@nx/js": "23.0.0-rc.
|
|
113
|
-
"@nx/eslint": "23.0.0-rc.
|
|
114
|
-
"@nx/web": "23.0.0-rc.
|
|
115
|
-
"@nx/module-federation": "23.0.0-rc.
|
|
116
|
-
"@nx/rollup": "23.0.0-rc.
|
|
111
|
+
"@nx/devkit": "23.0.0-rc.4",
|
|
112
|
+
"@nx/js": "23.0.0-rc.4",
|
|
113
|
+
"@nx/eslint": "23.0.0-rc.4",
|
|
114
|
+
"@nx/web": "23.0.0-rc.4",
|
|
115
|
+
"@nx/module-federation": "23.0.0-rc.4",
|
|
116
|
+
"@nx/rollup": "23.0.0-rc.4"
|
|
117
117
|
},
|
|
118
118
|
"devDependencies": {
|
|
119
|
-
"@nx/cypress": "23.0.0-rc.
|
|
120
|
-
"@nx/playwright": "23.0.0-rc.
|
|
121
|
-
"@nx/rsbuild": "23.0.0-rc.
|
|
122
|
-
"@nx/vite": "23.0.0-rc.
|
|
123
|
-
"@nx/vitest": "23.0.0-rc.
|
|
124
|
-
"@nx/webpack": "23.0.0-rc.
|
|
125
|
-
"@nx/storybook": "23.0.0-rc.
|
|
126
|
-
"nx": "23.0.0-rc.
|
|
119
|
+
"@nx/cypress": "23.0.0-rc.4",
|
|
120
|
+
"@nx/playwright": "23.0.0-rc.4",
|
|
121
|
+
"@nx/rsbuild": "23.0.0-rc.4",
|
|
122
|
+
"@nx/vite": "23.0.0-rc.4",
|
|
123
|
+
"@nx/vitest": "23.0.0-rc.4",
|
|
124
|
+
"@nx/webpack": "23.0.0-rc.4",
|
|
125
|
+
"@nx/storybook": "23.0.0-rc.4",
|
|
126
|
+
"nx": "23.0.0-rc.4"
|
|
127
127
|
},
|
|
128
128
|
"optionalDependencies": {
|
|
129
|
-
"@nx/vite": "23.0.0-rc.
|
|
129
|
+
"@nx/vite": "23.0.0-rc.4"
|
|
130
130
|
},
|
|
131
131
|
"publishConfig": {
|
|
132
132
|
"access": "public"
|