@nx/react 20.4.0-beta.0 → 20.4.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations.json +9 -0
- package/package.json +8 -7
- package/src/generators/application/application.js +9 -6
- package/src/generators/application/lib/add-project.js +6 -8
- package/src/generators/application/lib/get-app-tests.js +1 -1
- package/src/generators/application/lib/install-common-dependencies.d.ts +1 -1
- package/src/generators/application/lib/install-common-dependencies.js +6 -3
- package/src/generators/application/lib/normalize-options.js +7 -3
- package/src/generators/application/schema.json +1 -1
- package/src/generators/component/lib/normalize-options.js +3 -1
- package/src/generators/hook/hook.js +4 -2
- package/src/generators/host/host.js +1 -1
- package/src/generators/init/init.d.ts +1 -1
- package/src/generators/init/init.js +8 -6
- package/src/generators/library/lib/normalize-options.js +1 -1
- package/src/generators/library/library.js +10 -9
- package/src/generators/redux/redux.js +3 -2
- package/src/generators/remote/remote.js +7 -7
- package/src/generators/stories/stories.js +2 -1
- package/src/utils/version-utils.d.ts +14 -0
- package/src/utils/version-utils.js +56 -0
- package/src/utils/versions.d.ts +14 -7
- package/src/utils/versions.js +16 -8
package/migrations.json
CHANGED
@@ -197,6 +197,15 @@
|
|
197
197
|
"alwaysAddToPackageJson": false
|
198
198
|
}
|
199
199
|
}
|
200
|
+
},
|
201
|
+
"20.3.0": {
|
202
|
+
"version": "20.3.0-beta.0",
|
203
|
+
"packages": {
|
204
|
+
"@testing-library/react": {
|
205
|
+
"version": "16.1.0",
|
206
|
+
"alwaysAddToPackageJson": false
|
207
|
+
}
|
208
|
+
}
|
200
209
|
}
|
201
210
|
}
|
202
211
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/react",
|
3
|
-
"version": "20.4.0-beta.
|
3
|
+
"version": "20.4.0-beta.2",
|
4
4
|
"private": false,
|
5
5
|
"description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Vitest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
|
6
6
|
"repository": {
|
@@ -38,13 +38,14 @@
|
|
38
38
|
"minimatch": "9.0.3",
|
39
39
|
"picocolors": "^1.1.0",
|
40
40
|
"tslib": "^2.3.0",
|
41
|
-
"@nx/devkit": "20.4.0-beta.
|
42
|
-
"@nx/js": "20.4.0-beta.
|
43
|
-
"@nx/eslint": "20.4.0-beta.
|
44
|
-
"@nx/web": "20.4.0-beta.
|
45
|
-
"@nx/module-federation": "20.4.0-beta.
|
41
|
+
"@nx/devkit": "20.4.0-beta.2",
|
42
|
+
"@nx/js": "20.4.0-beta.2",
|
43
|
+
"@nx/eslint": "20.4.0-beta.2",
|
44
|
+
"@nx/web": "20.4.0-beta.2",
|
45
|
+
"@nx/module-federation": "20.4.0-beta.2",
|
46
46
|
"express": "^4.19.2",
|
47
|
-
"http-proxy-middleware": "^3.0.3"
|
47
|
+
"http-proxy-middleware": "^3.0.3",
|
48
|
+
"semver": "^7.6.3"
|
48
49
|
},
|
49
50
|
"publishConfig": {
|
50
51
|
"access": "public"
|
@@ -25,6 +25,7 @@ const add_webpack_1 = require("./lib/bundlers/add-webpack");
|
|
25
25
|
const add_rspack_1 = require("./lib/bundlers/add-rspack");
|
26
26
|
const add_rsbuild_1 = require("./lib/bundlers/add-rsbuild");
|
27
27
|
const add_vite_1 = require("./lib/bundlers/add-vite");
|
28
|
+
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
28
29
|
async function applicationGenerator(tree, schema) {
|
29
30
|
return await applicationGeneratorInternal(tree, {
|
30
31
|
addPlugin: false,
|
@@ -39,9 +40,15 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
39
40
|
skipFormat: true,
|
40
41
|
addTsPlugin: schema.useTsSolution,
|
41
42
|
formatter: schema.formatter,
|
43
|
+
platform: 'web',
|
42
44
|
});
|
43
45
|
tasks.push(jsInitTask);
|
44
46
|
const options = await (0, normalize_options_1.normalizeOptions)(tree, schema);
|
47
|
+
// If we are using the new TS solution
|
48
|
+
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
49
|
+
if (options.isUsingTsSolutionConfig) {
|
50
|
+
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
|
51
|
+
}
|
45
52
|
(0, show_possible_warnings_1.showPossibleWarnings)(tree, options);
|
46
53
|
const initTask = await (0, init_1.default)(tree, {
|
47
54
|
...options,
|
@@ -108,7 +115,7 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
108
115
|
}
|
109
116
|
// Handle tsconfig.spec.json for jest or vitest
|
110
117
|
(0, update_jest_config_1.updateSpecConfig)(tree, options);
|
111
|
-
const stylePreprocessorTask = (0, install_common_dependencies_1.installCommonDependencies)(tree, options);
|
118
|
+
const stylePreprocessorTask = await (0, install_common_dependencies_1.installCommonDependencies)(tree, options);
|
112
119
|
tasks.push(stylePreprocessorTask);
|
113
120
|
const styledTask = (0, add_styled_dependencies_1.addStyledModuleDependencies)(tree, options);
|
114
121
|
tasks.push(styledTask);
|
@@ -125,11 +132,7 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
125
132
|
}, options.linter === 'eslint'
|
126
133
|
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
127
134
|
: undefined);
|
128
|
-
|
129
|
-
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
130
|
-
if (options.isUsingTsSolutionConfig) {
|
131
|
-
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
|
132
|
-
}
|
135
|
+
(0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
|
133
136
|
if (!options.skipFormat) {
|
134
137
|
await (0, devkit_1.formatFiles)(tree);
|
135
138
|
}
|
@@ -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,
|
@@ -31,15 +30,14 @@ function addProject(host, options) {
|
|
31
30
|
}
|
32
31
|
if (options.isUsingTsSolutionConfig) {
|
33
32
|
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
|
34
|
-
name:
|
33
|
+
name: options.projectName,
|
35
34
|
version: '0.0.1',
|
36
35
|
private: true,
|
37
|
-
nx:
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
},
|
36
|
+
nx: options.parsedTags?.length
|
37
|
+
? {
|
38
|
+
tags: options.parsedTags,
|
39
|
+
}
|
40
|
+
: undefined,
|
43
41
|
});
|
44
42
|
}
|
45
43
|
if (!options.isUsingTsSolutionConfig || options.alwaysGenerateProjectJson) {
|
@@ -13,7 +13,7 @@ function getAppTests(options) {
|
|
13
13
|
${options.routing
|
14
14
|
? 'const { getByText } = render(<BrowserRouter><App /></BrowserRouter>);'
|
15
15
|
: 'const { getByText } = render(<App />);'}
|
16
|
-
expect(getByText(
|
16
|
+
expect(getByText(new RegExp('Welcome ${options.projectName}', 'gi'))).toBeTruthy();
|
17
17
|
});
|
18
18
|
`;
|
19
19
|
}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
2
2
|
import { NormalizedSchema } from '../schema';
|
3
|
-
export declare function installCommonDependencies(host: Tree, options: NormalizedSchema): import("@nx/devkit").GeneratorCallback
|
3
|
+
export declare function installCommonDependencies(host: Tree, options: NormalizedSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
@@ -3,15 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.installCommonDependencies = installCommonDependencies;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
5
|
const versions_1 = require("../../../utils/versions");
|
6
|
-
|
6
|
+
const version_utils_1 = require("../../../utils/version-utils");
|
7
|
+
async function installCommonDependencies(host, options) {
|
7
8
|
if (options.skipPackageJson) {
|
8
9
|
return () => { };
|
9
10
|
}
|
11
|
+
const reactDeps = await (0, version_utils_1.getReactDependenciesVersionsToInstall)(host);
|
10
12
|
const dependencies = {};
|
11
13
|
const devDependencies = {
|
12
14
|
'@types/node': versions_1.typesNodeVersion,
|
13
|
-
'@types/react':
|
14
|
-
'@types/react-dom':
|
15
|
+
'@types/react': reactDeps['@types/react'],
|
16
|
+
'@types/react-dom': reactDeps['@types/react-dom'],
|
15
17
|
};
|
16
18
|
if (options.bundler !== 'vite') {
|
17
19
|
dependencies['tslib'] = versions_1.tsLibVersion;
|
@@ -41,6 +43,7 @@ function installCommonDependencies(host, options) {
|
|
41
43
|
}
|
42
44
|
if (options.unitTestRunner && options.unitTestRunner !== 'none') {
|
43
45
|
devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
|
46
|
+
devDependencies['@testing-library/dom'] = versions_1.testingLibraryDomVersion;
|
44
47
|
}
|
45
48
|
return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies);
|
46
49
|
}
|
@@ -8,6 +8,7 @@ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project
|
|
8
8
|
const assertion_1 = require("../../../utils/assertion");
|
9
9
|
const find_free_port_1 = require("./find-free-port");
|
10
10
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
11
|
+
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
11
12
|
function normalizeDirectory(options) {
|
12
13
|
options.directory = options.directory?.replace(/\\{1,2}/g, '/');
|
13
14
|
const { projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
|
@@ -41,10 +42,13 @@ async function normalizeOptions(host, options) {
|
|
41
42
|
? null
|
42
43
|
: options.style;
|
43
44
|
(0, assertion_1.assertValidStyle)(options.style);
|
45
|
+
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
44
46
|
const normalized = {
|
45
47
|
...options,
|
46
|
-
name:
|
47
|
-
projectName:
|
48
|
+
name: appProjectName,
|
49
|
+
projectName: isUsingTsSolutionConfig
|
50
|
+
? (0, get_import_path_1.getImportPath)(host, appProjectName)
|
51
|
+
: appProjectName,
|
48
52
|
appProjectRoot,
|
49
53
|
e2eProjectName,
|
50
54
|
e2eProjectRoot,
|
@@ -52,7 +56,7 @@ async function normalizeOptions(host, options) {
|
|
52
56
|
fileName,
|
53
57
|
styledModule,
|
54
58
|
hasStyles: options.style !== 'none',
|
55
|
-
isUsingTsSolutionConfig
|
59
|
+
isUsingTsSolutionConfig,
|
56
60
|
};
|
57
61
|
normalized.routing = normalized.routing ?? false;
|
58
62
|
normalized.strict = normalized.strict ?? true;
|
@@ -101,7 +101,7 @@
|
|
101
101
|
"bundler": {
|
102
102
|
"description": "The bundler to use.",
|
103
103
|
"type": "string",
|
104
|
-
"enum": ["vite", "
|
104
|
+
"enum": ["vite", "rsbuild", "rspack", "webpack"],
|
105
105
|
"x-prompt": "Which bundler do you want to use to build the application?",
|
106
106
|
"default": "vite",
|
107
107
|
"x-priority": "important"
|
@@ -4,6 +4,7 @@ exports.normalizeOptions = normalizeOptions;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
5
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
6
6
|
const assertion_1 = require("../../../utils/assertion");
|
7
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
7
8
|
async function normalizeOptions(tree, options) {
|
8
9
|
(0, assertion_1.assertValidStyle)(options.style);
|
9
10
|
const { artifactName: name, directory, fileName, filePath, fileExtension, fileExtensionType, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
@@ -19,7 +20,8 @@ async function normalizeOptions(tree, options) {
|
|
19
20
|
const styledModule = /^(css|scss|less|none)$/.test(options.style)
|
20
21
|
? null
|
21
22
|
: options.style;
|
22
|
-
if (options.export &&
|
23
|
+
if (options.export &&
|
24
|
+
(0, ts_solution_setup_1.getProjectType)(tree, projectRoot, projectType) === 'application') {
|
23
25
|
devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
|
24
26
|
}
|
25
27
|
options.classComponent = options.classComponent ?? false;
|
@@ -7,6 +7,7 @@ const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/a
|
|
7
7
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
8
8
|
const path_1 = require("path");
|
9
9
|
const ast_utils_1 = require("../../utils/ast-utils");
|
10
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
10
11
|
async function hookGenerator(host, schema) {
|
11
12
|
const options = await normalizeOptions(host, schema);
|
12
13
|
createFiles(host, options);
|
@@ -61,8 +62,9 @@ async function normalizeOptions(host, options) {
|
|
61
62
|
: `use${className}`;
|
62
63
|
const hookTypeName = (0, devkit_1.names)(hookName).className;
|
63
64
|
const project = (0, devkit_1.getProjects)(host).get(projectName);
|
64
|
-
const { sourceRoot: projectSourceRoot, projectType } = project;
|
65
|
-
if (options.export &&
|
65
|
+
const { root, sourceRoot: projectSourceRoot, projectType } = project;
|
66
|
+
if (options.export &&
|
67
|
+
(0, ts_solution_setup_1.getProjectType)(host, root, projectType) === 'application') {
|
66
68
|
devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
|
67
69
|
}
|
68
70
|
return {
|
@@ -43,7 +43,7 @@ async function hostGenerator(host, schema) {
|
|
43
43
|
const initTask = await (0, application_1.default)(host, {
|
44
44
|
...options,
|
45
45
|
directory: options.appProjectRoot,
|
46
|
-
name: options.
|
46
|
+
name: options.name,
|
47
47
|
// The target use-case is loading remotes as child routes, thus always enable routing.
|
48
48
|
routing: true,
|
49
49
|
skipFormat: true,
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
2
2
|
import { InitSchema } from './schema';
|
3
|
-
export declare function reactInitGenerator(
|
3
|
+
export declare function reactInitGenerator(tree: Tree, schema: InitSchema): Promise<GeneratorCallback>;
|
4
4
|
export default reactInitGenerator;
|
@@ -3,19 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reactInitGenerator = reactInitGenerator;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
5
|
const versions_1 = require("../../utils/versions");
|
6
|
-
|
6
|
+
const version_utils_1 = require("../../utils/version-utils");
|
7
|
+
async function reactInitGenerator(tree, schema) {
|
7
8
|
const tasks = [];
|
8
9
|
if (!schema.skipPackageJson) {
|
9
|
-
tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(tree, ['@nx/react'], []));
|
11
|
+
const reactDeps = await (0, version_utils_1.getReactDependenciesVersionsToInstall)(tree);
|
12
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {
|
13
|
+
react: reactDeps.react,
|
14
|
+
'react-dom': reactDeps['react-dom'],
|
13
15
|
}, {
|
14
16
|
'@nx/react': versions_1.nxVersion,
|
15
17
|
}, undefined, schema.keepExistingVersions));
|
16
18
|
}
|
17
19
|
if (!schema.skipFormat) {
|
18
|
-
await (0, devkit_1.formatFiles)(
|
20
|
+
await (0, devkit_1.formatFiles)(tree);
|
19
21
|
}
|
20
22
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
21
23
|
}
|
@@ -22,6 +22,7 @@ const install_common_dependencies_1 = require("./lib/install-common-dependencies
|
|
22
22
|
const set_defaults_1 = require("./lib/set-defaults");
|
23
23
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
24
24
|
const determine_entry_fields_1 = require("./lib/determine-entry-fields");
|
25
|
+
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
25
26
|
async function libraryGenerator(host, schema) {
|
26
27
|
return await libraryGeneratorInternal(host, {
|
27
28
|
addPlugin: false,
|
@@ -36,6 +37,9 @@ async function libraryGeneratorInternal(host, schema) {
|
|
36
37
|
});
|
37
38
|
tasks.push(jsInitTask);
|
38
39
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
40
|
+
if (options.isUsingTsSolutionConfig) {
|
41
|
+
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
|
42
|
+
}
|
39
43
|
if (options.publishable === true && !schema.importPath) {
|
40
44
|
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
45
|
}
|
@@ -52,12 +56,11 @@ async function libraryGeneratorInternal(host, schema) {
|
|
52
56
|
name: options.importPath,
|
53
57
|
version: '0.0.1',
|
54
58
|
...(0, determine_entry_fields_1.determineEntryFields)(options),
|
55
|
-
nx:
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
},
|
59
|
+
nx: options.parsedTags?.length
|
60
|
+
? {
|
61
|
+
tags: options.parsedTags,
|
62
|
+
}
|
63
|
+
: undefined,
|
61
64
|
files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
|
62
65
|
});
|
63
66
|
}
|
@@ -206,9 +209,7 @@ async function libraryGeneratorInternal(host, schema) {
|
|
206
209
|
}, options.linter === 'eslint'
|
207
210
|
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
208
211
|
: undefined);
|
209
|
-
|
210
|
-
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
|
211
|
-
}
|
212
|
+
(0, sort_fields_1.sortPackageJsonFields)(host, options.projectRoot);
|
212
213
|
if (!options.skipFormat) {
|
213
214
|
await (0, devkit_1.formatFiles)(host);
|
214
215
|
}
|
@@ -8,6 +8,7 @@ const devkit_1 = require("@nx/devkit");
|
|
8
8
|
const js_1 = require("@nx/js");
|
9
9
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
10
10
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
11
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
11
12
|
let tsModule;
|
12
13
|
async function reduxGenerator(host, schema) {
|
13
14
|
const options = await normalizeOptions(host, schema);
|
@@ -88,12 +89,12 @@ async function normalizeOptions(host, options) {
|
|
88
89
|
const extraNames = (0, devkit_1.names)(name);
|
89
90
|
const projects = (0, devkit_1.getProjects)(host);
|
90
91
|
const project = projects.get(projectName);
|
91
|
-
const { sourceRoot, projectType } = project;
|
92
|
+
const { root, sourceRoot, projectType } = project;
|
92
93
|
const tsConfigJson = (0, devkit_1.readJson)(host, (0, js_1.getRootTsConfigPathInTree)(host));
|
93
94
|
const tsPaths = tsConfigJson.compilerOptions
|
94
95
|
? tsConfigJson.compilerOptions.paths || {}
|
95
96
|
: {};
|
96
|
-
const modulePath = projectType === 'application'
|
97
|
+
const modulePath = (0, ts_solution_setup_1.getProjectType)(host, root, projectType) === 'application'
|
97
98
|
? options.path
|
98
99
|
? `./app/${options.path}/${extraNames.fileName}.slice`
|
99
100
|
: `./app/${extraNames.fileName}.slice`
|
@@ -62,29 +62,29 @@ async function remoteGenerator(host, schema) {
|
|
62
62
|
if (options.dynamic) {
|
63
63
|
// Dynamic remotes generate with library { type: 'var' } by default.
|
64
64
|
// We need to ensure that the remote name is a valid variable name.
|
65
|
-
const isValidRemote = (0, js_1.isValidVariable)(options.
|
65
|
+
const isValidRemote = (0, js_1.isValidVariable)(options.name);
|
66
66
|
if (!isValidRemote.isValid) {
|
67
|
-
throw new Error(`Invalid remote name provided: ${options.
|
67
|
+
throw new Error(`Invalid remote name provided: ${options.name}. ${isValidRemote.message}`);
|
68
68
|
}
|
69
69
|
}
|
70
70
|
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
71
71
|
const REMOTE_NAME_REGEX = '^[a-zA-Z_$][a-zA-Z_$0-9]*$';
|
72
72
|
const remoteNameRegex = new RegExp(REMOTE_NAME_REGEX);
|
73
|
-
if (!remoteNameRegex.test(options.
|
74
|
-
throw new Error((0, devkit_1.stripIndents) `Invalid remote name: ${options.
|
73
|
+
if (!remoteNameRegex.test(options.name)) {
|
74
|
+
throw new Error((0, devkit_1.stripIndents) `Invalid remote name: ${options.name}. Remote project names must:
|
75
75
|
- Start with a letter, dollar sign ($) or underscore (_)
|
76
76
|
- Followed by any valid character (letters, digits, underscores, or dollar signs)
|
77
77
|
The regular expression used is ${REMOTE_NAME_REGEX}.`);
|
78
78
|
}
|
79
79
|
const initAppTask = await (0, application_1.default)(host, {
|
80
80
|
...options,
|
81
|
-
name: options.
|
81
|
+
name: options.name,
|
82
82
|
skipFormat: true,
|
83
83
|
alwaysGenerateProjectJson: true,
|
84
84
|
});
|
85
85
|
tasks.push(initAppTask);
|
86
|
-
if (
|
87
|
-
(0, update_host_with_remote_1.updateHostWithRemote)(host,
|
86
|
+
if (options.host) {
|
87
|
+
(0, update_host_with_remote_1.updateHostWithRemote)(host, options.host, options.name);
|
88
88
|
}
|
89
89
|
// Module federation requires bootstrap code to be dynamically imported.
|
90
90
|
// Renaming original entry file so we can use `import(./bootstrap)` in
|
@@ -11,10 +11,11 @@ const path_1 = require("path");
|
|
11
11
|
const minimatch_1 = require("minimatch");
|
12
12
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
13
13
|
const versions_1 = require("../../utils/versions");
|
14
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
14
15
|
let tsModule;
|
15
16
|
async function projectRootPath(tree, config) {
|
16
17
|
let projectDir;
|
17
|
-
if (config.projectType === 'application') {
|
18
|
+
if ((0, ts_solution_setup_1.getProjectType)(tree, config.root, config.projectType) === 'application') {
|
18
19
|
const isNextJs = await isNextJsProject(tree, config);
|
19
20
|
if (isNextJs) {
|
20
21
|
// Next.js apps
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
2
|
+
type ReactDependenciesVersions = {
|
3
|
+
react: string;
|
4
|
+
'react-dom': string;
|
5
|
+
'react-is': string;
|
6
|
+
'@types/react': string;
|
7
|
+
'@types/react-dom': string;
|
8
|
+
'@types/react-is': string;
|
9
|
+
};
|
10
|
+
export declare function getReactDependenciesVersionsToInstall(tree: Tree): Promise<ReactDependenciesVersions>;
|
11
|
+
export declare function isReact18(tree: Tree): Promise<boolean>;
|
12
|
+
export declare function getInstalledReactVersion(tree: Tree): string;
|
13
|
+
export declare function getInstalledReactVersionFromGraph(): Promise<string>;
|
14
|
+
export {};
|
@@ -0,0 +1,56 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getReactDependenciesVersionsToInstall = getReactDependenciesVersionsToInstall;
|
4
|
+
exports.isReact18 = isReact18;
|
5
|
+
exports.getInstalledReactVersion = getInstalledReactVersion;
|
6
|
+
exports.getInstalledReactVersionFromGraph = getInstalledReactVersionFromGraph;
|
7
|
+
const devkit_1 = require("@nx/devkit");
|
8
|
+
const semver_1 = require("semver");
|
9
|
+
const versions_1 = require("./versions");
|
10
|
+
async function getReactDependenciesVersionsToInstall(tree) {
|
11
|
+
if (await isReact18(tree)) {
|
12
|
+
return {
|
13
|
+
react: versions_1.reactV18Version,
|
14
|
+
'react-dom': versions_1.reactDomV18Version,
|
15
|
+
'react-is': versions_1.reactIsV18Version,
|
16
|
+
'@types/react': versions_1.typesReactV18Version,
|
17
|
+
'@types/react-dom': versions_1.typesReactDomV18Version,
|
18
|
+
'@types/react-is': versions_1.typesReactIsV18Version,
|
19
|
+
};
|
20
|
+
}
|
21
|
+
else {
|
22
|
+
return {
|
23
|
+
react: versions_1.reactVersion,
|
24
|
+
'react-dom': versions_1.reactDomVersion,
|
25
|
+
'react-is': versions_1.reactIsVersion,
|
26
|
+
'@types/react': versions_1.typesReactVersion,
|
27
|
+
'@types/react-dom': versions_1.typesReactDomVersion,
|
28
|
+
'@types/react-is': versions_1.typesReactIsVersion,
|
29
|
+
};
|
30
|
+
}
|
31
|
+
}
|
32
|
+
async function isReact18(tree) {
|
33
|
+
let installedReactVersion = await getInstalledReactVersionFromGraph();
|
34
|
+
if (!installedReactVersion) {
|
35
|
+
installedReactVersion = getInstalledReactVersion(tree);
|
36
|
+
}
|
37
|
+
return (0, semver_1.major)(installedReactVersion) === 18;
|
38
|
+
}
|
39
|
+
function getInstalledReactVersion(tree) {
|
40
|
+
const pkgJson = (0, devkit_1.readJson)(tree, 'package.json');
|
41
|
+
const installedReactVersion = pkgJson.dependencies && pkgJson.dependencies['react'];
|
42
|
+
if (!installedReactVersion ||
|
43
|
+
installedReactVersion === 'latest' ||
|
44
|
+
installedReactVersion === 'next') {
|
45
|
+
return (0, semver_1.clean)(versions_1.reactVersion) ?? (0, semver_1.coerce)(versions_1.reactVersion).version;
|
46
|
+
}
|
47
|
+
return (0, semver_1.clean)(installedReactVersion) ?? (0, semver_1.coerce)(installedReactVersion).version;
|
48
|
+
}
|
49
|
+
async function getInstalledReactVersionFromGraph() {
|
50
|
+
const graph = await (0, devkit_1.createProjectGraphAsync)();
|
51
|
+
const reactDep = graph.externalNodes?.['npm:react'];
|
52
|
+
if (!reactDep) {
|
53
|
+
return undefined;
|
54
|
+
}
|
55
|
+
return (0, semver_1.clean)(reactDep.data.version) ?? (0, semver_1.coerce)(reactDep.data.version).version;
|
56
|
+
}
|
package/src/utils/versions.d.ts
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
export declare const nxVersion: any;
|
2
|
-
export declare const reactVersion = "
|
3
|
-
export declare const
|
4
|
-
export declare const
|
2
|
+
export declare const reactVersion = "19.0.0";
|
3
|
+
export declare const reactV18Version = "18.3.1";
|
4
|
+
export declare const reactDomVersion = "19.0.0";
|
5
|
+
export declare const reactDomV18Version = "18.3.1";
|
6
|
+
export declare const reactIsVersion = "19.0.0";
|
7
|
+
export declare const reactIsV18Version = "18.3.1";
|
5
8
|
export declare const swcLoaderVersion = "0.1.15";
|
6
9
|
export declare const babelLoaderVersion = "^9.1.2";
|
7
|
-
export declare const
|
8
|
-
export declare const
|
9
|
-
export declare const
|
10
|
+
export declare const typesReactV18Version = "18.3.1";
|
11
|
+
export declare const typesReactVersion = "19.0.0";
|
12
|
+
export declare const typesReactDomV18Version = "18.3.0";
|
13
|
+
export declare const typesReactDomVersion = "19.0.0";
|
14
|
+
export declare const typesReactIsV18Version = "18.3.0";
|
15
|
+
export declare const typesReactIsVersion = "19.0.0";
|
10
16
|
export declare const reactViteVersion = "^4.2.0";
|
11
17
|
export declare const typesNodeVersion = "18.16.9";
|
12
18
|
export declare const babelPresetReactVersion = "^7.14.5";
|
@@ -18,7 +24,8 @@ export declare const emotionReactVersion = "11.11.1";
|
|
18
24
|
export declare const emotionBabelPlugin = "11.11.0";
|
19
25
|
export declare const styledJsxVersion = "5.1.2";
|
20
26
|
export declare const reactRouterDomVersion = "6.11.2";
|
21
|
-
export declare const testingLibraryReactVersion = "
|
27
|
+
export declare const testingLibraryReactVersion = "16.1.0";
|
28
|
+
export declare const testingLibraryDomVersion = "10.4.0";
|
22
29
|
export declare const reduxjsToolkitVersion = "1.9.3";
|
23
30
|
export declare const reactReduxVersion = "8.0.5";
|
24
31
|
export declare const eslintPluginImportVersion = "2.31.0";
|
package/src/utils/versions.js
CHANGED
@@ -1,15 +1,22 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
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.testingLibraryDomVersion = 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.typesReactIsV18Version = exports.typesReactDomVersion = exports.typesReactDomV18Version = exports.typesReactVersion = exports.typesReactV18Version = exports.babelLoaderVersion = exports.swcLoaderVersion = exports.reactIsV18Version = exports.reactIsVersion = exports.reactDomV18Version = exports.reactDomVersion = exports.reactV18Version = exports.reactVersion = exports.nxVersion = void 0;
|
4
|
+
exports.swcPluginStyledComponentsVersion = exports.swcPluginEmotionVersion = exports.swcPluginStyledJsxVersion = void 0;
|
4
5
|
exports.nxVersion = require('../../package.json').version;
|
5
|
-
exports.reactVersion = '
|
6
|
-
exports.
|
7
|
-
exports.
|
6
|
+
exports.reactVersion = '19.0.0';
|
7
|
+
exports.reactV18Version = '18.3.1';
|
8
|
+
exports.reactDomVersion = '19.0.0';
|
9
|
+
exports.reactDomV18Version = '18.3.1';
|
10
|
+
exports.reactIsVersion = '19.0.0';
|
11
|
+
exports.reactIsV18Version = '18.3.1';
|
8
12
|
exports.swcLoaderVersion = '0.1.15';
|
9
13
|
exports.babelLoaderVersion = '^9.1.2';
|
10
|
-
exports.
|
11
|
-
exports.
|
12
|
-
exports.
|
14
|
+
exports.typesReactV18Version = '18.3.1';
|
15
|
+
exports.typesReactVersion = '19.0.0';
|
16
|
+
exports.typesReactDomV18Version = '18.3.0';
|
17
|
+
exports.typesReactDomVersion = '19.0.0';
|
18
|
+
exports.typesReactIsV18Version = '18.3.0';
|
19
|
+
exports.typesReactIsVersion = '19.0.0';
|
13
20
|
exports.reactViteVersion = '^4.2.0';
|
14
21
|
exports.typesNodeVersion = '18.16.9';
|
15
22
|
exports.babelPresetReactVersion = '^7.14.5';
|
@@ -22,7 +29,8 @@ exports.emotionBabelPlugin = '11.11.0';
|
|
22
29
|
// WARNING: This needs to be in sync with Next.js' dependency or else there might be issues.
|
23
30
|
exports.styledJsxVersion = '5.1.2';
|
24
31
|
exports.reactRouterDomVersion = '6.11.2';
|
25
|
-
exports.testingLibraryReactVersion = '
|
32
|
+
exports.testingLibraryReactVersion = '16.1.0';
|
33
|
+
exports.testingLibraryDomVersion = '10.4.0';
|
26
34
|
exports.reduxjsToolkitVersion = '1.9.3';
|
27
35
|
exports.reactReduxVersion = '8.0.5';
|
28
36
|
exports.eslintPluginImportVersion = '2.31.0';
|