@nx/react 20.1.2 → 20.1.4
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/component/schema.d.ts +0 -1
- package/src/generators/component/schema.json +3 -5
- package/src/generators/hook/hook.js +10 -25
- package/src/generators/hook/schema.d.ts +0 -2
- package/src/generators/hook/schema.json +10 -18
- package/src/generators/redux/schema.json +13 -4
- package/src/module-federation/with-module-federation-ssr.js +9 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/react",
|
3
|
-
"version": "20.1.
|
3
|
+
"version": "20.1.4",
|
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
|
-
"@module-federation/enhanced": "0.6
|
42
|
-
"@nx/devkit": "20.1.
|
43
|
-
"@nx/js": "20.1.
|
44
|
-
"@nx/eslint": "20.1.
|
45
|
-
"@nx/web": "20.1.
|
41
|
+
"@module-federation/enhanced": "0.7.6",
|
42
|
+
"@nx/devkit": "20.1.4",
|
43
|
+
"@nx/js": "20.1.4",
|
44
|
+
"@nx/eslint": "20.1.4",
|
45
|
+
"@nx/web": "20.1.4",
|
46
46
|
"express": "^4.19.2",
|
47
47
|
"http-proxy-middleware": "^3.0.3"
|
48
48
|
},
|
@@ -8,19 +8,17 @@
|
|
8
8
|
"properties": {
|
9
9
|
"path": {
|
10
10
|
"type": "string",
|
11
|
-
"description": "
|
11
|
+
"description": "The file path to the component without the file extension. Relative to the current working directory.",
|
12
12
|
"$default": {
|
13
13
|
"$source": "argv",
|
14
14
|
"index": 0
|
15
15
|
},
|
16
|
-
"x-prompt": "
|
16
|
+
"x-prompt": "What is the component file path?",
|
17
17
|
"x-priority": "important"
|
18
18
|
},
|
19
19
|
"name": {
|
20
20
|
"type": "string",
|
21
|
-
"description": "The name of the
|
22
|
-
"x-prompt": "What name would you like to use for the component?",
|
23
|
-
"x-priority": "important"
|
21
|
+
"description": "The component symbol name. Defaults to the last segment of the file path."
|
24
22
|
},
|
25
23
|
"style": {
|
26
24
|
"description": "The file extension to be used for style files.",
|
@@ -49,22 +49,20 @@ function addExportsToBarrel(host, options) {
|
|
49
49
|
}
|
50
50
|
}
|
51
51
|
async function normalizeOptions(host, options) {
|
52
|
-
|
53
|
-
const { directory, fileName: _fileName, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
52
|
+
const { artifactName, directory, fileName: hookFilename, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
54
53
|
path: options.path,
|
55
54
|
name: options.name,
|
56
55
|
fileExtension: 'tsx',
|
57
56
|
});
|
58
|
-
const { className
|
59
|
-
//
|
60
|
-
//
|
61
|
-
const
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
: 'Use'.concat(className);
|
57
|
+
const { className } = (0, devkit_1.names)(hookFilename);
|
58
|
+
// if name is provided, use it as is for the hook name, otherwise prepend
|
59
|
+
// `use` to the pascal-cased file name if it doesn't already start with `use`
|
60
|
+
const hookName = options.name
|
61
|
+
? artifactName
|
62
|
+
: className.toLocaleLowerCase().startsWith('use')
|
63
|
+
? className
|
64
|
+
: `use${className}`;
|
65
|
+
const hookTypeName = (0, devkit_1.names)(hookName).className;
|
68
66
|
const project = (0, devkit_1.getProjects)(host).get(projectName);
|
69
67
|
const { sourceRoot: projectSourceRoot, projectType } = project;
|
70
68
|
if (options.export && projectType === 'application') {
|
@@ -80,17 +78,4 @@ async function normalizeOptions(host, options) {
|
|
80
78
|
projectName,
|
81
79
|
};
|
82
80
|
}
|
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
|
-
}
|
96
81
|
exports.default = hookGenerator;
|
@@ -7,26 +7,28 @@
|
|
7
7
|
"type": "object",
|
8
8
|
"examples": [
|
9
9
|
{
|
10
|
-
"
|
11
|
-
"
|
10
|
+
"description": "Generate a hook with the exported symbol matching the file name. It results in the hook `useFoo` at `mylib/src/lib/foo.ts`",
|
11
|
+
"command": "nx g @nx/react:hook mylib/src/lib/foo"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"description": "Generate a hook with the exported symbol different from the file name. It results in the hook `useCustom` at `mylib/src/lib/foo.ts`",
|
15
|
+
"command": "nx g @nx/react:hook mylib/src/lib/foo --name=useCustom"
|
12
16
|
}
|
13
17
|
],
|
14
18
|
"properties": {
|
15
19
|
"path": {
|
16
20
|
"type": "string",
|
17
|
-
"description": "
|
21
|
+
"description": "The file path to the hook without the file extension. Relative to the current working directory.",
|
18
22
|
"$default": {
|
19
23
|
"$source": "argv",
|
20
24
|
"index": 0
|
21
25
|
},
|
22
|
-
"x-prompt": "
|
26
|
+
"x-prompt": "What is the hook file path?",
|
23
27
|
"x-priority": "important"
|
24
28
|
},
|
25
29
|
"name": {
|
26
30
|
"type": "string",
|
27
|
-
"description": "The name of the
|
28
|
-
"x-prompt": "What name would you like to use for the hook?",
|
29
|
-
"x-priority": "important"
|
31
|
+
"description": "The hook symbol name. Defaults to the last segment of the file path."
|
30
32
|
},
|
31
33
|
"js": {
|
32
34
|
"type": "boolean",
|
@@ -39,16 +41,6 @@
|
|
39
41
|
"default": false,
|
40
42
|
"x-priority": "internal"
|
41
43
|
},
|
42
|
-
"directory": {
|
43
|
-
"type": "string",
|
44
|
-
"description": "The directory at which to create the hook file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the project root.",
|
45
|
-
"x-priority": "important"
|
46
|
-
},
|
47
|
-
"nameAndDirectoryFormat": {
|
48
|
-
"description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
|
49
|
-
"type": "string",
|
50
|
-
"enum": ["as-provided", "derived"]
|
51
|
-
},
|
52
44
|
"export": {
|
53
45
|
"type": "boolean",
|
54
46
|
"description": "When true, the hook is exported from the project `index.ts` (if it exists).",
|
@@ -57,5 +49,5 @@
|
|
57
49
|
"x-prompt": "Should this hook be exported in the project?"
|
58
50
|
}
|
59
51
|
},
|
60
|
-
"required": ["
|
52
|
+
"required": ["path"]
|
61
53
|
}
|
@@ -5,21 +5,30 @@
|
|
5
5
|
"title": "Create Redux state",
|
6
6
|
"description": "Create a Redux state slice for a React project.",
|
7
7
|
"type": "object",
|
8
|
+
"examples": [
|
9
|
+
{
|
10
|
+
"description": "Generate a Redux state slice with the exported symbol matching the file name. It results in the slice `fooSlice` at `mylib/src/lib/foo.slice.ts`",
|
11
|
+
"command": "nx g @nx/react:redux mylib/src/lib/foo"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"description": "Generate a Redux state slice with the exported symbol different from the file name. It results in the slice `customSlice` at `mylib/src/lib/foo.slice.ts`",
|
15
|
+
"command": "nx g @nx/react:redux mylib/src/lib/foo --name=custom"
|
16
|
+
}
|
17
|
+
],
|
8
18
|
"properties": {
|
9
19
|
"path": {
|
10
20
|
"type": "string",
|
11
|
-
"description": "
|
21
|
+
"description": "The file path to the Redux state slice without the file extension. Relative to the current working directory.",
|
12
22
|
"$default": {
|
13
23
|
"$source": "argv",
|
14
24
|
"index": 0
|
15
25
|
},
|
16
|
-
"x-prompt": "
|
26
|
+
"x-prompt": "What is the Redux stateslice file path?",
|
17
27
|
"x-priority": "important"
|
18
28
|
},
|
19
29
|
"name": {
|
20
30
|
"type": "string",
|
21
|
-
"description": "Redux slice name."
|
22
|
-
"x-priority": "important"
|
31
|
+
"description": "The Redux state slice symbol name. Defaults to the last segment of the file path."
|
23
32
|
},
|
24
33
|
"appProject": {
|
25
34
|
"type": "string",
|
@@ -24,10 +24,19 @@ async function withModuleFederationForSSR(options, configOverride) {
|
|
24
24
|
shared: {
|
25
25
|
...sharedDependencies,
|
26
26
|
},
|
27
|
+
remoteType: 'script',
|
28
|
+
library: {
|
29
|
+
type: 'commonjs-module',
|
30
|
+
},
|
27
31
|
/**
|
28
32
|
* Apply user-defined config overrides
|
29
33
|
*/
|
30
34
|
...(configOverride ? configOverride : {}),
|
35
|
+
experiments: {
|
36
|
+
federationRuntime: 'hoisted',
|
37
|
+
// We should allow users to override federationRuntime
|
38
|
+
...(configOverride?.experiments ?? {}),
|
39
|
+
},
|
31
40
|
runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
|
32
41
|
!options.disableNxRuntimeLibraryControlPlugin
|
33
42
|
? [
|