nx 22.7.0-beta.15 → 22.7.0-beta.17

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.
Files changed (49) hide show
  1. package/dist/bin/nx.js +41 -27
  2. package/dist/src/adapter/compat.js +0 -1
  3. package/dist/src/command-line/format/format.js +12 -12
  4. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +0 -1
  5. package/dist/src/command-line/init/implementation/dot-nx/nxw.js +0 -1
  6. package/dist/src/command-line/init/implementation/utils.js +0 -2
  7. package/dist/src/core/graph/main.js +1 -1
  8. package/dist/src/daemon/client/client.d.ts +1 -0
  9. package/dist/src/daemon/client/client.js +33 -5
  10. package/dist/src/daemon/logger.d.ts +14 -0
  11. package/dist/src/daemon/logger.js +16 -1
  12. package/dist/src/daemon/message-types/streaming-messages.d.ts +14 -0
  13. package/dist/src/daemon/message-types/streaming-messages.js +19 -0
  14. package/dist/src/daemon/server/client-socket-context.d.ts +23 -0
  15. package/dist/src/daemon/server/client-socket-context.js +89 -0
  16. package/dist/src/daemon/server/handle-request-project-graph.d.ts +2 -1
  17. package/dist/src/daemon/server/handle-request-project-graph.js +2 -2
  18. package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +2 -1
  19. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +15 -1
  20. package/dist/src/daemon/server/server.js +1 -1
  21. package/dist/src/daemon/server/shutdown-utils.js +0 -2
  22. package/dist/src/executors/run-commands/running-tasks.js +2 -0
  23. package/dist/src/migrations/update-17-2-0/move-default-base.js +0 -1
  24. package/dist/src/native/index.d.ts +31 -11
  25. package/dist/src/native/nx.wasi.cjs +0 -1
  26. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  27. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  28. package/dist/src/native/wasi-worker-browser.mjs +0 -2
  29. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +1 -1
  30. package/dist/src/project-graph/build-project-graph.d.ts +4 -4
  31. package/dist/src/project-graph/build-project-graph.js +35 -36
  32. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +24 -6
  33. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +8 -1
  34. package/dist/src/project-graph/plugins/isolation/messaging.js +11 -0
  35. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +5 -0
  36. package/dist/src/project-graph/plugins/isolation/worker-streaming.d.ts +14 -0
  37. package/dist/src/project-graph/plugins/isolation/worker-streaming.js +39 -0
  38. package/dist/src/project-graph/utils/project-configuration-utils.js +11 -11
  39. package/dist/src/project-graph/utils/retrieve-workspace-files.d.ts +1 -1
  40. package/dist/src/tasks-runner/pseudo-terminal.d.ts +1 -1
  41. package/dist/src/utils/db-connection.d.ts +2 -3
  42. package/dist/src/utils/db-connection.js +1 -1
  43. package/dist/src/utils/delayed-spinner.d.ts +9 -0
  44. package/dist/src/utils/delayed-spinner.js +10 -0
  45. package/dist/src/utils/perf-logging.js +35 -36
  46. package/dist/src/utils/progress-topics.d.ts +19 -0
  47. package/dist/src/utils/progress-topics.js +21 -0
  48. package/dist/src/utils/yarn-syml/index.js +0 -2
  49. package/package.json +12 -11
package/dist/bin/nx.js CHANGED
@@ -10,8 +10,6 @@ if (process.env.FORCE_COLOR === '0') {
10
10
  }
11
11
  const find_workspace_root_1 = require("../src/utils/find-workspace-root");
12
12
  const pc = tslib_1.__importStar(require("picocolors"));
13
- const dotenv_1 = require("../src/utils/dotenv");
14
- const init_local_1 = require("./init-local");
15
13
  const output_1 = require("../src/utils/output");
16
14
  const installation_directory_1 = require("../src/utils/installation-directory");
17
15
  const semver_1 = require("semver");
@@ -20,13 +18,11 @@ const child_process_1 = require("child_process");
20
18
  const module_1 = require("module");
21
19
  const path_1 = require("path");
22
20
  const fs_1 = require("fs");
23
- const assert_supported_platform_1 = require("../src/native/assert-supported-platform");
24
21
  const perf_hooks_1 = require("perf_hooks");
