@nx/react 0.0.0-pr-28808-eac89e6 → 0.0.0-pr-29114-41d0324
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 +4 -27
- 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 -43
- package/src/generators/application/lib/add-jest.js +0 -1
- 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 +0 -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 -22
- package/src/generators/library/library.js +16 -35
- package/src/generators/library/schema.d.ts +0 -1
- package/src/generators/library/schema.json +6 -6
- package/src/generators/remote/remote.js +2 -1
- package/src/migrations/update-20-2-0/migrate-mf-imports-to-new-package.js +3 -0
- package/src/rules/update-module-federation-project.js +0 -6
- 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-29114-41d0324",
|
|
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-29114-41d0324",
|
|
42
|
+
"@nx/js": "0.0.0-pr-29114-41d0324",
|
|
43
|
+
"@nx/eslint": "0.0.0-pr-29114-41d0324",
|
|
44
|
+
"@nx/web": "0.0.0-pr-29114-41d0324",
|
|
45
|
+
"@nx/module-federation": "0.0.0-pr-29114-41d0324",
|
|
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");
|
|
@@ -73,17 +72,16 @@ async function applicationGenerator(host, schema) {
|
|
|
73
72
|
});
|
|
74
73
|
}
|
|
75
74
|
async function applicationGeneratorInternal(host, schema) {
|
|
75
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'application');
|
|
76
76
|
const tasks = [];
|
|
77
|
+
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
78
|
+
(0, show_possible_warnings_1.showPossibleWarnings)(host, options);
|
|
77
79
|
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
78
80
|
...schema,
|
|
79
81
|
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
80
82
|
skipFormat: true,
|
|
81
|
-
addTsPlugin: schema.useTsSolution,
|
|
82
|
-
formatter: schema.formatter,
|
|
83
83
|
});
|
|
84
84
|
tasks.push(jsInitTask);
|
|
85
|
-
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
86
|
-
(0, show_possible_warnings_1.showPossibleWarnings)(host, options);
|
|
87
85
|
const initTask = await (0, init_1.default)(host, {
|
|
88
86
|
...options,
|
|
89
87
|
skipFormat: true,
|
|
@@ -117,7 +115,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
117
115
|
}
|
|
118
116
|
}
|
|
119
117
|
else if (options.bundler === 'rspack') {
|
|
120
|
-
const { rspackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.
|
|
118
|
+
const { rspackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxRspackVersion);
|
|
121
119
|
const rspackInitTask = await rspackInitGenerator(host, {
|
|
122
120
|
...options,
|
|
123
121
|
addPlugin: false,
|
|
@@ -152,7 +150,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
152
150
|
compiler: options.compiler,
|
|
153
151
|
skipFormat: true,
|
|
154
152
|
addPlugin: options.addPlugin,
|
|
155
|
-
projectType: 'application',
|
|
156
153
|
});
|
|
157
154
|
tasks.push(viteTask);
|
|
158
155
|
createOrEditViteConfig(host, {
|
|
@@ -173,21 +170,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
173
170
|
plugins: ['react()'],
|
|
174
171
|
}, false);
|
|
175
172
|
}
|
|
176
|
-
else if (options.bundler === 'rspack') {
|
|
177
|
-
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
|
|
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);
|
|
190
|
-
}
|
|
191
173
|
if (options.bundler !== 'vite' && options.unitTestRunner === 'vitest') {
|
|
192
174
|
const { createOrEditViteConfig, vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
193
175
|
const vitestTask = await vitestGenerator(host, {
|
|
@@ -260,11 +242,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
260
242
|
});
|
|
261
243
|
`);
|
|
262
244
|
}
|
|
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
245
|
if (!options.skipFormat) {
|
|
269
246
|
await (0, devkit_1.formatFiles)(host);
|
|
270
247
|
}
|
|
@@ -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
|
<%_ } _%>
|
|
@@ -38,28 +38,14 @@ async function addE2e(tree, options) {
|
|
|
38
38
|
switch (options.e2eTestRunner) {
|
|
39
39
|
case 'cypress': {
|
|
40
40
|
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
|
-
}
|
|
41
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
|
42
|
+
projectType: 'application',
|
|
43
|
+
root: options.e2eProjectRoot,
|
|
44
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
45
|
+
targets: {},
|
|
46
|
+
implicitDependencies: [options.projectName],
|
|
47
|
+
tags: [],
|
|
48
|
+
});
|
|
63
49
|
const e2eTask = await configurationGenerator(tree, {
|
|
64
50
|
...options,
|
|
65
51
|
project: options.e2eProjectName,
|
|
@@ -104,27 +90,13 @@ async function addE2e(tree, options) {
|
|
|
104
90
|
}
|
|
105
91
|
case 'playwright': {
|
|
106
92
|
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
|
-
}
|
|
93
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
|
94
|
+
projectType: 'application',
|
|
95
|
+
root: options.e2eProjectRoot,
|
|
96
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
97
|
+
targets: {},
|
|
98
|
+
implicitDependencies: [options.projectName],
|
|
99
|
+
});
|
|
128
100
|
const e2eTask = await configurationGenerator(tree, {
|
|
129
101
|
project: options.e2eProjectName,
|
|
130
102
|
skipFormat: true,
|
|
@@ -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": "eslint",
|
|
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": "vitest"
|
|
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);
|
|
@@ -15,8 +15,9 @@ const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
|
|
15
15
|
const js_1 = require("@nx/js");
|
|
16
16
|
const versions_1 = require("../../utils/versions");
|
|
17
17
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
18
|
-
const
|
|
18
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
19
19
|
async function hostGenerator(host, schema) {
|
|
20
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'host');
|
|
20
21
|
const tasks = [];
|
|
21
22
|
const options = {
|
|
22
23
|
...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
|
|
@@ -47,7 +48,6 @@ async function hostGenerator(host, schema) {
|
|
|
47
48
|
// The target use-case is loading remotes as child routes, thus always enable routing.
|
|
48
49
|
routing: true,
|
|
49
50
|
skipFormat: true,
|
|
50
|
-
alwaysGenerateProjectJson: true,
|
|
51
51
|
});
|
|
52
52
|
tasks.push(initTask);
|
|
53
53
|
const remotesWithPorts = [];
|
|
@@ -80,7 +80,6 @@ async function hostGenerator(host, schema) {
|
|
|
80
80
|
(0, add_module_federation_files_1.addModuleFederationFiles)(host, options, remotesWithPorts);
|
|
81
81
|
(0, update_module_federation_project_1.updateModuleFederationProject)(host, options);
|
|
82
82
|
(0, update_module_federation_e2e_project_1.updateModuleFederationE2eProject)(host, options);
|
|
83
|
-
(0, update_module_federation_tsconfig_1.updateModuleFederationTsconfig)(host, options);
|
|
84
83
|
if (options.ssr) {
|
|
85
84
|
const setupSsrTask = await (0, setup_ssr_1.default)(host, {
|
|
86
85
|
project: options.projectName,
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reactInitGenerator = reactInitGenerator;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
5
6
|
const versions_1 = require("../../utils/versions");
|
|
6
7
|
async function reactInitGenerator(host, schema) {
|
|
8
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'init');
|
|
7
9
|
const tasks = [];
|
|
8
10
|
if (!schema.skipPackageJson) {
|
|
9
11
|
tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/react'], []));
|
|
@@ -42,28 +42,8 @@ function createFiles(host, options) {
|
|
|
42
42
|
].filter(Boolean),
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
if (options.bundler === 'vite') {
|
|
48
|
-
(0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, {
|
|
49
|
-
name: options.importPath,
|
|
50
|
-
version: '0.0.1',
|
|
51
|
-
main: './index.js',
|
|
52
|
-
types: './index.d.ts',
|
|
53
|
-
exports: {
|
|
54
|
-
'.': {
|
|
55
|
-
import: './index.mjs',
|
|
56
|
-
require: './index.js',
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
(0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, {
|
|
63
|
-
name: options.importPath,
|
|
64
|
-
version: '0.0.1',
|
|
65
|
-
});
|
|
66
|
-
}
|
|
45
|
+
if (!options.publishable && !options.buildable) {
|
|
46
|
+
host.delete(`${options.projectRoot}/package.json`);
|
|
67
47
|
}
|
|
68
48
|
if (options.js) {
|
|
69
49
|
(0, devkit_1.toJS)(host);
|
|
@@ -4,28 +4,7 @@ exports.normalizeOptions = normalizeOptions;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
6
|
const assertion_1 = require("../../../utils/assertion");
|
|
7
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
|
-
const prompt_1 = require("@nx/devkit/src/generators/prompt");
|
|
9
7
|
async function normalizeOptions(host, options) {
|
|
10
|
-
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
11
|
-
if (isUsingTsSolutionConfig) {
|
|
12
|
-
options.bundler ??= await (0, prompt_1.promptWhenInteractive)({
|
|
13
|
-
type: 'autocomplete',
|
|
14
|
-
name: 'bundler',
|
|
15
|
-
message: `Which bundler would you like to use to build the library? Choose 'none' to skip build setup.`,
|
|
16
|
-
choices: [{ name: 'vite' }, { name: 'rollup' }, { name: 'none' }],
|
|
17
|
-
initial: 0,
|
|
18
|
-
}, { bundler: 'none' }).then(({ bundler }) => bundler);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
options.bundler ??= await (0, prompt_1.promptWhenInteractive)({
|
|
22
|
-
type: 'autocomplete',
|
|
23
|
-
name: 'bundler',
|
|
24
|
-
message: `Which bundler would you like to use to build the library? Choose 'none' to skip build setup.`,
|
|
25
|
-
choices: [{ name: 'none' }, { name: 'vite' }, { name: 'rollup' }],
|
|
26
|
-
initial: 0,
|
|
27
|
-
}, { bundler: undefined }).then(({ bundler }) => bundler);
|
|
28
|
-
}
|
|
29
8
|
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
|
|
30
9
|
const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
31
10
|
name: options.name,
|
|
@@ -83,7 +62,6 @@ async function normalizeOptions(host, options) {
|
|
|
83
62
|
}
|
|
84
63
|
}
|
|
85
64
|
(0, assertion_1.assertValidStyle)(normalized.style);
|
|
86
|
-
normalized.isUsingTsSolutionConfig = isUsingTsSolutionConfig;
|
|
87
65
|
return normalized;
|
|
88
66
|
}
|
|
89
67
|
function findMainEntry(tree, projectRoot) {
|
|
@@ -7,6 +7,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
8
8
|
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
9
9
|
const js_1 = require("@nx/js");
|
|
10
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
10
11
|
const versions_1 = require("../../utils/versions");
|
|
11
12
|
const maybe_js_1 = require("../../utils/maybe-js");
|
|
12
13
|
const component_1 = require("../component/component");
|
|
@@ -20,7 +21,6 @@ const create_files_1 = require("./lib/create-files");
|
|
|
20
21
|
const create_ts_config_1 = require("../../utils/create-ts-config");
|
|
21
22
|
const install_common_dependencies_1 = require("./lib/install-common-dependencies");
|
|
22
23
|
const set_defaults_1 = require("./lib/set-defaults");
|
|
23
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
24
24
|
async function libraryGenerator(host, schema) {
|
|
25
25
|
return await libraryGeneratorInternal(host, {
|
|
26
26
|
addPlugin: false,
|
|
@@ -28,12 +28,8 @@ async function libraryGenerator(host, schema) {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
async function libraryGeneratorInternal(host, schema) {
|
|
31
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'library');
|
|
31
32
|
const tasks = [];
|
|
32
|
-
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
33
|
-
...schema,
|
|
34
|
-
skipFormat: true,
|
|
35
|
-
});
|
|
36
|
-
tasks.push(jsInitTask);
|
|
37
33
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
38
34
|
if (options.publishable === true && !schema.importPath) {
|
|
39
35
|
throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
|
|
@@ -41,34 +37,26 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
41
37
|
if (!options.component) {
|
|
42
38
|
options.style = 'none';
|
|
43
39
|
}
|
|
40
|
+
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
41
|
+
...schema,
|
|
42
|
+
skipFormat: true,
|
|
43
|
+
});
|
|
44
|
+
tasks.push(jsInitTask);
|
|
44
45
|
const initTask = await (0, init_1.default)(host, {
|
|
45
46
|
...options,
|
|
46
47
|
skipFormat: true,
|
|
47
48
|
});
|
|
48
49
|
tasks.push(initTask);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
tags: options.parsedTags?.length ? options.parsedTags : undefined,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
(0, devkit_1.addProjectConfiguration)(host, options.name, {
|
|
62
|
-
root: options.projectRoot,
|
|
63
|
-
sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
|
|
64
|
-
projectType: 'library',
|
|
65
|
-
tags: options.parsedTags,
|
|
66
|
-
targets: {},
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
(0, create_files_1.createFiles)(host, options);
|
|
50
|
+
(0, devkit_1.addProjectConfiguration)(host, options.name, {
|
|
51
|
+
root: options.projectRoot,
|
|
52
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
|
|
53
|
+
projectType: 'library',
|
|
54
|
+
tags: options.parsedTags,
|
|
55
|
+
targets: {},
|
|
56
|
+
});
|
|
70
57
|
const lintTask = await (0, add_linting_1.addLinting)(host, options);
|
|
71
58
|
tasks.push(lintTask);
|
|
59
|
+
(0, create_files_1.createFiles)(host, options);
|
|
72
60
|
// Set up build target
|
|
73
61
|
if (options.buildable && options.bundler === 'vite') {
|
|
74
62
|
const { viteConfigurationGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
@@ -190,18 +178,11 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
190
178
|
tasks.push(routeTask);
|
|
191
179
|
(0, set_defaults_1.setDefaults)(host, options);
|
|
192
180
|
(0, create_ts_config_1.extractTsConfigBase)(host);
|
|
193
|
-
if (!options.skipTsConfig
|
|
181
|
+
if (!options.skipTsConfig) {
|
|
194
182
|
(0, js_1.addTsConfigPath)(host, options.importPath, [
|
|
195
183
|
(0, maybe_js_1.maybeJs)(options, (0, devkit_1.joinPathFragments)(options.projectRoot, './src/index.ts')),
|
|
196
184
|
]);
|
|
197
185
|
}
|
|
198
|
-
(0, ts_solution_setup_1.updateTsconfigFiles)(host, options.projectRoot, 'tsconfig.lib.json', {
|
|
199
|
-
jsx: 'react-jsx',
|
|
200
|
-
module: 'esnext',
|
|
201
|
-
moduleResolution: 'bundler',
|
|
202
|
-
}, options.linter === 'eslint'
|
|
203
|
-
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
204
|
-
: undefined);
|
|
205
186
|
if (!options.skipFormat) {
|
|
206
187
|
await (0, devkit_1.formatFiles)(host);
|
|
207
188
|
}
|
|
@@ -75,17 +75,14 @@
|
|
|
75
75
|
"description": "The tool to use for running lint checks.",
|
|
76
76
|
"type": "string",
|
|
77
77
|
"enum": ["eslint", "none"],
|
|
78
|
-
"default": "eslint"
|
|
79
|
-
"x-prompt": "Which linter would you like to use?",
|
|
80
|
-
"x-priority": "important"
|
|
78
|
+
"default": "eslint"
|
|
81
79
|
},
|
|
82
80
|
"unitTestRunner": {
|
|
83
81
|
"type": "string",
|
|
84
82
|
"enum": ["vitest", "jest", "none"],
|
|
85
83
|
"default": "vitest",
|
|
86
84
|
"description": "Test runner to use for unit tests.",
|
|
87
|
-
"x-prompt": "What unit test runner should be used?"
|
|
88
|
-
"x-priority": "important"
|
|
85
|
+
"x-prompt": "What unit test runner should be used?"
|
|
89
86
|
},
|
|
90
87
|
"inSourceTests": {
|
|
91
88
|
"type": "boolean",
|
|
@@ -160,7 +157,10 @@
|
|
|
160
157
|
"bundler": {
|
|
161
158
|
"type": "string",
|
|
162
159
|
"description": "The bundler to use. Choosing 'none' means this library is not buildable.",
|
|
163
|
-
"enum": ["none", "vite", "rollup"]
|
|
160
|
+
"enum": ["none", "vite", "rollup"],
|
|
161
|
+
"default": "none",
|
|
162
|
+
"x-prompt": "Which bundler would you like to use to build the library? Choose 'none' to skip build setup.",
|
|
163
|
+
"x-priority": "important"
|
|
164
164
|
},
|
|
165
165
|
"compiler": {
|
|
166
166
|
"type": "string",
|
|
@@ -17,6 +17,7 @@ const maybe_js_1 = require("../../utils/maybe-js");
|
|
|
17
17
|
const js_1 = require("@nx/js");
|
|
18
18
|
const versions_1 = require("../../utils/versions");
|
|
19
19
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
20
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
20
21
|
function addModuleFederationFiles(host, options) {
|
|
21
22
|
const templateVariables = {
|
|
22
23
|
...(0, devkit_1.names)(options.projectName),
|
|
@@ -46,6 +47,7 @@ function addModuleFederationFiles(host, options) {
|
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
async function remoteGenerator(host, schema) {
|
|
50
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'remote');
|
|
49
51
|
const tasks = [];
|
|
50
52
|
const options = {
|
|
51
53
|
...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
|
|
@@ -80,7 +82,6 @@ async function remoteGenerator(host, schema) {
|
|
|
80
82
|
...options,
|
|
81
83
|
name: options.projectName,
|
|
82
84
|
skipFormat: true,
|
|
83
|
-
alwaysGenerateProjectJson: true,
|
|
84
85
|
});
|
|
85
86
|
tasks.push(initAppTask);
|
|
86
87
|
if (schema.host) {
|
|
@@ -14,6 +14,9 @@ async function migrateMfImportsToNewPackage(tree) {
|
|
|
14
14
|
const rootsToCheck = new Set();
|
|
15
15
|
const graph = await (0, devkit_1.createProjectGraphAsync)();
|
|
16
16
|
for (const [project, dependencies] of Object.entries(graph.dependencies)) {
|
|
17
|
+
if (!graph.nodes[project]) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
17
20
|
const usesNxWebpackOrRspack = dependencies.some((dep) => dep.target === 'npm:@nx/webpack' || dep.target === 'npm:@nx/rspack');
|
|
18
21
|
if (usesNxWebpackOrRspack) {
|
|
19
22
|
const root = graph.nodes[project].data.root;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateModuleFederationProject = updateModuleFederationProject;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const maybe_js_1 = require("../utils/maybe-js");
|
|
6
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
7
6
|
function updateModuleFederationProject(host, options) {
|
|
8
7
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
9
8
|
if (options.bundler === 'rspack') {
|
|
@@ -79,10 +78,5 @@ function updateModuleFederationProject(host, options) {
|
|
|
79
78
|
},
|
|
80
79
|
},
|
|
81
80
|
};
|
|
82
|
-
// Typechecks must be performed first before build and serve to generate remote d.ts files.
|
|
83
|
-
if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
|
|
84
|
-
projectConfig.targets.build.dependsOn = ['^build', 'typecheck'];
|
|
85
|
-
projectConfig.targets.serve.dependsOn = ['typecheck'];
|
|
86
|
-
}
|
|
87
81
|
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
|
|
88
82
|
}
|
|
@@ -4,64 +4,7 @@ exports.createTsConfig = createTsConfig;
|
|
|
4
4
|
exports.extractTsConfigBase = extractTsConfigBase;
|
|
5
5
|
const shared = require("@nx/js/src/utils/typescript/create-ts-config");
|
|
6
6
|
const json_1 = require("nx/src/generators/utils/json");
|
|
7
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
7
|
function createTsConfig(host, projectRoot, type, options, relativePathToRootTsConfig) {
|
|
9
|
-
if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
|
|
10
|
-
createTsConfigForTsSolution(host, projectRoot, type, options, relativePathToRootTsConfig);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
createTsConfigForNonTsSolution(host, projectRoot, type, options, relativePathToRootTsConfig);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function extractTsConfigBase(host) {
|
|
17
|
-
shared.extractTsConfigBase(host);
|
|
18
|
-
if (host.exists('vite.config.ts')) {
|
|
19
|
-
const vite = host.read('vite.config.ts').toString();
|
|
20
|
-
host.write('vite.config.ts', vite.replace(`projects: []`, `projects: ['tsconfig.base.json']`));
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function createTsConfigForTsSolution(host, projectRoot, type, options, relativePathToRootTsConfig) {
|
|
24
|
-
const json = {
|
|
25
|
-
files: [],
|
|
26
|
-
include: [],
|
|
27
|
-
references: [
|
|
28
|
-
{
|
|
29
|
-
path: type === 'app' ? './tsconfig.app.json' : './tsconfig.lib.json',
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
};
|
|
33
|
-
// inline tsconfig.base.json into the project
|
|
34
|
-
if (options.rootProject) {
|
|
35
|
-
json.compileOnSave = false;
|
|
36
|
-
json.compilerOptions = {
|
|
37
|
-
...shared.tsConfigBaseOptions,
|
|
38
|
-
...json.compilerOptions,
|
|
39
|
-
};
|
|
40
|
-
json.exclude = ['node_modules', 'tmp'];
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
json.extends = relativePathToRootTsConfig;
|
|
44
|
-
}
|
|
45
|
-
(0, json_1.writeJson)(host, `${projectRoot}/tsconfig.json`, json);
|
|
46
|
-
const tsconfigProjectPath = `${projectRoot}/tsconfig.${type}.json`;
|
|
47
|
-
if (host.exists(tsconfigProjectPath)) {
|
|
48
|
-
(0, json_1.updateJson)(host, tsconfigProjectPath, (json) => {
|
|
49
|
-
if (options.bundler === 'vite') {
|
|
50
|
-
json.compilerOptions ??= {};
|
|
51
|
-
const types = new Set(json.compilerOptions.types ?? []);
|
|
52
|
-
types.add('node');
|
|
53
|
-
types.add('vite/client');
|
|
54
|
-
json.compilerOptions.types = Array.from(types);
|
|
55
|
-
}
|
|
56
|
-
if (options.style === '@emotion/styled') {
|
|
57
|
-
json.compilerOptions ??= {};
|
|
58
|
-
json.compilerOptions.jsxImportSource = '@emotion/react';
|
|
59
|
-
}
|
|
60
|
-
return json;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function createTsConfigForNonTsSolution(host, projectRoot, type, options, relativePathToRootTsConfig) {
|
|
65
8
|
const json = {
|
|
66
9
|
compilerOptions: {
|
|
67
10
|
jsx: 'react-jsx',
|
|
@@ -112,3 +55,10 @@ function createTsConfigForNonTsSolution(host, projectRoot, type, options, relati
|
|
|
112
55
|
});
|
|
113
56
|
}
|
|
114
57
|
}
|
|
58
|
+
function extractTsConfigBase(host) {
|
|
59
|
+
shared.extractTsConfigBase(host);
|
|
60
|
+
if (host.exists('vite.config.ts')) {
|
|
61
|
+
const vite = host.read('vite.config.ts').toString();
|
|
62
|
+
host.write('vite.config.ts', vite.replace(`projects: []`, `projects: ['tsconfig.base.json']`));
|
|
63
|
+
}
|
|
64
|
+
}
|
package/src/utils/versions.d.ts
CHANGED
package/src/utils/versions.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.swcPluginStyledComponentsVersion = exports.swcPluginEmotionVersion = exports.swcPluginStyledJsxVersion = exports.svgrRollupVersion = exports.rollupPluginUrlVersion = exports.sassVersion = exports.lessVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.typesCorsVersion = exports.corsVersion = exports.isbotVersion = exports.typesExpressVersion = exports.expressVersion = exports.autoprefixerVersion = exports.tailwindcssVersion = exports.postcssVersion = exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.reactReduxVersion = exports.reduxjsToolkitVersion = exports.testingLibraryReactVersion = exports.reactRouterDomVersion = exports.styledJsxVersion = exports.emotionBabelPlugin = exports.emotionReactVersion = exports.emotionStyledVersion = exports.typesStyledComponentsVersion = exports.styledComponentsVersion = exports.babelCoreVersion = exports.babelPresetReactVersion = exports.typesNodeVersion = exports.reactViteVersion = exports.typesReactIsVersion = exports.typesReactDomVersion = exports.typesReactVersion = exports.babelLoaderVersion = exports.swcLoaderVersion = exports.reactIsVersion = exports.reactDomVersion = exports.reactVersion = exports.nxVersion = void 0;
|
|
3
|
+
exports.swcPluginStyledComponentsVersion = exports.swcPluginEmotionVersion = exports.swcPluginStyledJsxVersion = exports.svgrRollupVersion = exports.rollupPluginUrlVersion = exports.sassVersion = exports.lessVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.typesCorsVersion = exports.corsVersion = exports.isbotVersion = exports.typesExpressVersion = exports.expressVersion = exports.autoprefixerVersion = exports.tailwindcssVersion = exports.postcssVersion = exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.reactReduxVersion = exports.reduxjsToolkitVersion = exports.testingLibraryReactVersion = exports.reactRouterDomVersion = exports.styledJsxVersion = exports.emotionBabelPlugin = exports.emotionReactVersion = exports.emotionStyledVersion = exports.typesStyledComponentsVersion = exports.styledComponentsVersion = exports.babelCoreVersion = exports.babelPresetReactVersion = exports.typesNodeVersion = exports.reactViteVersion = exports.typesReactIsVersion = exports.typesReactDomVersion = exports.typesReactVersion = exports.babelLoaderVersion = exports.swcLoaderVersion = exports.reactIsVersion = exports.reactDomVersion = exports.reactVersion = exports.nxRspackVersion = exports.nxVersion = void 0;
|
|
4
4
|
exports.nxVersion = require('../../package.json').version;
|
|
5
|
+
// Always pull the latest version until we merge rspack plugin into the repo.
|
|
6
|
+
exports.nxRspackVersion = '*';
|
|
5
7
|
exports.reactVersion = '18.3.1';
|
|
6
8
|
exports.reactDomVersion = '18.3.1';
|
|
7
9
|
exports.reactIsVersion = '18.3.1';
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateModuleFederationTsconfig = updateModuleFederationTsconfig;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
6
|
-
function updateModuleFederationTsconfig(host, options) {
|
|
7
|
-
const tsconfigPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json');
|
|
8
|
-
const tsconfigRuntimePath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json');
|
|
9
|
-
if (!host.exists(tsconfigPath) || !host.exists(tsconfigRuntimePath))
|
|
10
|
-
return;
|
|
11
|
-
// Not setting `baseUrl` does not work with MF.
|
|
12
|
-
if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
|
|
13
|
-
(0, devkit_1.updateJson)(host, 'tsconfig.base.json', (json) => {
|
|
14
|
-
json.compilerOptions.baseUrl = '.';
|
|
15
|
-
return json;
|
|
16
|
-
});
|
|
17
|
-
// Update references to match what `nx sync` does.
|
|
18
|
-
if (options.remotes?.length) {
|
|
19
|
-
(0, devkit_1.updateJson)(host, tsconfigPath, (json) => {
|
|
20
|
-
json.references ??= [];
|
|
21
|
-
for (const remote of options.remotes) {
|
|
22
|
-
const remotePath = `../${remote}`;
|
|
23
|
-
if (!json.references.some((ref) => ref.path === remotePath))
|
|
24
|
-
json.references.push({ path: remotePath });
|
|
25
|
-
}
|
|
26
|
-
return json;
|
|
27
|
-
});
|
|
28
|
-
(0, devkit_1.updateJson)(host, tsconfigRuntimePath, (json) => {
|
|
29
|
-
json.references ??= [];
|
|
30
|
-
for (const remote of options.remotes) {
|
|
31
|
-
const remotePath = `../${remote}/tsconfig.app.json`;
|
|
32
|
-
if (!json.references.some((ref) => ref.path === remotePath))
|
|
33
|
-
json.references.push({ path: remotePath });
|
|
34
|
-
}
|
|
35
|
-
return json;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|