nx 21.3.0-canary.20250717-8b4b3e9 → 21.3.0-canary.20250718-9f1c811
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 +11 -11
- package/src/command-line/report/report.js +1 -5
- package/src/command-line/watch/command-object.js +6 -0
- package/src/command-line/watch/watch.d.ts +1 -0
- package/src/command-line/watch/watch.js +9 -0
- package/src/daemon/client/client.js +3 -0
- package/src/daemon/server/project-graph-incremental-recomputation.js +5 -0
- package/src/executors/run-commands/running-tasks.js +19 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/lock-file/project-graph-pruning.js +2 -2
- package/src/project-graph/nx-deps-cache.js +8 -0
- package/src/tasks-runner/cache.d.ts +9 -0
- package/src/tasks-runner/cache.js +15 -3
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "21.3.0-canary.
|
3
|
+
"version": "21.3.0-canary.20250718-9f1c811",
|
4
4
|
"private": false,
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
6
6
|
"repository": {
|
@@ -83,16 +83,16 @@
|
|
83
83
|
}
|
84
84
|
},
|
85
85
|
"optionalDependencies": {
|
86
|
-
"@nx/nx-darwin-arm64": "21.3.0-canary.
|
87
|
-
"@nx/nx-darwin-x64": "21.3.0-canary.
|
88
|
-
"@nx/nx-freebsd-x64": "21.3.0-canary.
|
89
|
-
"@nx/nx-linux-arm-gnueabihf": "21.3.0-canary.
|
90
|
-
"@nx/nx-linux-arm64-gnu": "21.3.0-canary.
|
91
|
-
"@nx/nx-linux-arm64-musl": "21.3.0-canary.
|
92
|
-
"@nx/nx-linux-x64-gnu": "21.3.0-canary.
|
93
|
-
"@nx/nx-linux-x64-musl": "21.3.0-canary.
|
94
|
-
"@nx/nx-win32-arm64-msvc": "21.3.0-canary.
|
95
|
-
"@nx/nx-win32-x64-msvc": "21.3.0-canary.
|
86
|
+
"@nx/nx-darwin-arm64": "21.3.0-canary.20250718-9f1c811",
|
87
|
+
"@nx/nx-darwin-x64": "21.3.0-canary.20250718-9f1c811",
|
88
|
+
"@nx/nx-freebsd-x64": "21.3.0-canary.20250718-9f1c811",
|
89
|
+
"@nx/nx-linux-arm-gnueabihf": "21.3.0-canary.20250718-9f1c811",
|
90
|
+
"@nx/nx-linux-arm64-gnu": "21.3.0-canary.20250718-9f1c811",
|
91
|
+
"@nx/nx-linux-arm64-musl": "21.3.0-canary.20250718-9f1c811",
|
92
|
+
"@nx/nx-linux-x64-gnu": "21.3.0-canary.20250718-9f1c811",
|
93
|
+
"@nx/nx-linux-x64-musl": "21.3.0-canary.20250718-9f1c811",
|
94
|
+
"@nx/nx-win32-arm64-msvc": "21.3.0-canary.20250718-9f1c811",
|
95
|
+
"@nx/nx-win32-x64-msvc": "21.3.0-canary.20250718-9f1c811"
|
96
96
|
},
|
97
97
|
"nx-migrations": {
|
98
98
|
"migrations": "./migrations.json",
|
@@ -23,8 +23,6 @@ const nx_json_1 = require("../../config/nx-json");
|
|
23
23
|
const error_types_1 = require("../../project-graph/error-types");
|
24
24
|
const nx_key_1 = require("../../utils/nx-key");
|
25
25
|
const cache_1 = require("../../tasks-runner/cache");
|
26
|
-
const native_1 = require("../../native");
|
27
|
-
const cache_directory_1 = require("../../utils/cache-directory");
|
28
26
|
const nxPackageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(__dirname, '../../../package.json'));
|
29
27
|
exports.packagesWeCareAbout = [
|
30
28
|
'lerna',
|
@@ -184,9 +182,7 @@ async function getReportData() {
|
|
184
182
|
}
|
185
183
|
let cache = (0, cache_1.dbCacheEnabled)()
|
186
184
|
? {
|
187
|
-
max: nxJson
|
188
|
-
? (0, cache_1.parseMaxCacheSize)(nxJson.maxCacheSize)
|
189
|
-
: (0, native_1.getDefaultMaxCacheSize)(cache_directory_1.cacheDir),
|
185
|
+
max: (0, cache_1.resolveMaxCacheSize)(nxJson),
|
190
186
|
used: new cache_1.DbCache({ nxCloudRemoteCache: null }).getUsedCacheSpace(),
|
191
187
|
}
|
192
188
|
: null;
|
@@ -42,6 +42,12 @@ function withWatchOptions(yargs) {
|
|
42
42
|
.option('verbose', {
|
43
43
|
type: 'boolean',
|
44
44
|
description: 'Run watch mode in verbose mode, where commands are logged before execution.',
|
45
|
+
})
|
46
|
+
.option('initialRun', {
|
47
|
+
type: 'boolean',
|
48
|
+
description: 'Run the command once before watching for changes.',
|
49
|
+
alias: 'i',
|
50
|
+
default: false,
|
45
51
|
})
|
46
52
|
.conflicts({
|
47
53
|
all: 'projects',
|
@@ -137,6 +137,15 @@ async function watch(args) {
|
|
137
137
|
args.verbose && output_1.output.logSingleLine('starting watch process');
|
138
138
|
const whatToWatch = args.all ? 'all' : args.projects;
|
139
139
|
const batchQueue = new BatchCommandRunner(args.command ?? '', args.projectNameEnvName, args.fileChangesEnvName);
|
140
|
+
// Run the command initially if requested
|
141
|
+
if (args.initialRun) {
|
142
|
+
args.verbose && output_1.output.logSingleLine('running command initially...');
|
143
|
+
const initialProjects = args.all
|
144
|
+
? [] // When using --all, we don't need to pass specific projects
|
145
|
+
: args.projects || [];
|
146
|
+
// Execute the initial run
|
147
|
+
await batchQueue.enqueue(initialProjects, []);
|
148
|
+
}
|
140
149
|
await client_1.daemonClient.registerFileWatcher({
|
141
150
|
watchProjects: whatToWatch,
|
142
151
|
includeDependentProjects: args.includeDependentProjects,
|
@@ -35,6 +35,9 @@ const run_tasks_execution_hooks_1 = require("../message-types/run-tasks-executio
|
|
35
35
|
const DAEMON_ENV_SETTINGS = {
|
36
36
|
NX_PROJECT_GLOB_CACHE: 'false',
|
37
37
|
NX_CACHE_PROJECTS_CONFIG: 'false',
|
38
|
+
NX_VERBOSE_LOGGING: 'true',
|
39
|
+
NX_PERF_LOGGING: 'true',
|
40
|
+
NX_NATIVE_LOGGING: 'nx=debug',
|
38
41
|
};
|
39
42
|
var DaemonStatus;
|
40
43
|
(function (DaemonStatus) {
|
@@ -43,9 +43,14 @@ async function getCachedSerializedProjectGraphPromise() {
|
|
43
43
|
if (!cachedSerializedProjectGraphPromise) {
|
44
44
|
cachedSerializedProjectGraphPromise =
|
45
45
|
processFilesAndCreateAndSerializeProjectGraph(plugins);
|
46
|
+
logger_1.serverLogger.log('No files changed, but no in-memory cached project graph found. Recomputing it...');
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
logger_1.serverLogger.log('Reusing in-memory cached project graph because no files changed.');
|
46
50
|
}
|
47
51
|
}
|
48
52
|
else {
|
53
|
+
logger_1.serverLogger.log(`Recomputing project graph because of ${collectedUpdatedFiles.size} updated and ${collectedDeletedFiles.size} deleted files.`);
|
49
54
|
cachedSerializedProjectGraphPromise =
|
50
55
|
processFilesAndCreateAndSerializeProjectGraph(plugins);
|
51
56
|
}
|
@@ -294,6 +294,25 @@ class RunningNodeProcess {
|
|
294
294
|
}
|
295
295
|
}
|
296
296
|
});
|
297
|
+
// Terminate any task processes on exit
|
298
|
+
process.on('exit', () => {
|
299
|
+
this.childProcess.kill();
|
300
|
+
});
|
301
|
+
process.on('SIGINT', () => {
|
302
|
+
this.childProcess.kill('SIGTERM');
|
303
|
+
// we exit here because we don't need to write anything to cache.
|
304
|
+
process.exit((0, exit_codes_1.signalToCode)('SIGINT'));
|
305
|
+
});
|
306
|
+
process.on('SIGTERM', () => {
|
307
|
+
this.childProcess.kill('SIGTERM');
|
308
|
+
// no exit here because we expect child processes to terminate which
|
309
|
+
// will store results to the cache and will terminate this process
|
310
|
+
});
|
311
|
+
process.on('SIGHUP', () => {
|
312
|
+
this.childProcess.kill('SIGTERM');
|
313
|
+
// no exit here because we expect child processes to terminate which
|
314
|
+
// will store results to the cache and will terminate this process
|
315
|
+
});
|
297
316
|
}
|
298
317
|
}
|
299
318
|
async function runSingleCommandWithPseudoTerminal(normalized, context) {
|
Binary file
|
@@ -17,8 +17,8 @@ function pruneProjectGraph(graph, prunedPackageJson) {
|
|
17
17
|
const workspacePackages = (0, get_workspace_packages_from_graph_1.getWorkspacePackagesFromGraph)(graph);
|
18
18
|
const combinedDependencies = normalizeDependencies(prunedPackageJson, graph, workspacePackages);
|
19
19
|
addNodesAndDependencies(graph, combinedDependencies, workspacePackages, builder);
|
20
|
-
for (const
|
21
|
-
const node = graph.nodes[
|
20
|
+
for (const project of workspacePackages.values()) {
|
21
|
+
const node = graph.nodes[project.name];
|
22
22
|
builder.addNode(node);
|
23
23
|
}
|
24
24
|
// for NPM (as well as the graph consistency)
|
@@ -16,6 +16,8 @@ const cache_directory_1 = require("../utils/cache-directory");
|
|
16
16
|
const fileutils_1 = require("../utils/fileutils");
|
17
17
|
const versions_1 = require("../utils/versions");
|
18
18
|
const error_types_1 = require("./error-types");
|
19
|
+
const is_on_daemon_1 = require("../daemon/is-on-daemon");
|
20
|
+
const logger_1 = require("../daemon/server/logger");
|
19
21
|
exports.nxProjectGraph = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'project-graph.json');
|
20
22
|
exports.nxFileMap = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'file-map.json');
|
21
23
|
exports.nxSourceMaps = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'source-maps.json');
|
@@ -159,6 +161,9 @@ function writeCache(cache, projectGraph, sourceMaps, errors) {
|
|
159
161
|
(0, fileutils_1.writeJsonFile)(tmpFileMapPath, cache);
|
160
162
|
(0, node_fs_1.renameSync)(tmpFileMapPath, exports.nxFileMap);
|
161
163
|
}
|
164
|
+
if ((0, is_on_daemon_1.isOnDaemon)()) {
|
165
|
+
logger_1.serverLogger.log(`Wrote project graph cache to ${exports.nxProjectGraph}${errors.length > 0 ? ' with errors' : ''}`);
|
166
|
+
}
|
162
167
|
done = true;
|
163
168
|
}
|
164
169
|
catch (err) {
|
@@ -171,6 +176,9 @@ function writeCache(cache, projectGraph, sourceMaps, errors) {
|
|
171
176
|
++retry;
|
172
177
|
}
|
173
178
|
} while (!done && retry < 5);
|
179
|
+
if (!done) {
|
180
|
+
throw new Error(`Failed to write project graph cache to ${exports.nxProjectGraph} and ${exports.nxFileMap} after 5 attempts.`);
|
181
|
+
}
|
174
182
|
perf_hooks_1.performance.mark('write cache:end');
|
175
183
|
perf_hooks_1.performance.measure('write cache', 'write cache:start', 'write cache:end');
|
176
184
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { DefaultTasksRunnerOptions, RemoteCache } from './default-tasks-runner';
|
2
2
|
import { Task } from '../config/task-graph';
|
3
|
+
import { NxJsonConfiguration } from '../config/nx-json';
|
3
4
|
export type CachedResult = {
|
4
5
|
terminalOutput: string;
|
5
6
|
outputsPath: string;
|
@@ -68,6 +69,14 @@ export declare class Cache {
|
|
68
69
|
private createCacheDir;
|
69
70
|
private createTerminalOutputsDir;
|
70
71
|
}
|
72
|
+
/**
|
73
|
+
* Resolves the max cache size from environment variable or nx.json configuration
|
74
|
+
* and converts it to a number of bytes.
|
75
|
+
*
|
76
|
+
* @param nxJson The nx.json configuration object
|
77
|
+
* @returns The resolved max cache size in bytes
|
78
|
+
*/
|
79
|
+
export declare function resolveMaxCacheSize(nxJson: NxJsonConfiguration): number;
|
71
80
|
/**
|
72
81
|
* Converts a string representation of a max cache size to a number.
|
73
82
|
*
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Cache = exports.DbCache = void 0;
|
4
4
|
exports.dbCacheEnabled = dbCacheEnabled;
|
5
5
|
exports.getCache = getCache;
|
6
|
+
exports.resolveMaxCacheSize = resolveMaxCacheSize;
|
6
7
|
exports.parseMaxCacheSize = parseMaxCacheSize;
|
7
8
|
exports.formatCacheSize = formatCacheSize;
|
8
9
|
const workspace_root_1 = require("../utils/workspace-root");
|
@@ -55,9 +56,7 @@ class DbCache {
|
|
55
56
|
constructor(options) {
|
56
57
|
this.options = options;
|
57
58
|
this.nxJson = (0, nx_json_1.readNxJson)();
|
58
|
-
this.cache = new native_1.NxCache(workspace_root_1.workspaceRoot, cache_directory_1.cacheDir, (0, db_connection_1.getDbConnection)(), undefined, this.nxJson
|
59
|
-
? parseMaxCacheSize(this.nxJson.maxCacheSize)
|
60
|
-
: (0, native_1.getDefaultMaxCacheSize)(cache_directory_1.cacheDir));
|
59
|
+
this.cache = new native_1.NxCache(workspace_root_1.workspaceRoot, cache_directory_1.cacheDir, (0, db_connection_1.getDbConnection)(), undefined, resolveMaxCacheSize(this.nxJson));
|
61
60
|
this.isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
62
61
|
}
|
63
62
|
async init() {
|
@@ -472,6 +471,19 @@ function tryAndRetry(fn) {
|
|
472
471
|
};
|
473
472
|
return _try();
|
474
473
|
}
|
474
|
+
/**
|
475
|
+
* Resolves the max cache size from environment variable or nx.json configuration
|
476
|
+
* and converts it to a number of bytes.
|
477
|
+
*
|
478
|
+
* @param nxJson The nx.json configuration object
|
479
|
+
* @returns The resolved max cache size in bytes
|
480
|
+
*/
|
481
|
+
function resolveMaxCacheSize(nxJson) {
|
482
|
+
const rawMaxCacheSize = process.env.NX_MAX_CACHE_SIZE ?? nxJson.maxCacheSize;
|
483
|
+
return rawMaxCacheSize !== undefined
|
484
|
+
? parseMaxCacheSize(rawMaxCacheSize)
|
485
|
+
: (0, native_1.getDefaultMaxCacheSize)(cache_directory_1.cacheDir);
|
486
|
+
}
|
475
487
|
/**
|
476
488
|
* Converts a string representation of a max cache size to a number.
|
477
489
|
*
|