@nx/react 0.0.0-pr-29122-4727ac1 → 0.0.0-pr-29156-41ae81c
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 +6 -25
- package/src/generators/application/files/base-rspack/tsconfig.app.json__tmpl__ +4 -21
- package/src/generators/application/files/base-vite/tsconfig.app.json__tmpl__ +2 -19
- package/src/generators/application/files/base-webpack/tsconfig.app.json__tmpl__ +3 -20
- 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 +15 -45
- package/src/generators/application/lib/add-jest.js +0 -1
- package/src/generators/application/lib/add-project-root-to-rspack-plugin-excludes.d.ts +2 -0
- package/src/generators/application/lib/add-project-root-to-rspack-plugin-excludes.js +31 -0
- package/src/generators/application/lib/add-project.js +3 -19
- package/src/generators/application/lib/create-application-files.js +0 -2
- package/src/generators/application/lib/normalize-options.js +0 -2
- package/src/generators/application/lib/update-jest-config.js +0 -5
- package/src/generators/application/schema.d.ts +0 -5
- package/src/generators/application/schema.json +15 -19
- package/src/generators/component/component.js +1 -3
- package/src/generators/component/lib/normalize-options.js +1 -2
- package/src/generators/component/schema.d.ts +1 -1
- package/src/generators/component/schema.json +5 -3
- package/src/generators/hook/hook.js +25 -10
- package/src/generators/hook/schema.d.ts +2 -0
- package/src/generators/hook/schema.json +18 -10
- 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/rspack.server.config.js__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/rspack.config.prod.ts__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +1 -1
- package/src/generators/host/host.js +2 -3
- package/src/generators/init/init.js +2 -0
- package/src/generators/library/files/common/package.json__tmpl__ +4 -0
- package/src/generators/library/files/vite/package.json__tmpl__ +12 -0
- package/src/generators/library/lib/create-files.d.ts +1 -1
- package/src/generators/library/lib/create-files.js +2 -22
- package/src/generators/library/lib/normalize-options.js +0 -3
- package/src/generators/library/library.js +16 -46
- package/src/generators/library/schema.d.ts +0 -1
- package/src/generators/library/schema.json +11 -14
- package/src/generators/redux/schema.json +4 -13
- 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/rspack.server.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +1 -1
- package/src/generators/remote/remote.js +2 -1
- package/src/migrations/update-20-2-0/migrate-mf-imports-to-new-package.js +0 -3
- package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.js +2 -2
- package/src/rules/update-module-federation-project.js +0 -6
- package/src/utils/build-static.remotes.d.ts +1 -1
- package/src/utils/create-ts-config.js +7 -57
- package/src/utils/versions.d.ts +1 -0
- package/src/utils/versions.js +3 -1
- package/src/generators/host/lib/update-module-federation-tsconfig.d.ts +0 -3
- package/src/generators/host/lib/update-module-federation-tsconfig.js +0 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-29156-41ae81c",
|
|
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": "0.0.0-pr-
|
|
42
|
-
"@nx/js": "0.0.0-pr-
|
|
43
|
-
"@nx/eslint": "0.0.0-pr-
|
|
44
|
-
"@nx/web": "0.0.0-pr-
|
|
45
|
-
"@nx/module-federation": "0.0.0-pr-
|
|
41
|
+
"@nx/devkit": "0.0.0-pr-29156-41ae81c",
|
|
42
|
+
"@nx/js": "0.0.0-pr-29156-41ae81c",
|
|
43
|
+
"@nx/eslint": "0.0.0-pr-29156-41ae81c",
|
|
44
|
+
"@nx/web": "0.0.0-pr-29156-41ae81c",
|
|
45
|
+
"@nx/module-federation": "0.0.0-pr-29156-41ae81c",
|
|
46
46
|
"express": "^4.19.2",
|
|
47
47
|
"http-proxy-middleware": "^3.0.3"
|
|
48
48
|
},
|
|
@@ -15,7 +15,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
15
15
|
const init_1 = require("../init/init");
|
|
16
16
|
const eslint_1 = require("@nx/eslint");
|
|
17
17
|
const versions_1 = require("../../utils/versions");
|
|
18
|
-
const maybe_js_1 = require("../../utils/maybe-js");
|
|
19
18
|
const install_common_dependencies_1 = require("./lib/install-common-dependencies");
|
|
20
19
|
const create_ts_config_1 = require("../../utils/create-ts-config");
|
|
21
20
|
const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
|
|
@@ -28,6 +27,7 @@ const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-projec
|
|
|
28
27
|
const setup_tailwind_1 = require("../setup-tailwind/setup-tailwind");
|
|
29
28
|
const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
|
|
30
29
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
30
|
+
const add_project_root_to_rspack_plugin_excludes_1 = require("./lib/add-project-root-to-rspack-plugin-excludes");
|
|
31
31
|
async function addLinting(host, options) {
|
|
32
32
|
const tasks = [];
|
|
33
33
|
if (options.linter === eslint_1.Linter.EsLint) {
|
|
@@ -73,17 +73,16 @@ async function applicationGenerator(host, schema) {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
async function applicationGeneratorInternal(host, schema) {
|
|
76
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'application');
|
|
76
77
|
const tasks = [];
|
|
78
|
+
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
79
|
+
(0, show_possible_warnings_1.showPossibleWarnings)(host, options);
|
|
77
80
|
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
78
81
|
...schema,
|
|
79
82
|
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
80
83
|
skipFormat: true,
|
|
81
|
-
addTsPlugin: schema.useTsSolution,
|
|
82
|
-
formatter: schema.formatter,
|
|
83
84
|
});
|
|
84
85
|
tasks.push(jsInitTask);
|
|
85
|
-
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
86
|
-
(0, show_possible_warnings_1.showPossibleWarnings)(host, options);
|
|
87
86
|
const initTask = await (0, init_1.default)(host, {
|
|
88
87
|
...options,
|
|
89
88
|
skipFormat: true,
|
|
@@ -117,7 +116,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
else if (options.bundler === 'rspack') {
|
|
120
|
-
const { rspackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.
|
|
119
|
+
const { rspackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxRspackVersion);
|
|
121
120
|
const rspackInitTask = await rspackInitGenerator(host, {
|
|
122
121
|
...options,
|
|
123
122
|
addPlugin: false,
|
|
@@ -152,7 +151,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
152
151
|
compiler: options.compiler,
|
|
153
152
|
skipFormat: true,
|
|
154
153
|
addPlugin: options.addPlugin,
|
|
155
|
-
projectType: 'application',
|
|
156
154
|
});
|
|
157
155
|
tasks.push(viteTask);
|
|
158
156
|
createOrEditViteConfig(host, {
|
|
@@ -174,19 +172,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
174
172
|
}, false);
|
|
175
173
|
}
|
|
176
174
|
else if (options.bundler === 'rspack') {
|
|
177
|
-
|
|
178
|
-
const rspackTask = await configurationGenerator(host, {
|
|
179
|
-
project: options.projectName,
|
|
180
|
-
main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)({
|
|
181
|
-
js: options.js,
|
|
182
|
-
useJsx: true,
|
|
183
|
-
}, `src/main.tsx`)),
|
|
184
|
-
tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
185
|
-
target: 'web',
|
|
186
|
-
newProject: true,
|
|
187
|
-
framework: 'react',
|
|
188
|
-
});
|
|
189
|
-
tasks.push(rspackTask);
|
|
175
|
+
(0, add_project_root_to_rspack_plugin_excludes_1.addProjectRootToRspackPluginExcludesIfExists)(host, options.appProjectRoot);
|
|
190
176
|
}
|
|
191
177
|
if (options.bundler !== 'vite' && options.unitTestRunner === 'vitest') {
|
|
192
178
|
const { createOrEditViteConfig, vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
@@ -260,11 +246,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
260
246
|
});
|
|
261
247
|
`);
|
|
262
248
|
}
|
|
263
|
-
(0, ts_solution_setup_1.updateTsconfigFiles)(host, options.appProjectRoot, 'tsconfig.app.json', {
|
|
264
|
-
jsx: 'react-jsx',
|
|
265
|
-
module: 'esnext',
|
|
266
|
-
moduleResolution: 'bundler',
|
|
267
|
-
});
|
|
268
249
|
if (!options.skipFormat) {
|
|
269
250
|
await (0, devkit_1.formatFiles)(host);
|
|
270
251
|
}
|
|
@@ -1,31 +1,14 @@
|
|
|
1
|
-
|
|
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 { %>{
|
|
1
|
+
{
|
|
18
2
|
"extends": "./tsconfig.json",
|
|
19
3
|
"compilerOptions": {
|
|
20
4
|
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
|
21
5
|
"types": [
|
|
22
6
|
"node",
|
|
23
|
-
<%_ if (style === 'styled-jsx') {
|
|
7
|
+
<%_ if (style === 'styled-jsx') { %>"@nx/react/typings/styled-jsx.d.ts",<% } _%>
|
|
24
8
|
"@nx/react/typings/cssmodule.d.ts",
|
|
25
9
|
"@nx/react/typings/image.d.ts"
|
|
26
|
-
|
|
10
|
+
]
|
|
27
11
|
},
|
|
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"],
|
|
12
|
+
"exclude": ["jest.config.ts","src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
|
|
29
13
|
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
|
30
14
|
}
|
|
31
|
-
<% } %>
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
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 { %>{
|
|
1
|
+
{
|
|
18
2
|
"extends": "./tsconfig.json",
|
|
19
3
|
"compilerOptions": {
|
|
20
4
|
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
|
@@ -23,9 +7,8 @@
|
|
|
23
7
|
<%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
|
|
24
8
|
"@nx/react/typings/cssmodule.d.ts",
|
|
25
9
|
"@nx/react/typings/image.d.ts"
|
|
26
|
-
|
|
10
|
+
]
|
|
27
11
|
},
|
|
28
12
|
"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"],
|
|
29
13
|
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
|
30
14
|
}
|
|
31
|
-
<% } %>
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
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 { %>{
|
|
1
|
+
{
|
|
18
2
|
"extends": "./tsconfig.json",
|
|
19
3
|
"compilerOptions": {
|
|
20
4
|
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
|
@@ -23,9 +7,8 @@
|
|
|
23
7
|
<%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
|
|
24
8
|
"@nx/react/typings/cssmodule.d.ts",
|
|
25
9
|
"@nx/react/typings/image.d.ts"
|
|
26
|
-
|
|
10
|
+
]
|
|
27
11
|
},
|
|
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"],
|
|
12
|
+
"exclude": ["jest.config.ts","src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
|
|
29
13
|
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
|
30
14
|
}
|
|
31
|
-
<% } %>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<% if (classComponent) { %>
|
|
2
2
|
import { Component } from 'react';
|
|
3
3
|
<%_ } _%>
|
|
4
|
-
//
|
|
5
|
-
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import styles from './<%= fileName %>.module.<%= style %>';
|
|
6
6
|
<%_ if (!minimal) { _%>
|
|
7
7
|
import NxWelcome from "./nx-welcome";
|
|
8
8
|
<%_ } _%>
|
|
@@ -6,12 +6,10 @@ 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");
|
|
10
9
|
const find_plugin_for_config_file_1 = require("@nx/devkit/src/utils/find-plugin-for-config-file");
|
|
11
10
|
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
12
11
|
async function addE2e(tree, options) {
|
|
13
12
|
const hasNxBuildPlugin = (options.bundler === 'webpack' && (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)) ||
|
|
14
|
-
(options.bundler === 'rspack' && (0, has_rspack_plugin_1.hasRspackPlugin)(tree)) ||
|
|
15
13
|
(options.bundler === 'vite' && (0, has_vite_plugin_1.hasVitePlugin)(tree));
|
|
16
14
|
let e2eWebServerInfo = {
|
|
17
15
|
e2eWebServerAddress: `http://localhost:${options.devServerPort ?? 4200}`,
|
|
@@ -38,28 +36,14 @@ async function addE2e(tree, options) {
|
|
|
38
36
|
switch (options.e2eTestRunner) {
|
|
39
37
|
case 'cypress': {
|
|
40
38
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
}
|
|
39
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
|
40
|
+
projectType: 'application',
|
|
41
|
+
root: options.e2eProjectRoot,
|
|
42
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
43
|
+
targets: {},
|
|
44
|
+
implicitDependencies: [options.projectName],
|
|
45
|
+
tags: [],
|
|
46
|
+
});
|
|
63
47
|
const e2eTask = await configurationGenerator(tree, {
|
|
64
48
|
...options,
|
|
65
49
|
project: options.e2eProjectName,
|
|
@@ -104,27 +88,13 @@ async function addE2e(tree, options) {
|
|
|
104
88
|
}
|
|
105
89
|
case 'playwright': {
|
|
106
90
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
}
|
|
91
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
|
92
|
+
projectType: 'application',
|
|
93
|
+
root: options.e2eProjectRoot,
|
|
94
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
95
|
+
targets: {},
|
|
96
|
+
implicitDependencies: [options.projectName],
|
|
97
|
+
});
|
|
128
98
|
const e2eTask = await configurationGenerator(tree, {
|
|
129
99
|
project: options.e2eProjectName,
|
|
130
100
|
skipFormat: true,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addProjectRootToRspackPluginExcludesIfExists = addProjectRootToRspackPluginExcludesIfExists;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const devkit_2 = require("@nx/devkit");
|
|
6
|
+
function addProjectRootToRspackPluginExcludesIfExists(tree, projectRoot) {
|
|
7
|
+
const excludeProjectGlob = (0, devkit_1.joinPathFragments)(projectRoot, '/**');
|
|
8
|
+
const nxJson = (0, devkit_2.readNxJson)(tree);
|
|
9
|
+
if (!nxJson.plugins?.length) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
for (let i = 0; i < nxJson.plugins.length; i++) {
|
|
13
|
+
let plugin = nxJson.plugins[i];
|
|
14
|
+
const isRspackPlugin = typeof plugin === 'string'
|
|
15
|
+
? plugin === '@nx/rspack/plugin'
|
|
16
|
+
: plugin.plugin === '@nx/rspack/plugin';
|
|
17
|
+
if (isRspackPlugin) {
|
|
18
|
+
if (typeof plugin === 'string') {
|
|
19
|
+
plugin = {
|
|
20
|
+
plugin: plugin,
|
|
21
|
+
exclude: [excludeProjectGlob],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
plugin.exclude = [...(plugin.exclude ?? []), excludeProjectGlob];
|
|
26
|
+
}
|
|
27
|
+
nxJson.plugins[i] = plugin;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
31
|
+
}
|
|
@@ -5,7 +5,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
|
|
6
6
|
const maybe_js_1 = require("../../../utils/maybe-js");
|
|
7
7
|
const has_rspack_plugin_1 = require("../../../utils/has-rspack-plugin");
|
|
8
|
-
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
|
9
8
|
function addProject(host, options) {
|
|
10
9
|
const project = {
|
|
11
10
|
root: options.appProjectRoot,
|
|
@@ -29,24 +28,9 @@ function addProject(host, options) {
|
|
|
29
28
|
serve: createRspackServeTarget(options),
|
|
30
29
|
};
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
version: '0.0.1',
|
|
36
|
-
private: true,
|
|
37
|
-
nx: {
|
|
38
|
-
name: options.name,
|
|
39
|
-
projectType: 'application',
|
|
40
|
-
sourceRoot: `${options.appProjectRoot}/src`,
|
|
41
|
-
tags: options.parsedTags?.length ? options.parsedTags : undefined,
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
if (!options.isUsingTsSolutionConfig || options.alwaysGenerateProjectJson) {
|
|
46
|
-
(0, devkit_1.addProjectConfiguration)(host, options.projectName, {
|
|
47
|
-
...project,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
31
|
+
(0, devkit_1.addProjectConfiguration)(host, options.projectName, {
|
|
32
|
+
...project,
|
|
33
|
+
});
|
|
50
34
|
}
|
|
51
35
|
function createRspackBuildTarget(options) {
|
|
52
36
|
return {
|
|
@@ -11,7 +11,6 @@ const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
|
|
|
11
11
|
const get_app_tests_1 = require("./get-app-tests");
|
|
12
12
|
const onboarding_1 = require("nx/src/nx-cloud/utilities/onboarding");
|
|
13
13
|
const has_rspack_plugin_1 = require("../../../utils/has-rspack-plugin");
|
|
14
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
15
14
|
async function createApplicationFiles(host, options) {
|
|
16
15
|
let styleSolutionSpecificAppFiles;
|
|
17
16
|
if (options.styledModule && options.style !== 'styled-jsx') {
|
|
@@ -48,7 +47,6 @@ async function createApplicationFiles(host, options) {
|
|
|
48
47
|
inSourceVitestTests: (0, get_in_source_vitest_tests_template_1.getInSourceVitestTestsTemplate)(appTests),
|
|
49
48
|
style: options.style === 'tailwind' ? 'css' : options.style,
|
|
50
49
|
hasStyleFile,
|
|
51
|
-
isUsingTsSolutionSetup: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
|
|
52
50
|
};
|
|
53
51
|
if (options.bundler === 'vite') {
|
|
54
52
|
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-vite'), options.appProjectRoot, templateVariables);
|
|
@@ -7,7 +7,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
8
8
|
const assertion_1 = require("../../../utils/assertion");
|
|
9
9
|
const find_free_port_1 = require("./find-free-port");
|
|
10
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
11
10
|
function normalizeDirectory(options) {
|
|
12
11
|
options.directory = options.directory?.replace(/\\{1,2}/g, '/');
|
|
13
12
|
const { projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
|
|
@@ -52,7 +51,6 @@ async function normalizeOptions(host, options) {
|
|
|
52
51
|
fileName,
|
|
53
52
|
styledModule,
|
|
54
53
|
hasStyles: options.style !== 'none',
|
|
55
|
-
isUsingTsSolutionConfig: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
|
|
56
54
|
};
|
|
57
55
|
normalized.routing = normalized.routing ?? false;
|
|
58
56
|
normalized.strict = normalized.strict ?? true;
|
|
@@ -17,11 +17,6 @@ function updateSpecConfig(host, options) {
|
|
|
17
17
|
types.push('@nx/react/typings/cssmodule.d.ts', '@nx/react/typings/image.d.ts');
|
|
18
18
|
compilerOptions.types = types;
|
|
19
19
|
json.compilerOptions = compilerOptions;
|
|
20
|
-
if (options.isUsingTsSolutionConfig) {
|
|
21
|
-
// add project reference to the runtime tsconfig.app.json file
|
|
22
|
-
json.references ??= [];
|
|
23
|
-
json.references.push({ path: './tsconfig.app.json' });
|
|
24
|
-
}
|
|
25
20
|
return json;
|
|
26
21
|
});
|
|
27
22
|
if (options.unitTestRunner !== 'jest') {
|
|
@@ -25,12 +25,8 @@ export interface Schema {
|
|
|
25
25
|
rootProject?: boolean;
|
|
26
26
|
bundler?: 'webpack' | 'vite' | 'rspack';
|
|
27
27
|
minimal?: boolean;
|
|
28
|
-
// Internal options
|
|
29
28
|
addPlugin?: boolean;
|
|
30
29
|
nxCloudToken?: string;
|
|
31
|
-
useTsSolution?: boolean;
|
|
32
|
-
formatter?: 'prettier' | 'none';
|
|
33
|
-
alwaysGenerateProjectJson?: boolean; // this is needed for MF currently
|
|
34
30
|
}
|
|
35
31
|
|
|
36
32
|
export interface NormalizedSchema<T extends Schema = Schema> extends T {
|
|
@@ -44,5 +40,4 @@ export interface NormalizedSchema<T extends Schema = Schema> extends T {
|
|
|
44
40
|
hasStyles: boolean;
|
|
45
41
|
unitTestRunner: 'jest' | 'vitest' | 'none';
|
|
46
42
|
addPlugin?: boolean;
|
|
47
|
-
isUsingTsSolutionConfig?: boolean;
|
|
48
43
|
}
|
|
@@ -80,6 +80,12 @@
|
|
|
80
80
|
]
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
|
+
"linter": {
|
|
84
|
+
"description": "The tool to use for running lint checks.",
|
|
85
|
+
"type": "string",
|
|
86
|
+
"enum": ["eslint", "none"],
|
|
87
|
+
"default": "eslint"
|
|
88
|
+
},
|
|
83
89
|
"routing": {
|
|
84
90
|
"type": "boolean",
|
|
85
91
|
"description": "Generate application with routes.",
|
|
@@ -98,29 +104,11 @@
|
|
|
98
104
|
"default": false,
|
|
99
105
|
"x-priority": "internal"
|
|
100
106
|
},
|
|
101
|
-
"bundler": {
|
|
102
|
-
"description": "The bundler to use.",
|
|
103
|
-
"type": "string",
|
|
104
|
-
"enum": ["vite", "webpack", "rspack"],
|
|
105
|
-
"x-prompt": "Which bundler do you want to use to build the application?",
|
|
106
|
-
"default": "vite",
|
|
107
|
-
"x-priority": "important"
|
|
108
|
-
},
|
|
109
|
-
"linter": {
|
|
110
|
-
"description": "The tool to use for running lint checks.",
|
|
111
|
-
"type": "string",
|
|
112
|
-
"enum": ["eslint", "none"],
|
|
113
|
-
"default": "none",
|
|
114
|
-
"x-prompt": "Which linter would you like to use?",
|
|
115
|
-
"x-priority": "important"
|
|
116
|
-
},
|
|
117
107
|
"unitTestRunner": {
|
|
118
108
|
"type": "string",
|
|
119
109
|
"enum": ["vitest", "jest", "none"],
|
|
120
110
|
"description": "Test runner to use for unit tests.",
|
|
121
|
-
"default": "
|
|
122
|
-
"x-prompt": "What unit test runner should be used?",
|
|
123
|
-
"x-priority": "important"
|
|
111
|
+
"default": "vitest"
|
|
124
112
|
},
|
|
125
113
|
"inSourceTests": {
|
|
126
114
|
"type": "boolean",
|
|
@@ -183,6 +171,14 @@
|
|
|
183
171
|
"default": false,
|
|
184
172
|
"hidden": true
|
|
185
173
|
},
|
|
174
|
+
"bundler": {
|
|
175
|
+
"description": "The bundler to use.",
|
|
176
|
+
"type": "string",
|
|
177
|
+
"enum": ["vite", "webpack", "rspack"],
|
|
178
|
+
"x-prompt": "Which bundler do you want to use to build the application?",
|
|
179
|
+
"default": "vite",
|
|
180
|
+
"x-priority": "important"
|
|
181
|
+
},
|
|
186
182
|
"minimal": {
|
|
187
183
|
"description": "Generate a React app with a minimal setup, no separate test files.",
|
|
188
184
|
"type": "boolean",
|
|
@@ -67,9 +67,7 @@ function addExportsToBarrel(host, options) {
|
|
|
67
67
|
const workspace = (0, devkit_1.getProjects)(host);
|
|
68
68
|
const isApp = workspace.get(options.projectName).projectType === 'application';
|
|
69
69
|
if (options.export && !isApp) {
|
|
70
|
-
const indexFilePath = options.projectSourceRoot
|
|
71
|
-
? (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts')
|
|
72
|
-
: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src', options.js ? 'index.js' : 'index.ts');
|
|
70
|
+
const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts');
|
|
73
71
|
const indexSource = host.read(indexFilePath, 'utf-8');
|
|
74
72
|
if (indexSource !== null) {
|
|
75
73
|
const indexSourceFile = tsModule.createSourceFile(indexFilePath, indexSource, tsModule.ScriptTarget.Latest, true);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
1
2
|
import { SupportedStyles } from '../../../typings/style';
|
|
2
3
|
|
|
3
4
|
export interface Schema {
|
|
@@ -19,7 +20,6 @@ export interface Schema {
|
|
|
19
20
|
|
|
20
21
|
export interface NormalizedSchema extends Schema {
|
|
21
22
|
directory: string;
|
|
22
|
-
projectRoot: string;
|
|
23
23
|
projectSourceRoot: string;
|
|
24
24
|
projectName: string;
|
|
25
25
|
fileName: string;
|
|
@@ -8,17 +8,19 @@
|
|
|
8
8
|
"properties": {
|
|
9
9
|
"path": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"description": "
|
|
11
|
+
"description": "Path where the component will be generated.",
|
|
12
12
|
"$default": {
|
|
13
13
|
"$source": "argv",
|
|
14
14
|
"index": 0
|
|
15
15
|
},
|
|
16
|
-
"x-prompt": "
|
|
16
|
+
"x-prompt": "Where should the component be generated?",
|
|
17
17
|
"x-priority": "important"
|
|
18
18
|
},
|
|
19
19
|
"name": {
|
|
20
20
|
"type": "string",
|
|
21
|
-
"description": "The
|
|
21
|
+
"description": "The name of the component.",
|
|
22
|
+
"x-prompt": "What name would you like to use for the component?",
|
|
23
|
+
"x-priority": "important"
|
|
22
24
|
},
|
|
23
25
|
"style": {
|
|
24
26
|
"description": "The file extension to be used for style files.",
|
|
@@ -49,20 +49,22 @@ function addExportsToBarrel(host, options) {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
async function normalizeOptions(host, options) {
|
|
52
|
-
|
|
52
|
+
assertValidOptions(options);
|
|
53
|
+
const { directory, fileName: _fileName, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
53
54
|
path: options.path,
|
|
54
55
|
name: options.name,
|
|
55
56
|
fileExtension: 'tsx',
|
|
56
57
|
});
|
|
57
|
-
const { className } = (0, devkit_1.names)(
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
const { className, fileName } = (0, devkit_1.names)(_fileName);
|
|
59
|
+
// If using `as-provided` file and directory, then don't normalize.
|
|
60
|
+
// Otherwise, support legacy behavior of prefixing filename with `use-`.
|
|
61
|
+
const hookFilename = fileName;
|
|
62
|
+
const hookName = className.toLocaleLowerCase().startsWith('use')
|
|
63
|
+
? className
|
|
64
|
+
: 'use'.concat(className);
|
|
65
|
+
const hookTypeName = className.toLocaleLowerCase().startsWith('use')
|
|
66
|
+
? className
|
|
67
|
+
: 'Use'.concat(className);
|
|
66
68
|
const project = (0, devkit_1.getProjects)(host).get(projectName);
|
|
67
69
|
const { sourceRoot: projectSourceRoot, projectType } = project;
|
|
68
70
|
if (options.export && projectType === 'application') {
|
|
@@ -78,4 +80,17 @@ async function normalizeOptions(host, options) {
|
|
|
78
80
|
projectName,
|
|
79
81
|
};
|
|
80
82
|
}
|
|
83
|
+
function assertValidOptions(options) {
|
|
84
|
+
const slashes = ['/', '\\'];
|
|
85
|
+
slashes.forEach((s) => {
|
|
86
|
+
if (options.name.indexOf(s) !== -1) {
|
|
87
|
+
const [name, ...rest] = options.name.split(s).reverse();
|
|
88
|
+
let suggestion = rest.map((x) => x.toLowerCase()).join(s);
|
|
89
|
+
if (options.directory) {
|
|
90
|
+
suggestion = `${options.directory}${s}${suggestion}`;
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`Found "${s}" in the hook name. Did you mean to use the --directory option (e.g. \`nx g c ${name} --directory ${suggestion}\`)?`);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
81
96
|
exports.default = hookGenerator;
|