@nx/react 20.6.0-canary.20250311-d1a7ac9 → 20.6.0-canary.20250312-e4f5224

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "20.6.0-canary.20250311-d1a7ac9",
3
+ "version": "20.6.0-canary.20250312-e4f5224",
4
4
  "private": false,
5
5
  "description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Vitest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -38,11 +38,11 @@
38
38
  "minimatch": "9.0.3",
39
39
  "picocolors": "^1.1.0",
40
40
  "tslib": "^2.3.0",
41
- "@nx/devkit": "20.6.0-canary.20250311-d1a7ac9",
42
- "@nx/js": "20.6.0-canary.20250311-d1a7ac9",
43
- "@nx/eslint": "20.6.0-canary.20250311-d1a7ac9",
44
- "@nx/web": "20.6.0-canary.20250311-d1a7ac9",
45
- "@nx/module-federation": "20.6.0-canary.20250311-d1a7ac9",
41
+ "@nx/devkit": "20.6.0-canary.20250312-e4f5224",
42
+ "@nx/js": "20.6.0-canary.20250312-e4f5224",
43
+ "@nx/eslint": "20.6.0-canary.20250312-e4f5224",
44
+ "@nx/web": "20.6.0-canary.20250312-e4f5224",
45
+ "@nx/module-federation": "20.6.0-canary.20250312-e4f5224",
46
46
  "express": "^4.21.2",
47
47
  "http-proxy-middleware": "^3.0.3",
48
48
  "semver": "^7.6.3"
@@ -29,6 +29,7 @@ const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
29
29
  async function applicationGenerator(tree, schema) {
30
30
  return await applicationGeneratorInternal(tree, {
31
31
  addPlugin: false,
32
+ useProjectJson: true,
32
33
  ...schema,
33
34
  });
34
35
  }
@@ -44,11 +45,6 @@ async function applicationGeneratorInternal(tree, schema) {
44
45
  });
45
46
  tasks.push(jsInitTask);
46
47
  const options = await (0, normalize_options_1.normalizeOptions)(tree, schema);
