@nx/react 24.1.0-beta.0 → 24.1.0-beta.2
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/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +4 -1
- package/dist/src/generators/application/lib/add-linting.js +1 -1
- package/dist/src/generators/library/lib/add-linting.js +1 -1
- package/dist/src/generators/provider/files/rsbuild/rsbuild.config.ts__tmpl__ +5 -2
- package/dist/src/generators/provider/files/rspack/rspack.config.ts__tmpl__ +10 -1
- package/dist/src/generators/provider/files/vite/vite.config.mts__tmpl__ +1 -6
- package/dist/src/plugins/router-plugin-utils.d.ts +1 -4
- package/dist/src/plugins/router-plugin-utils.js +5 -8
- package/dist/src/plugins/router-plugin.js +108 -12
- package/dist/src/utils/lint.d.ts +27 -1
- package/dist/src/utils/lint.js +50 -2
- package/dist/src/utils/versions.d.ts +2 -0
- package/dist/src/utils/versions.js +8 -1
- package/package.json +17 -17
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { extraEslintDependencies, extendReactEslintJson, } from './src/utils/lint';
|
|
1
|
+
export { extraEslintDependencies, getExtraEslintDependencies, extendReactEslintJson, } from './src/utils/lint';
|
|
2
2
|
export { assertValidStyle } from './src/utils/assertion';
|
|
3
3
|
export { reactDomVersion, reactVersion } from './src/utils/versions';
|
|
4
4
|
export { applicationGenerator } from './src/generators/application/application';
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.componentTestGenerator = exports.cypressComponentConfigGenerator = exports.storybookConfigurationGenerator = exports.storiesGenerator = exports.reduxGenerator = exports.reactInitGenerator = exports.libraryGenerator = exports.componentStoryGenerator = exports.hookGenerator = exports.componentGenerator = exports.applicationGenerator = exports.reactVersion = exports.reactDomVersion = exports.assertValidStyle = exports.extendReactEslintJson = exports.extraEslintDependencies = void 0;
|
|
3
|
+
exports.componentTestGenerator = exports.cypressComponentConfigGenerator = exports.storybookConfigurationGenerator = exports.storiesGenerator = exports.reduxGenerator = exports.reactInitGenerator = exports.libraryGenerator = exports.componentStoryGenerator = exports.hookGenerator = exports.componentGenerator = exports.applicationGenerator = exports.reactVersion = exports.reactDomVersion = exports.assertValidStyle = exports.extendReactEslintJson = exports.getExtraEslintDependencies = exports.extraEslintDependencies = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var lint_1 = require("./src/utils/lint");
|
|
6
6
|
Object.defineProperty(exports, "extraEslintDependencies", { enumerable: true, get: function () { return lint_1.extraEslintDependencies; } });
|
|
7
|
+
Object.defineProperty(exports, "getExtraEslintDependencies", { enumerable: true, get: function () { return lint_1.getExtraEslintDependencies; } });
|
|
7
8
|
Object.defineProperty(exports, "extendReactEslintJson", { enumerable: true, get: function () { return lint_1.extendReactEslintJson; } });
|
|
8
9
|
var assertion_1 = require("./src/utils/assertion");
|
|
9
10
|
Object.defineProperty(exports, "assertValidStyle", { enumerable: true, get: function () { return assertion_1.assertValidStyle; } });
|
package/dist/internal.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { assertPackageIsInstalled } from './src/utils/assert-package';
|
|
|
4
4
|
export { isComponent } from './src/utils/ct-utils';
|
|
5
5
|
export { suppressReactComposeHelperWarnings } from './src/utils/deprecation';
|
|
6
6
|
export { hasWebpackPlugin } from './src/utils/has-webpack-plugin';
|
|
7
|
+
export { addExtraEslintDependencies, getExtraEslintDependencies, } from './src/utils/lint';
|
|
7
8
|
export { getReactDependenciesVersionsToInstall, isReact18, } from './src/utils/version-utils';
|
|
8
9
|
export { testingLibraryDomVersion, testingLibraryReactVersion, babelCoreVersion, babelPresetReactVersion, } from './src/utils/versions';
|
|
9
10
|
export { applyReactConfig } from './plugins/nx-react-webpack-plugin/lib/apply-react-config';
|
package/dist/internal.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// internal consumers and may change without semver protection. Mirrors
|
|
6
6
|
// `@nx/devkit/internal`.
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.applyReactConfig = exports.babelPresetReactVersion = exports.babelCoreVersion = exports.testingLibraryReactVersion = exports.testingLibraryDomVersion = exports.isReact18 = exports.getReactDependenciesVersionsToInstall = exports.hasWebpackPlugin = exports.suppressReactComposeHelperWarnings = exports.isComponent = exports.assertPackageIsInstalled = exports.addRollupBuildTarget = exports.addE2e = void 0;
|
|
8
|
+
exports.applyReactConfig = exports.babelPresetReactVersion = exports.babelCoreVersion = exports.testingLibraryReactVersion = exports.testingLibraryDomVersion = exports.isReact18 = exports.getReactDependenciesVersionsToInstall = exports.getExtraEslintDependencies = exports.addExtraEslintDependencies = exports.hasWebpackPlugin = exports.suppressReactComposeHelperWarnings = exports.isComponent = exports.assertPackageIsInstalled = exports.addRollupBuildTarget = exports.addE2e = void 0;
|
|
9
9
|
var add_e2e_1 = require("./src/generators/application/lib/add-e2e");
|
|
10
10
|
Object.defineProperty(exports, "addE2e", { enumerable: true, get: function () { return add_e2e_1.addE2e; } });
|
|
11
11
|
var add_rollup_build_target_1 = require("./src/generators/library/lib/add-rollup-build-target");
|
|
@@ -18,6 +18,9 @@ var deprecation_1 = require("./src/utils/deprecation");
|
|
|
18
18
|
Object.defineProperty(exports, "suppressReactComposeHelperWarnings", { enumerable: true, get: function () { return deprecation_1.suppressReactComposeHelperWarnings; } });
|
|
19
19
|
var has_webpack_plugin_1 = require("./src/utils/has-webpack-plugin");
|
|
20
20
|
Object.defineProperty(exports, "hasWebpackPlugin", { enumerable: true, get: function () { return has_webpack_plugin_1.hasWebpackPlugin; } });
|
|
21
|
+
var lint_1 = require("./src/utils/lint");
|
|
22
|
+
Object.defineProperty(exports, "addExtraEslintDependencies", { enumerable: true, get: function () { return lint_1.addExtraEslintDependencies; } });
|
|
23
|
+
Object.defineProperty(exports, "getExtraEslintDependencies", { enumerable: true, get: function () { return lint_1.getExtraEslintDependencies; } });
|
|
21
24
|
var version_utils_1 = require("./src/utils/version-utils");
|
|
22
25
|
Object.defineProperty(exports, "getReactDependenciesVersionsToInstall", { enumerable: true, get: function () { return version_utils_1.getReactDependenciesVersionsToInstall; } });
|
|
23
26
|
Object.defineProperty(exports, "isReact18", { enumerable: true, get: function () { return version_utils_1.isReact18; } });
|
|
@@ -41,7 +41,7 @@ async function addLinting(host, options) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
if (!options.skipPackageJson) {
|
|
44
|
-
const installTask = (0,
|
|
44
|
+
const installTask = (0, lint_1.addExtraEslintDependencies)(host);
|
|
45
45
|
const addSwcTask = (0, internal_2.addSwcDependencies)(host);
|
|
46
46
|
tasks.push(installTask, addSwcTask);
|
|
47
47
|
}
|
|
@@ -46,7 +46,7 @@ async function addLinting(host, options) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
if (!options.skipPackageJson) {
|
|
49
|
-
tasks.push((0,
|
|
49
|
+
tasks.push((0, lint_1.addExtraEslintDependencies)(host));
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
@@ -9,8 +9,11 @@ const NAME = '<%= federationName %>';
|
|
|
9
9
|
export default defineConfig({
|
|
10
10
|
server: {
|
|
11
11
|
port: PORT,
|
|
12
|
-
//
|
|
13
|
-
|
|
12
|
+
// Local origins only. Without an explicit origin, the federation plugin
|
|
13
|
+
// sends `Access-Control-Allow-Origin: *`.
|
|
14
|
+
cors: {
|
|
15
|
+
origin: /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/,
|
|
16
|
+
},
|
|
14
17
|
},
|
|
15
18
|
// assetPrefix:true tells rsbuild to emit chunks with the dev-server URL as
|
|
16
19
|
// their public path. Without it a consumer on a different port asks its
|
|
@@ -13,6 +13,9 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
13
13
|
|
|
14
14
|
const PORT = <%= port %>;
|
|
15
15
|
const NAME = '<%= federationName %>';
|
|
16
|
+
// localhost (and its subdomains), 127.0.0.1 or [::1], on any port.
|
|
17
|
+
const LOCAL_ORIGIN =
|
|
18
|
+
/^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;
|
|
16
19
|
|
|
17
20
|
// Read mode from the rspack CLI arg (`--mode=development|production`) so the
|
|
18
21
|
// config works the same on Windows + POSIX without depending on a shell
|
|
@@ -32,7 +35,13 @@ export default defineConfig((_env, argv) => {
|
|
|
32
35
|
port: PORT,
|
|
33
36
|
historyApiFallback: true,
|
|
34
37
|
hot: true,
|
|
35
|
-
|
|
38
|
+
// Lets consumers on local origins fetch the manifest and hot updates.
|
|
39
|
+
headers: (req): Record<string, string> => {
|
|
40
|
+
const origin = req.headers.origin;
|
|
41
|
+
return origin && LOCAL_ORIGIN.test(origin)
|
|
42
|
+
? { 'Access-Control-Allow-Origin': origin, Vary: 'Origin' }
|
|
43
|
+
: { Vary: 'Origin' };
|
|
44
|
+
},
|
|
36
45
|
},
|
|
37
46
|
resolve: { extensions: ['...', '.ts', '.tsx', '.jsx'] },
|
|
38
47
|
module: {
|
|
@@ -13,13 +13,8 @@ export default defineConfig({
|
|
|
13
13
|
strictPort: true,
|
|
14
14
|
origin: `http://localhost:${PORT}`,
|
|
15
15
|
host: '127.0.0.1',
|
|
16
|
-
// Allow cross-origin fetches of mf-manifest.json + chunks from a consumer
|
|
17
|
-
// running on a different port. Vite 8 narrows the default CORS allowlist
|
|
18
|
-
// to specific localhost patterns; setting `cors: true` emits a wildcard
|
|
19
|
-
// `Access-Control-Allow-Origin: *` for dev which is what federation needs.
|
|
20
|
-
cors: true,
|
|
21
16
|
},
|
|
22
|
-
preview: { port: PORT, strictPort: true
|
|
17
|
+
preview: { port: PORT, strictPort: true },
|
|
23
18
|
build: { target: 'chrome89' },
|
|
24
19
|
plugins: [
|
|
25
20
|
federation({
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
function canResolve(request, directory) {
|
|
3
|
+
exports.resolveOptionalModule = resolveOptionalModule;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
|
+
function resolveOptionalModule(request, directory) {
|
|
8
6
|
try {
|
|
9
|
-
|
|
10
|
-
return true;
|
|
7
|
+
return (0, internal_1.resolveInstalledPackage)(request, [directory], directory);
|
|
11
8
|
}
|
|
12
9
|
catch {
|
|
13
|
-
return
|
|
10
|
+
return null;
|
|
14
11
|
}
|
|
15
12
|
}
|
|
@@ -5,9 +5,16 @@ const internal_1 = require("@nx/devkit/internal");
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
|
+
const node_url_1 = require("node:url");
|
|
8
9
|
const js_1 = require("@nx/js");
|
|
9
10
|
const internal_2 = require("@nx/js/internal");
|
|
10
11
|
const router_plugin_utils_1 = require("./router-plugin-utils");
|
|
12
|
+
const node_module_1 = require("node:module");
|
|
13
|
+
// Node passes a stand-in require, without a cache, require.extensions or
|
|
14
|
+
// Module._load, when an ESM loader hook supplies this module's source, as
|
|
15
|
+
// Yarn PnP does.
|
|
16
|
+
if (!require.cache)
|
|
17
|
+
require = (0, node_module_1.createRequire)(__filename);
|
|
11
18
|
const reactRouterConfigBlob = '**/react-router.config.{ts,js,cjs,cts,mjs,mts}';
|
|
12
19
|
exports.createNodes = [
|
|
13
20
|
reactRouterConfigBlob,
|
|
@@ -32,14 +39,55 @@ exports.createNodes = [
|
|
|
32
39
|
const pmCommand = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
|
33
40
|
const lockfile = (0, js_1.getLockFileName)(packageManager);
|
|
34
41
|
const hashes = await (0, internal_1.calculateHashesForCreateNodes)(projectRoots, { ...normalizedOptions, isUsingTsSolutionSetup }, context, projectRoots.map((_) => [lockfile]));
|
|
42
|
+
const configFileHashes = new Map();
|
|
43
|
+
const getConfigFileHash = (file) => {
|
|
44
|
+
if (!configFileHashes.has(file)) {
|
|
45
|
+
configFileHashes.set(file, (0, internal_1.hashFile)(file) ?? null);
|
|
46
|
+
}
|
|
47
|
+
return configFileHashes.get(file) ?? null;
|
|
48
|
+
};
|
|
49
|
+
const getConfigDependencyHashes = (dependencies, configLoadStartedAt) => {
|
|
50
|
+
const hashes = {};
|
|
51
|
+
try {
|
|
52
|
+
for (const file of dependencies) {
|
|
53
|
+
const hash = getConfigFileHash(file);
|
|
54
|
+
if (hash === null)
|
|
55
|
+
return undefined;
|
|
56
|
+
const { mtimeMs, ctimeMs } = (0, fs_1.statSync)(file);
|
|
57
|
+
// Do not associate an earlier config result with newer file contents.
|
|
58
|
+
if (mtimeMs >= configLoadStartedAt ||
|
|
59
|
+
ctimeMs >= configLoadStartedAt) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
hashes[file] = hash;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
return hashes;
|
|
69
|
+
};
|
|
35
70
|
try {
|
|
36
71
|
return await (0, devkit_1.createNodesFromFiles)(async (configFile, _, context, idx) => {
|
|
37
72
|
const projectRoot = (0, path_1.dirname)(configFile);
|
|
38
73
|
const hash = hashes[idx] + configFile;
|
|
39
|
-
|
|
40
|
-
|
|
74
|
+
const cachedTargets = targetsCache.get(hash);
|
|
75
|
+
let result;
|
|
76
|
+
if (cachedTargets?.configDependencyHashes &&
|
|
77
|
+
Object.entries(cachedTargets.configDependencyHashes).every(([file, previousHash]) => getConfigFileHash(file) === previousHash)) {
|
|
78
|
+
result = cachedTargets;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const configLoadStartedAt = Date.now();
|
|
82
|
+
const { configDependencies, ...inferredTargets } = await buildReactRouterTargets(configFile, projectRoot, normalizedOptions, context, isUsingTsSolutionSetup, pmCommand);
|
|
83
|
+
result = inferredTargets;
|
|
84
|
+
const configDependencyHashes = configDependencies &&
|
|
85
|
+
getConfigDependencyHashes(configDependencies, configLoadStartedAt);
|
|
86
|
+
if (configDependencyHashes) {
|
|
87
|
+
targetsCache.set(hash, { ...result, configDependencyHashes });
|
|
88
|
+
}
|
|
41
89
|
}
|
|
42
|
-
const { projectType, metadata, targets } =
|
|
90
|
+
const { projectType, metadata, targets } = result;
|
|
43
91
|
const project = {
|
|
44
92
|
root: projectRoot,
|
|
45
93
|
targets,
|
|
@@ -74,7 +122,8 @@ async function buildReactRouterTargets(configFilePath, projectRoot, options, con
|
|
|
74
122
|
const { buildDirectory, serverBuildPath } = await getBuildPaths(reactRouterConfig, isLibMode);
|
|
75
123
|
const targets = {};
|
|
76
124
|
targets[options.buildTargetName] = await getBuildTargetConfig(options.buildTargetName, projectRoot, buildDirectory, serverBuildPath, namedInputs, isUsingTsSolutionSetup);
|
|
77
|
-
|
|
125
|
+
const { readyWhen, configDependencies } = await getDevReadyWhen(context.workspaceRoot, (0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
126
|
+
targets[options.devTargetName] = await devTarget(projectRoot, namedInputs, isUsingTsSolutionSetup, readyWhen);
|
|
78
127
|
if (serverBuildPath) {
|
|
79
128
|
targets[options.startTargetName] = await startTarget(projectRoot, serverBuildPath, options.buildTargetName, namedInputs, isUsingTsSolutionSetup);
|
|
80
129
|
}
|
|
@@ -84,6 +133,7 @@ async function buildReactRouterTargets(configFilePath, projectRoot, options, con
|
|
|
84
133
|
targets,
|
|
85
134
|
metadata,
|
|
86
135
|
projectType: isLibMode ? 'library' : 'application',
|
|
136
|
+
configDependencies,
|
|
87
137
|
};
|
|
88
138
|
}
|
|
89
139
|
async function getBuildTargetConfig(buildTargetName, projectRoot, buildDirectory, serverBuildDirectory, namedInputs, isUsingTsSolutionSetup) {
|
|
@@ -153,19 +203,65 @@ const viteConfigFiles = [
|
|
|
153
203
|
'vite.config.mts',
|
|
154
204
|
'vite.config.cts',
|
|
155
205
|
];
|
|
156
|
-
|
|
157
|
-
// and options, and waits for the server's port.
|
|
158
|
-
function getDevReadyWhen(workspaceRoot, absoluteProjectRoot) {
|
|
206
|
+
async function getDevReadyWhen(workspaceRoot, absoluteProjectRoot) {
|
|
159
207
|
// `react-router dev` serves with the default Vite config of its cwd.
|
|
160
208
|
const configFile = viteConfigFiles.find((file) => (0, fs_1.existsSync)((0, path_1.join)(absoluteProjectRoot, file)));
|
|
161
209
|
if (!configFile) {
|
|
162
|
-
return undefined;
|
|
210
|
+
return { readyWhen: undefined, configDependencies: [] };
|
|
211
|
+
}
|
|
212
|
+
// The command check runs from the workspace root and must resolve its helper there.
|
|
213
|
+
const viteReadyCheck = (0, router_plugin_utils_1.resolveOptionalModule)('@nx/vite/ready-check', workspaceRoot);
|
|
214
|
+
if (!viteReadyCheck) {
|
|
215
|
+
return { readyWhen: undefined, configDependencies: [] };
|
|
163
216
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
217
|
+
const commandReadyWhen = (0, internal_1.getReadyCheckReadyWhen)('@nx/vite/ready-check', configFile, 'react-router-dev');
|
|
218
|
+
try {
|
|
219
|
+
let vitePackageJsonPath;
|
|
220
|
+
try {
|
|
221
|
+
vitePackageJsonPath = (0, internal_1.resolveInstalledPackage)('vite/package.json', [absoluteProjectRoot, (0, path_1.dirname)(viteReadyCheck)], workspaceRoot);
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
// A linked @nx/vite may keep Vite in its own package directory.
|
|
225
|
+
const nxVitePackageJsonPath = (0, internal_1.resolveInstalledPackage)('@nx/vite/package.json', [workspaceRoot], workspaceRoot);
|
|
226
|
+
vitePackageJsonPath = (0, internal_1.resolveInstalledPackage)('vite/package.json', [(0, path_1.dirname)(viteReadyCheck)], (0, path_1.dirname)(nxVitePackageJsonPath));
|
|
227
|
+
}
|
|
228
|
+
const viteExport = (0, devkit_1.readJsonFile)(vitePackageJsonPath).exports['.'];
|
|
229
|
+
// Vite 5/6 expose a deprecated CJS shim under the require condition.
|
|
230
|
+
const esmEntry = typeof viteExport === 'string'
|
|
231
|
+
? viteExport
|
|
232
|
+
: (viteExport.import?.default ?? viteExport.import);
|
|
233
|
+
const { loadConfigFromFile } = await import((0, node_url_1.pathToFileURL)((0, path_1.join)((0, path_1.dirname)(vitePackageJsonPath), esmEntry)).href);
|
|
234
|
+
// Resolving serve plugins starts React Router's type generator. Loading only
|
|
235
|
+
// the config avoids a second generator deleting files the server is writing.
|
|
236
|
+
const viteConfig = await (0, internal_1.retryOnRequireEsmRace)(() => loadConfigFromFile({
|
|
237
|
+
command: 'serve',
|
|
238
|
+
mode: 'development',
|
|
239
|
+
isSsrBuild: false,
|
|
240
|
+
isPreview: false,
|
|
241
|
+
}, (0, path_1.join)(absoluteProjectRoot, configFile), absoluteProjectRoot, 'silent'));
|
|
242
|
+
return {
|
|
243
|
+
readyWhen: (await loadsReadySignalPlugin(viteConfig?.config.plugins))
|
|
244
|
+
? { signal: true }
|
|
245
|
+
: commandReadyWhen,
|
|
246
|
+
configDependencies: viteConfig
|
|
247
|
+
? [...new Set(viteConfig.dependencies.map((file) => (0, path_1.resolve)(file)))]
|
|
248
|
+
: undefined,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
// Optional readiness detection must not prevent graph creation.
|
|
253
|
+
}
|
|
254
|
+
return { readyWhen: commandReadyWhen };
|
|
255
|
+
}
|
|
256
|
+
async function loadsReadySignalPlugin(plugins) {
|
|
257
|
+
const plugin = await plugins;
|
|
258
|
+
if (Array.isArray(plugin)) {
|
|
259
|
+
return (await Promise.all(plugin.map(loadsReadySignalPlugin))).some(Boolean);
|
|
167
260
|
}
|
|
168
|
-
|
|
261
|
+
const candidate = plugin;
|
|
262
|
+
// Function predicates may depend on the task environment.
|
|
263
|
+
return (candidate?.name === 'nx-ready-signal' &&
|
|
264
|
+
(!candidate.apply || candidate.apply === 'serve'));
|
|
169
265
|
}
|
|
170
266
|
async function startTarget(projectRoot, serverBuildPath, buildTargetName, namedInputs, isUsingTsSolutionSetup) {
|
|
171
267
|
const serverPath = serverBuildPath === 'build/server'
|
package/dist/src/utils/lint.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
1
2
|
import { Linter } from 'eslint';
|
|
3
|
+
type EslintDependencies = {
|
|
4
|
+
dependencies: Record<string, string>;
|
|
5
|
+
devDependencies: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use {@link getExtraEslintDependencies}, which resolves the plugin
|
|
9
|
+
* set for the workspace's ESLint version. This static set targets ESLint v9 and
|
|
10
|
+
* earlier; on ESLint v10 it installs plugins that have no v10 release. This
|
|
11
|
+
* will be removed in Nx v25.
|
|
12
|
+
*/
|
|
2
13
|
export declare const extraEslintDependencies: {
|
|
3
14
|
dependencies: {};
|
|
4
15
|
devDependencies: {
|
|
@@ -9,6 +20,21 @@ export declare const extraEslintDependencies: {
|
|
|
9
20
|
};
|
|
10
21
|
};
|
|
11
22
|
/**
|
|
12
|
-
*
|
|
23
|
+
* Resolves the React ESLint plugin set for the workspace's ESLint version.
|
|
24
|
+
* ESLint v10 has no eslintrc API and no react/jsx-a11y/import release, so v10
|
|
25
|
+
* workspaces swap to eslint-plugin-import-x and react-hooks v7. We read the
|
|
26
|
+
* version from `@nx/eslint`'s resolver, the same one that installs ESLint, so
|
|
27
|
+
* the plugin set stays in lockstep with the workspace's ESLint major.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getExtraEslintDependencies(tree: Tree): EslintDependencies;
|
|
30
|
+
/**
|
|
31
|
+
* Adds the plugin set {@link getExtraEslintDependencies} resolves, plus
|
|
32
|
+
* `extraDevDependencies`, keeping versions the workspace already declares.
|
|
33
|
+
*/
|
|
34
|
+
export declare function addExtraEslintDependencies(tree: Tree, extraDevDependencies?: Record<string, string>): GeneratorCallback;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated Use `addExtendsToLintConfig` from `@nx/eslint` instead. This will
|
|
37
|
+
* be removed in Nx v25.
|
|
13
38
|
*/
|
|
14
39
|
export declare const extendReactEslintJson: (json: Linter.LegacyConfig) => Linter.LegacyConfig;
|
|
40
|
+
export {};
|
package/dist/src/utils/lint.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extendReactEslintJson = exports.extraEslintDependencies = void 0;
|
|
4
|
+
exports.getExtraEslintDependencies = getExtraEslintDependencies;
|
|
5
|
+
exports.addExtraEslintDependencies = addExtraEslintDependencies;
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
8
|
+
const internal_2 = require("@nx/eslint/internal");
|
|
9
|
+
const semver_1 = require("semver");
|
|
4
10
|
const versions_1 = require("./versions");
|
|
5
|
-
|
|
11
|
+
const eslintLegacyDependencies = {
|
|
6
12
|
dependencies: {},
|
|
7
13
|
devDependencies: {
|
|
8
14
|
'eslint-plugin-import': versions_1.eslintPluginImportVersion,
|
|
@@ -11,8 +17,50 @@ exports.extraEslintDependencies = {
|
|
|
11
17
|
'eslint-plugin-react-hooks': versions_1.eslintPluginReactHooksVersion,
|
|
12
18
|
},
|
|
13
19
|
};
|
|
20
|
+
const eslint10Dependencies = {
|
|
21
|
+
dependencies: {},
|
|
22
|
+
devDependencies: {
|
|
23
|
+
'eslint-plugin-import-x': versions_1.eslintPluginImportXVersion,
|
|
24
|
+
'eslint-plugin-react-hooks': versions_1.eslintPluginReactHooksV7Version,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Use {@link getExtraEslintDependencies}, which resolves the plugin
|
|
29
|
+
* set for the workspace's ESLint version. This static set targets ESLint v9 and
|
|
30
|
+
* earlier; on ESLint v10 it installs plugins that have no v10 release. This
|
|
31
|
+
* will be removed in Nx v25.
|
|
32
|
+
*/
|
|
33
|
+
exports.extraEslintDependencies = eslintLegacyDependencies;
|
|
34
|
+
/**
|
|
35
|
+
* Resolves the React ESLint plugin set for the workspace's ESLint version.
|
|
36
|
+
* ESLint v10 has no eslintrc API and no react/jsx-a11y/import release, so v10
|
|
37
|
+
* workspaces swap to eslint-plugin-import-x and react-hooks v7. We read the
|
|
38
|
+
* version from `@nx/eslint`'s resolver, the same one that installs ESLint, so
|
|
39
|
+
* the plugin set stays in lockstep with the workspace's ESLint major.
|
|
40
|
+
*/
|
|
41
|
+
function getExtraEslintDependencies(tree) {
|
|
42
|
+
const { eslintVersion } = (0, internal_2.versions)(tree);
|
|
43
|
+
const isLegacyEslint = ((0, semver_1.coerce)(eslintVersion)?.major ?? 10) < 10;
|
|
44
|
+
return isLegacyEslint ? eslintLegacyDependencies : eslint10Dependencies;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Adds the plugin set {@link getExtraEslintDependencies} resolves, plus
|
|
48
|
+
* `extraDevDependencies`, keeping versions the workspace already declares.
|
|
49
|
+
*/
|
|
50
|
+
function addExtraEslintDependencies(tree, extraDevDependencies = {}) {
|
|
51
|
+
const { dependencies, devDependencies } = getExtraEslintDependencies(tree);
|
|
52
|
+
if ('eslint-plugin-import-x' in devDependencies) {
|
|
53
|
+
// eslint-plugin-import-x depends on unrs-resolver, whose postinstall only
|
|
54
|
+
// fetches a fallback binding for platforms its prebuilt bindings miss.
|
|
55
|
+
(0, internal_1.acknowledgeBuildScripts)(tree, (0, devkit_1.detectPackageManager)(tree.root), {
|
|
56
|
+
'unrs-resolver': false,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, dependencies, { ...devDependencies, ...extraDevDependencies }, undefined, true);
|
|
60
|
+
}
|
|
14
61
|
/**
|
|
15
|
-
* @deprecated Use `addExtendsToLintConfig` from `@nx/eslint` instead.
|
|
62
|
+
* @deprecated Use `addExtendsToLintConfig` from `@nx/eslint` instead. This will
|
|
63
|
+
* be removed in Nx v25.
|
|
16
64
|
*/
|
|
17
65
|
const extendReactEslintJson = (json) => {
|
|
18
66
|
const { extends: pluginExtends, ...config } = json;
|
|
@@ -28,6 +28,8 @@ export declare const eslintPluginImportVersion = "2.31.0";
|
|
|
28
28
|
export declare const eslintPluginJsxA11yVersion = "6.10.1";
|
|
29
29
|
export declare const eslintPluginReactVersion = "^7.35.0";
|
|
30
30
|
export declare const eslintPluginReactHooksVersion = "5.0.0";
|
|
31
|
+
export declare const eslintPluginImportXVersion = "^4.17.1";
|
|
32
|
+
export declare const eslintPluginReactHooksV7Version = "7.1.1";
|
|
31
33
|
export declare const tsLibVersion = "^2.3.0";
|
|
32
34
|
export declare const postcssVersion = "8.4.38";
|
|
33
35
|
export declare const autoprefixerVersion = "10.4.13";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.svgrWebpackVersion = exports.svgrRollupVersion = exports.rollupPluginUrlVersion = exports.sassVersion = exports.expressVersion = exports.autoprefixerVersion = exports.postcssVersion = exports.tsLibVersion = exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.reactReduxVersion = exports.reduxjsToolkitVersion = exports.testingLibraryDomVersion = exports.testingLibraryReactVersion = exports.reactRouterIsBotVersion = exports.reactRouterVersion = exports.reactRouterDomVersion = exports.babelCoreVersion = exports.babelPresetReactVersion = exports.typesNodeVersion = exports.reactViteVersion = exports.typesReactIsVersion = exports.typesReactIsV18Version = exports.typesReactDomVersion = exports.typesReactDomV18Version = exports.typesReactVersion = exports.typesReactV18Version = exports.swcLoaderVersion = exports.reactIsV18Version = exports.reactIsVersion = exports.reactDomV18Version = exports.reactDomVersion = exports.reactV18Version = exports.reactVersion = exports.minSupportedReactVersion = exports.nxVersion = void 0;
|
|
3
|
+
exports.svgrWebpackVersion = exports.svgrRollupVersion = exports.rollupPluginUrlVersion = exports.sassVersion = exports.expressVersion = exports.autoprefixerVersion = exports.postcssVersion = exports.tsLibVersion = exports.eslintPluginReactHooksV7Version = exports.eslintPluginImportXVersion = exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.reactReduxVersion = exports.reduxjsToolkitVersion = exports.testingLibraryDomVersion = exports.testingLibraryReactVersion = exports.reactRouterIsBotVersion = exports.reactRouterVersion = exports.reactRouterDomVersion = exports.babelCoreVersion = exports.babelPresetReactVersion = exports.typesNodeVersion = exports.reactViteVersion = exports.typesReactIsVersion = exports.typesReactIsV18Version = exports.typesReactDomVersion = exports.typesReactDomV18Version = exports.typesReactVersion = exports.typesReactV18Version = exports.swcLoaderVersion = exports.reactIsV18Version = exports.reactIsVersion = exports.reactDomV18Version = exports.reactDomVersion = exports.reactV18Version = exports.reactVersion = exports.minSupportedReactVersion = exports.nxVersion = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
exports.nxVersion = require((0, path_1.join)('@nx/react', 'package.json')).version;
|
|
6
6
|
exports.minSupportedReactVersion = '18.0.0';
|
|
@@ -31,10 +31,17 @@ exports.testingLibraryDomVersion = '10.4.0';
|
|
|
31
31
|
// react-redux 8.0.5 / RTK 1.9.3 peer-cap at react ^18, breaking `nx g redux` on React 19.
|
|
32
32
|
exports.reduxjsToolkitVersion = '^2.5.0';
|
|
33
33
|
exports.reactReduxVersion = '^9.2.0';
|
|
34
|
+
// ESLint <10 (eslintrc / flat) stack. eslint-plugin-react, -jsx-a11y and -import
|
|
35
|
+
// have no ESLint v10 release, and react-hooks v5 peer-caps at v9.
|
|
34
36
|
exports.eslintPluginImportVersion = '2.31.0';
|
|
35
37
|
exports.eslintPluginJsxA11yVersion = '6.10.1';
|
|
36
38
|
exports.eslintPluginReactVersion = '^7.35.0';
|
|
37
39
|
exports.eslintPluginReactHooksVersion = '5.0.0';
|
|
40
|
+
// ESLint v10 stack. The pinned plugins above have no release that supports v10
|
|
41
|
+
// (react-hooks gains it in 7.1), so v10 workspaces swap to eslint-plugin-import-x
|
|
42
|
+
// and react-hooks v7. Nx does not pick a replacement for react/jsx-a11y.
|
|
43
|
+
exports.eslintPluginImportXVersion = '^4.17.1';
|
|
44
|
+
exports.eslintPluginReactHooksV7Version = '7.1.1';
|
|
38
45
|
exports.tsLibVersion = '^2.3.0';
|
|
39
46
|
exports.postcssVersion = '8.4.38';
|
|
40
47
|
exports.autoprefixerVersion = '10.4.13';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "24.1.0-beta.
|
|
3
|
+
"version": "24.1.0-beta.2",
|
|
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": {
|
|
@@ -103,28 +103,28 @@
|
|
|
103
103
|
"dependencies": {
|
|
104
104
|
"@babel/preset-react": "^7.22.5",
|
|
105
105
|
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
106
|
-
"minimatch": "
|
|
106
|
+
"minimatch": "11.0.8",
|
|
107
107
|
"tslib": "^2.3.0",
|
|
108
|
-
"@nx/devkit": "24.1.0-beta.
|
|
109
|
-
"@nx/js": "24.1.0-beta.
|
|
110
|
-
"@nx/eslint": "24.1.0-beta.
|
|
111
|
-
"@nx/web": "24.1.0-beta.
|
|
108
|
+
"@nx/devkit": "24.1.0-beta.2",
|
|
109
|
+
"@nx/js": "24.1.0-beta.2",
|
|
110
|
+
"@nx/eslint": "24.1.0-beta.2",
|
|
111
|
+
"@nx/web": "24.1.0-beta.2",
|
|
112
112
|
"semver": "^7.6.3"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
|
-
"@nx/cypress": "24.1.0-beta.
|
|
116
|
-
"@nx/playwright": "24.1.0-beta.
|
|
117
|
-
"@nx/rollup": "24.1.0-beta.
|
|
118
|
-
"@nx/rsbuild": "24.1.0-beta.
|
|
119
|
-
"@nx/rspack": "24.1.0-beta.
|
|
120
|
-
"@nx/vite": "24.1.0-beta.
|
|
121
|
-
"@nx/vitest": "24.1.0-beta.
|
|
122
|
-
"@nx/webpack": "24.1.0-beta.
|
|
123
|
-
"@nx/storybook": "24.1.0-beta.
|
|
124
|
-
"nx": "24.1.0-beta.
|
|
115
|
+
"@nx/cypress": "24.1.0-beta.2",
|
|
116
|
+
"@nx/playwright": "24.1.0-beta.2",
|
|
117
|
+
"@nx/rollup": "24.1.0-beta.2",
|
|
118
|
+
"@nx/rsbuild": "24.1.0-beta.2",
|
|
119
|
+
"@nx/rspack": "24.1.0-beta.2",
|
|
120
|
+
"@nx/vite": "24.1.0-beta.2",
|
|
121
|
+
"@nx/vitest": "24.1.0-beta.2",
|
|
122
|
+
"@nx/webpack": "24.1.0-beta.2",
|
|
123
|
+
"@nx/storybook": "24.1.0-beta.2",
|
|
124
|
+
"nx": "24.1.0-beta.2"
|
|
125
125
|
},
|
|
126
126
|
"optionalDependencies": {
|
|
127
|
-
"@nx/vite": "24.1.0-beta.
|
|
127
|
+
"@nx/vite": "24.1.0-beta.2"
|
|
128
128
|
},
|
|
129
129
|
"publishConfig": {
|
|
130
130
|
"access": "public"
|