@nx/react 18.2.0-beta.1 → 18.2.0-beta.3

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": "18.2.0-beta.1",
3
+ "version": "18.2.0-beta.3",
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, 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": {
@@ -36,11 +36,11 @@
36
36
  "chalk": "^4.1.0",
37
37
  "minimatch": "9.0.3",
38
38
  "tslib": "^2.3.0",
39
- "@nx/devkit": "18.2.0-beta.1",
40
- "@nx/js": "18.2.0-beta.1",
41
- "@nx/eslint": "18.2.0-beta.1",
42
- "@nx/web": "18.2.0-beta.1",
43
- "@nrwl/react": "18.2.0-beta.1"
39
+ "@nx/devkit": "18.2.0-beta.3",
40
+ "@nx/js": "18.2.0-beta.3",
41
+ "@nx/eslint": "18.2.0-beta.3",
42
+ "@nx/web": "18.2.0-beta.3",
43
+ "@nrwl/react": "18.2.0-beta.3"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public"
@@ -7,9 +7,10 @@ const file_server_impl_1 = require("@nx/web/src/executors/file-server/file-serve
7
7
  const module_federation_1 = require("@nx/webpack/src/utils/module-federation");
8
8
  const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
9
9
  const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
10
- const child_process_1 = require("child_process");
11
- const path_1 = require("path");
12
- const fs_1 = require("fs");
10
+ const cache_directory_1 = require("nx/src/utils/cache-directory");
11
+ const node_child_process_1 = require("node:child_process");
12
+ const node_path_1 = require("node:path");
13
+ const node_fs_1 = require("node:fs");
13
14
  function getBuildOptions(buildTarget, context) {
14
15
  const target = (0, devkit_1.parseTargetString)(buildTarget, context);
15
16
  const buildOptions = (0, devkit_1.readTargetOptions)(target, context);
@@ -31,10 +32,10 @@ function startStaticRemotesFileServer(staticRemotesConfig, context, options) {
31
32
  }
32
33
  }
33
34
  if (shouldMoveToCommonLocation) {
34
- commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
35
+ commonOutputDirectory = (0, node_path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
35
36
  for (const app of staticRemotesConfig.remotes) {
36
37
  const remoteConfig = staticRemotesConfig.config[app];
37
- (0, fs_1.cpSync)(remoteConfig.outputPath, (0, path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
38
+ (0, node_fs_1.cpSync)(remoteConfig.outputPath, (0, node_path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
38
39
  force: true,
39
40
  recursive: true,
40
41
  });
@@ -88,7 +89,7 @@ async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options)
88
89
  }
89
90
  process.env.NX_MF_DEV_SERVER_STATIC_REMOTES = JSON.stringify(mappedLocationOfRemotes);
90
91
  await new Promise((res) => {
91
- const staticProcess = (0, child_process_1.fork)(nxBin, [
92
+ const staticProcess = (0, node_child_process_1.fork)(nxBin, [
92
93
  'run-many',
93
94
  `--target=build`,
94
95
  `--projects=${staticRemotesConfig.remotes.join(',')}`,
@@ -100,9 +101,13 @@ async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options)
100
101
  cwd: context.root,
101
102
  stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
102
103
  });
104
+ // File to debug build failures e.g. 2024-01-01T00_00_0_0Z-build.log'
105
+ const remoteBuildLogFile = (0, node_path_1.join)(cache_directory_1.projectGraphCacheDirectory, `${new Date().toISOString().replace(/[:\.]/g, '_')}-build.log`);
106
+ const stdoutStream = (0, node_fs_1.createWriteStream)(remoteBuildLogFile);
103
107
  staticProcess.stdout.on('data', (data) => {
104
108
  const ANSII_CODE_REGEX = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
105
109
  const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
110
+ stdoutStream.write(stdoutString);
106
111
  if (stdoutString.includes('Successfully ran target build')) {
107
112
  staticProcess.stdout.removeAllListeners('data');
108
113
  devkit_1.logger.info(`NX Built ${staticRemotesConfig.remotes.length} static remotes`);
@@ -111,8 +116,9 @@ async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options)
111
116
  });
112
117
  staticProcess.stderr.on('data', (data) => devkit_1.logger.info(data.toString()));
113
118
  staticProcess.on('exit', (code) => {
119
+ stdoutStream.end();
114
120
  if (code !== 0) {
115
- throw new Error(`Remote failed to start. See above for errors.`);
121
+ throw new Error(`Remote failed to start. A complete log can be found in: ${remoteBuildLogFile}`);
116
122
  }
117
123
  });
118
124
  process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
@@ -126,8 +132,8 @@ function parseStaticRemotesConfig(staticRemotes, context) {
126
132
  const config = {};
127
133
  for (const app of staticRemotes) {
128
134
  const outputPath = context.projectGraph.nodes[app].data.targets['build'].options.outputPath;
129
- const basePath = (0, path_1.dirname)(outputPath);
130
- const urlSegment = (0, path_1.basename)(outputPath);
135
+ const basePath = (0, node_path_1.dirname)(outputPath);
136
+ const urlSegment = (0, node_path_1.basename)(outputPath);
131
137
  config[app] = { basePath, outputPath, urlSegment };
132
138
  }
133
139
  return { remotes: staticRemotes, config };
@@ -12,9 +12,10 @@ async function addE2e(tree, options) {
12
12
  const hasNxBuildPlugin = (options.bundler === 'webpack' && (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)) ||
13
13
  (options.bundler === 'vite' && (0, has_vite_plugin_1.hasVitePlugin)(tree));
14
14
  if (!hasNxBuildPlugin) {
15
- (0, web_1.webStaticServeGenerator)(tree, {
15
+ await (0, web_1.webStaticServeGenerator)(tree, {
16
16
  buildTarget: `${options.projectName}:build`,
17
17
  targetName: 'serve-static',
18
+ spa: true,
18
19
  });
19
20
  }
20
21
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);