@nx/react 20.0.0-canary.20241001-8fa7065 → 20.0.0-canary.20241003-84a5c7a
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/index.js +1 -1
- package/migrations.json +0 -112
- package/package.json +6 -6
- package/plugins/bundle-rollup.js +4 -1
- package/plugins/component-testing/index.js +1 -1
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +1 -1
- package/src/generators/application/application.js +4 -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 +4 -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/init/init.js +2 -0
- package/src/generators/library/lib/normalize-options.js +1 -1
- package/src/generators/library/library.js +4 -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 +4 -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/module-federation/with-module-federation-ssr.js +1 -1
- package/src/module-federation/with-module-federation.js +1 -1
- package/src/utils/testing-generators.js +1 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
- package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.d.ts +0 -2
- package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.js +0 -8
- package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.d.ts +0 -2
- package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.js +0 -8
- package/src/migrations/update-16-7-0/add-babel-core.d.ts +0 -2
- package/src/migrations/update-16-7-0/add-babel-core.js +0 -14
- package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.d.ts +0 -2
- package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.js +0 -57
package/index.js
CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setupTailwindGenerator = exports.componentTestGenerator = exports.cypressComponentConfigGenerator = exports.remoteGenerator = exports.hostGenerator = exports.storybookConfigurationGenerator = exports.storiesGenerator = exports.reduxGenerator = exports.reactInitGenerator = exports.libraryGenerator = exports.componentStoryGenerator = exports.hookGenerator = exports.componentGenerator = exports.applicationGenerator = exports.reactVersion = exports.reactDomVersion = exports.assertValidStyle = exports.cssInJsDependenciesBabel = exports.extendReactEslintJson = exports.extraEslintDependencies = exports.NxReactWebpackPlugin = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const nx_react_webpack_plugin_1 = require("./plugins/nx-react-webpack-plugin/nx-react-webpack-plugin");
|
6
|
-
// TODO(
|
6
|
+
// TODO(v21): Remove this in favor of deep imports in order to load configs faster (150-200ms faster).
|
7
7
|
/** @deprecated Use '@nx/react/webpack-plugin' instead. */
|
8
8
|
exports.NxReactWebpackPlugin = nx_react_webpack_plugin_1.NxReactWebpackPlugin;
|
9
9
|
var lint_1 = require("./src/utils/lint");
|
package/migrations.json
CHANGED
@@ -1,35 +1,5 @@
|
|
1
1
|
{
|
2
2
|
"generators": {
|
3
|
-
"update-16-0-0-add-nx-packages": {
|
4
|
-
"cli": "nx",
|
5
|
-
"version": "16.0.0-beta.1",
|
6
|
-
"description": "Replace @nrwl/react with @nx/react",
|
7
|
-
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
8
|
-
},
|
9
|
-
"update-16-2-0-remove-package": {
|
10
|
-
"cli": "nx",
|
11
|
-
"version": "16.2.0-beta.0",
|
12
|
-
"description": "Remove react-test-renderer from package.json",
|
13
|
-
"implementation": "./src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package"
|
14
|
-
},
|
15
|
-
"remove-types-react-router-dom": {
|
16
|
-
"cli": "nx",
|
17
|
-
"version": "16.3.0-beta.2",
|
18
|
-
"description": "Remove @types/react-router-dom from package.json",
|
19
|
-
"implementation": "./src/migrations/update-16-3-0/remove-types-react-router-dom-package"
|
20
|
-
},
|
21
|
-
"add-babel-core": {
|
22
|
-
"cli": "nx",
|
23
|
-
"version": "16.7.0-beta.2",
|
24
|
-
"description": "Add @babel/core to package.json if @babel/preset-react is present",
|
25
|
-
"implementation": "./src/migrations/update-16-7-0/add-babel-core"
|
26
|
-
},
|
27
|
-
"update-16-7-0-add-typings": {
|
28
|
-
"cli": "nx",
|
29
|
-
"version": "16.7.0-beta.2",
|
30
|
-
"description": "Add @nx/react types to tsconfig types array",
|
31
|
-
"implementation": "./src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings"
|
32
|
-
},
|
33
3
|
"add-module-federation-env-var-to-target-defaults": {
|
34
4
|
"cli": "nx",
|
35
5
|
"version": "18.0.0-beta.0",
|
@@ -62,88 +32,6 @@
|
|
62
32
|
}
|
63
33
|
},
|
64
34
|
"packageJsonUpdates": {
|
65
|
-
"16.3.0": {
|
66
|
-
"version": "16.3.0-beta.2",
|
67
|
-
"packages": {
|
68
|
-
"react-router-dom": {
|
69
|
-
"version": "6.11.2",
|
70
|
-
"alwaysAddToPackageJson": false
|
71
|
-
},
|
72
|
-
"@svgr/rollup": {
|
73
|
-
"version": "^8.0.1",
|
74
|
-
"alwaysAddToPackageJson": false
|
75
|
-
}
|
76
|
-
}
|
77
|
-
},
|
78
|
-
"16.4.0-beta.4": {
|
79
|
-
"version": "16.4.0-beta.4",
|
80
|
-
"packages": {
|
81
|
-
"stylus": {
|
82
|
-
"version": "^0.59.0",
|
83
|
-
"alwaysAddToPackageJson": false
|
84
|
-
}
|
85
|
-
}
|
86
|
-
},
|
87
|
-
"16.4.0-beta.7": {
|
88
|
-
"version": "16.4.0-beta.7",
|
89
|
-
"packages": {
|
90
|
-
"@types/react": {
|
91
|
-
"version": "18.2.12",
|
92
|
-
"alwaysAddToPackageJson": false
|
93
|
-
},
|
94
|
-
"@types/react-dom": {
|
95
|
-
"version": "18.2.5",
|
96
|
-
"alwaysAddToPackageJson": false
|
97
|
-
},
|
98
|
-
"@types/react-is": {
|
99
|
-
"version": "18.2.0",
|
100
|
-
"alwaysAddToPackageJson": false
|
101
|
-
}
|
102
|
-
}
|
103
|
-
},
|
104
|
-
"16.4.0-beta.8": {
|
105
|
-
"version": "16.4.0-beta.8",
|
106
|
-
"packages": {
|
107
|
-
"@emotion/styled": {
|
108
|
-
"version": "11.11.0",
|
109
|
-
"alwaysAddToPackageJson": false
|
110
|
-
},
|
111
|
-
"@emotion/react": {
|
112
|
-
"version": "11.11.1",
|
113
|
-
"alwaysAddToPackageJson": false
|
114
|
-
},
|
115
|
-
"@emotion/babel-plugin": {
|
116
|
-
"version": "11.11.0",
|
117
|
-
"alwaysAddToPackageJson": false
|
118
|
-
}
|
119
|
-
}
|
120
|
-
},
|
121
|
-
"16.4.0-beta.11": {
|
122
|
-
"version": "16.4.0-beta.11",
|
123
|
-
"packages": {
|
124
|
-
"@types/react": {
|
125
|
-
"version": "18.2.13",
|
126
|
-
"alwaysAddToPackageJson": false
|
127
|
-
},
|
128
|
-
"@types/react-dom": {
|
129
|
-
"version": "18.2.6",
|
130
|
-
"alwaysAddToPackageJson": false
|
131
|
-
},
|
132
|
-
"@types/react-is": {
|
133
|
-
"version": "18.2.1",
|
134
|
-
"alwaysAddToPackageJson": false
|
135
|
-
}
|
136
|
-
}
|
137
|
-
},
|
138
|
-
"16.5.0-beta.4": {
|
139
|
-
"version": "16.5.0-beta.4",
|
140
|
-
"packages": {
|
141
|
-
"@types/react": {
|
142
|
-
"version": "18.2.14",
|
143
|
-
"alwaysAddToPackageJson": false
|
144
|
-
}
|
145
|
-
}
|
146
|
-
},
|
147
35
|
"17.0.0-beta.0": {
|
148
36
|
"version": "17.0.0-beta.0",
|
149
37
|
"packages": {
|
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.20241003-84a5c7a",
|
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.20241003-84a5c7a",
|
43
|
+
"@nx/js": "20.0.0-canary.20241003-84a5c7a",
|
44
|
+
"@nx/eslint": "20.0.0-canary.20241003-84a5c7a",
|
45
|
+
"@nx/web": "20.0.0-canary.20241003-84a5c7a",
|
46
46
|
"express": "^4.19.2",
|
47
47
|
"http-proxy-middleware": "^3.0.0"
|
48
48
|
},
|
package/plugins/bundle-rollup.js
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
// TODO(
|
3
|
+
// TODO(v22): Remove this in Nx 22 and migrate to explicit rollup.config.js files.
|
4
|
+
/**
|
5
|
+
* @deprecated Use `withNx` function from `@nx/rollup/with-nx` in your rollup.config.js file instead. Use `nx g @nx/rollup:convert-to-inferred` to generate the rollup.config.js file if it does not exist.
|
6
|
+
*/
|
4
7
|
function getRollupOptions(options) {
|
5
8
|
const extraGlobals = {
|
6
9
|
react: 'React',
|
@@ -167,7 +167,7 @@ function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
|
|
167
167
|
}
|
168
168
|
return async () => {
|
169
169
|
customWebpack = await customWebpack;
|
170
|
-
// TODO(
|
170
|
+
// TODO(v21): Component testing need to be agnostic of the underlying executor. With Crystal, we're not using `@nx/webpack:webpack` by default.
|
171
171
|
// We need to decouple CT from the build target of the app, we just care about bundler config (e.g. webpack.config.js).
|
172
172
|
// The generated setup should support both Webpack and Vite as documented here: https://docs.cypress.io/guides/component-testing/react/overview
|
173
173
|
// Related issue: https://github.com/nrwl/nx/issues/21546
|
@@ -13,7 +13,7 @@ function applyReactConfig(options, config = {}) {
|
|
13
13
|
ref: true,
|
14
14
|
};
|
15
15
|
const svgrOptions = typeof options.svgr === 'object' ? options.svgr : defaultSvgrOptions;
|
16
|
-
// TODO(
|
16
|
+
// TODO(v21): Remove file-loader and use `?react` querystring to differentiate between asset and SVGR.
|
17
17
|
// It should be:
|
18
18
|
// use: [{
|
19
19
|
// test: /\.svg$/i,
|
@@ -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");
|
@@ -27,6 +27,7 @@ const js_1 = require("@nx/js");
|
|
27
27
|
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
28
28
|
const setup_tailwind_1 = require("../setup-tailwind/setup-tailwind");
|
29
29
|
const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
|
30
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
30
31
|
async function addLinting(host, options) {
|
31
32
|
const tasks = [];
|
32
33
|
if (options.linter === eslint_1.Linter.EsLint) {
|
@@ -72,6 +73,7 @@ async function applicationGenerator(host, schema) {
|
|
72
73
|
});
|
73
74
|
}
|
74
75
|
async function applicationGeneratorInternal(host, schema) {
|
76
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'application');
|
75
77
|
const tasks = [];
|
76
78
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
77
79
|
(0, show_possible_warnings_1.showPossibleWarnings)(host, options);
|
@@ -226,7 +228,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
226
228
|
tasks.push(routingTask);
|
227
229
|
(0, set_defaults_1.setDefaults)(host, options);
|
228
230
|
if (options.bundler === 'rspack' && options.style === 'styled-jsx') {
|
229
|
-
devkit_1.logger.warn(`${
|
231
|
+
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
232
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {}, { 'babel-loader': versions_1.babelLoaderVersion }));
|
231
233
|
host.write((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'rspack.config.js'), (0, devkit_1.stripIndents) `
|
232
234
|
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,7 +14,10 @@ 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");
|
18
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
17
19
|
async function hostGenerator(host, schema) {
|
20
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'host');
|
18
21
|
const tasks = [];
|
19
22
|
const options = {
|
20
23
|
...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
|
@@ -37,6 +40,7 @@ async function hostGenerator(host, schema) {
|
|
37
40
|
}
|
38
41
|
});
|
39
42
|
}
|
43
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
40
44
|
const initTask = await (0, application_1.default)(host, {
|
41
45
|
...options,
|
42
46
|
name: options.projectName,
|
@@ -61,7 +65,6 @@ async function hostGenerator(host, schema) {
|
|
61
65
|
devServerPort: remotePort,
|
62
66
|
ssr: options.ssr,
|
63
67
|
skipFormat: true,
|
64
|
-
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
65
68
|
typescriptConfiguration: options.typescriptConfiguration,
|
66
69
|
js: options.js,
|
67
70
|
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
|
}
|
@@ -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'], []));
|
@@ -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' &&
|
@@ -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");
|
@@ -27,6 +28,7 @@ async function libraryGenerator(host, schema) {
|
|
27
28
|
});
|
28
29
|
}
|
29
30
|
async function libraryGeneratorInternal(host, schema) {
|
31
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'library');
|
30
32
|
const tasks = [];
|
31
33
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
32
34
|
if (options.publishable === true && !schema.importPath) {
|
@@ -147,10 +149,9 @@ async function libraryGeneratorInternal(host, schema) {
|
|
147
149
|
}
|
148
150
|
if (options.component) {
|
149
151
|
const relativeCwd = (0, artifact_name_and_directory_utils_1.getRelativeCwd)();
|
150
|
-
const
|
152
|
+
const path = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/lib', options.fileName);
|
151
153
|
const componentTask = await (0, component_1.default)(host, {
|
152
|
-
|
153
|
-
name: relativeCwd ? (0, path_1.relative)(relativeCwd, name) : name,
|
154
|
+
path: relativeCwd ? (0, path_1.relative)(relativeCwd, path) : path,
|
154
155
|
style: options.style,
|
155
156
|
skipTests: options.unitTestRunner === 'none' ||
|
156
157
|
(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,8 @@ 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");
|
20
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
19
21
|
function addModuleFederationFiles(host, options) {
|
20
22
|
const templateVariables = {
|
21
23
|
...(0, devkit_1.names)(options.projectName),
|
@@ -45,6 +47,7 @@ function addModuleFederationFiles(host, options) {
|
|
45
47
|
}
|
46
48
|
}
|
47
49
|
async function remoteGenerator(host, schema) {
|
50
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'remote');
|
48
51
|
const tasks = [];
|
49
52
|
const options = {
|
50
53
|
...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
|
@@ -66,6 +69,7 @@ async function remoteGenerator(host, schema) {
|
|
66
69
|
throw new Error(`Invalid remote name provided: ${options.projectName}. ${isValidRemote.message}`);
|
67
70
|
}
|
68
71
|
}
|
72
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
69
73
|
const initAppTask = await (0, application_1.default)(host, {
|
70
74
|
...options,
|
71
75
|
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: {
|
@@ -17,7 +17,7 @@ async function withModuleFederationForSSR(options, configOverride) {
|
|
17
17
|
runtimeChunk: false,
|
18
18
|
};
|
19
19
|
config.plugins.push(new (require('@module-federation/enhanced').ModuleFederationPlugin)({
|
20
|
-
name: options.name,
|
20
|
+
name: options.name.replace(/-/g, '_'),
|
21
21
|
filename: 'remoteEntry.js',
|
22
22
|
exposes: options.exposes,
|
23
23
|
remotes: mappedRemotes,
|
@@ -26,7 +26,7 @@ async function withModuleFederation(options, configOverride) {
|
|
26
26
|
config.optimization.runtimeChunk = 'single';
|
27
27
|
}
|
28
28
|
config.plugins.push(new webpack_1.ModuleFederationPlugin({
|
29
|
-
name: options.name,
|
29
|
+
name: options.name.replace(/-/g, '_'),
|
30
30
|
filename: 'remoteEntry.js',
|
31
31
|
exposes: options.exposes,
|
32
32
|
remotes: mappedRemotes,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = replacePackage;
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
5
|
-
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
6
|
-
async function replacePackage(tree) {
|
7
|
-
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/react', '@nx/react');
|
8
|
-
await (0, devkit_1.formatFiles)(tree);
|
9
|
-
}
|
@@ -1,8 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = removePackage;
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
5
|
-
async function removePackage(tree) {
|
6
|
-
(0, devkit_1.removeDependenciesFromPackageJson)(tree, [], ['react-test-renderer']);
|
7
|
-
await (0, devkit_1.formatFiles)(tree);
|
8
|
-
}
|
@@ -1,8 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = removePackage;
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
5
|
-
async function removePackage(tree) {
|
6
|
-
(0, devkit_1.removeDependenciesFromPackageJson)(tree, [], ['react-test-renderer']);
|
7
|
-
await (0, devkit_1.formatFiles)(tree);
|
8
|
-
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = addBabelCore;
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
5
|
-
const versions_1 = require("../../utils/versions");
|
6
|
-
async function addBabelCore(tree) {
|
7
|
-
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
8
|
-
if (packageJson?.devDependencies['@babel/preset-react']) {
|
9
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
10
|
-
'@babel/core': versions_1.babelCoreVersion,
|
11
|
-
});
|
12
|
-
await (0, devkit_1.formatFiles)(tree);
|
13
|
-
}
|
14
|
-
}
|
@@ -1,57 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = addTypings;
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
5
|
-
async function addTypings(tree) {
|
6
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
7
|
-
const buildExecutors = [
|
8
|
-
'@nx/webpack:webpack',
|
9
|
-
'@nx/vite:build',
|
10
|
-
'@nx/rspack:rspack',
|
11
|
-
];
|
12
|
-
const serveExecutors = [
|
13
|
-
'@nx/webpack:dev-server',
|
14
|
-
'@nx/vite:dev-server',
|
15
|
-
'@nx/rspack:dev-server',
|
16
|
-
];
|
17
|
-
const relatedTsConfigs = [
|
18
|
-
'tsconfig.app.json',
|
19
|
-
'tsconfig.lib.json',
|
20
|
-
'tsconfig.spec.json',
|
21
|
-
];
|
22
|
-
const typesToAdd = [
|
23
|
-
'@nx/react/typings/cssmodule.d.ts',
|
24
|
-
'@nx/react/typings/image.d.ts',
|
25
|
-
];
|
26
|
-
for (const [, config] of projects) {
|
27
|
-
if (!buildExecutors.includes(config?.targets?.build?.executor)) {
|
28
|
-
continue;
|
29
|
-
}
|
30
|
-
if (config?.targets?.serve?.executor &&
|
31
|
-
!serveExecutors.includes(config?.targets?.serve?.executor)) {
|
32
|
-
continue;
|
33
|
-
}
|
34
|
-
const rootPath = config.root;
|
35
|
-
const projectTsConfigPath = (0, devkit_1.joinPathFragments)(rootPath, 'tsconfig.json');
|
36
|
-
const projectTsConfig = (0, devkit_1.readJson)(tree, projectTsConfigPath);
|
37
|
-
if (projectTsConfig.compilerOptions?.jsx !== 'react-jsx') {
|
38
|
-
continue;
|
39
|
-
}
|
40
|
-
relatedTsConfigs.forEach((tsConfig) => {
|
41
|
-
const tsConfigPath = (0, devkit_1.joinPathFragments)(rootPath, tsConfig);
|
42
|
-
if (tree.exists(tsConfigPath)) {
|
43
|
-
(0, devkit_1.updateJson)(tree, tsConfigPath, (json) => {
|
44
|
-
const compilerOptions = json.compilerOptions || {};
|
45
|
-
compilerOptions.types = [
|
46
|
-
...new Set([...(compilerOptions.types || []), ...typesToAdd]),
|
47
|
-
];
|
48
|
-
if (json.files?.length > 0) {
|
49
|
-
json.files = json.files.filter((file) => !['cssmodule.d.ts', 'image.d.ts'].includes(file));
|
50
|
-
}
|
51
|
-
return { ...json, compilerOptions };
|
52
|
-
});
|
53
|
-
}
|
54
|
-
});
|
55
|
-
}
|
56
|
-
await (0, devkit_1.formatFiles)(tree);
|
57
|
-
}
|