@nx/react 20.0.0-canary.20241001-8fa7065 → 20.0.0-canary.20241002-1d10a19
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 +2 -2
- package/src/generators/application/lib/normalize-options.js +2 -3
- package/src/generators/application/lib/show-possible-warnings.js +2 -2
- package/src/generators/application/schema.d.ts +2 -4
- package/src/generators/application/schema.json +11 -16
- package/src/generators/component/lib/normalize-options.js +2 -3
- package/src/generators/component/schema.d.ts +3 -3
- package/src/generators/component/schema.json +9 -14
- package/src/generators/federate-module/federate-module.js +10 -19
- package/src/generators/federate-module/schema.d.ts +0 -1
- package/src/generators/federate-module/schema.json +0 -5
- package/src/generators/hook/hook.js +1 -2
- package/src/generators/hook/schema.d.ts +2 -3
- package/src/generators/hook/schema.json +10 -4
- package/src/generators/host/host.js +2 -1
- package/src/generators/host/lib/normalize-remote.js +0 -1
- package/src/generators/host/schema.d.ts +2 -4
- package/src/generators/host/schema.json +8 -14
- package/src/generators/library/lib/normalize-options.js +1 -1
- package/src/generators/library/library.js +2 -3
- package/src/generators/library/schema.d.ts +2 -4
- package/src/generators/library/schema.json +11 -15
- package/src/generators/redux/redux.js +8 -9
- package/src/generators/redux/schema.d.ts +3 -5
- package/src/generators/redux/schema.json +6 -12
- package/src/generators/remote/remote.js +2 -0
- package/src/generators/remote/schema.d.ts +2 -4
- package/src/generators/remote/schema.json +8 -14
- package/src/generators/setup-ssr/setup-ssr.js +6 -0
- package/src/utils/testing-generators.js +1 -2
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/react",
|
3
|
-
"version": "20.0.0-canary.
|
3
|
+
"version": "20.0.0-canary.20241002-1d10a19",
|
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": {
|
@@ -34,15 +34,15 @@
|
|
34
34
|
"dependencies": {
|
35
35
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
36
36
|
"@svgr/webpack": "^8.0.1",
|
37
|
-
"chalk": "^4.1.0",
|
38
37
|
"file-loader": "^6.2.0",
|
39
38
|
"minimatch": "9.0.3",
|
39
|
+
"picocolors": "^1.1.0",
|
40
40
|
"tslib": "^2.3.0",
|
41
41
|
"@module-federation/enhanced": "0.6.6",
|
42
|
-
"@nx/devkit": "20.0.0-canary.
|
43
|
-
"@nx/js": "20.0.0-canary.
|
44
|
-
"@nx/eslint": "20.0.0-canary.
|
45
|
-
"@nx/web": "20.0.0-canary.
|
42
|
+
"@nx/devkit": "20.0.0-canary.20241002-1d10a19",
|
43
|
+
"@nx/js": "20.0.0-canary.20241002-1d10a19",
|
44
|
+
"@nx/eslint": "20.0.0-canary.20241002-1d10a19",
|
45
|
+
"@nx/web": "20.0.0-canary.20241002-1d10a19",
|
46
46
|
"express": "^4.19.2",
|
47
47
|
"http-proxy-middleware": "^3.0.0"
|
48
48
|
},
|
@@ -19,7 +19,7 @@ const maybe_js_1 = require("../../utils/maybe-js");
|
|
19
19
|
const install_common_dependencies_1 = require("./lib/install-common-dependencies");
|
20
20
|
const create_ts_config_1 = require("../../utils/create-ts-config");
|
21
21
|
const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
|
22
|
-
const
|
22
|
+
const pc = require("picocolors");
|
23
23
|
const show_possible_warnings_1 = require("./lib/show-possible-warnings");
|
24
24
|
const add_e2e_1 = require("./lib/add-e2e");
|
25
25
|
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
@@ -226,7 +226,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
226
226
|
tasks.push(routingTask);
|
227
227
|
(0, set_defaults_1.setDefaults)(host, options);
|
228
228
|
if (options.bundler === 'rspack' && options.style === 'styled-jsx') {
|
229
|
-
devkit_1.logger.warn(`${
|
229
|
+
devkit_1.logger.warn(`${pc.bold('styled-jsx')} is not supported by ${pc.bold('Rspack')}. We've added ${pc.bold('babel-loader')} to your project, but using babel will slow down your build.`);
|
230
230
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {}, { 'babel-loader': versions_1.babelLoaderVersion }));
|
231
231
|
host.write((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'rspack.config.js'), (0, devkit_1.stripIndents) `
|
232
232
|
const { composePlugins, withNx, withReact } = require('@nx/rspack');
|
@@ -18,11 +18,11 @@ function normalizeProjectName(options) {
|
|
18
18
|
return normalizeDirectory(options).replace(new RegExp('/', 'g'), '-');
|
19
19
|
}
|
20
20
|
async function normalizeOptions(host, options) {
|
21
|
-
|
21
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
22
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
22
23
|
name: options.name,
|
23
24
|
projectType: 'application',
|
24
25
|
directory: options.directory,
|
25
|
-
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
26
26
|
rootProject: options.rootProject,
|
27
27
|
});
|
28
28
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
@@ -30,7 +30,6 @@ async function normalizeOptions(host, options) {
|
|
30
30
|
nxJson.useInferencePlugins !== false;
|
31
31
|
options.addPlugin ??= addPlugin;
|
32
32
|
options.rootProject = appProjectRoot === '.';
|
33
|
-
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
34
33
|
const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
35
34
|
const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
36
35
|
const parsedTags = options.tags
|
@@ -1,10 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.showPossibleWarnings = showPossibleWarnings;
|
4
|
-
const
|
4
|
+
const pc = require("picocolors");
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
6
6
|
function showPossibleWarnings(tree, options) {
|
7
7
|
if (options.style === 'styled-jsx' && options.compiler === 'swc') {
|
8
|
-
devkit_1.logger.warn(`styled-jsx may not work with SWC. Try using ${
|
8
|
+
devkit_1.logger.warn(`styled-jsx may not work with SWC. Try using ${pc.bold('nx g @nx/react:app --compiler=babel')} instead.`);
|
9
9
|
}
|
10
10
|
}
|
@@ -1,13 +1,11 @@
|
|
1
|
-
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
2
1
|
import type { Linter, LinterType } from '@nx/eslint';
|
3
2
|
import type { SupportedStyles } from '../../../typings/style';
|
4
3
|
|
5
4
|
export interface Schema {
|
6
|
-
|
5
|
+
directory: string;
|
6
|
+
name?: string;
|
7
7
|
style: SupportedStyles;
|
8
8
|
skipFormat?: boolean;
|
9
|
-
directory?: string;
|
10
|
-
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
11
9
|
tags?: string;
|
12
10
|
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
13
11
|
inSourceTests?: boolean;
|
@@ -6,41 +6,36 @@
|
|
6
6
|
"description": "Create a React application for Nx.",
|
7
7
|
"examples": [
|
8
8
|
{
|
9
|
-
"command": "nx g app myapp
|
9
|
+
"command": "nx g app apps/myorg/myapp",
|
10
10
|
"description": "Generate `apps/myorg/myapp` and `apps/myorg/myapp-e2e`"
|
11
11
|
},
|
12
12
|
{
|
13
|
-
"command": "nx g app myapp --classComponent",
|
13
|
+
"command": "nx g app apps/myapp --classComponent",
|
14
14
|
"description": "Use class components instead of functional components"
|
15
15
|
},
|
16
16
|
{
|
17
|
-
"command": "nx g app myapp --routing",
|
17
|
+
"command": "nx g app apps/myapp --routing",
|
18
18
|
"description": "Set up React Router"
|
19
19
|
}
|
20
20
|
],
|
21
21
|
"type": "object",
|
22
22
|
"properties": {
|
23
|
-
"
|
24
|
-
"description": "The
|
23
|
+
"directory": {
|
24
|
+
"description": "The directory of the new application.",
|
25
25
|
"type": "string",
|
26
|
+
"alias": "dir",
|
26
27
|
"$default": {
|
27
28
|
"$source": "argv",
|
28
29
|
"index": 0
|
29
30
|
},
|
30
|
-
"x-prompt": "
|
31
|
-
"pattern": "^[a-zA-Z][^:]*$"
|
31
|
+
"x-prompt": "Which directory do you want to create the application in?"
|
32
32
|
},
|
33
|
-
"
|
34
|
-
"description": "The
|
33
|
+
"name": {
|
34
|
+
"description": "The name of the application.",
|
35
35
|
"type": "string",
|
36
|
-
"
|
36
|
+
"pattern": "^[a-zA-Z][^:]*$",
|
37
37
|
"x-priority": "important"
|
38
38
|
},
|
39
|
-
"projectNameAndRootFormat": {
|
40
|
-
"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`).",
|
41
|
-
"type": "string",
|
42
|
-
"enum": ["as-provided", "derived"]
|
43
|
-
},
|
44
39
|
"style": {
|
45
40
|
"description": "The file extension to be used for style files.",
|
46
41
|
"type": "string",
|
@@ -190,6 +185,6 @@
|
|
190
185
|
"default": false
|
191
186
|
}
|
192
187
|
},
|
193
|
-
"required": ["
|
188
|
+
"required": ["directory"],
|
194
189
|
"examplesFile": "../../../docs/application-examples.md"
|
195
190
|
}
|
@@ -7,9 +7,8 @@ const assertion_1 = require("../../../utils/assertion");
|
|
7
7
|
async function normalizeOptions(tree, options) {
|
8
8
|
(0, assertion_1.assertValidStyle)(options.style);
|
9
9
|
const { artifactName: name, directory, fileName, filePath, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
10
|
+
path: options.path,
|
10
11
|
name: options.name,
|
11
|
-
directory: options.directory,
|
12
|
-
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
13
12
|
fileExtension: 'tsx',
|
14
13
|
fileName: options.fileName,
|
15
14
|
});
|
@@ -30,8 +29,8 @@ async function normalizeOptions(tree, options) {
|
|
30
29
|
options.isNextPage = options.isNextPage ?? false;
|
31
30
|
return {
|
32
31
|
...options,
|
33
|
-
projectName,
|
34
32
|
directory,
|
33
|
+
projectName,
|
35
34
|
styledModule,
|
36
35
|
hasStyles: options.style !== 'none',
|
37
36
|
className,
|
@@ -2,10 +2,10 @@ import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-
|
|
2
2
|
import { SupportedStyles } from '../../../typings/style';
|
3
3
|
|
4
4
|
export interface Schema {
|
5
|
-
|
5
|
+
path: string;
|
6
|
+
name?: string;
|
6
7
|
style: SupportedStyles;
|
7
8
|
skipTests?: boolean;
|
8
|
-
directory?: string;
|
9
9
|
export?: boolean;
|
10
10
|
classComponent?: boolean;
|
11
11
|
routing?: boolean;
|
@@ -14,12 +14,12 @@ export interface Schema {
|
|
14
14
|
fileName?: string;
|
15
15
|
inSourceTests?: boolean;
|
16
16
|
skipFormat?: boolean;
|
17
|
-
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
18
17
|
// Used by Next.js to determine how React should generate the page
|
19
18
|
isNextPage?: boolean;
|
20
19
|
}
|
21
20
|
|
22
21
|
export interface NormalizedSchema extends Schema {
|
22
|
+
directory: string;
|
23
23
|
projectSourceRoot: string;
|
24
24
|
projectName: string;
|
25
25
|
fileName: string;
|
@@ -6,13 +6,19 @@
|
|
6
6
|
"description": "Create a React Component for Nx.",
|
7
7
|
"type": "object",
|
8
8
|
"properties": {
|
9
|
-
"
|
9
|
+
"path": {
|
10
10
|
"type": "string",
|
11
|
-
"description": "
|
11
|
+
"description": "Path where the component will be generated.",
|
12
12
|
"$default": {
|
13
13
|
"$source": "argv",
|
14
14
|
"index": 0
|
15
15
|
},
|
16
|
+
"x-prompt": "Where should the component be generated?",
|
17
|
+
"x-priority": "important"
|
18
|
+
},
|
19
|
+
"name": {
|
20
|
+
"type": "string",
|
21
|
+
"description": "The name of the component.",
|
16
22
|
"x-prompt": "What name would you like to use for the component?",
|
17
23
|
"x-priority": "important"
|
18
24
|
},
|
@@ -67,17 +73,6 @@
|
|
67
73
|
"default": false,
|
68
74
|
"x-priority": "internal"
|
69
75
|
},
|
70
|
-
"directory": {
|
71
|
-
"type": "string",
|
72
|
-
"description": "The directory at which to create the component file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the project root.",
|
73
|
-
"alias": "dir",
|
74
|
-
"x-priority": "important"
|
75
|
-
},
|
76
|
-
"nameAndDirectoryFormat": {
|
77
|
-
"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`).",
|
78
|
-
"type": "string",
|
79
|
-
"enum": ["as-provided", "derived"]
|
80
|
-
},
|
81
76
|
"export": {
|
82
77
|
"type": "boolean",
|
83
78
|
"description": "When true, the component is exported from the project `index.ts` (if it exists).",
|
@@ -116,6 +111,6 @@
|
|
116
111
|
"x-priority": "internal"
|
117
112
|
}
|
118
113
|
},
|
119
|
-
"required": ["
|
114
|
+
"required": ["path"],
|
120
115
|
"examplesFile": "../../../docs/component-examples.md"
|
121
116
|
}
|
@@ -14,14 +14,18 @@ async function federateModuleGenerator(tree, schema) {
|
|
14
14
|
Path: ${schema.path}`);
|
15
15
|
}
|
16
16
|
const tasks = [];
|
17
|
+
const { projectName: remoteName, projectRoot: remoteRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
18
|
+
name: schema.remote,
|
19
|
+
directory: schema.remoteDirectory,
|
20
|
+
projectType: 'application',
|
21
|
+
});
|
17
22
|
// Check remote exists
|
18
|
-
const remote = (0, utils_1.checkRemoteExists)(tree,
|
19
|
-
let projectRoot, remoteName;
|
23
|
+
const remote = (0, utils_1.checkRemoteExists)(tree, remoteName);
|
20
24
|
if (!remote) {
|
21
25
|
// create remote
|
22
26
|
const remoteGeneratorTask = await (0, remote_1.remoteGenerator)(tree, {
|
23
|
-
name:
|
24
|
-
directory:
|
27
|
+
name: remoteName,
|
28
|
+
directory: remoteRoot,
|
25
29
|
e2eTestRunner: schema.e2eTestRunner,
|
26
30
|
skipFormat: schema.skipFormat,
|
27
31
|
linter: schema.linter,
|
@@ -29,27 +33,14 @@ async function federateModuleGenerator(tree, schema) {
|
|
29
33
|
unitTestRunner: schema.unitTestRunner,
|
30
34
|
host: schema.host,
|
31
35
|
bundler: schema.bundler ?? 'rspack',
|
32
|
-
projectNameAndRootFormat: schema.projectNameAndRootFormat,
|
33
36
|
});
|
34
37
|
tasks.push(remoteGeneratorTask);
|
35
|
-
const { projectName, projectRoot: remoteRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
36
|
-
name: schema.remote,
|
37
|
-
directory: schema.remoteDirectory,
|
38
|
-
projectType: 'application',
|
39
|
-
projectNameAndRootFormat: schema.projectNameAndRootFormat,
|
40
|
-
});
|
41
|
-
projectRoot = remoteRoot;
|
42
|
-
remoteName = projectName;
|
43
|
-
}
|
44
|
-
else {
|
45
|
-
projectRoot = remote.root;
|
46
|
-
remoteName = remote.name;
|
47
38
|
}
|
48
39
|
// add path to exposes property
|
49
40
|
const normalizedModulePath = schema.bundler === 'rspack'
|
50
|
-
? (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(
|
41
|
+
? (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(remoteRoot), schema.path)
|
51
42
|
: schema.path;
|
52
|
-
(0, utils_1.addPathToExposes)(tree,
|
43
|
+
(0, utils_1.addPathToExposes)(tree, remoteRoot, schema.name, normalizedModulePath);
|
53
44
|
// Add new path to tsconfig
|
54
45
|
const rootJSON = (0, devkit_1.readJson)(tree, (0, js_1.getRootTsConfigPathInTree)(tree));
|
55
46
|
if (!rootJSON?.compilerOptions?.paths[`${remoteName}/${schema.name}`]) {
|
@@ -37,11 +37,6 @@
|
|
37
37
|
"description": "The directory of the new remote application if one needs to be created.",
|
38
38
|
"type": "string"
|
39
39
|
},
|
40
|
-
"projectNameAndRootFormat": {
|
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`).",
|
42
|
-
"type": "string",
|
43
|
-
"enum": ["as-provided", "derived"]
|
44
|
-
},
|
45
40
|
"style": {
|
46
41
|
"description": "The file extension to be used for style files.",
|
47
42
|
"type": "string",
|
@@ -51,9 +51,8 @@ function addExportsToBarrel(host, options) {
|
|
51
51
|
async function normalizeOptions(host, options) {
|
52
52
|
assertValidOptions(options);
|
53
53
|
const { directory, fileName: _fileName, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
54
|
+
path: options.path,
|
54
55
|
name: options.name,
|
55
|
-
directory: options.directory,
|
56
|
-
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
57
56
|
fileExtension: 'tsx',
|
58
57
|
});
|
59
58
|
const { className, fileName } = (0, devkit_1.names)(_fileName);
|
@@ -7,18 +7,24 @@
|
|
7
7
|
"type": "object",
|
8
8
|
"examples": [
|
9
9
|
{
|
10
|
-
"command": "nx g hook my-hook
|
11
|
-
"description": "Generate a hook in the `mylib` library"
|
10
|
+
"command": "nx g hook mylib/my-hook",
|
11
|
+
"description": "Generate a hook `my-hook` in the `mylib` library"
|
12
12
|
}
|
13
13
|
],
|
14
14
|
"properties": {
|
15
|
-
"
|
15
|
+
"path": {
|
16
16
|
"type": "string",
|
17
|
-
"description": "
|
17
|
+
"description": "Path where the hook will be generated.",
|
18
18
|
"$default": {
|
19
19
|
"$source": "argv",
|
20
20
|
"index": 0
|
21
21
|
},
|
22
|
+
"x-prompt": "Where should the hook be generated?",
|
23
|
+
"x-priority": "important"
|
24
|
+
},
|
25
|
+
"name": {
|
26
|
+
"type": "string",
|
27
|
+
"description": "The name of the hook.",
|
22
28
|
"x-prompt": "What name would you like to use for the hook?",
|
23
29
|
"x-priority": "important"
|
24
30
|
},
|
@@ -14,6 +14,7 @@ const update_module_federation_e2e_project_1 = require("./lib/update-module-fede
|
|
14
14
|
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
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
17
18
|
async function hostGenerator(host, schema) {
|
18
19
|
const tasks = [];
|
19
20
|
const options = {
|
@@ -37,6 +38,7 @@ async function hostGenerator(host, schema) {
|
|
37
38
|
}
|
38
39
|
});
|
39
40
|
}
|
41
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
40
42
|
const initTask = await (0, application_1.default)(host, {
|
41
43
|
...options,
|
42
44
|
name: options.projectName,
|
@@ -61,7 +63,6 @@ async function hostGenerator(host, schema) {
|
|
61
63
|
devServerPort: remotePort,
|
62
64
|
ssr: options.ssr,
|
63
65
|
skipFormat: true,
|
64
|
-
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
65
66
|
typescriptConfiguration: options.typescriptConfiguration,
|
66
67
|
js: options.js,
|
67
68
|
dynamic: options.dynamic,
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
2
1
|
import type { Linter, LinterType } from '@nx/eslint';
|
3
2
|
import type { SupportedStyles } from '../../../typings/style';
|
4
3
|
|
@@ -6,13 +5,12 @@ export interface Schema {
|
|
6
5
|
classComponent?: boolean;
|
7
6
|
compiler?: 'babel' | 'swc';
|
8
7
|
devServerPort?: number;
|
9
|
-
directory
|
10
|
-
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
8
|
+
directory: string;
|
11
9
|
e2eTestRunner: 'cypress' | 'playwright' | 'none';
|
12
10
|
globalCss?: boolean;
|
13
11
|
js?: boolean;
|
14
12
|
linter: Linter | LinterType;
|
15
|
-
name
|
13
|
+
name?: string;
|
16
14
|
remotes?: string[];
|
17
15
|
setParserOptionsProject?: boolean;
|
18
16
|
skipFormat?: boolean;
|
@@ -6,28 +6,22 @@
|
|
6
6
|
"description": "Create Module Federation configuration files for given React Host Application.",
|
7
7
|
"type": "object",
|
8
8
|
"properties": {
|
9
|
-
"
|
9
|
+
"directory": {
|
10
|
+
"description": "The directory of the new application.",
|
10
11
|
"type": "string",
|
11
|
-
"
|
12
|
+
"alias": "dir",
|
12
13
|
"$default": {
|
13
14
|
"$source": "argv",
|
14
15
|
"index": 0
|
15
16
|
},
|
16
|
-
"x-prompt": "
|
17
|
-
"pattern": "^[a-zA-Z][^:]*$",
|
18
|
-
"x-priority": "important"
|
17
|
+
"x-prompt": "Which directory do you want to create the application in?"
|
19
18
|
},
|
20
|
-
"
|
21
|
-
"description": "The directory of the new application.",
|
19
|
+
"name": {
|
22
20
|
"type": "string",
|
23
|
-
"
|
21
|
+
"description": "The name of the host application to generate the Module Federation configuration",
|
22
|
+
"pattern": "^[a-zA-Z][^:]*$",
|
24
23
|
"x-priority": "important"
|
25
24
|
},
|
26
|
-
"projectNameAndRootFormat": {
|
27
|
-
"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`).",
|
28
|
-
"type": "string",
|
29
|
-
"enum": ["as-provided", "derived"]
|
30
|
-
},
|
31
25
|
"style": {
|
32
26
|
"description": "The file extension to be used for style files.",
|
33
27
|
"type": "string",
|
@@ -187,6 +181,6 @@
|
|
187
181
|
"x-priority": "important"
|
188
182
|
}
|
189
183
|
},
|
190
|
-
"required": ["
|
184
|
+
"required": ["directory"],
|
191
185
|
"additionalProperties": false
|
192
186
|
}
|
@@ -5,12 +5,12 @@ 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
7
|
async function normalizeOptions(host, options) {
|
8
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
|
8
9
|
const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
9
10
|
name: options.name,
|
10
11
|
projectType: 'library',
|
11
12
|
directory: options.directory,
|
12
13
|
importPath: options.importPath,
|
13
|
-
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
14
14
|
});
|
15
15
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
16
16
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
@@ -147,10 +147,9 @@ async function libraryGeneratorInternal(host, schema) {
|
|
147
147
|
}
|
148
148
|
if (options.component) {
|
149
149
|
const relativeCwd = (0, artifact_name_and_directory_utils_1.getRelativeCwd)();
|
150
|
-
const
|
150
|
+
const path = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/lib', options.fileName);
|
151
151
|
const componentTask = await (0, component_1.default)(host, {
|
152
|
-
|
153
|
-
name: relativeCwd ? (0, path_1.relative)(relativeCwd, name) : name,
|
152
|
+
path: relativeCwd ? (0, path_1.relative)(relativeCwd, path) : path,
|
154
153
|
style: options.style,
|
155
154
|
skipTests: options.unitTestRunner === 'none' ||
|
156
155
|
(options.unitTestRunner === 'vitest' && options.inSourceTests == true),
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
2
1
|
import type { Linter, LinterType } from '@nx/eslint';
|
3
2
|
import type { SupportedStyles } from '../../../typings/style';
|
4
3
|
|
@@ -8,14 +7,13 @@ export interface Schema {
|
|
8
7
|
bundler?: 'none' | 'rollup' | 'vite';
|
9
8
|
compiler?: 'babel' | 'swc';
|
10
9
|
component?: boolean;
|
11
|
-
directory
|
12
|
-
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
10
|
+
directory: string;
|
13
11
|
globalCss?: boolean;
|
14
12
|
importPath?: string;
|
15
13
|
inSourceTests?: boolean;
|
16
14
|
js?: boolean;
|
17
15
|
linter: Linter | LinterType;
|
18
|
-
name
|
16
|
+
name?: string;
|
19
17
|
publishable?: boolean;
|
20
18
|
routing?: boolean;
|
21
19
|
setParserOptionsProject?: boolean;
|
@@ -16,28 +16,21 @@
|
|
16
16
|
}
|
17
17
|
],
|
18
18
|
"properties": {
|
19
|
-
"
|
19
|
+
"directory": {
|
20
20
|
"type": "string",
|
21
|
-
"description": "
|
21
|
+
"description": "A directory where the lib is placed.",
|
22
|
+
"alias": "dir",
|
22
23
|
"$default": {
|
23
24
|
"$source": "argv",
|
24
25
|
"index": 0
|
25
26
|
},
|
26
|
-
"x-prompt": "
|
27
|
-
"pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$",
|
28
|
-
"x-priority": "important"
|
27
|
+
"x-prompt": "Which directory do you want to create the library in?"
|
29
28
|
},
|
30
|
-
"
|
29
|
+
"name": {
|
31
30
|
"type": "string",
|
32
|
-
"description": "
|
33
|
-
"alias": "dir",
|
31
|
+
"description": "Library name",
|
34
32
|
"x-priority": "important"
|
35
33
|
},
|
36
|
-
"projectNameAndRootFormat": {
|
37
|
-
"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
|
-
"type": "string",
|
39
|
-
"enum": ["as-provided", "derived"]
|
40
|
-
},
|
41
34
|
"style": {
|
42
35
|
"description": "The file extension to be used for style files.",
|
43
36
|
"type": "string",
|
@@ -47,7 +40,10 @@
|
|
47
40
|
"message": "Which stylesheet format would you like to use?",
|
48
41
|
"type": "list",
|
49
42
|
"items": [
|
50
|
-
{
|
43
|
+
{
|
44
|
+
"value": "css",
|
45
|
+
"label": "CSS"
|
46
|
+
},
|
51
47
|
{
|
52
48
|
"value": "scss",
|
53
49
|
"label": "SASS(.scss) [ https://sass-lang.com ]"
|
@@ -189,5 +185,5 @@
|
|
189
185
|
"default": false
|
190
186
|
}
|
191
187
|
},
|
192
|
-
"required": ["
|
188
|
+
"required": ["directory"]
|
193
189
|
}
|
@@ -20,7 +20,7 @@ async function reduxGenerator(host, schema) {
|
|
20
20
|
return installTask;
|
21
21
|
}
|
22
22
|
function generateReduxFiles(host, options) {
|
23
|
-
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files'), options.
|
23
|
+
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files'), options.projectDirectory, {
|
24
24
|
...options,
|
25
25
|
tmpl: '',
|
26
26
|
});
|
@@ -42,8 +42,8 @@ function addExportsToBarrel(host, options) {
|
|
42
42
|
const indexSource = host.read(indexFilePath, 'utf-8');
|
43
43
|
if (indexSource !== null) {
|
44
44
|
const indexSourceFile = tsModule.createSourceFile(indexFilePath, indexSource, tsModule.ScriptTarget.Latest, true);
|
45
|
-
const statePath = options.
|
46
|
-
? `./lib/${options.
|
45
|
+
const statePath = options.path
|
46
|
+
? `./lib/${options.path}/${options.fileName}`
|
47
47
|
: `./lib/${options.fileName}`;
|
48
48
|
const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, ast_utils_1.addImport)(indexSourceFile, `export * from '${statePath}.slice';`));
|
49
49
|
host.write(indexFilePath, changes);
|
@@ -78,9 +78,8 @@ function updateReducerConfiguration(host, options) {
|
|
78
78
|
}
|
79
79
|
async function normalizeOptions(host, options) {
|
80
80
|
const { artifactName: name, directory, fileName, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
81
|
+
path: options.path,
|
81
82
|
name: options.name,
|
82
|
-
directory: options.directory,
|
83
|
-
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
84
83
|
fileExtension: 'tsx',
|
85
84
|
});
|
86
85
|
let appProjectSourcePath;
|
@@ -94,8 +93,8 @@ async function normalizeOptions(host, options) {
|
|
94
93
|
? tsConfigJson.compilerOptions.paths || {}
|
95
94
|
: {};
|
96
95
|
const modulePath = projectType === 'application'
|
97
|
-
? options.
|
98
|
-
? `./app/${options.
|
96
|
+
? options.path
|
97
|
+
? `./app/${options.path}/${extraNames.fileName}.slice`
|
99
98
|
: `./app/${extraNames.fileName}.slice`
|
100
99
|
: Object.keys(tsPaths).find((k) => tsPaths[k].some((s) => s.includes(sourceRoot)));
|
101
100
|
// If --project is set to an app, automatically configure store
|
@@ -118,8 +117,8 @@ async function normalizeOptions(host, options) {
|
|
118
117
|
...options,
|
119
118
|
...extraNames,
|
120
119
|
fileName,
|
121
|
-
constantName: (0, devkit_1.names)(
|
122
|
-
directory,
|
120
|
+
constantName: (0, devkit_1.names)(name).constantName.toUpperCase(),
|
121
|
+
projectDirectory: directory,
|
123
122
|
projectType,
|
124
123
|
projectSourcePath: sourceRoot,
|
125
124
|
projectModulePath: modulePath,
|
@@ -1,15 +1,13 @@
|
|
1
|
-
import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
2
|
-
|
3
1
|
export interface Schema {
|
4
|
-
|
5
|
-
|
2
|
+
path: string;
|
3
|
+
name?: string;
|
6
4
|
appProject?: string;
|
7
5
|
js?: string;
|
8
|
-
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
9
6
|
}
|
10
7
|
|
11
8
|
interface NormalizedSchema extends Schema {
|
12
9
|
projectType: string;
|
10
|
+
projectDirectory: string;
|
13
11
|
projectSourcePath: string;
|
14
12
|
projectModulePath: string;
|
15
13
|
appProjectSourcePath: string;
|
@@ -6,27 +6,21 @@
|
|
6
6
|
"description": "Create a Redux state slice for a React project.",
|
7
7
|
"type": "object",
|
8
8
|
"properties": {
|
9
|
-
"
|
9
|
+
"path": {
|
10
10
|
"type": "string",
|
11
|
-
"description": "Redux slice
|
11
|
+
"description": "Path where the Redux slice will be generated.",
|
12
12
|
"$default": {
|
13
13
|
"$source": "argv",
|
14
14
|
"index": 0
|
15
15
|
},
|
16
|
+
"x-prompt": "Where should the Redux slice be generated?",
|
16
17
|
"x-priority": "important"
|
17
18
|
},
|
18
|
-
"
|
19
|
+
"name": {
|
19
20
|
"type": "string",
|
20
|
-
"
|
21
|
-
"default": "",
|
22
|
-
"description": "The directory at which to create the Redux files. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the project root.",
|
21
|
+
"description": "Redux slice name.",
|
23
22
|
"x-priority": "important"
|
24
23
|
},
|
25
|
-
"nameAndDirectoryFormat": {
|
26
|
-
"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`).",
|
27
|
-
"type": "string",
|
28
|
-
"enum": ["as-provided", "derived"]
|
29
|
-
},
|
30
24
|
"appProject": {
|
31
25
|
"type": "string",
|
32
26
|
"description": "The application project to add the slice to.",
|
@@ -38,5 +32,5 @@
|
|
38
32
|
"default": false
|
39
33
|
}
|
40
34
|
},
|
41
|
-
"required": ["
|
35
|
+
"required": ["path"]
|
42
36
|
}
|
@@ -16,6 +16,7 @@ const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
|
16
16
|
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
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
19
20
|
function addModuleFederationFiles(host, options) {
|
20
21
|
const templateVariables = {
|
21
22
|
...(0, devkit_1.names)(options.projectName),
|
@@ -66,6 +67,7 @@ async function remoteGenerator(host, schema) {
|
|
66
67
|
throw new Error(`Invalid remote name provided: ${options.projectName}. ${isValidRemote.message}`);
|
67
68
|
}
|
68
69
|
}
|
70
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
69
71
|
const initAppTask = await (0, application_1.default)(host, {
|
70
72
|
...options,
|
71
73
|
name: options.projectName,
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
2
1
|
import type { Linter, LinterType } from '@nx/eslint';
|
3
2
|
import type { SupportedStyles } from '../../../typings/style';
|
4
3
|
import type { NormalizedSchema as ApplicationNormalizedSchema } from '../application/schema';
|
@@ -7,14 +6,13 @@ export interface Schema {
|
|
7
6
|
classComponent?: boolean;
|
8
7
|
compiler?: 'babel' | 'swc';
|
9
8
|
devServerPort?: number;
|
10
|
-
directory
|
11
|
-
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
9
|
+
directory: string;
|
12
10
|
e2eTestRunner: 'cypress' | 'playwright' | 'none';
|
13
11
|
globalCss?: boolean;
|
14
12
|
host?: string;
|
15
13
|
js?: boolean;
|
16
14
|
linter: Linter | LinterType;
|
17
|
-
name
|
15
|
+
name?: string;
|
18
16
|
routing?: boolean;
|
19
17
|
setParserOptionsProject?: boolean;
|
20
18
|
skipFormat: boolean;
|
@@ -6,28 +6,22 @@
|
|
6
6
|
"description": "Create Module Federation configuration files for given React Remote Application.",
|
7
7
|
"type": "object",
|
8
8
|
"properties": {
|
9
|
-
"
|
9
|
+
"directory": {
|
10
|
+
"description": "The directory of the new application.",
|
10
11
|
"type": "string",
|
11
|
-
"
|
12
|
+
"alias": "dir",
|
12
13
|
"$default": {
|
13
14
|
"$source": "argv",
|
14
15
|
"index": 0
|
15
16
|
},
|
16
|
-
"x-prompt": "
|
17
|
-
"pattern": "^[a-zA-Z][^:]*$",
|
18
|
-
"x-priority": "important"
|
17
|
+
"x-prompt": "Which directory do you want to create the application in?"
|
19
18
|
},
|
20
|
-
"
|
21
|
-
"description": "The directory of the new application.",
|
19
|
+
"name": {
|
22
20
|
"type": "string",
|
23
|
-
"
|
21
|
+
"description": "The name of the remote application to generate the Module Federation configuration",
|
22
|
+
"pattern": "^[a-zA-Z][^:]*$",
|
24
23
|
"x-priority": "important"
|
25
24
|
},
|
26
|
-
"projectNameAndRootFormat": {
|
27
|
-
"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`).",
|
28
|
-
"type": "string",
|
29
|
-
"enum": ["as-provided", "derived"]
|
30
|
-
},
|
31
25
|
"dynamic": {
|
32
26
|
"type": "boolean",
|
33
27
|
"description": "Should the host application use dynamic federation?",
|
@@ -186,6 +180,6 @@
|
|
186
180
|
"x-priority": "important"
|
187
181
|
}
|
188
182
|
},
|
189
|
-
"required": ["
|
183
|
+
"required": ["directory"],
|
190
184
|
"additionalProperties": false
|
191
185
|
}
|
@@ -65,6 +65,12 @@ async function setupSsrGenerator(tree, options) {
|
|
65
65
|
if (projectConfig.targets.build.options?.outputPath) {
|
66
66
|
projectConfig.targets.build.options.outputPath = (0, devkit_1.joinPathFragments)(originalOutputPath, 'browser');
|
67
67
|
}
|
68
|
+
if (projectConfig.targets.build.executor === '@nx/rspack:rspack') {
|
69
|
+
options.bundler = 'rspack';
|
70
|
+
}
|
71
|
+
else if (projectConfig.targets.build.executor === '@nx/webpack:webpack') {
|
72
|
+
options.bundler = 'webpack';
|
73
|
+
}
|
68
74
|
projectConfig.targets = {
|
69
75
|
...projectConfig.targets,
|
70
76
|
server: {
|