25
- const workspace_context_1 = require("../src/utils/workspace-context");
26
- const client_1 = require("../src/daemon/client/client");
27
- const db_connection_1 = require("../src/utils/db-connection");
28
- const analytics_prompt_1 = require("../src/utils/analytics-prompt");
29
- const analytics_1 = require("../src/analytics");
22
+ // Register the performance observer as early as possible so any
23
+ // `performance.mark` / `measure` anywhere downstream is captured. The module
24
+ // is side-effect only and its heavy deps (analytics, daemon logger) are
25
+ // lazy-loaded inside the observer callback, so the import itself is cheap.
30
26
  require("../src/utils/perf-logging");
31
27
  const isTsExt = (0, path_1.extname)(__filename).endsWith('.ts');
32
28
  const pathToPkgJson = isTsExt ? '../package.json' : '../../package.json';
@@ -35,12 +31,19 @@ async function main() {
35
31
  process.argv[2] !== '--version' &&
36
32
  process.argv[2] !== '--help' &&
37
33
  process.argv[2] !== 'reset') {
38
- (0, assert_supported_platform_1.assertSupportedPlatform)();
34
+ const { assertSupportedPlatform } = await import('../src/native/assert-supported-platform.js');
35
+ assertSupportedPlatform();
39
36
  }
40
37
  const workspace = (0, find_workspace_root_1.findWorkspaceRoot)(process.cwd());
