@nx/react 22.0.0-canary.20251014-82acc84 → 22.0.0-canary.20251015-f37c13b

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": "22.0.0-canary.20251014-82acc84",
3
+ "version": "22.0.0-canary.20251015-f37c13b",
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,22 +38,22 @@
38
38
  "minimatch": "9.0.3",
39
39
  "picocolors": "^1.1.0",
40
40
  "tslib": "^2.3.0",
41
- "@nx/devkit": "22.0.0-canary.20251014-82acc84",
42
- "@nx/js": "22.0.0-canary.20251014-82acc84",
43
- "@nx/eslint": "22.0.0-canary.20251014-82acc84",
44
- "@nx/web": "22.0.0-canary.20251014-82acc84",
45
- "@nx/vite": "22.0.0-canary.20251014-82acc84",
46
- "@nx/module-federation": "22.0.0-canary.20251014-82acc84",
47
- "@nx/rollup": "22.0.0-canary.20251014-82acc84",
41
+ "@nx/devkit": "22.0.0-canary.20251015-f37c13b",
42
+ "@nx/js": "22.0.0-canary.20251015-f37c13b",
43
+ "@nx/eslint": "22.0.0-canary.20251015-f37c13b",
44
+ "@nx/web": "22.0.0-canary.20251015-f37c13b",
45
+ "@nx/vite": "22.0.0-canary.20251015-f37c13b",
46
+ "@nx/module-federation": "22.0.0-canary.20251015-f37c13b",
47
+ "@nx/rollup": "22.0.0-canary.20251015-f37c13b",
48
48
  "express": "^4.21.2",
49
49
  "http-proxy-middleware": "^3.0.5",
50
50
  "semver": "^7.6.3"
51
51
  },
52
52
  "devDependencies": {
53
- "@nx/cypress": "22.0.0-canary.20251014-82acc84",
54
- "@nx/playwright": "22.0.0-canary.20251014-82acc84",
55
- "@nx/rsbuild": "22.0.0-canary.20251014-82acc84",
56
- "nx": "22.0.0-canary.20251014-82acc84"
53
+ "@nx/cypress": "22.0.0-canary.20251015-f37c13b",
54
+ "@nx/playwright": "22.0.0-canary.20251015-f37c13b",
55
+ "@nx/rsbuild": "22.0.0-canary.20251015-f37c13b",
56
+ "nx": "22.0.0-canary.20251015-f37c13b"
57
57
  },
58
58
  "publishConfig": {
59
59
  "access": "public"
@@ -1 +1 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/host/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAIjB,IAAI,EAEL,MAAM,YAAY,CAAC;AAapB,OAAO,EAAoB,MAAM,EAAE,MAAM,UAAU,CAAC;AAWpD,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,CAAC,CAkI5B;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/host/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAKjB,IAAI,EAGL,MAAM,YAAY,CAAC;AAapB,OAAO,EAAoB,MAAM,EAAE,MAAM,UAAU,CAAC;AAYpD,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,CAAC,CAmJ5B;AAmCD,eAAe,aAAa,CAAC"}
@@ -13,6 +13,7 @@ const setup_ssr_for_host_1 = require("./lib/setup-ssr-for-host");
13
13
  const update_module_federation_e2e_project_1 = require("./lib/update-module-federation-e2e-project");
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
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
16
17
  const versions_1 = require("../../utils/versions");
17
18
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
18
19
  const update_module_federation_tsconfig_1 = require("./lib/update-module-federation-tsconfig");
@@ -24,7 +25,6 @@ async function hostGenerator(host, schema) {
24
25
  ...(await (0, normalize_options_1.normalizeOptions)(host, {
25
26
  ...schema,
26
27
  name,
27
- useProjectJson: true,
28
28
  })),
29
29
  js: schema.js ?? false,
30
30
  typescriptConfiguration: schema.js
@@ -53,9 +53,18 @@ async function hostGenerator(host, schema) {
53
53
  // The target use-case is loading remotes as child routes, thus always enable routing.
54
54
  routing: true,
55
55
  skipFormat: true,
56
- useProjectJson: true,
57
56
  });
58
57
  tasks.push(initTask);
58
+ // In TS solution setup, update package.json to use simple name instead of scoped name
59
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
60
+ const hostPackageJsonPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json');
61
+ if (host.exists(hostPackageJsonPath)) {
62
+ (0, devkit_1.updateJson)(host, hostPackageJsonPath, (json) => {
63
+ json.name = options.projectName;
64
+ return json;
65
+ });
66
+ }
67
+ }
59
68
  const remotesWithPorts = [];
