nx 20.1.0-canary.20241108-6882ad1 → 20.1.0-canary.20241109-77d6704

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.
Binary file
@@ -18,9 +18,5 @@ export type CreateNodesResultWithContext = CreateNodesResult & {
18
18
  file: string;
19
19
  pluginName: string;
20
20
  };
21
- export declare const nxPluginCache: Map<unknown, [
22
- Promise<LoadedNxPlugin>,
23
- () => void
24
- ]>;
25
21
  export declare function loadNxPlugins(plugins: PluginConfiguration[], root?: string): Promise<readonly [LoadedNxPlugin[], () => void]>;
26
22
  export declare function getDefaultPlugins(root: string): Promise<string[]>;
@@ -2,7 +2,7 @@
2
2
  // This file contains the bits and bobs of the internal API for loading and interacting with Nx plugins.
3
3
  // For the public API, used by plugin authors, see `./public-api.ts`.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.nxPluginCache = exports.LoadedNxPlugin = void 0;
5
+ exports.LoadedNxPlugin = void 0;
6
6
  exports.loadNxPlugins = loadNxPlugins;
7
7
  exports.getDefaultPlugins = getDefaultPlugins;
8
8
  const path_1 = require("path");
@@ -65,11 +65,6 @@ class LoadedNxPlugin {
65
65
  }
66
66
  }
67
67
  exports.LoadedNxPlugin = LoadedNxPlugin;
