nx 24.0.6 → 24.1.0-beta.1
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/dist/bin/init-local.js +2 -4
- package/dist/bin/nx-cloud.js +2 -1
- package/dist/bin/nx.js +12 -14
- package/dist/bin/run-executor.js +5 -0
- package/dist/src/adapter/compat.d.ts +1 -1
- package/dist/src/adapter/compat.js +1 -0
- package/dist/src/adapter/ngcli-adapter.js +7 -20
- package/dist/src/command-line/completion/scripts/bash.sh +9 -2
- package/dist/src/command-line/completion/scripts/fish.fish +10 -2
- package/dist/src/command-line/completion/scripts/zsh.zsh +8 -2
- package/dist/src/command-line/completion/scripts.js +18 -8
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +0 -1
- package/dist/src/command-line/conformance/command-object.d.ts +3 -0
- package/dist/src/command-line/conformance/command-object.js +66 -0
- package/dist/src/command-line/generate/generate.js +14 -27
- package/dist/src/command-line/generate/generator-utils.d.ts +1 -0
- package/dist/src/command-line/generate/generator-utils.js +9 -0
- package/dist/src/command-line/graph/graph.js +1 -7
- package/dist/src/command-line/import/import.js +26 -2
- package/dist/src/command-line/import/utils/ai-output.d.ts +9 -1
- package/dist/src/command-line/import/utils/ai-output.js +20 -1
- package/dist/src/command-line/import/utils/prepare-source-repo.js +0 -3
- package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +2 -2
- package/dist/src/command-line/init/init-v2.js +2 -2
- package/dist/src/command-line/migrate/migrate.js +1 -4
- package/dist/src/command-line/migrate/prompt-files.js +5 -5
- package/dist/src/command-line/migrate/run/orchestrator.js +2 -3
- package/dist/src/command-line/migrate/run/worker.js +7 -5
- package/dist/src/command-line/migrate/run-migration-process.js +3 -2
- package/dist/src/command-line/nx-commands.d.ts +1 -1
- package/dist/src/command-line/nx-commands.js +82 -132
- package/dist/src/command-line/release/changelog.js +8 -39
- package/dist/src/command-line/release/command-object.d.ts +1 -0
- package/dist/src/command-line/release/command-object.js +4 -0
- package/dist/src/command-line/release/config/use-legacy-versioning.js +1 -1
- package/dist/src/command-line/release/release.js +6 -4
- package/dist/src/command-line/release/utils/diff.js +0 -14
- package/dist/src/command-line/release/utils/git.js +1 -1
- package/dist/src/command-line/release/utils/resolve-nx-json-error-message.js +2 -24
- package/dist/src/command-line/report/report.js +1 -1
- package/dist/src/command-line/run/executor-utils.js +1 -1
- package/dist/src/command-line/show/show-target/utils.js +1 -1
- package/dist/src/command-line/watch/watch.js +1 -1
- package/dist/src/commands-runner/get-command-projects.js +0 -3
- package/dist/src/config/misc-interfaces.d.ts +0 -1
- package/dist/src/config/nx-json.d.ts +117 -0
- package/dist/src/config/workspace-json-project-json.d.ts +6 -7
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/styles.css +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +13 -20
- package/dist/src/devkit-exports.d.ts +1 -1
- package/dist/src/devkit-internals.d.ts +11 -4
- package/dist/src/devkit-internals.js +27 -5
- package/dist/src/executors/run-commands/run-commands.impl.d.ts +1 -1
- package/dist/src/executors/run-commands/run-commands.impl.js +35 -13
- package/dist/src/hasher/hash-task.js +4 -4
- package/dist/src/hasher/task-hasher.js +2 -2
- package/dist/src/migrations/update-24-1-0/replace-powerpack-conformance.d.ts +4 -0
- package/dist/src/migrations/update-24-1-0/replace-powerpack-conformance.js +117 -0
- package/dist/src/migrations/update-24-1-0/replace-powerpack-conformance.md +38 -0
- package/dist/src/native/index.d.ts +6 -4
- package/dist/src/native/index.js +5 -0
- package/dist/src/native/native-bindings.js +1 -0
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/native/transform-objects.d.ts +2 -0
- package/dist/src/native/transform-objects.js +15 -0
- package/dist/src/nx-cloud/utilities/environment.js +0 -17
- package/dist/src/plugins/js/lock-file/bun-parser.d.ts +1 -2
- package/dist/src/plugins/js/lock-file/bun-parser.js +5 -5
- package/dist/src/plugins/js/lock-file/lock-file-names.d.ts +6 -0
- package/dist/src/plugins/js/lock-file/lock-file-names.js +16 -0
- package/dist/src/plugins/js/lock-file/lock-file.d.ts +1 -2
- package/dist/src/plugins/js/lock-file/lock-file.js +24 -31
- package/dist/src/plugins/js/lock-file/npm-parser.js +1 -2
- package/dist/src/plugins/js/project-graph/affected/npm-packages.js +50 -2
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +5 -0
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +75 -13
- package/dist/src/plugins/js/utils/get-workspace-packages-from-graph.js +1 -1
- package/dist/src/plugins/js/utils/register.js +13 -6
- package/dist/src/project-graph/affected/affected-tasks.js +1 -1
- package/dist/src/project-graph/build-project-graph.js +5 -2
- package/dist/src/project-graph/nx-deps-cache.d.ts +3 -2
- package/dist/src/project-graph/nx-deps-cache.js +8 -2
- package/dist/src/project-graph/utils/project-graph-paths.d.ts +8 -0
- package/dist/src/project-graph/utils/project-graph-paths.js +170 -0
- package/dist/src/tasks-runner/batch/run-batch.js +3 -13
- package/dist/src/tasks-runner/cache.js +19 -18
- package/dist/src/tasks-runner/run-command.js +12 -10
- package/dist/src/tasks-runner/task-orchestrator.d.ts +1 -0
- package/dist/src/tasks-runner/task-orchestrator.js +14 -3
- package/dist/src/tasks-runner/utils.js +1 -12
- package/dist/src/ultracache/overrides.js +1 -1
- package/dist/src/utils/child-process.js +2 -1
- package/dist/src/utils/code-frames.js +0 -1
- package/dist/src/utils/db-connection.js +6 -4
- package/dist/src/utils/find-workspace-root.js +2 -4
- package/dist/src/utils/git-utils.d.ts +5 -0
- package/dist/src/utils/git-utils.js +23 -1
- package/dist/src/utils/handle-import.js +6 -0
- package/dist/src/utils/installation-directory.d.ts +16 -0
- package/dist/src/utils/installation-directory.js +96 -2
- package/dist/src/utils/json.d.ts +7 -0
- package/dist/src/utils/json.js +27 -0
- package/dist/src/utils/min-release-age/behavior/pnpm.js +9 -9
- package/dist/src/utils/min-release-age/behavior/yarn.js +2 -2
- package/dist/src/utils/nx-key.js +11 -8
- package/dist/src/utils/output.d.ts +5 -0
- package/dist/src/utils/output.js +11 -4
- package/dist/src/utils/owned-private-dir.d.ts +10 -0
- package/dist/src/utils/owned-private-dir.js +28 -0
- package/dist/src/utils/plugins/output.js +0 -2
- package/dist/src/utils/require-nx-key.js +6 -4
- package/dist/src/utils/workspace-root.d.ts +12 -0
- package/dist/src/utils/workspace-root.js +56 -7
- package/migrations.json +6 -0
- package/package.json +14 -12
- package/schemas/nx-schema.json +75 -9
- package/schemas/project-schema.json +5 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// No imports: the project graph builder loads this, and must not load the lock file parsers.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.LOCKFILES = exports.BUN_TEXT_LOCK_FILE = exports.BUN_LOCK_FILE = exports.PNPM_LOCK_FILE = exports.NPM_LOCK_FILE = exports.YARN_LOCK_FILE = void 0;
|
|
5
|
+
exports.YARN_LOCK_FILE = 'yarn.lock';
|
|
6
|
+
exports.NPM_LOCK_FILE = 'package-lock.json';
|
|
7
|
+
exports.PNPM_LOCK_FILE = 'pnpm-lock.yaml';
|
|
8
|
+
exports.BUN_LOCK_FILE = 'bun.lockb';
|
|
9
|
+
exports.BUN_TEXT_LOCK_FILE = 'bun.lock';
|
|
10
|
+
exports.LOCKFILES = [
|
|
11
|
+
exports.YARN_LOCK_FILE,
|
|
12
|
+
exports.NPM_LOCK_FILE,
|
|
13
|
+
exports.PNPM_LOCK_FILE,
|
|
14
|
+
exports.BUN_LOCK_FILE,
|
|
15
|
+
exports.BUN_TEXT_LOCK_FILE,
|
|
16
|
+
];
|
|
@@ -7,7 +7,7 @@ import { CreateDependenciesContext, CreateNodesContext } from '../../../project-
|
|
|
7
7
|
import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
|
|
8
8
|
import { PackageJson } from '../../../utils/package-json';
|
|
9
9
|
import { PackageManager } from '../../../utils/package-manager';
|
|
10
|
-
export
|
|
10
|
+
export { LOCKFILES } from './lock-file-names';
|
|
11
11
|
export declare const AUTO_AFFECTED_LOCK_FILES: readonly ["yarn.lock", "package-lock.json", "pnpm-lock.yaml", "pnpm-lock.yml", "bun.lockb", "bun.lock"];
|
|
12
12
|
/**
|
|
13
13
|
* Parses the lockfile into external nodes, plus the keyMap that getLockFileDependencies reads.
|
|
@@ -82,4 +82,3 @@ export declare function generatePrunedDeployOutput(packageJson: PackageJson, gra
|
|
|
82
82
|
packageManager: PackageManager;
|
|
83
83
|
workspaceRoot?: string;
|
|
84
84
|
}): void;
|
|
85
|
-
export {};
|
|
@@ -24,35 +24,28 @@ const package_manager_1 = require("../../../utils/package-manager");
|
|
|
24
24
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
25
25
|
const get_workspace_packages_from_graph_1 = require("../utils/get-workspace-packages-from-graph");
|
|
26
26
|
const bun_parser_1 = require("./bun-parser");
|
|
27
|
+
const lock_file_names_1 = require("./lock-file-names");
|
|
27
28
|
const npm_parser_1 = require("./npm-parser");
|
|
28
29
|
const pnpm_parser_1 = require("./pnpm-parser");
|
|
29
30
|
const project_graph_pruning_1 = require("./project-graph-pruning");
|
|
30
31
|
const package_json_1 = require("./utils/package-json");
|
|
31
32
|
const yarn_parser_1 = require("./yarn-parser");
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const PNPM_LOCK_FILE = 'pnpm-lock.yaml';
|
|
33
|
+
var lock_file_names_2 = require("./lock-file-names");
|
|
34
|
+
Object.defineProperty(exports, "LOCKFILES", { enumerable: true, get: function () { return lock_file_names_2.LOCKFILES; } });
|
|
35
35
|
const PNPM_LOCK_FILE_LEGACY = 'pnpm-lock.yml';
|
|
36
|
-
exports.LOCKFILES = [
|
|
37
|
-
YARN_LOCK_FILE,
|
|
38
|
-
NPM_LOCK_FILE,
|
|
39
|
-
PNPM_LOCK_FILE,
|
|
40
|
-
bun_parser_1.BUN_LOCK_FILE,
|
|
41
|
-
bun_parser_1.BUN_TEXT_LOCK_FILE,
|
|
42
|
-
];
|
|
43
36
|
exports.AUTO_AFFECTED_LOCK_FILES = [
|
|
44
|
-
YARN_LOCK_FILE,
|
|
45
|
-
NPM_LOCK_FILE,
|
|
46
|
-
PNPM_LOCK_FILE,
|
|
37
|
+
lock_file_names_1.YARN_LOCK_FILE,
|
|
38
|
+
lock_file_names_1.NPM_LOCK_FILE,
|
|
39
|
+
lock_file_names_1.PNPM_LOCK_FILE,
|
|
47
40
|
PNPM_LOCK_FILE_LEGACY,
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
lock_file_names_1.BUN_LOCK_FILE,
|
|
42
|
+
lock_file_names_1.BUN_TEXT_LOCK_FILE,
|
|
50
43
|
];
|
|
51
|
-
const YARN_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, YARN_LOCK_FILE);
|
|
52
|
-
const NPM_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, NPM_LOCK_FILE);
|
|
53
|
-
const PNPM_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, PNPM_LOCK_FILE);
|
|
54
|
-
const BUN_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot,
|
|
55
|
-
const BUN_TEXT_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot,
|
|
44
|
+
const YARN_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, lock_file_names_1.YARN_LOCK_FILE);
|
|
45
|
+
const NPM_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, lock_file_names_1.NPM_LOCK_FILE);
|
|
46
|
+
const PNPM_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, lock_file_names_1.PNPM_LOCK_FILE);
|
|
47
|
+
const BUN_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, lock_file_names_1.BUN_LOCK_FILE);
|
|
48
|
+
const BUN_TEXT_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot, lock_file_names_1.BUN_TEXT_LOCK_FILE);
|
|
56
49
|
/**
|
|
57
50
|
* Parses the lockfile into external nodes, plus the keyMap that getLockFileDependencies reads.
|
|
58
51
|
*/
|
|
@@ -75,19 +68,19 @@ function getLockFileNodes(packageManager, lockFile, contents, lockFileHash, cont
|
|
|
75
68
|
throw new Error(`Unknown package manager: ${packageManager}`);
|
|
76
69
|
}
|
|
77
70
|
function getLockFileNodesForName(lockFile, contents, lockFileHash, packageJson) {
|
|
78
|
-
if (lockFile === YARN_LOCK_FILE || lockFile ===
|
|
71
|
+
if (lockFile === lock_file_names_1.YARN_LOCK_FILE || lockFile === lock_file_names_1.BUN_LOCK_FILE) {
|
|
79
72
|
// yarn-parser only reads optional fields plus an unused `name` for the
|
|
80
73
|
// synthetic root workspace node, which is identical across base/head and
|
|
81
74
|
// therefore irrelevant for affected diffing.
|
|
82
75
|
return (0, yarn_parser_1.getYarnLockfileNodes)(contents, lockFileHash, packageJson ?? {});
|
|
83
76
|
}
|
|
84
|
-
if (lockFile === PNPM_LOCK_FILE || lockFile === PNPM_LOCK_FILE_LEGACY) {
|
|
77
|
+
if (lockFile === lock_file_names_1.PNPM_LOCK_FILE || lockFile === PNPM_LOCK_FILE_LEGACY) {
|
|
85
78
|
return (0, pnpm_parser_1.getPnpmLockfileNodes)(contents, lockFileHash);
|
|
86
79
|
}
|
|
87
|
-
if (lockFile === NPM_LOCK_FILE) {
|
|
80
|
+
if (lockFile === lock_file_names_1.NPM_LOCK_FILE) {
|
|
88
81
|
return (0, npm_parser_1.getNpmLockfileNodes)(contents, lockFileHash);
|
|
89
82
|
}
|
|
90
|
-
if (lockFile ===
|
|
83
|
+
if (lockFile === lock_file_names_1.BUN_TEXT_LOCK_FILE) {
|
|
91
84
|
const nodes = (0, bun_parser_1.getBunTextLockfileNodes)(contents, lockFileHash);
|
|
92
85
|
return { nodes, keyMap: new Map() };
|
|
93
86
|
}
|
|
@@ -108,7 +101,7 @@ function getLockFileDependencies(packageManager, lockFile, contents, lockFileHas
|
|
|
108
101
|
return (0, npm_parser_1.getNpmLockfileDependencies)(contents, lockFileHash, context, keyMap);
|
|
109
102
|
}
|
|
110
103
|
if (packageManager === 'bun') {
|
|
111
|
-
if (lockFile ===
|
|
104
|
+
if (lockFile === lock_file_names_1.BUN_TEXT_LOCK_FILE) {
|
|
112
105
|
// Bun parser doesn't use keyMap
|
|
113
106
|
return (0, bun_parser_1.getBunTextLockfileDependencies)(contents, lockFileHash, context);
|
|
114
107
|
}
|
|
@@ -151,19 +144,19 @@ function lockFileExists(packageManager) {
|
|
|
151
144
|
*/
|
|
152
145
|
function getLockFileName(packageManager) {
|
|
153
146
|
if (packageManager === 'yarn') {
|
|
154
|
-
return YARN_LOCK_FILE;
|
|
147
|
+
return lock_file_names_1.YARN_LOCK_FILE;
|
|
155
148
|
}
|
|
156
149
|
if (packageManager === 'pnpm') {
|
|
157
|
-
return PNPM_LOCK_FILE;
|
|
150
|
+
return lock_file_names_1.PNPM_LOCK_FILE;
|
|
158
151
|
}
|
|
159
152
|
if (packageManager === 'npm') {
|
|
160
|
-
return NPM_LOCK_FILE;
|
|
153
|
+
return lock_file_names_1.NPM_LOCK_FILE;
|
|
161
154
|
}
|
|
162
155
|
if (packageManager === 'bun') {
|
|
163
156
|
const lockFilePath = getLockFilePath(packageManager);
|
|
164
|
-
return lockFilePath.endsWith(
|
|
165
|
-
?
|
|
166
|
-
:
|
|
157
|
+
return lockFilePath.endsWith(lock_file_names_1.BUN_TEXT_LOCK_FILE)
|
|
158
|
+
? lock_file_names_1.BUN_TEXT_LOCK_FILE
|
|
159
|
+
: lock_file_names_1.BUN_LOCK_FILE;
|
|
167
160
|
}
|
|
168
161
|
throw new Error(`Unknown package manager: ${packageManager}`);
|
|
169
162
|
}
|
|
@@ -580,10 +580,9 @@ function getPeerDependencies(path) {
|
|
|
580
580
|
const fullPath = `${workspace_root_1.workspaceRoot}/${path}/package.json`;
|
|
581
581
|
if ((0, fs_1.existsSync)(fullPath)) {
|
|
582
582
|
const content = (0, fs_1.readFileSync)(fullPath, 'utf-8');
|
|
583
|
-
const { peerDependencies
|
|
583
|
+
const { peerDependencies } = JSON.parse(content);
|
|
584
584
|
return {
|
|
585
585
|
...(peerDependencies && { peerDependencies }),
|
|
586
|
-
...(peerDependenciesMeta && { peerDependenciesMeta }),
|
|
587
586
|
};
|
|
588
587
|
}
|
|
589
588
|
else {
|
|
@@ -25,18 +25,62 @@ function packageJsonDependencyChanges(touchedFiles, nxJson, projectGraph) {
|
|
|
25
25
|
projects: touched.filter((name) => name in projectGraph.nodes),
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
const PNPM_WORKSPACE_FILES = ['pnpm-workspace.yaml', 'pnpm-workspace.yml'];
|
|
28
29
|
/**
|
|
29
30
|
* External nodes and workspace projects the root package.json change names,
|
|
30
31
|
* or null when it cannot be pinned to them: a removed dependency, a global
|
|
31
32
|
* package, or an override selector matching nothing in the graph.
|
|
33
|
+
*
|
|
34
|
+
* Also reads `overrides` from `pnpm-workspace.yaml` (pnpm 10+): the field
|
|
35
|
+
* moves there when the root `package.json` has no `pnpm` block, and pnpm 12
|
|
36
|
+
* no longer reads `package.json#pnpm` at all. Yaml override diffs are rewritten
|
|
37
|
+
* to the `pnpm.overrides.*` path and matched by the existing pnpm selector
|
|
38
|
+
* logic. Catalog and other workspace settings are left alone.
|
|
32
39
|
*/
|
|
33
40
|
function touchedNpmPackages(touchedFiles, nxJson, projectGraph) {
|
|
34
41
|
const packageJsonChange = touchedFiles.find((f) => f.file === 'package.json');
|
|
35
|
-
|
|
42
|
+
const workspaceYamlChange = touchedFiles.find((f) => PNPM_WORKSPACE_FILES.includes(f.file));
|
|
43
|
+
if (!packageJsonChange && !workspaceYamlChange)
|
|
36
44
|
return [];
|
|
37
45
|
const globalPackages = new Set(getGlobalPackages(nxJson.plugins));
|
|
38
46
|
let touched = [];
|
|
39
|
-
const changes = packageJsonChange
|
|
47
|
+
const changes = packageJsonChange
|
|
48
|
+
? [...packageJsonChange.getChanges()]
|
|
49
|
+
: [];
|
|
50
|
+
if (workspaceYamlChange) {
|
|
51
|
+
for (const c of workspaceYamlChange.getChanges()) {
|
|
52
|
+
// Unparseable yaml - be conservative and fall back to all projects.
|
|
53
|
+
if (!(0, json_diff_1.isJsonChange)(c))
|
|
54
|
+
return null;
|
|
55
|
+
// Catalog, patchedDependencies, settings, etc. do not change which
|
|
56
|
+
// packages the lockfile resolves to.
|
|
57
|
+
if (c.path[0] !== 'overrides')
|
|
58
|
+
continue;
|
|
59
|
+
// Replacing the whole `overrides` map with something non-mappy
|
|
60
|
+
// (null, scalar, array) is a shape we don't understand - fall back.
|
|
61
|
+
if (c.path.length === 1) {
|
|
62
|
+
if (!isObjectOrUndefined(c.value.lhs))
|
|
63
|
+
return null;
|
|
64
|
+
if (!isObjectOrUndefined(c.value.rhs))
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// pnpm's workspace overrides take string selectors as keys and
|
|
69
|
+
// string versions as leaves; a non-string leaf is a shape we
|
|
70
|
+
// don't model.
|
|
71
|
+
if (c.value.lhs !== undefined && typeof c.value.lhs !== 'string') {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
if (c.value.rhs !== undefined && typeof c.value.rhs !== 'string') {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
changes.push({
|
|
79
|
+
...c,
|
|
80
|
+
path: ['pnpm', 'overrides', ...c.path.slice(1)],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
40
84
|
const npmPackages = Object.values(projectGraph.externalNodes);
|
|
41
85
|
let packagesByName;
|
|
42
86
|
const missingTouchedNpmPackages = [];
|
|
@@ -143,3 +187,7 @@ function getGlobalPackages(plugins) {
|
|
|
143
187
|
.map((p) => (0, get_package_name_from_import_path_1.getPackageNameFromImportPath)(typeof p === 'string' ? p : p.plugin))
|
|
144
188
|
.concat('nx');
|
|
145
189
|
}
|
|
190
|
+
function isObjectOrUndefined(value) {
|
|
191
|
+
return (value === undefined ||
|
|
192
|
+
(value !== null && typeof value === 'object' && !Array.isArray(value)));
|
|
193
|
+
}
|
|
@@ -75,7 +75,12 @@ export declare class TargetProjectLocator {
|
|
|
75
75
|
* In some cases, such as when multiple module formats are published, the resolved package.json
|
|
76
76
|
* might only contain the "type" field - no "name" or "version", so in such cases we keep traversing
|
|
77
77
|
* until we find a package.json that contains the "name" and "version" fields.
|
|
78
|
+
*
|
|
79
|
+
* A nested manifest whose name is a subpath of the requested package (for example
|
|
80
|
+
* `@stencil/core/internal`) is not that package. Prefer `node_modules/<name>/package.json`
|
|
81
|
+
* — aliases keep that file's own name — and skip subpath manifests while walking up.
|
|
78
82
|
*/
|
|
79
83
|
private readPackageJson;
|
|
84
|
+
private readCompletePackageJson;
|
|
80
85
|
}
|
|
81
86
|
export {};
|
|
@@ -19,6 +19,26 @@ const typescript_1 = require("../../utils/typescript");
|
|
|
19
19
|
const defaultNpmResolutionCache = new Map();
|
|
20
20
|
const defaultPackageJsonResolutionCache = new Map();
|
|
21
21
|
const experimentalNodeModules = new Set(['node:sqlite']);
|
|
22
|
+
/**
|
|
23
|
+
* Package root for a file that Node resolved inside `node_modules/<name>/`.
|
|
24
|
+
* `realpath` keeps that directory for a normal install, including pnpm's store path.
|
|
25
|
+
*/
|
|
26
|
+
function installedPackageJsonFromResolvedFile(resolvedFile, packageName) {
|
|
27
|
+
if (!resolvedFile) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const normalized = resolvedFile.replace(/\\/g, '/');
|
|
31
|
+
const marker = `/node_modules/${packageName}/`;
|
|
32
|
+
const index = normalized.lastIndexOf(marker);
|
|
33
|
+
if (index === -1) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const root = normalized.slice(0, index + marker.length - 1);
|
|
37
|
+
return (0, node_path_1.join)(root, 'package.json');
|
|
38
|
+
}
|
|
39
|
+
function isNestedPackageName(manifestName, packageName) {
|
|
40
|
+
return !!manifestName && manifestName.startsWith(`${packageName}/`);
|
|
41
|
+
}
|
|
22
42
|
// Node's isBuiltin is false for Bun's runtime modules (`bun`, `bun:*`).
|
|
23
43
|
function isBunModuleImport(importExpr) {
|
|
24
44
|
return importExpr === 'bun' || importExpr.startsWith('bun:');
|
|
@@ -416,10 +436,14 @@ class TargetProjectLocator {
|
|
|
416
436
|
* In some cases, such as when multiple module formats are published, the resolved package.json
|
|
417
437
|
* might only contain the "type" field - no "name" or "version", so in such cases we keep traversing
|
|
418
438
|
* until we find a package.json that contains the "name" and "version" fields.
|
|
439
|
+
*
|
|
440
|
+
* A nested manifest whose name is a subpath of the requested package (for example
|
|
441
|
+
* `@stencil/core/internal`) is not that package. Prefer `node_modules/<name>/package.json`
|
|
442
|
+
* — aliases keep that file's own name — and skip subpath manifests while walking up.
|
|
419
443
|
*/
|
|
420
444
|
readPackageJson(packageName, relativeToDir) {
|
|
421
|
-
//
|
|
422
|
-
const packageJsonPath = (0, resolve_relative_to_dir_1.resolveRelativeToDir)(
|
|
445
|
+
// Package specifiers use `/` on every OS. path.join() would use `\` on Windows.
|
|
446
|
+
const packageJsonPath = (0, resolve_relative_to_dir_1.resolveRelativeToDir)(`${packageName}/package.json`, relativeToDir);
|
|
423
447
|
if (packageJsonPath) {
|
|
424
448
|
if (this.packageJsonResolutionCache.has(packageJsonPath)) {
|
|
425
449
|
const cached = this.packageJsonResolutionCache.get(packageJsonPath);
|
|
@@ -436,27 +460,44 @@ class TargetProjectLocator {
|
|
|
436
460
|
try {
|
|
437
461
|
// Resolve the main entry point of the package
|
|
438
462
|
const pathOfFileInPackage = packageJsonPath ?? (0, resolve_relative_to_dir_1.resolveRelativeToDir)(packageName, relativeToDir);
|
|
463
|
+
const installedPackageJsonPath = installedPackageJsonFromResolvedFile(pathOfFileInPackage, packageName);
|
|
464
|
+
if (installedPackageJsonPath &&
|
|
465
|
+
installedPackageJsonPath !== packageJsonPath) {
|
|
466
|
+
const installedPackageJson = this.readCompletePackageJson(installedPackageJsonPath);
|
|
467
|
+
if (installedPackageJson) {
|
|
468
|
+
return installedPackageJson;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
439
471
|
let dir = (0, node_path_1.dirname)(pathOfFileInPackage);
|
|
440
472
|
while (dir !== (0, node_path_1.dirname)(dir)) {
|
|
441
|
-
const
|
|
442
|
-
if (this.packageJsonResolutionCache.has(
|
|
443
|
-
const cached = this.packageJsonResolutionCache.get(
|
|
444
|
-
if (cached
|
|
473
|
+
const candidatePath = (0, node_path_1.join)(dir, 'package.json');
|
|
474
|
+
if (this.packageJsonResolutionCache.has(candidatePath)) {
|
|
475
|
+
const cached = this.packageJsonResolutionCache.get(candidatePath);
|
|
476
|
+
if (cached?.name &&
|
|
477
|
+
cached.version &&
|
|
478
|
+
!isNestedPackageName(cached.name, packageName)) {
|
|
445
479
|
return cached;
|
|
446
480
|
}
|
|
447
|
-
// Cached incomplete manifests
|
|
481
|
+
// Cached incomplete manifests, and nested packages, are traversal points.
|
|
448
482
|
}
|
|
449
483
|
else {
|
|
450
484
|
try {
|
|
451
|
-
const parsedPackageJson = (0, fileutils_1.readJsonFile)(
|
|
485
|
+
const parsedPackageJson = (0, fileutils_1.readJsonFile)(candidatePath);
|
|
452
486
|
// Ensure the package.json contains the "name" and "version" fields
|
|
453
487
|
if (parsedPackageJson.name && parsedPackageJson.version) {
|
|
454
|
-
|
|
455
|
-
|
|
488
|
+
if (isNestedPackageName(parsedPackageJson.name, packageName)) {
|
|
489
|
+
this.packageJsonResolutionCache.set(candidatePath, null);
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
this.packageJsonResolutionCache.set(candidatePath, parsedPackageJson);
|
|
493
|
+
return parsedPackageJson;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
// A module-format stub without name/version: remember it and keep
|
|
498
|
+
// traversing towards the real manifest.
|
|
499
|
+
this.packageJsonResolutionCache.set(candidatePath, null);
|
|
456
500
|
}
|
|
457
|
-
// A module-format stub without name/version: remember it and keep
|
|
458
|
-
// traversing towards the real manifest.
|
|
459
|
-
this.packageJsonResolutionCache.set(packageJsonPath, null);
|
|
460
501
|
}
|
|
461
502
|
catch {
|
|
462
503
|
// Package.json is invalid, keep traversing
|
|
@@ -470,5 +511,26 @@ class TargetProjectLocator {
|
|
|
470
511
|
return null;
|
|
471
512
|
}
|
|
472
513
|
}
|
|
514
|
+
readCompletePackageJson(packageJsonPath) {
|
|
515
|
+
if (!packageJsonPath) {
|
|
516
|
+
return null;
|
|
517
|
+
}
|
|
518
|
+
const cached = this.packageJsonResolutionCache.get(packageJsonPath);
|
|
519
|
+
if (cached?.name && cached.version) {
|
|
520
|
+
return cached;
|
|
521
|
+
}
|
|
522
|
+
try {
|
|
523
|
+
const parsedPackageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
|
|
524
|
+
if (parsedPackageJson.name && parsedPackageJson.version) {
|
|
525
|
+
this.packageJsonResolutionCache.set(packageJsonPath, parsedPackageJson);
|
|
526
|
+
return parsedPackageJson;
|
|
527
|
+
}
|
|
528
|
+
this.packageJsonResolutionCache.set(packageJsonPath, null);
|
|
529
|
+
return null;
|
|
530
|
+
}
|
|
531
|
+
catch {
|
|
532
|
+
return null;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
473
535
|
}
|
|
474
536
|
exports.TargetProjectLocator = TargetProjectLocator;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getWorkspacePackagesFromGraph = getWorkspacePackagesFromGraph;
|
|
4
4
|
function getWorkspacePackagesFromGraph(graph) {
|
|
5
5
|
const workspacePackages = new Map();
|
|
6
|
-
for (const [
|
|
6
|
+
for (const [, project] of Object.entries(graph.nodes)) {
|
|
7
7
|
const pkgName = project.data?.metadata?.js?.packageName;
|
|
8
8
|
if (pkgName) {
|
|
9
9
|
workspacePackages.set(pkgName, project);
|
|
@@ -29,6 +29,12 @@ const installation_directory_1 = require("../../../utils/installation-directory"
|
|
|
29
29
|
const logger_1 = require("../../../utils/logger");
|
|
30
30
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
31
31
|
const typescript_1 = require("./typescript");
|
|
32
|
+
const node_module_1 = require("node:module");
|
|
33
|
+
// Node passes a stand-in require, without a cache, require.extensions or
|
|
34
|
+
// Module._load, when an ESM loader hook supplies this module's source, as
|
|
35
|
+
// Yarn PnP does.
|
|
36
|
+
if (!require.cache)
|
|
37
|
+
require = (0, node_module_1.createRequire)(__filename);
|
|
32
38
|
const swcNodeInstalled = packageIsInstalled('@swc-node/register');
|
|
33
39
|
const tsNodeInstalled = packageIsInstalled('ts-node/register');
|
|
34
40
|
let ts;
|
|
@@ -385,7 +391,7 @@ function ensureCjsResolverPatched() {
|
|
|
385
391
|
}
|
|
386
392
|
function tryResolveLoader(specifier) {
|
|
387
393
|
try {
|
|
388
|
-
return
|
|
394
|
+
return (0, installation_directory_1.resolveInstalledPackage)(specifier, [__dirname]);
|
|
389
395
|
}
|
|
390
396
|
catch {
|
|
391
397
|
return null;
|
|
@@ -589,8 +595,7 @@ function registerTsProject(tsConfigPath) {
|
|
|
589
595
|
}
|
|
590
596
|
function getSwcTranspiler(compilerOptions) {
|
|
591
597
|
// These are requires to prevent it from registering when it shouldn't
|
|
592
|
-
const register = require('@swc-node/register/register')
|
|
593
|
-
.register;
|
|
598
|
+
const register = require((0, installation_directory_1.resolveInstalledPackage)('@swc-node/register/register', [__dirname])).register;
|
|
594
599
|
const cleanupFn = register({
|
|
595
600
|
...compilerOptions,
|
|
596
601
|
baseUrl: compilerOptions.baseUrl ?? './',
|
|
@@ -598,7 +603,7 @@ function getSwcTranspiler(compilerOptions) {
|
|
|
598
603
|
return typeof cleanupFn === 'function' ? cleanupFn : () => { };
|
|
599
604
|
}
|
|
600
605
|
function getTsNodeTranspiler(compilerOptions, tsNodeOptions, preferTsNode) {
|
|
601
|
-
const { register } = require('ts-node');
|
|
606
|
+
const { register } = require((0, installation_directory_1.resolveInstalledPackage)('ts-node', [__dirname]));
|
|
602
607
|
// ts-node doesn't provide a cleanup method
|
|
603
608
|
const service = register({
|
|
604
609
|
...tsNodeOptions,
|
|
@@ -1115,7 +1120,9 @@ function readCompilerOptions(tsConfigPath) {
|
|
|
1115
1120
|
}
|
|
1116
1121
|
}
|
|
1117
1122
|
function readCompilerOptionsWithSwc(tsConfigPath) {
|
|
1118
|
-
const { readDefaultTsConfig, } = require('@swc-node/register/read-default-tsconfig'
|
|
1123
|
+
const { readDefaultTsConfig, } = require((0, installation_directory_1.resolveInstalledPackage)('@swc-node/register/read-default-tsconfig', [
|
|
1124
|
+
__dirname,
|
|
1125
|
+
]));
|
|
1119
1126
|
const compilerOptions = readDefaultTsConfig(tsConfigPath);
|
|
1120
1127
|
// This is returned in compiler options for some reason, but not part of the typings.
|
|
1121
1128
|
// @swc-node/register filters the files to transpile based on it, but it can be limiting when processing
|
|
@@ -1168,7 +1175,7 @@ function warnNoTranspiler() {
|
|
|
1168
1175
|
}
|
|
1169
1176
|
function packageIsInstalled(m) {
|
|
1170
1177
|
try {
|
|
1171
|
-
|
|
1178
|
+
(0, installation_directory_1.resolveInstalledPackage)(m, [__dirname]);
|
|
1172
1179
|
return true;
|
|
1173
1180
|
}
|
|
1174
1181
|
catch {
|
|
@@ -176,7 +176,7 @@ async function matchAffectedTasks(projectGraph, nxJson, planningContext, request
|
|
|
176
176
|
const dependencies = dependencyChanges(projectGraph, touchedFiles, nxJson, packageJson);
|
|
177
177
|
const namedProjects = new Set(dependencies.projects);
|
|
178
178
|
const projects = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph).projects;
|
|
179
|
-
// TODO(v25): remove custom hasher support.
|
|
179
|
+
// TODO(v25): remove custom hasher support (NXC-5052).
|
|
180
180
|
const customHashed = new Set(taskIds.filter((id) => hasCustomHasher(taskGraph.tasks[id], projects)));
|
|
181
181
|
const options = {
|
|
182
182
|
projectGlobPatterns: await (0, affected_projects_1.getProjectGlobPatterns)(nxJson),
|
|
@@ -10,12 +10,14 @@ const perf_hooks_1 = require("perf_hooks");
|
|
|
10
10
|
const analytics_1 = require("../analytics");
|
|
11
11
|
const configuration_1 = require("../config/configuration");
|
|
12
12
|
const file_hasher_1 = require("../hasher/file-hasher");
|
|
13
|
+
const lock_file_names_1 = require("../plugins/js/lock-file/lock-file-names");
|
|
13
14
|
const typescript_1 = require("../plugins/js/utils/typescript");
|
|
14
15
|
const assert_workspace_validity_1 = require("../utils/assert-workspace-validity");
|
|
15
16
|
const delayed_spinner_1 = require("../utils/delayed-spinner");
|
|
16
17
|
const fileutils_1 = require("../utils/fileutils");
|
|
17
18
|
const plugin_progress_text_1 = require("../utils/plugin-progress-text");
|
|
18
19
|
const progress_topics_1 = require("../utils/progress-topics");
|
|
20
|
+
const workspace_context_1 = require("../utils/workspace-context");
|
|
19
21
|
const workspace_root_1 = require("../utils/workspace-root");
|
|
20
22
|
const error_types_1 = require("./error-types");
|
|
21
23
|
const nx_deps_cache_1 = require("./nx-deps-cache");
|
|
@@ -72,10 +74,11 @@ async function buildProjectGraphUsingProjectFileMap(projectRootMap, externalNode
|
|
|
72
74
|
const packageJsonDeps = readCombinedDeps();
|
|
73
75
|
const rootTsConfig = readRootTsConfig();
|
|
74
76
|
const externalNodesHash = hashExternalNodes(externalNodes);
|
|
77
|
+
const lockFileHash = await (0, workspace_context_1.hashWithWorkspaceContext)(workspace_root_1.workspaceRoot, lock_file_names_1.LOCKFILES);
|
|
75
78
|
let filesToProcess;
|
|
76
79
|
let cachedFileData;
|
|
77
80
|
const useCacheData = fileMapCache &&
|
|
78
|
-
!(0, nx_deps_cache_1.shouldRecomputeWholeGraph)(fileMapCache, packageJsonDeps, projects, nxJson, rootTsConfig, externalNodesHash);
|
|
81
|
+
!(0, nx_deps_cache_1.shouldRecomputeWholeGraph)(fileMapCache, packageJsonDeps, projects, nxJson, rootTsConfig, externalNodesHash, lockFileHash);
|
|
79
82
|
if (useCacheData) {
|
|
80
83
|
const fromCache = (0, nx_deps_cache_1.extractCachedFileData)(fileMap, fileMapCache);
|
|
81
84
|
filesToProcess = fromCache.filesToProcess;
|
|
@@ -93,7 +96,7 @@ async function buildProjectGraphUsingProjectFileMap(projectRootMap, externalNode
|
|
|
93
96
|
try {
|
|
94
97
|
const context = createContext(projects, nxJson, externalNodes, fileMap, filesToProcess);
|
|
95
98
|
projectGraph = await buildProjectGraphUsingContext(externalNodes, context, cachedFileData, projectGraphVersion, plugins, sourceMap);
|
|
96
|
-
projectFileMapCache = (0, nx_deps_cache_1.createProjectFileMapCache)(nxJson, packageJsonDeps, fileMap, rootTsConfig, externalNodesHash);
|
|
99
|
+
projectFileMapCache = (0, nx_deps_cache_1.createProjectFileMapCache)(nxJson, packageJsonDeps, fileMap, rootTsConfig, externalNodesHash, lockFileHash);
|
|
97
100
|
}
|
|
98
101
|
catch (e) {
|
|
99
102
|
// we need to include the workspace validity errors in the final error
|
|
@@ -11,6 +11,7 @@ export interface FileMapCache {
|
|
|
11
11
|
pluginsConfig?: any;
|
|
12
12
|
fileMap: FileMap;
|
|
13
13
|
externalNodesHash?: string;
|
|
14
|
+
lockFileHash?: string;
|
|
14
15
|
}
|
|
15
16
|
export declare const nxProjectGraph: string;
|
|
16
17
|
export declare const nxFileMap: string;
|
|
@@ -28,7 +29,7 @@ export declare function createProjectFileMapCache(nxJson: NxJsonConfiguration<'*
|
|
|
28
29
|
[p: string]: any;
|
|
29
30
|
};
|
|
30
31
|
};
|
|
31
|
-
}, externalNodesHash: string): FileMapCache;
|
|
32
|
+
}, externalNodesHash: string, lockFileHash: string): FileMapCache;
|
|
32
33
|
export declare function writeCache(cache: FileMapCache, projectGraph: ProjectGraph, sourceMaps: ConfigurationSourceMaps, errors: ProjectGraphErrorTypes[], computedAt: number): void;
|
|
33
34
|
/**
|
|
34
35
|
* Writes the cache only if the on-disk cache file has been modified since
|
|
@@ -46,7 +47,7 @@ export declare function shouldRecomputeWholeGraph(cache: FileMapCache, packageJs
|
|
|
46
47
|
[k: string]: any;
|
|
47
48
|
};
|
|
48
49
|
};
|
|
49
|
-
}, externalNodesHash: string): boolean;
|
|
50
|
+
}, externalNodesHash: string, lockFileHash: string): boolean;
|
|
50
51
|
export type CachedFileData = {
|
|
51
52
|
nonProjectFiles: Record<string, FileData>;
|
|
52
53
|
projectFileMap: {
|
|
@@ -120,7 +120,7 @@ function readSourceMapsCache() {
|
|
|
120
120
|
perf_hooks_1.performance.measure('read cache', 'read source-maps:start', 'read source-maps:end');
|
|
121
121
|
return data ?? null;
|
|
122
122
|
}
|
|
123
|
-
function createProjectFileMapCache(nxJson, packageJsonDeps, fileMap, tsConfig, externalNodesHash) {
|
|
123
|
+
function createProjectFileMapCache(nxJson, packageJsonDeps, fileMap, tsConfig, externalNodesHash, lockFileHash) {
|
|
124
124
|
const nxJsonPlugins = getNxJsonPluginsData(nxJson, packageJsonDeps);
|
|
125
125
|
const newValue = {
|
|
126
126
|
version: '6.0',
|
|
@@ -131,6 +131,7 @@ function createProjectFileMapCache(nxJson, packageJsonDeps, fileMap, tsConfig, e
|
|
|
131
131
|
pluginsConfig: nxJson?.pluginsConfig,
|
|
132
132
|
fileMap,
|
|
133
133
|
externalNodesHash,
|
|
134
|
+
lockFileHash,
|
|
134
135
|
};
|
|
135
136
|
return newValue;
|
|
136
137
|
}
|
|
@@ -223,7 +224,7 @@ function writeCacheIfStale(cache, projectGraph, sourceMaps, errors) {
|
|
|
223
224
|
}
|
|
224
225
|
writeCache(cache, projectGraph, sourceMaps, errors, Date.now());
|
|
225
226
|
}
|
|
226
|
-
function shouldRecomputeWholeGraph(cache, packageJsonDeps, projects, nxJson, tsConfig, externalNodesHash) {
|
|
227
|
+
function shouldRecomputeWholeGraph(cache, packageJsonDeps, projects, nxJson, tsConfig, externalNodesHash, lockFileHash) {
|
|
227
228
|
if (cache.version !== '6.0') {
|
|
228
229
|
return true;
|
|
229
230
|
}
|
|
@@ -260,6 +261,11 @@ function shouldRecomputeWholeGraph(cache, packageJsonDeps, projects, nxJson, tsC
|
|
|
260
261
|
if (externalNodesHash !== cache.externalNodesHash) {
|
|
261
262
|
return true;
|
|
262
263
|
}
|
|
264
|
+
// Cached import edges follow node_modules, which an install can re-hoist
|
|
265
|
+
// after a lock file change that leaves the external nodes unchanged.
|
|
266
|
+
if (lockFileHash !== cache.lockFileHash) {
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
263
269
|
return false;
|
|
264
270
|
}
|
|
265
271
|
/*
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type FileData, type ProjectFileMap, type ProjectGraph, type ProjectGraphProjectNode } from '../../config/project-graph';
|
|
2
|
+
export declare function getPath(graph: ProjectGraph, sourceProjectName: string, targetProjectName: string): Array<ProjectGraphProjectNode>;
|
|
3
|
+
export declare function pathExists(graph: ProjectGraph, sourceProjectName: string, targetProjectName: string): boolean;
|
|
4
|
+
export declare function checkCircularPath(graph: ProjectGraph, sourceProject: ProjectGraphProjectNode, targetProject: ProjectGraphProjectNode): ProjectGraphProjectNode[];
|
|
5
|
+
export declare function circularPathHasPair(circularPath: ProjectGraphProjectNode[], ignored: Map<string, Set<string>>): boolean;
|
|
6
|
+
export declare function findFilesInCircularPath(projectFileMap: ProjectFileMap, circularPath: ProjectGraphProjectNode[]): Array<string[]>;
|
|
7
|
+
export declare function findFilesWithDynamicImports(projectFileMap: ProjectFileMap, sourceProjectName: string, targetProjectName: string): FileData[];
|
|
8
|
+
export declare function expandIgnoredCircularDependencies(ignoredCircularDependencies: Array<[string, string]>, projectGraph: ProjectGraph): Map<string, Set<string>>;
|