@nx/react 21.3.0-canary.20250613-18155f4 → 21.3.0-canary.20250617-b97222d

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": "21.3.0-canary.20250613-18155f4",
3
+ "version": "21.3.0-canary.20250617-b97222d",
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": "21.3.0-canary.20250613-18155f4",
42
- "@nx/js": "21.3.0-canary.20250613-18155f4",
43
- "@nx/eslint": "21.3.0-canary.20250613-18155f4",
44
- "@nx/web": "21.3.0-canary.20250613-18155f4",
45
- "@nx/module-federation": "21.3.0-canary.20250613-18155f4",
41
+ "@nx/devkit": "21.3.0-canary.20250617-b97222d",
42
+ "@nx/js": "21.3.0-canary.20250617-b97222d",
43
+ "@nx/eslint": "21.3.0-canary.20250617-b97222d",
44
+ "@nx/web": "21.3.0-canary.20250617-b97222d",
45
+ "@nx/module-federation": "21.3.0-canary.20250617-b97222d",
46
46
  "express": "^4.21.2",
47
47
  "http-proxy-middleware": "^3.0.3",
48
48
  "semver": "^7.6.3"
@@ -8,7 +8,7 @@ module.exports = {
8
8
  path: join(__dirname, '<%= rspackPluginOptions.outputPath %>'),
9
9
  },
10
10
  devServer: {
11
- port: 4200,
11
+ port: <%= port %>,
12
12
  historyApiFallback: {
13
13
  index: '/index.html',
14
14
  disableDotRule: true,
@@ -8,7 +8,7 @@ module.exports = {
8
8
  path: join(__dirname, '<%= webpackPluginOptions.outputPath %>'),
9
9
  },
10
10
  devServer: {
11
- port: 4200,
11
+ port: <%= port %>,
12
12
  historyApiFallback: {
13
13
  index: '/index.html',
14
14
  disableDotRule: true,
@@ -18,7 +18,7 @@ async function addE2e(tree, options) {
18
18
  e2eWebServerAddress: `http://localhost:${options.devServerPort ?? 4200}`,
19
19
  e2eWebServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx run ${options.projectName}:serve`,
20
20
  e2eCiWebServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx run ${options.projectName}:serve-static`,
21
- e2eCiBaseUrl: `http://localhost:4200`,
21
+ e2eCiBaseUrl: `http://localhost:${options.port ?? 4300}`,
22
22
  e2eDevServerTarget: `${options.projectName}:serve`,
23
23
  };
24
24
  if (options.bundler === 'webpack') {
@@ -32,8 +32,12 @@ async function addE2e(tree, options) {
32
32
  else if (options.bundler === 'vite') {
33
33
  const { getViteE2EWebServerInfo, getReactRouterE2EWebServerInfo } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
34
34
  e2eWebServerInfo = options.useReactRouter
35
- ? await getReactRouterE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.devServerPort ?? 4200)
36
- : await getViteE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.devServerPort ?? 4200);
35
+ ? await getReactRouterE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.devServerPort ?? 4200,
36
+ // If the user manually sets the port, then use it for dev and preview
37
+ options.port)
38
+ : await getViteE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.devServerPort ?? 4200,
39
+ // If the user manually sets the port, then use it for dev and preview
40
+ options.port);
37
41
  }
38
42
  else if (options.bundler === 'rsbuild') {
39
43
  (0, devkit_1.ensurePackage)('@nx/rsbuild', versions_1.nxVersion);
@@ -33,6 +33,7 @@ async function setupViteConfiguration(tree, options, tasks) {
33
33
  skipFormat: true,
34
34
  addPlugin: options.addPlugin,
35
35
  projectType: 'application',
36
+ port: options.port,
36
37
  });
37
38
  tasks.push(viteTask);
38
39
  createOrEditViteConfig(tree, {
@@ -41,6 +42,8 @@ async function setupViteConfiguration(tree, options, tasks) {
41
42
  includeVitest: options.unitTestRunner === 'vitest',
42
43
  inSourceTests: options.inSourceTests,
43
44
  rollupOptionsExternal: ["'react'", "'react-dom'", "'react/jsx-runtime'"],
45
+ port: options.port,
46
+ previewPort: options.port,
44
47
  ...(options.useReactRouter
45
48
  ? reactRouterFrameworkConfig
46
49
  : baseReactConfig),
@@ -18,6 +18,7 @@ export declare function getDefaultTemplateVariables(host: Tree, options: Normali
18
18
  style: "none" | "styled-components" | "@emotion/styled" | "styled-jsx" | "css" | "scss" | "less";
19
19
  hasStyleFile: boolean;
20
20
  isUsingTsSolutionSetup: boolean;
21
+ port: number;
21
22
  projectName: string;
22
23
  appProjectRoot: string;
23
24
  e2eProjectName: string;
@@ -36,6 +36,7 @@ function getDefaultTemplateVariables(host, options) {
36
36
  style: options.style === 'tailwind' ? 'css' : options.style,
37
37
  hasStyleFile,
38
38
  isUsingTsSolutionSetup: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
39
+ port: options.port ?? 4200,
39
40
  };
40
41
  }
41
42
  function createNxRspackPluginOptions(options, rootOffset, tsx = true) {
@@ -60,7 +60,7 @@ async function normalizeOptions(host, options) {
60
60
  normalized.unitTestRunner = normalized.unitTestRunner ?? 'jest';
61
61
  normalized.e2eTestRunner = normalized.e2eTestRunner ?? 'playwright';
62
62
  normalized.inSourceTests = normalized.minimal || normalized.inSourceTests;
63
- normalized.devServerPort ??= (0, find_free_port_1.findFreePort)(host);
63
+ normalized.devServerPort ??= options.port ?? (0, find_free_port_1.findFreePort)(host);
64
64
  normalized.minimal = normalized.minimal ?? false;
65
65
  return normalized;
66
66
  }
@@ -33,6 +33,7 @@ export interface Schema {
33
33
  useTsSolution?: boolean;
34
34
  formatter?: 'prettier' | 'none';
35
35
  useProjectJson?: boolean;
36
+ port?: number;
36
37
  }
37
38
 
38
39
  export interface NormalizedSchema<T extends Schema = Schema> extends T {
@@ -16,6 +16,10 @@
16
16
  {
17
17
  "command": "nx g app apps/myapp --routing",
18
18
  "description": "Set up React Router"
19
+ },
20
+ {
21
+ "command": "nx g app apps/myapp --port=3000",
22
+ "description": "Set up the dev server to use port 3000"
19
23
  }
20
24
  ],
21
25
  "type": "object",
@@ -196,6 +200,12 @@
196
200
  "useProjectJson": {
197
201
  "type": "boolean",
198
202
  "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
203
+ },
204
+ "port": {
205
+ "type": "number",
206
+ "description": "The port to use for the development server",
207
+ "x-prompt": "Which port would you like to use for the dev server?",
208
+ "default": 4200
199
209
  }
200
210
  },
201
211
  "required": ["directory"],