68
- // Short lived cache (cleared between cmd runs)
69
- // holding resolved nx plugin objects.
70
- // Allows loaded plugins to not be reloaded when
71
- // referenced multiple times.
72
- exports.nxPluginCache = new Map();
73
68
  function isIsolationEnabled() {
74
69
  // Explicitly enabled, regardless of further conditions
75
70
  if (process.env.NX_ISOLATE_PLUGINS === 'true') {
@@ -86,11 +86,7 @@ export interface PluginCreateMetadataResult {
86
86
  tx: string;
87
87
  };
88
88
  }
89
- export interface PluginWorkerShutdownMessage {
90
- type: 'shutdown';
91
- payload: {};
92
- }
93
- export type PluginWorkerMessage = PluginWorkerLoadMessage | PluginWorkerShutdownMessage | PluginWorkerCreateNodesMessage | PluginCreateDependenciesMessage | PluginCreateMetadataMessage;
89
+ export type PluginWorkerMessage = PluginWorkerLoadMessage | PluginWorkerCreateNodesMessage | PluginCreateDependenciesMessage | PluginCreateMetadataMessage;
94
90
  export type PluginWorkerResult = PluginWorkerLoadResult | PluginWorkerCreateNodesResult | PluginCreateDependenciesResult | PluginCreateMetadataResult;
95
91
  export declare function isPluginWorkerMessage(message: Serializable): message is PluginWorkerMessage;
96
92
  export declare function isPluginWorkerResult(message: Serializable): message is PluginWorkerResult;
@@ -4,12 +4,8 @@ exports.loadRemoteNxPlugin = loadRemoteNxPlugin;
4
4
  const child_process_1 = require("child_process");
5
5
  const path = require("path");
6
6
  const net_1 = require("net");
7
- // TODO (@AgentEnder): After scoped verbose logging is implemented, re-add verbose logs here.
8
- // import { logger } from '../../utils/logger';
9
- const internal_api_1 = require("../internal-api");
10
7
  const socket_utils_1 = require("../../../daemon/socket-utils");
11
8
  const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
12
- const exit_codes_1 = require("../../../utils/exit-codes");
13
9
  const messaging_1 = require("./messaging");
14
10
  const cleanupFunctions = new Set();
15
11
  const pluginNames = new Map();
@@ -29,7 +25,6 @@ async function loadRemoteNxPlugin(plugin, root) {
29
25
  const exitHandler = createWorkerExitHandler(worker, pendingPromises);
30
26
  const cleanupFunction = () => {
31
27
  worker.off('exit', exitHandler);
32
- shutdownPluginWorker(socket);
33
28
  socket.destroy();
34
29
  nxPluginWorkerCache.delete(cacheKey);
35
30
  };
@@ -55,9 +50,6 @@ async function loadRemoteNxPlugin(plugin, root) {
55
50
  nxPluginWorkerCache.set(cacheKey, pluginPromise);
56
51
  return [pluginPromise, cleanupFunction];
57
52
  }
58
- function shutdownPluginWorker(socket) {
59
- (0, messaging_1.sendMessageOverSocket)(socket, { type: 'shutdown', payload: {} });
60
- }
61
53
  /**
62
54
  * Creates a message handler for the given worker.
63
55
  * @param worker Instance of plugin-worker
@@ -172,20 +164,6 @@ function createWorkerExitHandler(worker, pendingPromises) {
172
164
  }
173
165
  };
174
166
  }
175
- let cleanedUp = false;
176
- const exitHandler = () => {
177
- internal_api_1.nxPluginCache.clear();
178
- for (const fn of cleanupFunctions) {
179
- fn();
180
- }
181
- cleanedUp = true;
182
- };
183
- process.on('exit', exitHandler);
184
- process.on('SIGINT', () => {
185
- exitHandler();
186
- process.exit((0, exit_codes_1.signalToCode)('SIGINT'));
187
- });
188
- process.on('SIGTERM', exitHandler);
189
167
  function registerPendingPromise(tx, pending, callback, context) {
190
168
  let resolver, rejector, timeout;
191
169
  const promise = new Promise((res, rej) => {
@@ -49,21 +49,6 @@ const server = (0, net_1.createServer)((socket) => {
49
49
  };
50
50
  }
51
51
  },
52
- shutdown: async () => {
53
- // Stops accepting new connections, but existing connections are
54
- // not closed immediately.
55
- server.close(() => {
56
- try {
57
- (0, fs_1.unlinkSync)(socketPath);
58
- }
59
- catch (e) { }
60
- process.exit(0);
61
- });
62
- // Closes existing connection.
63
- socket.end();
64
- // Destroys the socket once it's fully closed.
65
- socket.destroySoon();
66
- },
67
52
  createNodes: async ({ configFiles, context, tx }) => {
68
53
  try {
69
54
  const result = await plugin.createNodes[1](configFiles, context);
@@ -123,6 +108,22 @@ const server = (0, net_1.createServer)((socket) => {
123
108
  },
124
109
  });
125
110
  }));
111
+ // There should only ever be one host -> worker connection
112
+ // since the worker is spawned per host process. As such,
113
+ // we can safely close the worker when the host disconnects.
114
+ socket.on('end', () => {
115
+ // Stops accepting new connections, but existing connections are
116
+ // not closed immediately.
117
+ server.close(() => {
118
+ try {
119
+ (0, fs_1.unlinkSync)(socketPath);
120
+ }
121
+ catch (e) { }
122
+ process.exit(0);
123
+ });
124
+ // Destroys the socket once it's fully closed.
125
+ socket.destroySoon();
126
+ });
126
127
  });
127
128
  server.listen(socketPath);
128
129
  const exitHandler = (exitCode) => () => {
@@ -140,7 +140,7 @@ class ProcessTasks {
140
140
  }
141
141
  }
142
142
  else {
143
- const dummyId = this.getId(depProject.name, DUMMY_TASK_TARGET, undefined);
143
+ const dummyId = this.getId(depProject.name, task.target.target + DUMMY_TASK_TARGET, undefined);
144
144
  this.dependencies[task.id].push(dummyId);
145
145
  this.dependencies[dummyId] ??= [];
146
146
  const noopTask = this.createDummyTask(dummyId, task);
@@ -298,7 +298,7 @@ async function promptForApplyingSyncGeneratorChanges() {
298
298
  try {
299
299
  const promptConfig = {
300
300
  name: 'applyChanges',
301
- type: 'select',
301
+ type: 'autocomplete',
302
302
  message: 'Would you like to sync the identified changes to get your workspace up to date?',
303
303
  choices: [
304
304
  {
@@ -322,7 +322,7 @@ async function confirmRunningTasksWithSyncFailures() {
322
322
  try {
323
323
  const promptConfig = {
324
324
  name: 'runTasks',
325
- type: 'select',
325
+ type: 'autocomplete',
326
326
  message: 'Would you like to ignore the sync failures and continue running the tasks?',
327
327
  choices: [
328
328
  {