@nx/react 20.4.0-canary.20250110-cbfc6fe → 20.4.0-canary.20250111-bbbfd9f

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/migrations.json CHANGED
@@ -47,6 +47,12 @@
47
47
  "version": "20.3.0-beta.2",
48
48
  "description": "If workspace includes Module Federation projects, ensure the new @nx/module-federation package is installed.",
49
49
  "factory": "./src/migrations/update-20-3-0/ensure-nx-module-federation-package"
50
+ },
51
+ "add-mf-env-var-to-target-defaults": {
52
+ "cli": "nx",
53
+ "version": "20.4.0-beta.0",
54
+ "description": "Add NX_MF_DEV_REMOTES to inputs for task hashing when '@nx/webpack:webpack' or '@nx/rspack:rspack' is used for Module Federation.",
55
+ "factory": "./src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults"
50
56
  }
51
57
  },
52
58
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "20.4.0-canary.20250110-cbfc6fe",
3
+ "version": "20.4.0-canary.20250111-bbbfd9f",
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.4.0-canary.20250110-cbfc6fe",
42
- "@nx/js": "20.4.0-canary.20250110-cbfc6fe",
43
- "@nx/eslint": "20.4.0-canary.20250110-cbfc6fe",
44
- "@nx/web": "20.4.0-canary.20250110-cbfc6fe",
45
- "@nx/module-federation": "20.4.0-canary.20250110-cbfc6fe",
41
+ "@nx/devkit": "20.4.0-canary.20250111-bbbfd9f",
42
+ "@nx/js": "20.4.0-canary.20250111-bbbfd9f",
43
+ "@nx/eslint": "20.4.0-canary.20250111-bbbfd9f",
44
+ "@nx/web": "20.4.0-canary.20250111-bbbfd9f",
45
+ "@nx/module-federation": "20.4.0-canary.20250111-bbbfd9f",
46
46
  "express": "^4.19.2",
47
47
  "http-proxy-middleware": "^3.0.3"
48
48
  },