60
69
  if (schema.remotes) {
61
70
  let remotePort = options.devServerPort + 1;
@@ -87,6 +96,10 @@ async function hostGenerator(host, schema) {
87
96
  (0, update_module_federation_project_1.updateModuleFederationProject)(host, options, true);
88
97
  (0, update_module_federation_e2e_project_1.updateModuleFederationE2eProject)(host, options);
89
98
  (0, update_module_federation_tsconfig_1.updateModuleFederationTsconfig)(host, options);
99
+ // Add remotes as devDependencies in TS solution setup
100
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host) && remotesWithPorts.length > 0) {
101
+ addRemotesAsHostDependencies(host, options.projectName, remotesWithPorts);
102
+ }
90
103
  if (options.ssr) {
91
104
  if (options.bundler !== 'rspack') {
92
105
  const setupSsrTask = await (0, setup_ssr_1.default)(host, {
@@ -118,4 +131,22 @@ async function hostGenerator(host, schema) {
118
131
  }
119
132
  return (0, devkit_1.runTasksInSerial)(...tasks);
120
133
  }
134
+ function addRemotesAsHostDependencies(tree, hostName, remotes) {
135
+ const hostConfig = (0, devkit_1.readProjectConfiguration)(tree, hostName);
136
+ const hostPackageJsonPath = (0, devkit_1.joinPathFragments)(hostConfig.root, 'package.json');
137
+ if (!tree.exists(hostPackageJsonPath)) {
138
+ throw new Error(`Host package.json not found at ${hostPackageJsonPath}. ` +
139
+ `TypeScript solution setup requires package.json for all projects.`);
140
+ }
141
+ const packageManager = (0, devkit_1.detectPackageManager)(tree.root);
142
+ const versionSpec = packageManager === 'npm' ? '*' : 'workspace:*';
143
+ (0, devkit_1.updateJson)(tree, hostPackageJsonPath, (json) => {
144
+ json.devDependencies ??= {};
145
+ for (const remote of remotes) {
146
+ // Use simple remote name directly to match module-federation.config.ts
147
+ json.devDependencies[remote.name] = versionSpec;
148
+ }
149
+ return json;
150
+ });
151
+ }
121
152
  exports.default = hostGenerator;
@@ -1 +1 @@
1
- {"version":3,"file":"add-module-federation-files.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/host/lib/add-module-federation-files.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAML,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,EACzB,qBAAqB,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,QAuIxD"}
1
+ {"version":3,"file":"add-module-federation-files.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/host/lib/add-module-federation-files.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAML,MAAM,YAAY,CAAC;AAUpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,EACzB,qBAAqB,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,QAgJxD"}
@@ -68,6 +68,13 @@ function addModuleFederationFiles(host, options, defaultRemoteManifest) {
68
68
  processBundlerConfigFile(options, host, 'webpack.config.js');
69
69
  processBundlerConfigFile(options, host, 'webpack.config.prod.js');
70
70
  }
71
+ // Delete TypeScript prod config in TS solution setup - not needed in Crystal
72
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
73
+ const prodConfigFileName = options.bundler === 'rspack'
74
+ ? 'rspack.config.prod.ts'
75
+ : 'webpack.config.prod.ts';
76
+ processBundlerConfigFile(options, host, prodConfigFileName);
77
+ }
71
78
  }
72
79
  if (options.dynamic) {
73
80
  processBundlerConfigFile(options, host, 'webpack.config.prod.js');
@@ -0,0 +1,4 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from '../../application/schema';
3
+ export declare function setupPackageJsonExportsForRemote(tree: Tree, options: NormalizedSchema): void;
4
+ //# sourceMappingURL=setup-package-json-exports-for-remote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-package-json-exports-for-remote.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/remote/lib/setup-package-json-exports-for-remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,IAAI,EAEL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,QA+B1B"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupPackageJsonExportsForRemote = setupPackageJsonExportsForRemote;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
+ const maybe_js_1 = require("../../../utils/maybe-js");
7
+ function setupPackageJsonExportsForRemote(tree, options) {
8
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
9
+ const packageJsonPath = (0, devkit_1.joinPathFragments)(project.root, 'package.json');
10
+ if (!tree.exists(packageJsonPath)) {
11
+ throw new Error(`package.json not found at ${packageJsonPath}. ` +
12
+ `TypeScript solution setup requires package.json for all projects.`);
13
+ }
14
+ const exportPath = (0, maybe_js_1.maybeJs)(options, './src/remote-entry.ts');
15
+ const customCondition = (0, ts_solution_setup_1.getDefinedCustomConditionName)(tree);
16
+ (0, devkit_1.updateJson)(tree, packageJsonPath, (json) => {
17
+ json.exports = {
18
+ ...json.exports,
19
+ './Module': {
20
+ [customCondition]: exportPath,
21
+ types: exportPath,
22
+ import: exportPath,
23
+ default: exportPath,
24
+ },
25
+ };
26
+ // Set types for IDE support (no main needed - this is an app, not a library)
27
+ json.types = exportPath;
28
+ return json;
29
+ });
30
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"update-host-with-remote.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/remote/lib/update-host-with-remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,IAAI,EACL,MAAM,YAAY,CAAC;AAUpB,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,QAmEnB"}
1
+ {"version":3,"file":"update-host-with-remote.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/remote/lib/update-host-with-remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,IAAI,EAEL,MAAM,YAAY,CAAC;AAapB,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,QAwEnB"}
@@ -35,6 +35,10 @@ function updateHostWithRemote(host, hostName, remoteName) {
35
35
  else {
36
36
  devkit_1.logger.warn(`Could not find app component at ${appComponentPath}. Did you generate this project with "@nx/react:host" or "@nx/react:consumer"?`);
37
37
  }
38
+ // Add remote as devDependency in TS solution setup
39
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
40
+ addRemoteAsHostDependency(host, hostName, remoteName);
41
+ }
38
42
  }
39
43
  function findAppComponentPath(host, sourceRoot) {
40
44
  const locations = [
@@ -57,3 +61,20 @@ function findAppComponentPath(host, sourceRoot) {
57
61
  }
58
62
  }
59
63
  }
64
+ function addRemoteAsHostDependency(tree, hostName, remoteName) {
65
+ const hostConfig = (0, devkit_1.readProjectConfiguration)(tree, hostName);
66
+ const hostPackageJsonPath = (0, devkit_1.joinPathFragments)(hostConfig.root, 'package.json');
67
+ if (!tree.exists(hostPackageJsonPath)) {
68
+ throw new Error(`Host package.json not found at ${hostPackageJsonPath}. ` +
69
+ `TypeScript solution setup requires package.json for all projects.`);
70
+ }
71
+ const packageManager = (0, devkit_1.detectPackageManager)(tree.root);
72
+ // npm doesn't support workspace: protocol, use * instead
73
+ const versionSpec = packageManager === 'npm' ? '*' : 'workspace:*';
74
+ (0, devkit_1.updateJson)(tree, hostPackageJsonPath, (json) => {
75
+ json.devDependencies ??= {};
76
+ // Use simple remote name directly to match module-federation.config.ts
77
+ json.devDependencies[remoteName] = versionSpec;
78
+ return json;
79
+ });
80
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/remote/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAMjB,IAAI,EAEL,MAAM,YAAY,CAAC;AAoBpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAMzD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,QAsElC;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,8BAmJ/D;AAED,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/remote/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAOjB,IAAI,EAGL,MAAM,YAAY,CAAC;AAuBpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAOzD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,QAmFlC;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,8BAqK/D;AAED,eAAe,eAAe,CAAC"}
@@ -17,6 +17,7 @@ const create_application_files_1 = require("../application/lib/create-applicatio
17
17
  const normalize_options_1 = require("../application/lib/normalize-options");
18
18
  const setup_ssr_1 = require("../setup-ssr/setup-ssr");
19
19
  const add_remote_to_dynamic_host_1 = require("./lib/add-remote-to-dynamic-host");
20
+ const setup_package_json_exports_for_remote_1 = require("./lib/setup-package-json-exports-for-remote");
20
21
  const setup_ssr_for_remote_1 = require("./lib/setup-ssr-for-remote");
21
22
  const setup_tspath_for_remote_1 = require("./lib/setup-tspath-for-remote");
22
23
  const update_host_with_remote_1 = require("./lib/update-host-with-remote");
@@ -54,6 +55,15 @@ function addModuleFederationFiles(host, options) {
54
55
  if (host.exists(pathToWebpackProdConfig)) {
55
56
  host.delete(pathToWebpackProdConfig);
56
57
  }
58
+ // Delete TypeScript prod config in TS solution setup - not needed in Crystal
59
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
60
+ const pathToTsProdConfig = (0, devkit_1.joinPathFragments)(options.appProjectRoot, options.bundler === 'rspack'
61
+ ? 'rspack.config.prod.ts'
62
+ : 'webpack.config.prod.ts');
63
+ if (host.exists(pathToTsProdConfig)) {
64
+ host.delete(pathToTsProdConfig);
65
+ }
66
+ }
57
67
  }
58
68
  }
59
69
  async function remoteGenerator(host, schema) {
@@ -63,7 +73,6 @@ async function remoteGenerator(host, schema) {
63
73
  ...(await (0, normalize_options_1.normalizeOptions)(host, {
64
74
  ...schema,
65
75
  name,
66
- useProjectJson: true,
67
76
  })),
68
77
  // when js is set to true, we want to use the js configuration
69
78
  js: schema.js ?? false,
@@ -92,9 +101,18 @@ async function remoteGenerator(host, schema) {
92
101
  ...options,
93
102
  name: options.projectName,
94
103
  skipFormat: true,
95
- useProjectJson: true,
96
104
  });
97
105
  tasks.push(initAppTask);
106
+ // In TS solution setup, update package.json to use simple name instead of scoped name
107
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
108
+ const remotePackageJsonPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json');
109
+ if (host.exists(remotePackageJsonPath)) {
110
+ (0, devkit_1.updateJson)(host, remotePackageJsonPath, (json) => {
111
+ json.name = options.projectName;
112
+ return json;
113
+ });
114
+ }
115
+ }
98
116
  if (options.host) {
99
117
  (0, update_host_with_remote_1.updateHostWithRemote)(host, options.host, options.projectName);
100
118
  }
@@ -104,7 +122,13 @@ async function remoteGenerator(host, schema) {
104
122
  host.rename((0, path_1.join)(options.appProjectRoot, (0, maybe_js_1.maybeJs)({ js: options.js, useJsx: options.bundler === 'rspack' }, 'src/main.tsx')), (0, path_1.join)(options.appProjectRoot, (0, maybe_js_1.maybeJs)({ js: options.js, useJsx: options.bundler === 'rspack' }, 'src/bootstrap.tsx')));
105
123
  addModuleFederationFiles(host, options);
106
124
  (0, update_module_federation_project_1.updateModuleFederationProject)(host, options);
107
- (0, setup_tspath_for_remote_1.setupTspathForRemote)(host, options);
125
+ // Conditionally setup TS path or package.json exports based on TS solution setup
126
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
127
+ (0, setup_package_json_exports_for_remote_1.setupPackageJsonExportsForRemote)(host, options);
128
+ }
129
+ else {
130
+ (0, setup_tspath_for_remote_1.setupTspathForRemote)(host, options);
131
+ }
108
132
  if (options.ssr) {
109
133
  if (options.bundler !== 'rspack') {
110
134
  const setupSsrTask = await (0, setup_ssr_1.default)(host, {
@@ -6,6 +6,7 @@ const maybe_js_1 = require("../utils/maybe-js");
6
6
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
7
  function updateModuleFederationProject(host, options, isHost = false) {
8
8
  const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
9
+ projectConfig.targets ??= {};
9
10
  if (options.bundler !== 'rspack') {
10
11
  projectConfig.targets.build.options = {
11
12
  ...(projectConfig.targets.build.options ?? {}),