@nx/react 17.0.0-rc.0 → 17.0.0-rc.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/babel.d.ts +3 -0
- package/package.json +6 -6
- package/src/generators/application/lib/normalize-options.js +2 -4
- package/src/generators/component/component.js +1 -1
- package/src/generators/component/lib/normalize-options.js +1 -1
- package/src/generators/component/schema.d.ts +2 -1
- package/src/generators/federate-module/federate-module.js +21 -8
- package/src/generators/federate-module/schema.d.ts +1 -0
- package/src/generators/federate-module/schema.json +8 -42
- package/src/generators/hook/hook.js +3 -2
- package/src/generators/redux/redux.js +1 -1
- package/src/generators/redux/schema.d.ts +4 -1
- package/src/generators/stories/schema.json +3 -0
- package/src/generators/storybook-configuration/schema.json +3 -0
package/babel.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "17.0.0-rc.
|
|
3
|
+
"version": "17.0.0-rc.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, 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": {
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"file-loader": "^6.2.0",
|
|
38
38
|
"minimatch": "3.0.5",
|
|
39
39
|
"tslib": "^2.3.0",
|
|
40
|
-
"@nx/devkit": "17.0.0-rc.
|
|
41
|
-
"@nx/js": "17.0.0-rc.
|
|
42
|
-
"@nx/eslint": "17.0.0-rc.
|
|
43
|
-
"@nx/web": "17.0.0-rc.
|
|
44
|
-
"@nrwl/react": "17.0.0-rc.
|
|
40
|
+
"@nx/devkit": "17.0.0-rc.2",
|
|
41
|
+
"@nx/js": "17.0.0-rc.2",
|
|
42
|
+
"@nx/eslint": "17.0.0-rc.2",
|
|
43
|
+
"@nx/web": "17.0.0-rc.2",
|
|
44
|
+
"@nrwl/react": "17.0.0-rc.2"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
@@ -38,7 +38,7 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/react:app
|
|
|
38
38
|
? null
|
|
39
39
|
: options.style;
|
|
40
40
|
(0, assertion_1.assertValidStyle)(options.style);
|
|
41
|
-
if (options.bundler === 'vite') {
|
|
41
|
+
if (options.bundler === 'vite' && options.unitTestRunner !== 'none') {
|
|
42
42
|
options.unitTestRunner = 'vitest';
|
|
43
43
|
}
|
|
44
44
|
const normalized = {
|
|
@@ -58,9 +58,7 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/react:app
|
|
|
58
58
|
normalized.classComponent = normalized.classComponent ?? false;
|
|
59
59
|
normalized.compiler = normalized.compiler ?? 'babel';
|
|
60
60
|
normalized.bundler = normalized.bundler ?? 'webpack';
|
|
61
|
-
normalized.unitTestRunner =
|
|
62
|
-
normalized.unitTestRunner ??
|
|
63
|
-
(normalized.bundler === 'vite' ? 'vitest' : 'jest');
|
|
61
|
+
normalized.unitTestRunner = normalized.unitTestRunner ?? 'jest';
|
|
64
62
|
normalized.e2eTestRunner = normalized.e2eTestRunner ?? 'cypress';
|
|
65
63
|
normalized.inSourceTests = normalized.minimal || normalized.inSourceTests;
|
|
66
64
|
normalized.devServerPort ??= (0, find_free_port_1.findFreePort)(host);
|
|
@@ -73,7 +73,7 @@ function addExportsToBarrel(host, options) {
|
|
|
73
73
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
74
74
|
}
|
|
75
75
|
const workspace = (0, devkit_1.getProjects)(host);
|
|
76
|
-
const isApp = workspace.get(options.
|
|
76
|
+
const isApp = workspace.get(options.projectName).projectType === 'application';
|
|
77
77
|
if (options.export && !isApp) {
|
|
78
78
|
const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts');
|
|
79
79
|
const indexSource = host.read(indexFilePath, 'utf-8');
|
|
@@ -5,7 +5,7 @@ export interface Schema {
|
|
|
5
5
|
/**
|
|
6
6
|
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18.
|
|
7
7
|
*/
|
|
8
|
-
project
|
|
8
|
+
project?: string;
|
|
9
9
|
style: SupportedStyles;
|
|
10
10
|
skipTests?: boolean;
|
|
11
11
|
directory?: string;
|
|
@@ -37,6 +37,7 @@ export interface Schema {
|
|
|
37
37
|
|
|
38
38
|
export interface NormalizedSchema extends Schema {
|
|
39
39
|
projectSourceRoot: string;
|
|
40
|
+
projectName: string;
|
|
40
41
|
fileName: string;
|
|
41
42
|
filePath: string;
|
|
42
43
|
className: string;
|
|
@@ -7,19 +7,21 @@ const utils_1 = require("./lib/utils");
|
|
|
7
7
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
8
8
|
const js_1 = require("@nx/js");
|
|
9
9
|
async function federateModuleGenerator(tree, schema) {
|
|
10
|
+
// Check if the file exists
|
|
11
|
+
if (!tree.exists(schema.path)) {
|
|
12
|
+
throw new Error((0, devkit_1.stripIndents) `The "path" provided does not exist. Please verify the path is correct and pointing to a file that exists in the workspace.
|
|
13
|
+
|
|
14
|
+
Path: ${schema.path}`);
|
|
15
|
+
}
|
|
10
16
|
const tasks = [];
|
|
11
17
|
// Check remote exists
|
|
12
18
|
const remote = (0, utils_1.checkRemoteExists)(tree, schema.remote);
|
|
13
|
-
|
|
14
|
-
name: schema.remote,
|
|
15
|
-
projectType: 'application',
|
|
16
|
-
projectNameAndRootFormat: schema.projectNameAndRootFormat,
|
|
17
|
-
callingGenerator: '@nx/react:federate-module',
|
|
18
|
-
});
|
|
19
|
+
let projectRoot, remoteName;
|
|
19
20
|
if (!remote) {
|
|
20
21
|
// create remote
|
|
21
22
|
const remoteGenerator = await (0, remote_1.remoteGeneratorInternal)(tree, {
|
|
22
23
|
name: schema.remote,
|
|
24
|
+
directory: schema.remoteDirectory,
|
|
23
25
|
e2eTestRunner: schema.e2eTestRunner,
|
|
24
26
|
skipFormat: schema.skipFormat,
|
|
25
27
|
linter: schema.linter,
|
|
@@ -29,9 +31,20 @@ async function federateModuleGenerator(tree, schema) {
|
|
|
29
31
|
projectNameAndRootFormat: schema.projectNameAndRootFormat ?? 'derived',
|
|
30
32
|
});
|
|
31
33
|
tasks.push(remoteGenerator);
|
|
34
|
+
const { projectName, projectRoot: remoteRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
35
|
+
name: schema.remote,
|
|
36
|
+
directory: schema.remoteDirectory,
|
|
37
|
+
projectType: 'application',
|
|
38
|
+
projectNameAndRootFormat: schema.projectNameAndRootFormat ?? 'derived',
|
|
39
|
+
callingGenerator: '@nx/react:federate-module',
|
|
40
|
+
});
|
|
41
|
+
projectRoot = remoteRoot;
|
|
42
|
+
remoteName = projectName;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
projectRoot = remote.root;
|
|
46
|
+
remoteName = remote.name;
|
|
32
47
|
}
|
|
33
|
-
const projectRoot = remote ? remote.root : remoteRoot;
|
|
34
|
-
const remoteName = remote ? remote.name : projectName;
|
|
35
48
|
// add path to exposes property
|
|
36
49
|
(0, utils_1.addPathToExposes)(tree, projectRoot, schema.name, schema.path);
|
|
37
50
|
// Add new path to tsconfig
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "Create a federated module, which can be loaded by a remote host.",
|
|
7
7
|
"examples": [
|
|
8
8
|
{
|
|
9
|
-
"command": "nx g federate-module MyModule --path=./src/component/my-cmp.ts --remote=my-remote-app",
|
|
9
|
+
"command": "nx g federate-module MyModule --path=./src/component/my-cmp.ts --remote=my-remote-app --remoteDirectory=apps/my-remote-app",
|
|
10
10
|
"description": "Create a federated module from my-remote-app, that exposes my-cmp from ./src/component/my-cmp.ts as MyModule."
|
|
11
11
|
}
|
|
12
12
|
],
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"path": {
|
|
27
27
|
"type": "string",
|
|
28
|
-
"description": "The path to locate the federated module.",
|
|
28
|
+
"description": "The path to locate the federated module. This path should be relative to the workspace root and the file should exist.",
|
|
29
29
|
"x-prompt": "What is the path to the module to be federated?"
|
|
30
30
|
},
|
|
31
31
|
"remote": {
|
|
@@ -33,6 +33,10 @@
|
|
|
33
33
|
"description": "The name of the remote.",
|
|
34
34
|
"x-prompt": "What is/should the remote be named?"
|
|
35
35
|
},
|
|
36
|
+
"remoteDirectory": {
|
|
37
|
+
"description": "The directory of the new remote application if one needs to be created.",
|
|
38
|
+
"type": "string"
|
|
39
|
+
},
|
|
36
40
|
"projectNameAndRootFormat": {
|
|
37
41
|
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
38
42
|
"type": "string",
|
|
@@ -41,46 +45,8 @@
|
|
|
41
45
|
"style": {
|
|
42
46
|
"description": "The file extension to be used for style files.",
|
|
43
47
|
"type": "string",
|
|
44
|
-
"default": "
|
|
45
|
-
"alias": "s"
|
|
46
|
-
"x-prompt": {
|
|
47
|
-
"message": "Which stylesheet format would you like to use?",
|
|
48
|
-
"type": "list",
|
|
49
|
-
"items": [
|
|
50
|
-
{
|
|
51
|
-
"value": "css",
|
|
52
|
-
"label": "CSS"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"value": "scss",
|
|
56
|
-
"label": "SASS(.scss) [ http://sass-lang.com ]"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"value": "less",
|
|
60
|
-
"label": "LESS [ http://lesscss.org ]"
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"value": "styled-components",
|
|
64
|
-
"label": "styled-components [ https://styled-components.com ]"
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"value": "@emotion/styled",
|
|
68
|
-
"label": "emotion [ https://emotion.sh ]"
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"value": "styled-jsx",
|
|
72
|
-
"label": "styled-jsx [ https://www.npmjs.com/package/styled-jsx ]"
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"value": "styl",
|
|
76
|
-
"label": "DEPRECATD: Stylus(.styl) [ http://stylus-lang.com ]"
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
"value": "none",
|
|
80
|
-
"label": "None"
|
|
81
|
-
}
|
|
82
|
-
]
|
|
83
|
-
}
|
|
48
|
+
"default": "none",
|
|
49
|
+
"alias": "s"
|
|
84
50
|
},
|
|
85
51
|
"linter": {
|
|
86
52
|
"description": "The tool to use for running lint checks.",
|
|
@@ -45,7 +45,7 @@ function addExportsToBarrel(host, options) {
|
|
|
45
45
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
46
46
|
}
|
|
47
47
|
const workspace = (0, devkit_1.getProjects)(host);
|
|
48
|
-
const isApp = workspace.get(options.
|
|
48
|
+
const isApp = workspace.get(options.projectName).projectType === 'application';
|
|
49
49
|
if (options.export && !isApp) {
|
|
50
50
|
const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts');
|
|
51
51
|
const indexSource = host.read(indexFilePath, 'utf-8');
|
|
@@ -88,7 +88,7 @@ async function normalizeOptions(host, options) {
|
|
|
88
88
|
: 'use-'.concat(fileName);
|
|
89
89
|
const hookName = 'use'.concat(className);
|
|
90
90
|
const hookTypeName = 'Use'.concat(className);
|
|
91
|
-
const project = (0, devkit_1.getProjects)(host).get(
|
|
91
|
+
const project = (0, devkit_1.getProjects)(host).get(projectName);
|
|
92
92
|
const { sourceRoot: projectSourceRoot, projectType } = project;
|
|
93
93
|
if (options.export && projectType === 'application') {
|
|
94
94
|
devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
|
|
@@ -112,6 +112,7 @@ async function normalizeOptions(host, options) {
|
|
|
112
112
|
hookTypeName,
|
|
113
113
|
fileName: hookFilename,
|
|
114
114
|
projectSourceRoot,
|
|
115
|
+
projectName,
|
|
115
116
|
};
|
|
116
117
|
}
|
|
117
118
|
function assertValidOptions(options) {
|
|
@@ -115,7 +115,7 @@ async function normalizeOptions(host, options) {
|
|
|
115
115
|
// for it without needing to specify --appProject.
|
|
116
116
|
options.appProject =
|
|
117
117
|
options.appProject ||
|
|
118
|
-
(projectType === 'application' ?
|
|
118
|
+
(projectType === 'application' ? projectName : undefined);
|
|
119
119
|
if (options.appProject) {
|
|
120
120
|
const appConfig = projects.get(options.appProject);
|
|
121
121
|
if (appConfig.projectType !== 'application') {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export interface Schema {
|
|
2
2
|
name: string;
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18.
|
|
5
|
+
*/
|
|
6
|
+
project?: string;
|
|
4
7
|
directory?: string;
|
|
5
8
|
appProject?: string;
|
|
6
9
|
js?: string;
|