@nx/react 20.0.0-beta.5 → 20.0.0-beta.7

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.
Files changed (51) hide show
  1. package/index.js +1 -1
  2. package/migrations.json +0 -112
  3. package/package.json +7 -7
  4. package/plugins/bundle-rollup.js +4 -1
  5. package/plugins/component-testing/index.js +1 -1
  6. package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +1 -1
  7. package/src/generators/application/application.js +4 -2
  8. package/src/generators/application/lib/normalize-options.js +2 -3
  9. package/src/generators/application/lib/show-possible-warnings.js +2 -2
  10. package/src/generators/application/schema.d.ts +2 -4
  11. package/src/generators/application/schema.json +13 -18
  12. package/src/generators/component/lib/normalize-options.js +2 -3
  13. package/src/generators/component/schema.d.ts +3 -3
  14. package/src/generators/component/schema.json +9 -14
  15. package/src/generators/federate-module/federate-module.js +10 -19
  16. package/src/generators/federate-module/schema.d.ts +0 -1
  17. package/src/generators/federate-module/schema.json +0 -5
  18. package/src/generators/hook/hook.js +1 -2
  19. package/src/generators/hook/schema.d.ts +2 -3
  20. package/src/generators/hook/schema.json +10 -4
  21. package/src/generators/host/host.js +4 -1
  22. package/src/generators/host/lib/normalize-remote.js +0 -1
  23. package/src/generators/host/schema.d.ts +2 -4
  24. package/src/generators/host/schema.json +8 -14
  25. package/src/generators/init/init.js +2 -0
  26. package/src/generators/library/lib/normalize-options.js +1 -1
  27. package/src/generators/library/library.js +5 -3
  28. package/src/generators/library/schema.d.ts +2 -4
  29. package/src/generators/library/schema.json +13 -16
  30. package/src/generators/redux/redux.js +8 -9
  31. package/src/generators/redux/schema.d.ts +3 -5
  32. package/src/generators/redux/schema.json +6 -12
  33. package/src/generators/remote/remote.js +4 -0
  34. package/src/generators/remote/schema.d.ts +2 -4
  35. package/src/generators/remote/schema.json +8 -14
  36. package/src/generators/setup-ssr/setup-ssr.js +6 -0
  37. package/src/module-federation/with-module-federation-ssr.js +1 -1
  38. package/src/module-federation/with-module-federation.js +1 -1
  39. package/src/utils/testing-generators.js +1 -2
  40. package/src/utils/versions.d.ts +1 -1
  41. package/src/utils/versions.js +1 -1
  42. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
  43. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
  44. package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.d.ts +0 -2
  45. package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.js +0 -8
  46. package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.d.ts +0 -2
  47. package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.js +0 -8
  48. package/src/migrations/update-16-7-0/add-babel-core.d.ts +0 -2
  49. package/src/migrations/update-16-7-0/add-babel-core.js +0 -14
  50. package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.d.ts +0 -2
  51. 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(v20): Remove this in favor of deep imports in order to load configs faster (150-200ms faster).
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-beta.5",
3
+ "version": "20.0.0-beta.7",
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
- "@module-federation/enhanced": "~0.6.0",
42
- "@nx/devkit": "20.0.0-beta.5",
43
- "@nx/js": "20.0.0-beta.5",
44
- "@nx/eslint": "20.0.0-beta.5",
45
- "@nx/web": "20.0.0-beta.5",
41
+ "@module-federation/enhanced": "0.6.6",
42
+ "@nx/devkit": "20.0.0-beta.7",
43
+ "@nx/js": "20.0.0-beta.7",
44
+ "@nx/eslint": "20.0.0-beta.7",
45
+ "@nx/web": "20.0.0-beta.7",
46
46
  "express": "^4.19.2",
47
47
  "http-proxy-middleware": "^3.0.0"
48
48
  },
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // TODO(v20): This should be deprecated and removed in v22.
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(v20): Component testing need to be agnostic of the underlying executor. With Crystal, we're not using `@nx/webpack:webpack` by default.
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(v20): Remove file-loader and use `?react` querystring to differentiate between asset and SVGR.
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 chalk = require("chalk");
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(`${chalk.bold('styled-jsx')} is not supported by ${chalk.bold('Rspack')}. We've added ${chalk.bold('babel-loader')} to your project, but using babel will slow down your build.`);
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
- const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
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 chalk = require("chalk");
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 ${chalk.bold('nx g @nx/react:app --compiler=babel')} instead.`);
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
- name: string;
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 --directory=myorg",
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
- "name": {
24
- "description": "The name of the application.",
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": "What name would you like to use for the application?",
31
- "pattern": "^[a-zA-Z][^:]*$"
31
+ "x-prompt": "Which directory do you want to create the application in?"
32
32
  },
33
- "directory": {
34
- "description": "The directory of the new application.",
33
+ "name": {
34
+ "description": "The name of the application.",
35
35
  "type": "string",
36
- "alias": "dir",
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",
@@ -111,9 +106,9 @@
111
106
  },
112
107
  "unitTestRunner": {
113
108
  "type": "string",
114
- "enum": ["jest", "vitest", "none"],
109
+ "enum": ["vitest", "jest", "none"],
115
110
  "description": "Test runner to use for unit tests.",
116
- "default": "jest"
111
+ "default": "vitest"
117
112
  },
118
113
  "inSourceTests": {
119
114
  "type": "boolean",
@@ -190,6 +185,6 @@
190
185
  "default": false
191
186
  }
192
187
  },
193
- "required": ["name"],
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
- name: string;
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
- "name": {
9
+ "path": {
10
10
  "type": "string",
11
- "description": "The name of the component.",
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": ["name"],
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, schema.remote);
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: schema.remote,
24
- directory: schema.remoteDirectory,
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)(projectRoot), schema.path)
41
+ ? (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(remoteRoot), schema.path)
51
42
  : schema.path;
52
- (0, utils_1.addPathToExposes)(tree, projectRoot, schema.name, normalizedModulePath);
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}`]) {
@@ -5,7 +5,6 @@ export interface Schema {
5
5
  path: string;
6
6
  remote: string;
7
7
  remoteDirectory?: string;
8
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
9
8
  e2eTestRunner?: 'cypress' | 'playwright' | 'none';
10
9
  host?: string;
11
10
  linter?: Linter | LinterType;
@@ -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);
@@ -1,7 +1,6 @@
1
- import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
-
3
1
  export interface Schema {
4
- name: string;
2
+ path: string;
3
+ name?: string;
5
4
  skipTests?: boolean;
6
5
  directory?: string;
7
6
  export?: boolean;
@@ -7,18 +7,24 @@
7
7
  "type": "object",
8
8
  "examples": [
9
9
  {
10
- "command": "nx g hook my-hook --project=mylib",
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
- "name": {
15
+ "path": {
16
16
  "type": "string",
17
- "description": "The name of the hook.",
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,
@@ -9,7 +9,6 @@ async function normalizeRemoteName(tree, remote, options) {
9
9
  name: remote,
10
10
  projectType: 'application',
11
11
  directory: options.directory,
12
- projectNameAndRootFormat: options.projectNameAndRootFormat,
13
12
  });
14
13
  return remoteName;
15
14
  }
@@ -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?: string;
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: string;
13
+ name?: string;
16
14
  remotes?: string[];
17
15
  setParserOptionsProject?: boolean;
18
16
  skipFormat?: boolean;