47
- // If we are using the new TS solution
48
- // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
49
- if (options.isUsingTsSolutionConfig) {
50
- (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
51
- }
52
48
  (0, show_possible_warnings_1.showPossibleWarnings)(tree, options);
53
49
  const initTask = await (0, init_1.default)(tree, {
54
50
  ...options,
@@ -83,6 +79,11 @@ async function applicationGeneratorInternal(tree, schema) {
83
79
  }
84
80
  await (0, create_application_files_1.createApplicationFiles)(tree, options);
85
81
  (0, add_project_1.addProject)(tree, options);
82
+ // If we are using the new TS solution
83
+ // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
84
+ if (options.isUsingTsSolutionConfig) {
85
+ await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
86
+ }
86
87
  if (options.style === 'tailwind') {
87
88
  const twTask = await (0, setup_tailwind_1.setupTailwindGenerator)(tree, {
88
89
  project: options.projectName,
@@ -46,15 +46,15 @@ async function addE2e(tree, options) {
46
46
  switch (options.e2eTestRunner) {
47
47
  case 'cypress': {
48
48
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
49
- if (options.isUsingTsSolutionConfig) {
50
- (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
51
- name: options.e2eProjectName,
52
- version: '0.0.1',
53
- private: true,
54
- nx: {
55
- implicitDependencies: [options.projectName],
56
- },
57
- });
49
+ const packageJson = {
50
+ name: options.e2eProjectName,
51
+ version: '0.0.1',
52
+ private: true,
53
+ };
54
+ if (!options.useProjectJson) {
55
+ packageJson.nx = {
56
+ implicitDependencies: [options.projectName],
57
+ };
58
58
  }
59
59
  else {
60
60
  (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
@@ -66,6 +66,9 @@ async function addE2e(tree, options) {
66
66
  tags: [],
67
67
  });
68
68
  }
69
+ if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
70
+ (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
71
+ }
69
72
  const e2eTask = await configurationGenerator(tree, {
70
73
  ...options,
71
74
  project: options.e2eProjectName,
@@ -114,15 +117,15 @@ async function addE2e(tree, options) {
114
117
  }
115
118
  case 'playwright': {
116
119
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
117
- if (options.isUsingTsSolutionConfig) {
118
- (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
119
- name: options.e2eProjectName,
120
- version: '0.0.1',
121
- private: true,
122
- nx: {
123
- implicitDependencies: [options.projectName],
124
- },
125
- });
120
+ const packageJson = {
121
+ name: options.e2eProjectName,
122
+ version: '0.0.1',
123
+ private: true,
124
+ };
125
+ if (!options.useProjectJson) {
126
+ packageJson.nx = {
127
+ implicitDependencies: [options.projectName],
128
+ };
126
129
  }
127
130
  else {
128
131
  (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
@@ -131,8 +134,12 @@ async function addE2e(tree, options) {
131
134
  sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
132
135
  targets: {},
133
136
  implicitDependencies: [options.projectName],
137
+ tags: [],
134
138
  });
135
139
  }
140
+ if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
141
+ (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
142
+ }
136
143
  const e2eTask = await configurationGenerator(tree, {
137
144
  project: options.e2eProjectName,
138
145
  skipFormat: true,
@@ -28,12 +28,12 @@ function addProject(host, options) {
28
28
  serve: createRspackServeTarget(options),
29
29
  };
30
30
  }
31
- if (options.isUsingTsSolutionConfig) {
32
- const packageJson = {
33
- name: options.importPath,
34
- version: '0.0.1',
35
- private: true,
36
- };
31
+ const packageJson = {
32
+ name: options.importPath,
33
+ version: '0.0.1',
34
+ private: true,
35
+ };
36
+ if (!options.useProjectJson) {
37
37
  if (options.projectName !== options.importPath) {
38
38
  packageJson.nx = { name: options.projectName };
39
39
  }
@@ -45,21 +45,14 @@ function addProject(host, options) {
45
45
  packageJson.nx ??= {};
46
46
  packageJson.nx.tags = options.parsedTags;
47
47
  }
48
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
49
48
  }
50
- if (!options.isUsingTsSolutionConfig || options.alwaysGenerateProjectJson) {
49
+ else {
51
50
  (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
52
51
  ...project,
53
52
  });
54
53
  }
55
- else if (options.parsedTags?.length ||
56
- Object.keys(project.targets).length) {
57
- const updatedProject = {
58
- root: options.appProjectRoot,
59
- targets: project.targets,
60
- tags: options.parsedTags?.length ? options.parsedTags : undefined,
61
- };
62
- (0, devkit_1.updateProjectConfiguration)(host, options.projectName, updatedProject);
54
+ if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
55
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
63
56
  }
64
57
  }
65
58
  function createRspackBuildTarget(options) {
@@ -44,6 +44,7 @@ async function normalizeOptions(host, options) {
44
44
  hasStyles: options.style !== 'none',
45
45
  names: (0, devkit_1.names)(projectNames.projectSimpleName),
46
46
  isUsingTsSolutionConfig,
47
+ useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
47
48
  };
48
49
  normalized.routing = normalized.routing ?? false;
49
50
  normalized.strict = normalized.strict ?? true;
@@ -31,7 +31,7 @@ export interface Schema {
31
31
  nxCloudToken?: string;
32
32
  useTsSolution?: boolean;
33
33
  formatter?: 'prettier' | 'none';
34
- alwaysGenerateProjectJson?: boolean; // this is needed for MF currently
34
+ useProjectJson?: boolean;
35
35
  }
36
36
 
37
37
  export interface NormalizedSchema<T extends Schema = Schema> extends T {
@@ -187,6 +187,10 @@
187
187
  "description": "Generate a React app with a minimal setup, no separate test files.",
188
188
  "type": "boolean",
189
189
  "default": false
190
+ },
191
+ "useProjectJson": {
192
+ "type": "boolean",
193
+ "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
190
194
  }
191
195
  },
192
196
  "required": ["directory"],
@@ -21,7 +21,7 @@ async function hostGenerator(host, schema) {
21
21
  const options = {
22
22
  ...(await (0, normalize_options_1.normalizeOptions)(host, {
23
23
  ...schema,
24
- alwaysGenerateProjectJson: true,
24
+ useProjectJson: true,
25
25
  })),
26
26
  js: schema.js ?? false,
27
27
  typescriptConfiguration: schema.js
@@ -50,7 +50,7 @@ async function hostGenerator(host, schema) {
50
50
  // The target use-case is loading remotes as child routes, thus always enable routing.
51
51
  routing: true,
52
52
  skipFormat: true,
53
- alwaysGenerateProjectJson: true,
53
+ useProjectJson: true,
54
54
  });
55
55
  tasks.push(initTask);
56
56
  const remotesWithPorts = [];
@@ -43,7 +43,8 @@ function createFiles(host, options) {
43
43
  });
44
44
  }
45
45
  if ((options.publishable || options.buildable) &&
46
- !options.isUsingTsSolutionConfig) {
46
+ !options.isUsingTsSolutionConfig &&
47
+ options.useProjectJson) {
47
48
  if (options.bundler === 'vite') {
48
49
  (0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, {
49
50
  name: options.importPath,
@@ -45,6 +45,7 @@ async function normalizeOptions(host, options) {
45
45
  projectRoot,
46
46
  parsedTags,
47
47
  importPath,
48
+ useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
48
49
  };
49
50
  // Libraries with a bundler or is publishable must also be buildable.
50
51
  normalized.buildable = Boolean(normalized.bundler !== 'none' || options.buildable || options.publishable);
@@ -27,6 +27,7 @@ const add_release_config_1 = require("@nx/js/src/generators/library/utils/add-re
27
27
  async function libraryGenerator(host, schema) {
28
28
  return await libraryGeneratorInternal(host, {
29
29
  addPlugin: false,
30
+ useProjectJson: true,
30
31
  ...schema,
31
32
  });
32
33
  }
@@ -39,7 +40,7 @@ async function libraryGeneratorInternal(host, schema) {
39
40
  tasks.push(jsInitTask);
40
41
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
41
42
  if (options.isUsingTsSolutionConfig) {
42
- (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
43
+ await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
43
44
  }
44
45
  if (options.publishable === true && !schema.importPath) {
45
46
  throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
@@ -52,13 +53,13 @@ async function libraryGeneratorInternal(host, schema) {
52
53
  skipFormat: true,
53
54
  });
54
55
  tasks.push(initTask);
55
- if (options.isUsingTsSolutionConfig) {
56
- const packageJson = {
57
- name: options.importPath,
58
- version: '0.0.1',
59
- ...(0, determine_entry_fields_1.determineEntryFields)(options),
60
- files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
61
- };
56
+ const packageJson = {
57
+ name: options.importPath,
58
+ version: '0.0.1',
59
+ ...(0, determine_entry_fields_1.determineEntryFields)(options),
60
+ files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
61
+ };
62
+ if (!options.useProjectJson) {
62
63
  if (options.name !== options.importPath) {
63
64
  packageJson.nx = { name: options.name };
64
65
  }
@@ -66,7 +67,6 @@ async function libraryGeneratorInternal(host, schema) {
66
67
  packageJson.nx ??= {};
67
68
  packageJson.nx.tags = options.parsedTags;
68
69
  }
69
- (0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, packageJson);
70
70
  }
71
71
  else {
72
72
  (0, devkit_1.addProjectConfiguration)(host, options.name, {
@@ -77,6 +77,9 @@ async function libraryGeneratorInternal(host, schema) {
77
77
  targets: {},
78
78
  });
79
79
  }
80
+ if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
81
+ (0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, packageJson);
82
+ }
80
83
  (0, create_files_1.createFiles)(host, options);
81
84
  const lintTask = await (0, add_linting_1.addLinting)(host, options);
82
85
  tasks.push(lintTask);
@@ -27,6 +27,7 @@ export interface Schema {
27
27
  minimal?: boolean;
28
28
  simpleName?: boolean;
29
29
  addPlugin?: boolean;
30
+ useProjectJson?: boolean;
30
31
  }
31
32
 
32
33
  export interface NormalizedSchema extends Schema {
@@ -190,6 +190,10 @@
190
190
  "description": "Don't include the directory in the name of the module of the library.",
191
191
  "type": "boolean",
192
192
  "default": false
193
+ },
194
+ "useProjectJson": {
195
+ "type": "boolean",
196
+ "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
193
197
  }
194
198
  },
195
199
  "required": ["directory"]
@@ -50,7 +50,7 @@ async function remoteGenerator(host, schema) {
50
50
  const options = {
51
51
  ...(await (0, normalize_options_1.normalizeOptions)(host, {
52
52
  ...schema,
53
- alwaysGenerateProjectJson: true,
53
+ useProjectJson: true,
54
54
  })),
55
55
  // when js is set to true, we want to use the js configuration
56
56
  js: schema.js ?? false,
@@ -83,7 +83,7 @@ async function remoteGenerator(host, schema) {
83
83
  ...options,
84
84
  name: options.projectName,
85
85
  skipFormat: true,
86
- alwaysGenerateProjectJson: true,
86
+ useProjectJson: true,
87
87
  });
88
88
  tasks.push(initAppTask);
89
89
  if (options.host) {