41
- if (workspace) {
38
+ // --version doesn't need any env / daemon / analytics state — skip dotenv
39
+ // loading (and the heavy modules it would pull in).
40
+ if (workspace && process.argv[2] !== '--version') {
41
+ const { workspaceDataDirectoryForWorkspace } = await import('../src/utils/cache-directory.js');
42
+ process.report.reportOnFatalError = true;
43
+ process.report.directory = workspaceDataDirectoryForWorkspace(workspace.dir);
44
+ const { loadRootEnvFiles } = await import('../src/utils/dotenv.js');
42
45
  perf_hooks_1.performance.mark('loading dotenv files:start');
43
- (0, dotenv_1.loadRootEnvFiles)(workspace.dir);
46
+ loadRootEnvFiles(workspace.dir);
44
47
  perf_hooks_1.performance.mark('loading dotenv files:end');
45
48
  perf_hooks_1.performance.measure('loading dotenv files', 'loading dotenv files:start', 'loading dotenv files:end');
46
49
  }
@@ -51,7 +54,7 @@ async function main() {
51
54
  process.argv[2] === 'configure-ai-agents' ||
52
55
  (process.argv[2] === 'graph' && !workspace)) {
53
56
  process.env.NX_DAEMON = 'false';
54
- require('nx/src/command-line/nx-commands').commandsObject.argv;
57
+ (await import('nx/src/command-line/nx-commands')).commandsObject.argv;
55
58
  }
56
59
  else {
57
60
  // polyfill rxjs observable to avoid issues with multiple version of Observable installed in node_modules
@@ -79,20 +82,25 @@ async function main() {
79
82
  }
80
83
  // this file is already in the local workspace
81
84
  if (isNxCloudCommand(process.argv[2])) {
82
- if (!client_1.daemonClient.enabled() && workspace !== null) {
83
- (0, workspace_context_1.setupWorkspaceContext)(workspace.dir);
85
+ const { daemonClient } = await import('../src/daemon/client/client.js');
86
+ if (!daemonClient.enabled() && workspace !== null) {
87
+ const { setupWorkspaceContext } = await import('../src/utils/workspace-context.js');
88
+ setupWorkspaceContext(workspace.dir);
84
89
  }
85
90
  await initAnalytics();
86
91
  // nx-cloud commands can run without local Nx installation
87
92
  process.env.NX_DAEMON = 'false';
88
- require('nx/src/command-line/nx-commands').commandsObject.argv;
93
+ (await import('nx/src/command-line/nx-commands')).commandsObject.argv;
89
94
  }
90
95
  else if (isLocalInstall) {
91
- if (!client_1.daemonClient.enabled() && workspace !== null) {
92
- (0, workspace_context_1.setupWorkspaceContext)(workspace.dir);
96
+ const { daemonClient } = await import('../src/daemon/client/client.js');
97
+ if (!daemonClient.enabled() && workspace !== null) {
98
+ const { setupWorkspaceContext } = await import('../src/utils/workspace-context.js');
99
+ setupWorkspaceContext(workspace.dir);
93
100
  }
94
101
  await initAnalytics();
95
- await (0, init_local_1.initLocal)(workspace);
102
+ const { initLocal } = await import('./init-local.js');
103
+ await initLocal(workspace);
96
104
  }
97
105
  else if (localNx) {
98
106
  // Nx is being run from globally installed CLI - hand off to the local
@@ -101,10 +109,10 @@ async function main() {
101
109
  warnIfUsingOutdatedGlobalInstall(GLOBAL_NX_VERSION, LOCAL_NX_VERSION);
102
110
  if (localNx.includes('.nx')) {
103
111
  const nxWrapperPath = localNx.replace(/\.nx.*/, '.nx/') + 'nxw.js';
104
- require(nxWrapperPath);
112
+ await import(nxWrapperPath);
105
113
  }
106
114
  else {
107
- require(localNx);
115
+ await import(localNx);
108
116
  }
109
117
  }
110
118
  }
@@ -177,12 +185,16 @@ function isNxCloudCommand(command) {
177
185
  ];
178
186
  return nxCloudCommands.includes(command);
179
187
  }
188
+ let analyticsStarted = false;
180
189
  async function initAnalytics() {
190
+ const { ensureAnalyticsPreferenceSet } = await import('../src/utils/analytics-prompt.js');
191
+ const { startAnalytics } = await import('../src/analytics/index.js');
181
192
  try {
182
- await (0, analytics_prompt_1.ensureAnalyticsPreferenceSet)();
193
+ await ensureAnalyticsPreferenceSet();
183
194
  }
184
195
  catch { }
185
- await (0, analytics_1.startAnalytics)();
196
+ await startAnalytics();
197
+ analyticsStarted = true;
186
198
  }
187
199
  function handleMissingLocalInstallation(detectedWorkspaceRoot) {
188
200
  output_1.output.error({
@@ -279,11 +291,13 @@ const getLatestVersionOfNx = ((fn) => {
279
291
  let cache = null;
280
292
  return () => cache || (cache = fn());
281
293
  })(_getLatestVersionOfNx);
282
- process.on('exit', () => {
283
- (0, db_connection_1.removeDbConnections)();
284
- });
285
- main().catch((error) => {
294
+ main().catch(async (error) => {
286
295
  console.error(error);
287
- (0, analytics_1.flushAnalytics)();
296
+ if (analyticsStarted) {
297
+ // analyticsStarted implies '../src/analytics' is already in the module
298
+ // cache, so this resolves from cache without any disk work.
299
+ const { flushAnalytics } = await import('../src/analytics/index.js');
300
+ flushAnalytics();
301
+ }
288
302
  process.exit(1);
289
303
  });
@@ -4,7 +4,6 @@ exports.allowedWorkspaceExtensions = exports.allowedProjectExtensions = void 0;
4
4
  const project_graph_1 = require("../project-graph/project-graph");
5
5
  const configuration_1 = require("../config/configuration");
6
6
  const angular_json_1 = require("./angular-json");
7
- /* eslint-disable */
8
7
  const Module = require('module');
9
8
  const originalRequire = Module.prototype.require;
10
9
  let patched = false;
@@ -5,17 +5,16 @@ const tslib_1 = require("tslib");
5
5
  const node_child_process_1 = require("node:child_process");
6
6
  const path = tslib_1.__importStar(require("node:path"));
7
7
  const semver_1 = require("semver");
8
- const handle_import_1 = require("../../utils/handle-import");
9
- const file_utils_1 = require("../../project-graph/file-utils");
10
- const command_line_utils_1 = require("../../utils/command-line-utils");
11
- const fileutils_1 = require("../../utils/fileutils");
12
- const ignore_1 = require("../../utils/ignore");
13
8
  const configuration_1 = require("../../config/configuration");
14
9
  const typescript_1 = require("../../plugins/js/utils/typescript");
15
10
  const affected_project_graph_1 = require("../../project-graph/affected/affected-project-graph");
11
+ const file_utils_1 = require("../../project-graph/file-utils");
16
12
  const project_graph_1 = require("../../project-graph/project-graph");
17
- const all_file_data_1 = require("../../utils/all-file-data");
18
13
  const chunkify_1 = require("../../utils/chunkify");
14
+ const command_line_utils_1 = require("../../utils/command-line-utils");
15
+ const fileutils_1 = require("../../utils/fileutils");
16
+ const handle_import_1 = require("../../utils/handle-import");
17
+ const ignore_1 = require("../../utils/ignore");
19
18
  const object_sort_1 = require("../../utils/object-sort");
20
19
  const output_1 = require("../../utils/output");
21
20
  const package_json_1 = require("../../utils/package-json");
@@ -77,13 +76,13 @@ async function format(command, args) {
77
76
  }
78
77
  }
79
78
  async function getPatterns(prettier, args) {
80
- const graph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
81
79
  const allFilesPattern = ['.'];
82
80
  if (args.all) {
83
81
  return allFilesPattern;
84
82
  }
85
83
  try {
86
84
  if (args.projects && args.projects.length > 0) {
85
+ const graph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
87
86
  return getPatternsFromProjects(args.projects, graph);
88
87
  }
89
88
  const p = (0, command_line_utils_1.parseFiles)(args);
@@ -99,9 +98,10 @@ async function getPatterns(prettier, args) {
99
98
  .filter((f) => (0, fileutils_1.fileExists)(f) && supportedExtensions.has(path.extname(f)));
100
99
  // exclude patterns in .nxignore or .gitignore
101
100
  const nonIgnoredPatterns = (0, ignore_1.getIgnoreObject)().filter(patterns);
102
- return args.libsAndApps
103
- ? await getPatternsFromApps(nonIgnoredPatterns, await (0, all_file_data_1.allFileData)(), graph)
104
- : nonIgnoredPatterns;
101
+ if (args.libsAndApps) {
102
+ return getPatternsFromApps(nonIgnoredPatterns);
103
+ }
104
+ return nonIgnoredPatterns;
105
105
  }
106
106
  catch (err) {
107
107
  output_1.output.error({
@@ -112,12 +112,12 @@ async function getPatterns(prettier, args) {
112
112
  return allFilesPattern;
113
113
  }
114
114
  }
115
- async function getPatternsFromApps(affectedFiles, allWorkspaceFiles, projectGraph) {
115
+ async function getPatternsFromApps(affectedFiles) {
116
116
  const graph = await (0, project_graph_1.createProjectGraphAsync)({
117
117
  exitOnError: true,
118
118
  });
119
119
  const affectedGraph = await (0, affected_project_graph_1.filterAffected)(graph, (0, file_utils_1.calculateFileChanges)(affectedFiles));
120
- return getPatternsFromProjects(Object.keys(affectedGraph.nodes), projectGraph);
120
+ return getPatternsFromProjects(Object.keys(affectedGraph.nodes), affectedGraph);
121
121
  }
122
122
  function addRootConfigFiles(chunkList, nxArgs) {
123
123
  if (nxArgs.all) {
@@ -34,7 +34,6 @@ async function addNxToNpmRepo(options, guided = true) {
34
34
  },
35
35
  ])).cacheableOperations;
36
36
  for (const scriptName of cacheableOperations) {
37
- // eslint-disable-next-line no-await-in-loop
38
37
  scriptOutputs[scriptName] = (await enquirer.prompt([
39
38
  {
40
39
  type: 'input',
@@ -119,5 +119,4 @@ function ensureUpToDateInstallation() {
119
119
  if (!process.env.NX_WRAPPER_SKIP_INSTALL) {
120
120
  ensureUpToDateInstallation();
121
121
  }
122
- // eslint-disable-next-line no-restricted-modules
123
122
  require('./installation/node_modules/nx/dist/bin/nx');
@@ -28,7 +28,6 @@ function createNxJsonFile(repoRoot, topologicalTargets, cacheableOperations, scr
28
28
  let nxJson = {};
29
29
  try {
30
30
  nxJson = (0, fileutils_1.readJsonFile)(nxJsonPath);
31
- // eslint-disable-next-line no-empty
32
31
  }
33
32
  catch { }
34
33
  nxJson.$schema = './node_modules/nx/schemas/nx-schema.json';
@@ -41,7 +40,6 @@ function createNxJsonFile(repoRoot, topologicalTargets, cacheableOperations, scr
41
40
  }
42
41
  for (const [scriptName, output] of Object.entries(scriptOutputs)) {
43
42
  if (!output) {
44
- // eslint-disable-next-line no-continue
45
43
  continue;
46
44
  }
47
45
  nxJson.targetDefaults[scriptName] ??= {};