@nx/react 23.2.0-beta.1 → 23.2.0-beta.10
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/internal.d.ts +1 -0
- package/dist/internal.js +3 -1
- package/dist/module-federation.d.ts +1 -2
- package/dist/module-federation.js +2 -3
- package/dist/plugins/component-testing/webpack-fallback.js +5 -0
- package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +11 -7
- package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +10 -6
- package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts +2 -2
- package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.js +14 -9
- package/dist/src/generators/application/application.js +12 -25
- package/dist/src/generators/application/files/nx-welcome/claimed/src/app/nx-welcome.tsx__tmpl__ +2 -0
- package/dist/src/generators/application/files/nx-welcome/not-configured/src/app/nx-welcome.tsx__tmpl__ +2 -0
- package/dist/src/generators/application/files/nx-welcome/unclaimed/src/app/nx-welcome.tsx__tmpl__ +2 -0
- package/dist/src/generators/application/files/react-router-ssr/common/app/entry.server.tsx__tmpl__ +1 -1
- package/dist/src/generators/application/files/react-router-ssr/common/tests/routes/_index.spec.tsx__tmpl__ +2 -2
- package/dist/src/generators/application/files/react-router-ssr/nx-welcome/claimed/app/nx-welcome.tsx__tmpl__ +2 -0
- package/dist/src/generators/application/files/react-router-ssr/nx-welcome/not-configured/app/nx-welcome.tsx__tmpl__ +2 -0
- package/dist/src/generators/application/files/react-router-ssr/nx-welcome/unclaimed/app/nx-welcome.tsx__tmpl__ +2 -0
- package/dist/src/generators/application/lib/add-e2e.js +3 -1
- package/dist/src/generators/application/lib/add-linting.d.ts +0 -1
- package/dist/src/generators/application/lib/add-linting.js +21 -31
- package/dist/src/generators/application/lib/create-application-files.d.ts +3 -2
- package/dist/src/generators/application/lib/create-application-files.js +3 -3
- package/dist/src/generators/application/lib/find-free-port.d.ts +1 -1
- package/dist/src/generators/application/lib/normalize-options.js +15 -11
- package/dist/src/generators/application/schema.d.ts +9 -3
- package/dist/src/generators/application/schema.json +15 -6
- package/dist/src/generators/cypress-component-configuration/lib/add-files.js +3 -3
- package/dist/src/generators/federate-module/schema.d.ts +2 -2
- package/dist/src/generators/federate-module/schema.json +3 -4
- package/dist/src/generators/host/files/rspack-module-federation/module-federation.config.js__tmpl__ +1 -1
- package/dist/src/generators/host/host.js +13 -4
- package/dist/src/generators/host/lib/setup-ssr-for-host.js +7 -8
- package/dist/src/generators/host/schema.d.ts +8 -2
- package/dist/src/generators/host/schema.json +11 -6
- package/dist/src/generators/library/lib/add-linting.d.ts +1 -2
- package/dist/src/generators/library/lib/add-linting.js +28 -30
- package/dist/src/generators/library/lib/add-rollup-build-target.d.ts +1 -2
- package/dist/src/generators/library/lib/determine-entry-fields.d.ts +1 -1
- package/dist/src/generators/library/lib/normalize-options.js +28 -21
- package/dist/src/generators/library/lib/update-app-routes.js +1 -2
- package/dist/src/generators/library/schema.d.ts +8 -2
- package/dist/src/generators/library/schema.json +10 -6
- package/dist/src/generators/remote/lib/setup-ssr-for-remote.js +8 -9
- package/dist/src/generators/remote/lib/setup-tspath-for-remote.js +3 -2
- package/dist/src/generators/remote/remote.js +15 -6
- package/dist/src/generators/remote/schema.d.ts +6 -2
- package/dist/src/generators/remote/schema.json +11 -6
- package/dist/src/generators/storybook-configuration/schema.d.ts +2 -2
- package/dist/src/generators/storybook-configuration/schema.json +1 -2
- package/dist/src/migrations/update-23-2-0/add-optional-module-federation-packages.d.ts +2 -0
- package/dist/src/migrations/update-23-2-0/add-optional-module-federation-packages.js +61 -0
- package/dist/src/migrations/update-23-2-0/add-optional-module-federation-packages.md +37 -0
- package/dist/src/migrations/update-23-2-0/add-svgr-webpack-if-used.d.ts +2 -0
- package/dist/src/migrations/update-23-2-0/add-svgr-webpack-if-used.js +55 -0
- package/dist/src/migrations/update-23-2-0/add-svgr-webpack-if-used.md +28 -0
- package/dist/src/plugins/router-plugin.js +2 -4
- package/dist/src/utils/assert-package.d.ts +1 -0
- package/dist/src/utils/assert-package.js +17 -0
- package/dist/src/utils/ast-utils.js +2 -2
- package/dist/src/utils/create-ts-config.d.ts +1 -1
- package/dist/src/utils/create-ts-config.js +5 -5
- package/dist/src/utils/versions.d.ts +2 -0
- package/dist/src/utils/versions.js +3 -1
- package/migrations.json +12 -0
- package/package.json +32 -20
- /package/dist/src/generators/consumer/files/vite/{vite.config.ts__tmpl__ → vite.config.mts__tmpl__} +0 -0
- /package/dist/src/generators/provider/files/vite/{vite.config.ts__tmpl__ → vite.config.mts__tmpl__} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { names } from '@nx/devkit';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LinterType } from '@nx/js';
|
|
3
3
|
import type { SupportedStyles } from '../../../typings/style';
|
|
4
4
|
|
|
5
5
|
export interface Schema {
|
|
@@ -11,7 +11,7 @@ export interface Schema {
|
|
|
11
11
|
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
12
12
|
inSourceTests?: boolean;
|
|
13
13
|
e2eTestRunner: 'cypress' | 'playwright' | 'none';
|
|
14
|
-
linter
|
|
14
|
+
linter?: LinterType;
|
|
15
15
|
classComponent?: boolean;
|
|
16
16
|
routing?: boolean;
|
|
17
17
|
useReactRouter?: boolean;
|
|
@@ -19,6 +19,10 @@ export interface Schema {
|
|
|
19
19
|
js?: boolean;
|
|
20
20
|
globalCss?: boolean;
|
|
21
21
|
strict?: boolean;
|
|
22
|
+
enableTypedLinting?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
|
|
25
|
+
*/
|
|
22
26
|
setParserOptionsProject?: boolean;
|
|
23
27
|
compiler?: 'babel' | 'swc';
|
|
24
28
|
remotes?: string[];
|
|
@@ -31,12 +35,14 @@ export interface Schema {
|
|
|
31
35
|
addPlugin?: boolean;
|
|
32
36
|
nxCloudToken?: string;
|
|
33
37
|
useTsSolution?: boolean;
|
|
34
|
-
formatter?: 'prettier' | 'none';
|
|
38
|
+
formatter?: 'prettier' | 'oxfmt' | 'none';
|
|
35
39
|
useProjectJson?: boolean;
|
|
36
40
|
port?: number;
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
export interface NormalizedSchema<T extends Schema = Schema> extends T {
|
|
44
|
+
// `normalizeOptions` always resolves this, so it is no longer optional.
|
|
45
|
+
linter: LinterType;
|
|
40
46
|
projectName: string;
|
|
41
47
|
appProjectRoot: string;
|
|
42
48
|
e2eProjectName: string;
|
|
@@ -97,13 +97,16 @@
|
|
|
97
97
|
"x-priority": "important"
|
|
98
98
|
},
|
|
99
99
|
"linter": {
|
|
100
|
-
"description": "The tool to use for running lint checks.",
|
|
100
|
+
"description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
|
|
101
101
|
"type": "string",
|
|
102
|
-
"enum": ["eslint", "none"],
|
|
103
|
-
"default": "none",
|
|
104
|
-
"x-prompt": "Which linter would you like to use?",
|
|
102
|
+
"enum": ["eslint", "oxlint", "none"],
|
|
105
103
|
"x-priority": "important"
|
|
106
104
|
},
|
|
105
|
+
"formatter": {
|
|
106
|
+
"description": "The tool to use for code formatting.",
|
|
107
|
+
"type": "string",
|
|
108
|
+
"enum": ["none", "prettier", "oxfmt"]
|
|
109
|
+
},
|
|
107
110
|
"unitTestRunner": {
|
|
108
111
|
"type": "string",
|
|
109
112
|
"enum": ["vitest", "jest", "none"],
|
|
@@ -150,11 +153,17 @@
|
|
|
150
153
|
"description": "Creates an application with strict mode and strict type checking.",
|
|
151
154
|
"default": true
|
|
152
155
|
},
|
|
153
|
-
"
|
|
156
|
+
"enableTypedLinting": {
|
|
154
157
|
"type": "boolean",
|
|
155
|
-
"description": "Whether
|
|
158
|
+
"description": "Whether to enable typed linting. For flat configs, this configures the recommended `parserOptions.projectService` and `tsconfigRootDir`. For legacy `.eslintrc` configs, this configures `parserOptions.project`. We do not enable this by default for lint performance reasons.",
|
|
156
159
|
"default": false
|
|
157
160
|
},
|
|
161
|
+
"setParserOptionsProject": {
|
|
162
|
+
"type": "boolean",
|
|
163
|
+
"description": "Deprecated alias for `enableTypedLinting`.",
|
|
164
|
+
"default": false,
|
|
165
|
+
"x-deprecated": "Use `enableTypedLinting` instead. This option will be removed in Nx v24."
|
|
166
|
+
},
|
|
158
167
|
"compiler": {
|
|
159
168
|
"type": "string",
|
|
160
169
|
"description": "The compiler to use.",
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addFiles = addFiles;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const internal_1 = require("@nx/js/internal");
|
|
6
|
-
const versions_1 = require("nx/src/utils/versions");
|
|
7
6
|
const ct_utils_1 = require("../../../utils/ct-utils");
|
|
8
7
|
const component_test_1 = require("../../component-test/component-test");
|
|
8
|
+
const internal_2 = require("@nx/devkit/internal");
|
|
9
9
|
async function addFiles(tree, projectConfig, options, found) {
|
|
10
10
|
// must dynamicaly import to prevent packages not using cypress from erroring out
|
|
11
11
|
// when importing react
|
|
@@ -24,11 +24,11 @@ async function addFiles(tree, projectConfig, options, found) {
|
|
|
24
24
|
tree.write(commandFile, `import { mount } from '${moduleSpecifier}';\n${updatedCommandFile}`);
|
|
25
25
|
if (options.bundler === 'webpack' ||
|
|
26
26
|
(!options.bundler && actualBundler === 'webpack')) {
|
|
27
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/webpack':
|
|
27
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/webpack': internal_2.nxVersion }, undefined, true);
|
|
28
28
|
}
|
|
29
29
|
if (options.bundler === 'vite' ||
|
|
30
30
|
(!options.bundler && actualBundler === 'vite')) {
|
|
31
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/vite':
|
|
31
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/vite': internal_2.nxVersion }, undefined, true);
|
|
32
32
|
}
|
|
33
33
|
if (options.generateTests) {
|
|
34
34
|
const filePaths = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LinterType } from '@nx/js';
|
|
2
2
|
|
|
3
3
|
export interface Schema {
|
|
4
4
|
name: string;
|
|
@@ -7,7 +7,7 @@ export interface Schema {
|
|
|
7
7
|
remoteDirectory?: string;
|
|
8
8
|
e2eTestRunner?: 'cypress' | 'playwright' | 'none';
|
|
9
9
|
host?: string;
|
|
10
|
-
linter?:
|
|
10
|
+
linter?: LinterType;
|
|
11
11
|
skipFormat?: boolean;
|
|
12
12
|
style?: SupportedStyles;
|
|
13
13
|
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
@@ -50,10 +50,9 @@
|
|
|
50
50
|
"alias": "s"
|
|
51
51
|
},
|
|
52
52
|
"linter": {
|
|
53
|
-
"description": "The tool to use for running lint checks.",
|
|
53
|
+
"description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
|
|
54
54
|
"type": "string",
|
|
55
|
-
"enum": ["eslint"]
|
|
56
|
-
"default": "eslint"
|
|
55
|
+
"enum": ["eslint", "oxlint", "none"]
|
|
57
56
|
},
|
|
58
57
|
"skipFormat": {
|
|
59
58
|
"description": "Skip formatting files.",
|
|
@@ -63,7 +62,7 @@
|
|
|
63
62
|
},
|
|
64
63
|
"unitTestRunner": {
|
|
65
64
|
"type": "string",
|
|
66
|
-
"enum": ["jest", "none"],
|
|
65
|
+
"enum": ["jest", "vitest", "none"],
|
|
67
66
|
"description": "Test runner to use for unit tests.",
|
|
68
67
|
"default": "jest"
|
|
69
68
|
},
|
|
@@ -4,6 +4,7 @@ exports.hostGenerator = hostGenerator;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const internal_1 = require("@nx/devkit/internal");
|
|
6
6
|
const assert_supported_react_version_1 = require("../../utils/assert-supported-react-version");
|
|
7
|
+
const internal_2 = require("@nx/eslint/internal");
|
|
7
8
|
const devkit_1 = require("@nx/devkit");
|
|
8
9
|
const update_module_federation_project_1 = require("../../rules/update-module-federation-project");
|
|
9
10
|
const application_1 = tslib_1.__importDefault(require("../application/application"));
|
|
@@ -16,7 +17,7 @@ const setup_ssr_for_host_1 = require("./lib/setup-ssr-for-host");
|
|
|
16
17
|
const update_module_federation_e2e_project_1 = require("./lib/update-module-federation-e2e-project");
|
|
17
18
|
const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
|
18
19
|
const js_1 = require("@nx/js");
|
|
19
|
-
const
|
|
20
|
+
const internal_3 = require("@nx/js/internal");
|
|
20
21
|
const versions_1 = require("../../utils/versions");
|
|
21
22
|
const update_module_federation_tsconfig_1 = require("./lib/update-module-federation-tsconfig");
|
|
22
23
|
const normalize_host_name_1 = require("./lib/normalize-host-name");
|
|
@@ -61,7 +62,7 @@ async function hostGenerator(host, schema) {
|
|
|
61
62
|
});
|
|
62
63
|
tasks.push(initTask);
|
|
63
64
|
// In TS solution setup, update package.json to use simple name instead of scoped name
|
|
64
|
-
if ((0,
|
|
65
|
+
if ((0, internal_3.isUsingTsSolutionSetup)(host)) {
|
|
65
66
|
const hostPackageJsonPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json');
|
|
66
67
|
if (host.exists(hostPackageJsonPath)) {
|
|
67
68
|
(0, devkit_1.updateJson)(host, hostPackageJsonPath, (json) => {
|
|
@@ -102,7 +103,7 @@ async function hostGenerator(host, schema) {
|
|
|
102
103
|
(0, update_module_federation_e2e_project_1.updateModuleFederationE2eProject)(host, options);
|
|
103
104
|
(0, update_module_federation_tsconfig_1.updateModuleFederationTsconfig)(host, options);
|
|
104
105
|
// Add remotes as devDependencies in TS solution setup
|
|
105
|
-
if ((0,
|
|
106
|
+
if ((0, internal_3.isUsingTsSolutionSetup)(host) && remotesWithPorts.length > 0) {
|
|
106
107
|
addRemotesAsHostDependencies(host, options.projectName, remotesWithPorts);
|
|
107
108
|
}
|
|
108
109
|
if (options.ssr) {
|
|
@@ -122,13 +123,21 @@ async function hostGenerator(host, schema) {
|
|
|
122
123
|
}
|
|
123
124
|
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
|
|
124
125
|
}
|
|
125
|
-
if (!
|
|
126
|
+
if (!(0, internal_2.isTypedLintingEnabled)(options)) {
|
|
126
127
|
host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.lint.json'));
|
|
127
128
|
}
|
|
128
129
|
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host, options.bundler);
|
|
129
130
|
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, { '@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion }, {
|
|
130
131
|
'@nx/web': versions_1.nxVersion,
|
|
131
132
|
'@nx/module-federation': versions_1.nxVersion,
|
|
133
|
+
// The webpack path also generates a `serve-static` target running the
|
|
134
|
+
// `module-federation-static-server` executor, which proxies via express.
|
|
135
|
+
...(options.bundler !== 'rspack'
|
|
136
|
+
? {
|
|
137
|
+
express: versions_1.expressVersion,
|
|
138
|
+
'http-proxy-middleware': versions_1.httpProxyMiddlewareVersion,
|
|
139
|
+
}
|
|
140
|
+
: {}),
|
|
132
141
|
}, undefined, true);
|
|
133
142
|
tasks.push(installTask);
|
|
134
143
|
if (!options.skipFormat) {
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setupSsrForHost = setupSsrForHost;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const devkit_2 = require("@nx/devkit");
|
|
6
5
|
const versions_1 = require("../../../utils/versions");
|
|
7
6
|
const create_application_files_1 = require("../../application/lib/create-application-files");
|
|
8
7
|
async function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
|
|
9
8
|
const tasks = [];
|
|
10
|
-
let project = (0,
|
|
9
|
+
let project = (0, devkit_1.readProjectConfiguration)(tree, appName);
|
|
11
10
|
if (options.bundler !== 'rspack') {
|
|
12
11
|
project.targets.serve.executor =
|
|
13
12
|
'@nx/react:module-federation-ssr-dev-server';
|
|
14
|
-
(0,
|
|
13
|
+
(0, devkit_1.updateProjectConfiguration)(tree, appName, project);
|
|
15
14
|
}
|
|
16
15
|
const pathToModuleFederationSsrFiles = options.typescriptConfiguration
|
|
17
16
|
? `${options.bundler === 'rspack' ? 'rspack-' : 'webpack-'}module-federation-ssr-ts`
|
|
@@ -28,7 +27,7 @@ async function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
|
|
|
28
27
|
static: !options?.dynamic,
|
|
29
28
|
remotes: defaultRemoteManifest.map(({ name, port }) => {
|
|
30
29
|
return {
|
|
31
|
-
...(0,
|
|
30
|
+
...(0, devkit_1.names)(name),
|
|
32
31
|
port,
|
|
33
32
|
};
|
|
34
33
|
}),
|
|
@@ -42,13 +41,13 @@ async function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
|
|
|
42
41
|
browserBuildOutputPath: project.targets.build?.options?.outputPath,
|
|
43
42
|
remotes: defaultRemoteManifest.map(({ name, port }) => {
|
|
44
43
|
return {
|
|
45
|
-
...(0,
|
|
44
|
+
...(0, devkit_1.names)(name),
|
|
46
45
|
port,
|
|
47
46
|
};
|
|
48
47
|
}),
|
|
49
48
|
};
|
|
50
|
-
(0,
|
|
51
|
-
const installTask = (0,
|
|
49
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, `../files/${pathToModuleFederationSsrFiles}`), project.root, templateVariables);
|
|
50
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
52
51
|
'@module-federation/node': versions_1.moduleFederationNodeVersion,
|
|
53
52
|
cors: versions_1.corsVersion,
|
|
54
53
|
isbot: versions_1.isbotVersion,
|
|
@@ -56,5 +55,5 @@ async function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
|
|
|
56
55
|
'@types/express': versions_1.typesExpressVersion,
|
|
57
56
|
}, {}, undefined, true);
|
|
58
57
|
tasks.push(installTask);
|
|
59
|
-
return (0,
|
|
58
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
60
59
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LinterType } from '@nx/js';
|
|
2
2
|
import type { SupportedStyles } from '../../../typings/style';
|
|
3
3
|
|
|
4
4
|
export interface Schema {
|
|
@@ -9,9 +9,13 @@ export interface Schema {
|
|
|
9
9
|
e2eTestRunner: 'cypress' | 'playwright' | 'none';
|
|
10
10
|
globalCss?: boolean;
|
|
11
11
|
js?: boolean;
|
|
12
|
-
linter
|
|
12
|
+
linter?: LinterType;
|
|
13
13
|
name?: string;
|
|
14
14
|
remotes?: string[];
|
|
15
|
+
enableTypedLinting?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
|
|
18
|
+
*/
|
|
15
19
|
setParserOptionsProject?: boolean;
|
|
16
20
|
skipFormat?: boolean;
|
|
17
21
|
skipNxJson?: boolean;
|
|
@@ -29,6 +33,8 @@ export interface Schema {
|
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
export interface NormalizedSchema extends Schema {
|
|
36
|
+
// `normalizeOptions` always resolves this, so it is no longer optional.
|
|
37
|
+
linter: LinterType;
|
|
32
38
|
appProjectRoot: string;
|
|
33
39
|
e2eProjectName: string;
|
|
34
40
|
projectName: string;
|
|
@@ -48,10 +48,9 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"linter": {
|
|
51
|
-
"description": "The tool to use for running lint checks.",
|
|
51
|
+
"description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
|
|
52
52
|
"type": "string",
|
|
53
|
-
"enum": ["eslint"]
|
|
54
|
-
"default": "eslint"
|
|
53
|
+
"enum": ["eslint", "oxlint", "none"]
|
|
55
54
|
},
|
|
56
55
|
"dynamic": {
|
|
57
56
|
"type": "boolean",
|
|
@@ -72,7 +71,7 @@
|
|
|
72
71
|
},
|
|
73
72
|
"unitTestRunner": {
|
|
74
73
|
"type": "string",
|
|
75
|
-
"enum": ["jest", "none"],
|
|
74
|
+
"enum": ["jest", "vitest", "none"],
|
|
76
75
|
"description": "Test runner to use for unit tests.",
|
|
77
76
|
"default": "jest"
|
|
78
77
|
},
|
|
@@ -109,11 +108,17 @@
|
|
|
109
108
|
"description": "Creates an application with strict mode and strict type checking",
|
|
110
109
|
"default": true
|
|
111
110
|
},
|
|
112
|
-
"
|
|
111
|
+
"enableTypedLinting": {
|
|
113
112
|
"type": "boolean",
|
|
114
|
-
"description": "Whether
|
|
113
|
+
"description": "Whether to enable typed linting. For flat configs, this configures the recommended `parserOptions.projectService` and `tsconfigRootDir`. For legacy `.eslintrc` configs, this configures `parserOptions.project`. We do not enable this by default for lint performance reasons.",
|
|
115
114
|
"default": false
|
|
116
115
|
},
|
|
116
|
+
"setParserOptionsProject": {
|
|
117
|
+
"type": "boolean",
|
|
118
|
+
"description": "Deprecated alias for `enableTypedLinting`.",
|
|
119
|
+
"default": false,
|
|
120
|
+
"x-deprecated": "Use `enableTypedLinting` instead. This option will be removed in Nx v24."
|
|
121
|
+
},
|
|
117
122
|
"compiler": {
|
|
118
123
|
"type": "string",
|
|
119
124
|
"description": "The compiler to use",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Tree } from 'nx/
|
|
2
|
-
import { GeneratorCallback } from '@nx/devkit';
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
3
2
|
import { NormalizedSchema } from '../schema';
|
|
4
3
|
export declare function addLinting(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
|
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addLinting = addLinting;
|
|
4
|
-
const eslint_1 = require("@nx/eslint");
|
|
5
|
-
const path_1 = require("nx/src/utils/path");
|
|
6
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const internal_1 = require("@nx/js/internal");
|
|
7
6
|
const lint_1 = require("../../../utils/lint");
|
|
8
|
-
const
|
|
7
|
+
const internal_2 = require("@nx/eslint/internal");
|
|
9
8
|
async function addLinting(host, options) {
|
|
9
|
+
if (options.linter === 'none') {
|
|
10
|
+
return () => { };
|
|
11
|
+
}
|
|
12
|
+
const tasks = [];
|
|
13
|
+
tasks.push(await (0, internal_1.addLintingToProject)(host, {
|
|
14
|
+
oxlintPlugins: ['react', 'react-perf', 'jsx-a11y'],
|
|
15
|
+
linter: options.linter,
|
|
16
|
+
project: options.name,
|
|
17
|
+
tsConfigPaths: [
|
|
18
|
+
(0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json'),
|
|
19
|
+
],
|
|
20
|
+
unitTestRunner: options.unitTestRunner,
|
|
21
|
+
skipPackageJson: options.skipPackageJson,
|
|
22
|
+
enableTypedLinting: (0, internal_2.isTypedLintingEnabled)(options),
|
|
23
|
+
addPlugin: options.addPlugin,
|
|
24
|
+
}));
|
|
25
|
+
// Predefined configs, `extends` and ignore entries are ESLint concepts with
|
|
26
|
+
// no equivalent in other linters.
|
|
10
27
|
if (options.linter === 'eslint') {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
project: options.name,
|
|
15
|
-
tsConfigPaths: [
|
|
16
|
-
(0, path_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json'),
|
|
17
|
-
],
|
|
18
|
-
unitTestRunner: options.unitTestRunner,
|
|
19
|
-
skipFormat: true,
|
|
20
|
-
skipPackageJson: options.skipPackageJson,
|
|
21
|
-
setParserOptionsProject: options.setParserOptionsProject,
|
|
22
|
-
addPlugin: options.addPlugin,
|
|
23
|
-
});
|
|
24
|
-
tasks.push(lintTask);
|
|
25
|
-
if ((0, internal_1.isEslintConfigSupported)(host)) {
|
|
26
|
-
if ((0, internal_1.useFlatConfig)(host)) {
|
|
27
|
-
(0, internal_1.addPredefinedConfigToFlatLintConfig)(host, options.projectRoot, 'flat/react', { checkBaseConfig: true });
|
|
28
|
+
if ((0, internal_2.isEslintConfigSupported)(host)) {
|
|
29
|
+
if ((0, internal_2.useFlatConfig)(host)) {
|
|
30
|
+
(0, internal_2.addPredefinedConfigToFlatLintConfig)(host, options.projectRoot, 'flat/react', { checkBaseConfig: true });
|
|
28
31
|
// Add an empty rules object to users know how to add/override rules
|
|
29
|
-
(0,
|
|
32
|
+
(0, internal_2.addOverrideToLintConfig)(host, options.projectRoot, {
|
|
30
33
|
files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
|
|
31
34
|
rules: {},
|
|
32
35
|
});
|
|
33
36
|
}
|
|
34
37
|
else {
|
|
35
|
-
const addExtendsTask = (0,
|
|
38
|
+
const addExtendsTask = (0, internal_2.addExtendsToLintConfig)(host, options.projectRoot, {
|
|
36
39
|
name: 'plugin:@nx/react',
|
|
37
40
|
needCompatFixup: true,
|
|
38
41
|
});
|
|
@@ -40,17 +43,12 @@ async function addLinting(host, options) {
|
|
|
40
43
|
}
|
|
41
44
|
// Add out-tsc ignore pattern when using TS solution setup
|
|
42
45
|
if (options.isUsingTsSolutionConfig) {
|
|
43
|
-
(0,
|
|
46
|
+
(0, internal_2.addIgnoresToLintConfig)(host, options.projectRoot, ['**/out-tsc']);
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
|
-
let installTask = () => { };
|
|
47
49
|
if (!options.skipPackageJson) {
|
|
48
|
-
|
|
49
|
-
tasks.push(installTask);
|
|
50
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies, undefined, true));
|
|
50
51
|
}
|
|
51
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return () => { };
|
|
55
52
|
}
|
|
53
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
56
54
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Tree } from 'nx/
|
|
2
|
-
import { GeneratorCallback } from '@nx/devkit';
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
3
2
|
import { NormalizedSchema } from '../schema';
|
|
4
3
|
export declare function addRollupBuildTarget(host: Tree, options: NormalizedSchema & {
|
|
5
4
|
format?: Array<'esm' | 'cjs'>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { PackageJson } from 'nx/src/utils/package-json';
|
|
2
1
|
import type { NormalizedSchema } from '../schema';
|
|
2
|
+
import { type PackageJson } from '@nx/devkit/internal';
|
|
3
3
|
export declare function determineEntryFields(options: NormalizedSchema): Pick<PackageJson, 'main' | 'types' | 'exports'>;
|
|
@@ -33,39 +33,46 @@ async function normalizeOptions(host, options) {
|
|
|
33
33
|
bundler = 'rollup';
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
compiler: options.compiler ?? 'babel',
|
|
39
|
-
bundler,
|
|
40
|
-
fileName,
|
|
41
|
-
routePath: `/${projectNames.projectSimpleName}`,
|
|
42
|
-
name: isUsingTsSolutionConfig && !options.name ? importPath : projectName,
|
|
43
|
-
projectRoot,
|
|
44
|
-
parsedTags,
|
|
45
|
-
importPath,
|
|
46
|
-
useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
|
|
47
|
-
};
|
|
48
|
-
// Libraries with a bundler or is publishable must also be buildable.
|
|
49
|
-
normalized.buildable = Boolean(normalized.bundler !== 'none' || options.buildable || options.publishable);
|
|
50
|
-
normalized.inSourceTests === normalized.minimal || normalized.inSourceTests;
|
|
36
|
+
let appMain;
|
|
37
|
+
let appSourceRoot;
|
|
51
38
|
if (options.appProject) {
|
|
52
39
|
const appProjectConfig = (0, devkit_1.getProjects)(host).get(options.appProject);
|
|
53
40
|
const appProjectType = (0, internal_2.getProjectType)(host, appProjectConfig.root, appProjectConfig.projectType);
|
|
54
41
|
if (appProjectType !== 'application') {
|
|
55
42
|
throw new Error(`appProject expected type of "application" but got "${appProjectType}"`);
|
|
56
43
|
}
|
|
57
|
-
|
|
58
|
-
normalized.appMain =
|
|
44
|
+
appMain =
|
|
59
45
|
appProjectConfig.targets.build?.options?.main ??
|
|
60
46
|
findMainEntry(host, appProjectConfig.root);
|
|
61
|
-
|
|
47
|
+
appSourceRoot = (0, devkit_1.normalizePath)((0, internal_2.getProjectSourceRoot)(appProjectConfig, host));
|
|
62
48
|
// TODO(jack): We should use appEntryFile instead of appProject so users can directly set it rather than us inferring it.
|
|
63
|
-
if (!
|
|
49
|
+
if (!appMain) {
|
|
64
50
|
throw new Error(`Could not locate project main for ${options.appProject}`);
|
|
65
51
|
}
|
|
66
52
|
}
|
|
67
|
-
(0, assertion_1.assertValidStyle)(
|
|
68
|
-
normalized
|
|
53
|
+
(0, assertion_1.assertValidStyle)(options.style);
|
|
54
|
+
const normalized = {
|
|
55
|
+
...options,
|
|
56
|
+
compiler: options.compiler ?? 'babel',
|
|
57
|
+
bundler,
|
|
58
|
+
fileName,
|
|
59
|
+
routePath: `/${projectNames.projectSimpleName}`,
|
|
60
|
+
name: isUsingTsSolutionConfig && !options.name ? importPath : projectName,
|
|
61
|
+
projectRoot,
|
|
62
|
+
parsedTags,
|
|
63
|
+
importPath,
|
|
64
|
+
useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
|
|
65
|
+
isUsingTsSolutionConfig,
|
|
66
|
+
js: options.js ?? false,
|
|
67
|
+
unitTestRunner: options.unitTestRunner ?? 'none',
|
|
68
|
+
// Libraries with a bundler or that are publishable must also be buildable.
|
|
69
|
+
buildable: Boolean(bundler !== 'none' || options.buildable || options.publishable),
|
|
70
|
+
appMain,
|
|
71
|
+
appSourceRoot,
|
|
72
|
+
// The React-specific ESLint shaping is guarded on `=== 'eslint'`, so an
|
|
73
|
+
// unresolved `undefined` would create a bare config with none of it.
|
|
74
|
+
linter: await (0, internal_2.normalizeLinterOption)(host, options.linter),
|
|
75
|
+
};
|
|
69
76
|
return normalized;
|
|
70
77
|
}
|
|
71
78
|
function findMainEntry(tree, projectRoot) {
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateAppRoutes = updateAppRoutes;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const ast_utils_1 = require("../../../utils/ast-utils");
|
|
6
|
-
const ast_utils_2 = require("../../../utils/ast-utils");
|
|
7
6
|
const maybe_js_1 = require("../../../utils/maybe-js");
|
|
8
7
|
const versions_1 = require("../../../utils/versions");
|
|
9
8
|
const internal_1 = require("@nx/js/internal");
|
|
@@ -32,7 +31,7 @@ function updateAppRoutes(host, options) {
|
|
|
32
31
|
const { content: componentContent, source: componentSource } = readComponent(host, appComponentPath);
|
|
33
32
|
const isComponentRouterPresent = componentContent.match(/react-router-dom/);
|
|
34
33
|
if (!isComponentRouterPresent) {
|
|
35
|
-
const changes = (0, devkit_1.applyChangesToString)(componentContent, (0,
|
|
34
|
+
const changes = (0, devkit_1.applyChangesToString)(componentContent, (0, ast_utils_1.addInitialRoutes)(appComponentPath, componentSource));
|
|
36
35
|
host.write(appComponentPath, changes);
|
|
37
36
|
}
|
|
38
37
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LinterType } from '@nx/js';
|
|
2
2
|
import type { SupportedStyles } from '../../../typings/style';
|
|
3
3
|
|
|
4
4
|
export interface Schema {
|
|
@@ -12,10 +12,14 @@ export interface Schema {
|
|
|
12
12
|
importPath?: string;
|
|
13
13
|
inSourceTests?: boolean;
|
|
14
14
|
js?: boolean;
|
|
15
|
-
linter
|
|
15
|
+
linter?: LinterType;
|
|
16
16
|
name?: string;
|
|
17
17
|
publishable?: boolean;
|
|
18
18
|
routing?: boolean;
|
|
19
|
+
enableTypedLinting?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
|
|
22
|
+
*/
|
|
19
23
|
setParserOptionsProject?: boolean;
|
|
20
24
|
skipFormat?: boolean;
|
|
21
25
|
skipPackageJson?: boolean;
|
|
@@ -30,6 +34,8 @@ export interface Schema {
|
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
export interface NormalizedSchema extends Schema {
|
|
37
|
+
// `normalizeOptions` always resolves this, so it is no longer optional.
|
|
38
|
+
linter: LinterType;
|
|
33
39
|
js: boolean;
|
|
34
40
|
name: string;
|
|
35
41
|
fileName: string;
|
|
@@ -65,11 +65,9 @@
|
|
|
65
65
|
"x-priority": "important"
|
|
66
66
|
},
|
|
67
67
|
"linter": {
|
|
68
|
-
"description": "The tool to use for running lint checks.",
|
|
68
|
+
"description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
|
|
69
69
|
"type": "string",
|
|
70
|
-
"enum": ["eslint", "none"],
|
|
71
|
-
"default": "none",
|
|
72
|
-
"x-prompt": "Which linter would you like to use?",
|
|
70
|
+
"enum": ["eslint", "oxlint", "none"],
|
|
73
71
|
"x-priority": "important"
|
|
74
72
|
},
|
|
75
73
|
"unitTestRunner": {
|
|
@@ -145,11 +143,17 @@
|
|
|
145
143
|
"description": "Whether to enable tsconfig strict mode or not.",
|
|
146
144
|
"default": true
|
|
147
145
|
},
|
|
148
|
-
"
|
|
146
|
+
"enableTypedLinting": {
|
|
149
147
|
"type": "boolean",
|
|
150
|
-
"description": "Whether
|
|
148
|
+
"description": "Whether to enable typed linting. For flat configs, this configures the recommended `parserOptions.projectService` and `tsconfigRootDir`. For legacy `.eslintrc` configs, this configures `parserOptions.project`. We do not enable this by default for lint performance reasons.",
|
|
151
149
|
"default": false
|
|
152
150
|
},
|
|
151
|
+
"setParserOptionsProject": {
|
|
152
|
+
"type": "boolean",
|
|
153
|
+
"description": "Deprecated alias for `enableTypedLinting`.",
|
|
154
|
+
"default": false,
|
|
155
|
+
"x-deprecated": "Use `enableTypedLinting` instead. This option will be removed in Nx v24."
|
|
156
|
+
},
|
|
153
157
|
"compiler": {
|
|
154
158
|
"type": "string",
|
|
155
159
|
"enum": ["babel", "swc"],
|