@@ -104,7 +104,7 @@ async function hostGenerator(host, schema) {
104
104
  if (!options.setParserOptionsProject) {
105
105
  host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.lint.json'));
106
106
  }
107
- (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host);
107
+ (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host, options.bundler);
108
108
  const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, { '@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion }, {
109
109
  '@nx/web': versions_1.nxVersion,
110
110
  '@nx/module-federation': versions_1.nxVersion,
@@ -0,0 +1,3 @@
1
+ import type { PackageJson } from 'nx/src/utils/package-json';
2
+ import type { NormalizedSchema } from '../schema';
3
+ export declare function determineEntryFields(options: NormalizedSchema): Pick<PackageJson, 'main' | 'types' | 'exports'>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.determineEntryFields = determineEntryFields;
4
+ function determineEntryFields(options) {
5
+ if (options.bundler !== 'none') {
6
+ return {};
7
+ }
8
+ return {
9
+ main: options.js ? './src/index.js' : './src/index.ts',
10
+ types: options.js ? './src/index.js' : './src/index.ts',
11
+ exports: {
12
+ '.': options.js
13
+ ? './src/index.js'
14
+ : {
15
+ types: './src/index.ts',
16
+ import: './src/index.ts',
17
+ default: './src/index.ts',
18
+ },
19
+ './package.json': './package.json',
20
+ },
21
+ };
22
+ }
@@ -21,6 +21,7 @@ const create_ts_config_1 = require("../../utils/create-ts-config");
21
21
  const install_common_dependencies_1 = require("./lib/install-common-dependencies");
22
22
  const set_defaults_1 = require("./lib/set-defaults");
23
23
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
24
+ const determine_entry_fields_1 = require("./lib/determine-entry-fields");
24
25
  async function libraryGenerator(host, schema) {
25
26
  return await libraryGeneratorInternal(host, {
26
27
  addPlugin: false,
@@ -47,16 +48,10 @@ async function libraryGeneratorInternal(host, schema) {
47
48
  });
48
49
  tasks.push(initTask);
49
50
  if (options.isUsingTsSolutionConfig) {
50
- const sourceEntry = options.bundler === 'none'
51
- ? options.js
52
- ? './src/index.js'
53
- : './src/index.ts'
54
- : undefined;
55
51
  (0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, {
56
52
  name: options.importPath,
57
53
  version: '0.0.1',
58
- main: sourceEntry,
59
- types: sourceEntry,
54
+ ...(0, determine_entry_fields_1.determineEntryFields)(options),
60
55
  nx: {
61
56
  name: options.importPath === options.name ? undefined : options.name,
62
57
  projectType: 'library',
@@ -122,7 +122,7 @@ async function remoteGenerator(host, schema) {
122
122
  const pathToMFManifest = (0, devkit_1.joinPathFragments)(hostConfig.sourceRoot, 'assets/module-federation.manifest.json');
123
123
  (0, add_remote_to_dynamic_host_1.addRemoteToDynamicHost)(host, options.projectName, options.devServerPort, pathToMFManifest);
124
124
  }
125
- (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host);
125
+ (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host, options.bundler);
126
126
  const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
127
127
  '@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion,
128
128
  '@nx/web': versions_1.nxVersion,
@@ -4,10 +4,11 @@ exports.default = default_1;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
6
6
  async function default_1(tree) {
7
- if (!hasModuleFederationProject(tree)) {
7
+ const bundler = hasModuleFederationProject(tree);
8
+ if (!bundler) {
8
9
  return;
9
10
  }
10
- (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(tree);
11
+ (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(tree, bundler);
11
12
  await (0, devkit_1.formatFiles)(tree);
12
13
  }
13
14
  function hasModuleFederationProject(tree) {
@@ -15,10 +16,14 @@ function hasModuleFederationProject(tree) {
15
16
  for (const project of projects.values()) {
16
17
  const targets = project.targets || {};
17
18
  for (const [_, target] of Object.entries(targets)) {
18
- if (target.executor === '@nx/webpack:webpack' &&
19
- (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||
20
- tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.js')))) {
21
- return true;
19
+ if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||
20
+ tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.js'))) {
21
+ if (target.executor === '@nx/webpack:webpack') {
22
+ return 'webpack';
23
+ }
24
+ else if (target.executor === '@nx/rspack:rspack') {
25
+ return 'rspack';
26
+ }
22
27
  }
23
28
  }
24
29
  }
@@ -1,2 +1,2 @@
1
1
  import { type Tree } from '@nx/devkit';
2
- export declare function addMfEnvToTargetDefaultInputs(tree: Tree): void;
2
+ export declare function addMfEnvToTargetDefaultInputs(tree: Tree, bundler: 'rspack' | 'webpack'): void;
@@ -2,27 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addMfEnvToTargetDefaultInputs = addMfEnvToTargetDefaultInputs;
4
4
  const devkit_1 = require("@nx/devkit");
5
- function addMfEnvToTargetDefaultInputs(tree) {
5
+ function addMfEnvToTargetDefaultInputs(tree, bundler) {
6
6
  const nxJson = (0, devkit_1.readNxJson)(tree);
7
- const webpackExecutor = '@nx/webpack:webpack';
7
+ const executor = bundler === 'rspack' ? '@nx/rspack:rspack' : '@nx/webpack:webpack';
8
8
  const mfEnvVar = 'NX_MF_DEV_REMOTES';
9
9
  nxJson.targetDefaults ??= {};
10
- nxJson.targetDefaults[webpackExecutor] ??= {};
11
- nxJson.targetDefaults[webpackExecutor].inputs ??= [
12
- 'production',
13
- '^production',
14
- ];
15
- nxJson.targetDefaults[webpackExecutor].dependsOn ??= ['^build'];
10
+ nxJson.targetDefaults[executor] ??= {};
11
+ nxJson.targetDefaults[executor].inputs ??= ['production', '^production'];
12
+ nxJson.targetDefaults[executor].dependsOn ??= ['^build'];
16
13
  let mfEnvVarExists = false;
17
- for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
14
+ for (const input of nxJson.targetDefaults[executor].inputs) {
18
15
  if (typeof input === 'object' && input['env'] === mfEnvVar) {
19
16
  mfEnvVarExists = true;
20
17
  break;
21
18
  }
22
19
  }
23
20
  if (!mfEnvVarExists) {
24
- nxJson.targetDefaults[webpackExecutor].inputs.push({ env: mfEnvVar });
21
+ nxJson.targetDefaults[executor].inputs.push({ env: mfEnvVar });
25
22
  }
26
- nxJson.targetDefaults[webpackExecutor].cache = true;
23
+ nxJson.targetDefaults[executor].cache = true;
27
24
  (0, devkit_1.updateNxJson)(tree, nxJson);
28
25
  }