@nx/react 19.5.6 → 19.6.0-beta.0

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": "19.5.6",
3
+ "version": "19.6.0-beta.0",
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": {
@@ -39,11 +39,11 @@
39
39
  "minimatch": "9.0.3",
40
40
  "tslib": "^2.3.0",
41
41
  "@module-federation/enhanced": "~0.2.3",
42
- "@nx/devkit": "19.5.6",
43
- "@nx/js": "19.5.6",
44
- "@nx/eslint": "19.5.6",
45
- "@nx/web": "19.5.6",
46
- "@nrwl/react": "19.5.6"
42
+ "@nx/devkit": "19.6.0-beta.0",
43
+ "@nx/js": "19.6.0-beta.0",
44
+ "@nx/eslint": "19.6.0-beta.0",
45
+ "@nx/web": "19.6.0-beta.0",
46
+ "@nrwl/react": "19.6.0-beta.0"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"
@@ -6,18 +6,20 @@ const web_1 = require("@nx/web");
6
6
  const versions_1 = require("../../../utils/versions");
7
7
  const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
8
8
  const has_vite_plugin_1 = require("../../../utils/has-vite-plugin");
9
+ const find_plugin_for_config_file_1 = require("@nx/devkit/src/utils/find-plugin-for-config-file");
10
+ const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
9
11
  async function addE2e(tree, options) {
12
+ const hasNxBuildPlugin = (options.bundler === 'webpack' && (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)) ||
13
+ (options.bundler === 'vite' && (0, has_vite_plugin_1.hasVitePlugin)(tree));
14
+ if (!hasNxBuildPlugin) {
15
+ await (0, web_1.webStaticServeGenerator)(tree, {
16
+ buildTarget: `${options.projectName}:build`,
17
+ targetName: 'serve-static',
18
+ spa: true,
19
+ });
20
+ }
10
21
  switch (options.e2eTestRunner) {
11
22
  case 'cypress': {
12
- const hasNxBuildPlugin = (options.bundler === 'webpack' && (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)) ||
13
- (options.bundler === 'vite' && (0, has_vite_plugin_1.hasVitePlugin)(tree));
14
- if (!hasNxBuildPlugin) {
15
- await (0, web_1.webStaticServeGenerator)(tree, {
16
- buildTarget: `${options.projectName}:build`,
17
- targetName: 'serve-static',
18
- spa: true,
19
- });
20
- }
21
23
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
22
24
  (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
23
25
  projectType: 'application',
@@ -27,7 +29,7 @@ async function addE2e(tree, options) {
27
29
  implicitDependencies: [options.projectName],
28
30
  tags: [],
29
31
  });
30
- return await configurationGenerator(tree, {
32
+ const e2eTask = await configurationGenerator(tree, {
31
33
  ...options,
32
34
  project: options.e2eProjectName,
33
35
  directory: 'src',
@@ -45,9 +47,29 @@ async function addE2e(tree, options) {
45
47
  }
46
48
  : undefined,
47
49
  ciWebServerCommand: hasNxBuildPlugin
48
- ? `nx run ${options.projectName}:serve-static`
50
+ ? `nx run ${options.projectName}:${options.e2eCiWebServerTarget}`
49
51
  : undefined,
52
+ ciBaseUrl: options.bundler === 'vite' ? options.e2eCiBaseUrl : undefined,
50
53
  });
54
+ if (options.addPlugin ||
55
+ (0, devkit_1.readNxJson)(tree).plugins?.find((p) => typeof p === 'string'
56
+ ? p === '@nx/cypress/plugin'
57
+ : p.plugin === '@nx/cypress/plugin')) {
58
+ let buildTarget = '^build';
59
+ if (hasNxBuildPlugin) {
60
+ const configFile = options.bundler === 'webpack'
61
+ ? 'webpack.config.js'
62
+ : options.bundler === 'vite'
63
+ ? `vite.config.${options.js ? 'js' : 'ts'}`
64
+ : 'webpack.config.js';
65
+ const matchingPlugin = await (0, find_plugin_for_config_file_1.findPluginForConfigFile)(tree, `@nx/${options.bundler}/plugin`, (0, devkit_1.joinPathFragments)(options.appProjectRoot, configFile));
66
+ if (matchingPlugin && typeof matchingPlugin !== 'string') {
67
+ buildTarget = `^${matchingPlugin.options?.buildTargetName ?? 'build'}`;
68
+ }
69
+ }
70
+ await (0, target_defaults_utils_1.addE2eCiTargetDefaults)(tree, '@nx/cypress/plugin', buildTarget, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, `cypress.config.${options.js ? 'js' : 'ts'}`));
71
+ }
72
+ return e2eTask;
51
73
  }
52
74
  case 'playwright': {
53
75
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
@@ -58,7 +80,7 @@ async function addE2e(tree, options) {
58
80
  targets: {},
59
81
  implicitDependencies: [options.projectName],
60
82
  });
61
- return configurationGenerator(tree, {
83
+ const e2eTask = await configurationGenerator(tree, {
62
84
  project: options.e2eProjectName,
63
85
  skipFormat: true,
64
86
  skipPackageJson: options.skipPackageJson,
@@ -66,11 +88,30 @@ async function addE2e(tree, options) {
66
88
  js: false,
67
89
  linter: options.linter,
68
90
  setParserOptionsProject: options.setParserOptionsProject,
69
- webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx ${options.e2eWebServerTarget} ${options.name}`,
70
- webServerAddress: options.e2eWebServerAddress,
91
+ webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx run ${options.projectName}:${options.e2eCiWebServerTarget}`,
92
+ webServerAddress: options.e2eCiBaseUrl,
71
93
  rootProject: options.rootProject,
72
94
  addPlugin: options.addPlugin,
73
95
  });
96
+ if (options.addPlugin ||
97
+ (0, devkit_1.readNxJson)(tree).plugins?.find((p) => typeof p === 'string'
98
+ ? p === '@nx/playwright/plugin'
99
+ : p.plugin === '@nx/playwright/plugin')) {
100
+ let buildTarget = '^build';
101
+ if (hasNxBuildPlugin) {
102
+ const configFile = options.bundler === 'webpack'
103
+ ? 'webpack.config.js'
104
+ : options.bundler === 'vite'
105
+ ? `vite.config.${options.js ? 'js' : 'ts'}`
106
+ : 'webpack.config.js';
107
+ const matchingPlugin = await (0, find_plugin_for_config_file_1.findPluginForConfigFile)(tree, `@nx/${options.bundler}/plugin`, (0, devkit_1.joinPathFragments)(options.appProjectRoot, configFile));
108
+ if (matchingPlugin && typeof matchingPlugin !== 'string') {
109
+ buildTarget = `^${matchingPlugin.options?.buildTargetName ?? 'build'}`;
110
+ }
111
+ }
112
+ await (0, target_defaults_utils_1.addE2eCiTargetDefaults)(tree, '@nx/playwright/plugin', buildTarget, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, `playwright.config.ts`));
113
+ }
114
+ return e2eTask;
74
115
  }
75
116
  case 'none':
76
117
  default:
@@ -32,28 +32,35 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/react:app
32
32
  options.addPlugin ??= addPlugin;
33
33
  options.rootProject = appProjectRoot === '.';
34
34
  options.projectNameAndRootFormat = projectNameAndRootFormat;
35
+ let e2ePort = options.devServerPort ?? 4200;
35
36
  let e2eWebServerTarget = 'serve';
37
+ let e2eCiWebServerTarget = options.bundler === 'vite' ? 'preview' : 'serve-static';
36
38
  if (options.addPlugin) {
37
39
  if (nxJson.plugins) {
38
40
  for (const plugin of nxJson.plugins) {
39
41
  if (options.bundler === 'vite' &&
40
42
  typeof plugin === 'object' &&
41
- plugin.plugin === '@nx/vite/plugin' &&
42
- plugin.options.serveTargetName) {
43
- e2eWebServerTarget = plugin.options
44
- .serveTargetName;
43
+ plugin.plugin === '@nx/vite/plugin') {
44
+ e2eCiWebServerTarget =
45
+ plugin.options?.previewTargetName ??
46
+ e2eCiWebServerTarget;
47
+ e2eWebServerTarget =
48
+ plugin.options?.serveTargetName ??
49
+ e2eWebServerTarget;
45
50
  }
46
51
  else if (options.bundler === 'webpack' &&
47
52
  typeof plugin === 'object' &&
48
- plugin.plugin === '@nx/webpack/plugin' &&
49
- plugin.options.serveTargetName) {
50
- e2eWebServerTarget = plugin.options
51
- .serveTargetName;
53
+ plugin.plugin === '@nx/webpack/plugin') {
54
+ e2eCiWebServerTarget =
55
+ plugin.options?.serveStaticTargetName ??
56
+ e2eCiWebServerTarget;
57
+ e2eWebServerTarget =
58
+ plugin.options?.serveTargetName ??
59
+ e2eWebServerTarget;
52
60
  }
53
61
  }
54
62
  }
55
63
  }
56
- let e2ePort = options.devServerPort ?? 4200;
57
64
  if (nxJson.targetDefaults?.[e2eWebServerTarget] &&
58
65
  nxJson.targetDefaults?.[e2eWebServerTarget].options?.port) {
59
66
  e2ePort = nxJson.targetDefaults?.[e2eWebServerTarget].options?.port;
@@ -61,6 +68,9 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/react:app
61
68
  const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
62
69
  const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
63
70
  const e2eWebServerAddress = `http://localhost:${e2ePort}`;
71
+ const e2eCiBaseUrl = options.bundler === 'vite'
72
+ ? 'http://localhost:4300'
73
+ : `http://localhost:${e2ePort}`;
64
74
  const parsedTags = options.tags
65
75
  ? options.tags.split(',').map((s) => s.trim())
66
76
  : [];
@@ -78,6 +88,8 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/react:app
78
88
  e2eProjectRoot,
79
89
  e2eWebServerAddress,
80
90
  e2eWebServerTarget,
91
+ e2eCiWebServerTarget,
92
+ e2eCiBaseUrl,
81
93
  e2ePort,
82
94
  parsedTags,
83
95
  fileName,
@@ -38,6 +38,8 @@ export interface NormalizedSchema<T extends Schema = Schema> extends T {
38
38
  e2eProjectRoot: string;
39
39
  e2eWebServerAddress: string;
40
40
  e2eWebServerTarget: string;
41
+ e2eCiWebServerTarget: string;
42
+ e2eCiBaseUrl: string;
41
43
  e2ePort: number;
42
44
  parsedTags: string[];
43
45
  fileName: string;