@nx/react 20.0.0-canary.20240928-f221a41 → 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.
Files changed (33) hide show
  1. package/package.json +7 -7
  2. package/src/generators/application/application.js +2 -2
  3. package/src/generators/application/lib/normalize-options.js +2 -3
  4. package/src/generators/application/lib/show-possible-warnings.js +2 -2
  5. package/src/generators/application/schema.d.ts +2 -4
  6. package/src/generators/application/schema.json +13 -18
  7. package/src/generators/component/lib/normalize-options.js +2 -3
  8. package/src/generators/component/schema.d.ts +3 -3
  9. package/src/generators/component/schema.json +9 -14
  10. package/src/generators/federate-module/federate-module.js +10 -19
  11. package/src/generators/federate-module/schema.d.ts +0 -1
  12. package/src/generators/federate-module/schema.json +0 -5
  13. package/src/generators/hook/hook.js +1 -2
  14. package/src/generators/hook/schema.d.ts +2 -3
  15. package/src/generators/hook/schema.json +10 -4
  16. package/src/generators/host/host.js +2 -1
  17. package/src/generators/host/lib/normalize-remote.js +0 -1
  18. package/src/generators/host/schema.d.ts +2 -4
  19. package/src/generators/host/schema.json +8 -14
  20. package/src/generators/library/lib/normalize-options.js +1 -1
  21. package/src/generators/library/library.js +3 -3
  22. package/src/generators/library/schema.d.ts +2 -4
  23. package/src/generators/library/schema.json +13 -16
  24. package/src/generators/redux/redux.js +8 -9
  25. package/src/generators/redux/schema.d.ts +3 -5
  26. package/src/generators/redux/schema.json +6 -12
  27. package/src/generators/remote/remote.js +2 -0
  28. package/src/generators/remote/schema.d.ts +2 -4
  29. package/src/generators/remote/schema.json +8 -14
  30. package/src/generators/setup-ssr/setup-ssr.js +6 -0
  31. package/src/utils/testing-generators.js +1 -2
  32. package/src/utils/versions.d.ts +1 -1
  33. package/src/utils/versions.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "20.0.0-canary.20240928-f221a41",
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
- "@module-federation/enhanced": "~0.6.0",
42
- "@nx/devkit": "20.0.0-canary.20240928-f221a41",
43
- "@nx/js": "20.0.0-canary.20240928-f221a41",
44
- "@nx/eslint": "20.0.0-canary.20240928-f221a41",
45
- "@nx/web": "20.0.0-canary.20240928-f221a41",
41
+ "@module-federation/enhanced": "0.6.6",
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 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");
@@ -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(`${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.`);
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
- 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,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,
@@ -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;
@@ -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
- "name": {
9
+ "directory": {
10
+ "description": "The directory of the new application.",
10
11
  "type": "string",
11
- "description": "The name of the host application to generate the Module Federation configuration",
12
+ "alias": "dir",
12
13
  "$default": {
13
14
  "$source": "argv",
14
15
  "index": 0
15
16
  },
16
- "x-prompt": "What name would you like to use as the host application?",
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
- "directory": {
21
- "description": "The directory of the new application.",
19
+ "name": {
22
20
  "type": "string",
23
- "alias": "dir",
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": ["name"],
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' &&
@@ -124,6 +124,7 @@ async function libraryGeneratorInternal(host, schema) {
124
124
  skipFormat: true,
125
125
  testEnvironment: 'jsdom',
126
126
  addPlugin: options.addPlugin,
127
+ compiler: options.compiler,
127
128
  });
128
129
  tasks.push(vitestTask);
129
130
  createOrEditViteConfig(host, {
@@ -146,10 +147,9 @@ async function libraryGeneratorInternal(host, schema) {
146
147
  }
147
148
  if (options.component) {
148
149
  const relativeCwd = (0, artifact_name_and_directory_utils_1.getRelativeCwd)();
149
- const name = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/lib', options.fileName);
150
+ const path = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/lib', options.fileName);
150
151
  const componentTask = await (0, component_1.default)(host, {
151
- nameAndDirectoryFormat: 'as-provided',
152
- name: relativeCwd ? (0, path_1.relative)(relativeCwd, name) : name,
152
+ path: relativeCwd ? (0, path_1.relative)(relativeCwd, path) : path,
153
153
  style: options.style,
154
154
  skipTests: options.unitTestRunner === 'none' ||
155
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?: string;
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: string;
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
- "name": {
19
+ "directory": {
20
20
  "type": "string",
21
- "description": "Library name",
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": "What name would you like to use for the library?",
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
- "directory": {
29
+ "name": {
31
30
  "type": "string",
32
- "description": "A directory where the lib is placed.",
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
- { "value": "css", "label": "CSS" },
43
+ {
44
+ "value": "css",
45
+ "label": "CSS"
46
+ },
51
47
  {
52
48
  "value": "scss",
53
49
  "label": "SASS(.scss) [ https://sass-lang.com ]"
@@ -83,7 +79,8 @@
83
79
  },
84
80
  "unitTestRunner": {
85
81
  "type": "string",
86
- "enum": ["jest", "vitest", "none"],
82
+ "enum": ["vitest", "jest", "none"],
83
+ "default": "vitest",
87
84
  "description": "Test runner to use for unit tests.",
88
85
  "x-prompt": "What unit test runner should be used?"
89
86
  },
@@ -188,5 +185,5 @@
188
185
  "default": false
189
186
  }
190
187
  },
191
- "required": ["name"]
188
+ "required": ["directory"]
192
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.directory, {
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.directory
46
- ? `./lib/${options.directory}/${options.fileName}`
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.directory
98
- ? `./app/${options.directory}/${extraNames.fileName}.slice`
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)(options.name).constantName.toUpperCase(),
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
- name: string;
5
- directory?: string;
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
- "name": {
9
+ "path": {
10
10
  "type": "string",
11
- "description": "Redux slice name.",
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
- "directory": {
19
+ "name": {
19
20
  "type": "string",
20
- "alias": "dir",
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": ["name"]
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?: string;
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: string;
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
- "name": {
9
+ "directory": {
10
+ "description": "The directory of the new application.",
10
11
  "type": "string",
11
- "description": "The name of the remote application to generate the Module Federation configuration",
12
+ "alias": "dir",
12
13
  "$default": {
13
14
  "$source": "argv",
14
15
  "index": 0
15
16
  },
16
- "x-prompt": "What name would you like to use as the remote application?",
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
- "directory": {
21
- "description": "The directory of the new application.",
19
+ "name": {
22
20
  "type": "string",
23
- "alias": "dir",
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": ["name"],
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: {
@@ -12,8 +12,7 @@ async function createApp(tree, appName) {
12
12
  skipFormat: true,
13
13
  style: 'css',
14
14
  unitTestRunner: 'none',
15
- name: appName,
16
- projectNameAndRootFormat: 'as-provided',
15
+ directory: appName,
17
16
  });
18
17
  }
19
18
  async function createLib(tree, libName) {
@@ -37,7 +37,7 @@ export declare const isbotVersion = "^3.6.5";
37
37
  export declare const corsVersion = "~2.8.5";
38
38
  export declare const typesCorsVersion = "~2.8.12";
39
39
  export declare const moduleFederationNodeVersion = "~2.5.0";
40
- export declare const moduleFederationEnhancedVersion = "~0.6.0";
40
+ export declare const moduleFederationEnhancedVersion = "0.6.6";
41
41
  export declare const lessVersion = "3.12.2";
42
42
  export declare const sassVersion = "^1.55.0";
43
43
  export declare const rollupPluginUrlVersion = "^8.0.2";
@@ -43,7 +43,7 @@ exports.isbotVersion = '^3.6.5';
43
43
  exports.corsVersion = '~2.8.5';
44
44
  exports.typesCorsVersion = '~2.8.12';
45
45
  exports.moduleFederationNodeVersion = '~2.5.0';
46
- exports.moduleFederationEnhancedVersion = '~0.6.0';
46
+ exports.moduleFederationEnhancedVersion = '0.6.6';
47
47
  // style preprocessors
48
48
  exports.lessVersion = '3.12.2';
49
49
  exports.sassVersion = '^1.55.0';