nx 22.4.0-canary.20260113-246d4fd → 22.4.0-canary.20260115-21d1555
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/bin/init-local.js +1 -1
- package/package.json +12 -12
- package/project.json +2 -2
- package/src/native/index.js +48 -8
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/lock-file/yarn-parser.d.ts.map +1 -1
- package/src/plugins/js/lock-file/yarn-parser.js +6 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts.map +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +1 -14
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +4 -1
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts.map +1 -1
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +20 -2
package/bin/init-local.js
CHANGED
|
@@ -119,7 +119,7 @@ function shouldDelegateToAngularCLI() {
|
|
|
119
119
|
}
|
|
120
120
|
async function ensureNxConsoleInstalledViaDaemon() {
|
|
121
121
|
// Only proceed if daemon is available
|
|
122
|
-
if (!client_1.daemonClient.enabled()) {
|
|
122
|
+
if (!client_1.daemonClient.enabled() || !(await client_1.daemonClient.isServerAvailable())) {
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
125
|
// Get status from daemon
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nx",
|
|
3
|
-
"version": "22.4.0-canary.
|
|
3
|
+
"version": "22.4.0-canary.20260115-21d1555",
|
|
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": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"jest-diff": "^30.0.2",
|
|
54
54
|
"jsonc-parser": "3.2.0",
|
|
55
55
|
"lines-and-columns": "2.0.3",
|
|
56
|
-
"minimatch": "
|
|
56
|
+
"minimatch": "10.1.1",
|
|
57
57
|
"node-machine-id": "1.1.12",
|
|
58
58
|
"npm-run-path": "^4.0.1",
|
|
59
59
|
"open": "^8.4.0",
|
|
@@ -83,16 +83,16 @@
|
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
85
|
"optionalDependencies": {
|
|
86
|
-
"@nx/nx-darwin-arm64": "22.4.0-canary.
|
|
87
|
-
"@nx/nx-darwin-x64": "22.4.0-canary.
|
|
88
|
-
"@nx/nx-freebsd-x64": "22.4.0-canary.
|
|
89
|
-
"@nx/nx-linux-arm-gnueabihf": "22.4.0-canary.
|
|
90
|
-
"@nx/nx-linux-arm64-gnu": "22.4.0-canary.
|
|
91
|
-
"@nx/nx-linux-arm64-musl": "22.4.0-canary.
|
|
92
|
-
"@nx/nx-linux-x64-gnu": "22.4.0-canary.
|
|
93
|
-
"@nx/nx-linux-x64-musl": "22.4.0-canary.
|
|
94
|
-
"@nx/nx-win32-arm64-msvc": "22.4.0-canary.
|
|
95
|
-
"@nx/nx-win32-x64-msvc": "22.4.0-canary.
|
|
86
|
+
"@nx/nx-darwin-arm64": "22.4.0-canary.20260115-21d1555",
|
|
87
|
+
"@nx/nx-darwin-x64": "22.4.0-canary.20260115-21d1555",
|
|
88
|
+
"@nx/nx-freebsd-x64": "22.4.0-canary.20260115-21d1555",
|
|
89
|
+
"@nx/nx-linux-arm-gnueabihf": "22.4.0-canary.20260115-21d1555",
|
|
90
|
+
"@nx/nx-linux-arm64-gnu": "22.4.0-canary.20260115-21d1555",
|
|
91
|
+
"@nx/nx-linux-arm64-musl": "22.4.0-canary.20260115-21d1555",
|
|
92
|
+
"@nx/nx-linux-x64-gnu": "22.4.0-canary.20260115-21d1555",
|
|
93
|
+
"@nx/nx-linux-x64-musl": "22.4.0-canary.20260115-21d1555",
|
|
94
|
+
"@nx/nx-win32-arm64-msvc": "22.4.0-canary.20260115-21d1555",
|
|
95
|
+
"@nx/nx-win32-x64-msvc": "22.4.0-canary.20260115-21d1555"
|
|
96
96
|
},
|
|
97
97
|
"nx-migrations": {
|
|
98
98
|
"migrations": "./migrations.json",
|
package/project.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"inputs": ["native"],
|
|
16
16
|
"outputs": [
|
|
17
17
|
"{projectRoot}/src/native/*.wasm",
|
|
18
|
-
"{projectRoot}/src/native
|
|
18
|
+
"{projectRoot}/src/native/!(index|browser).js",
|
|
19
19
|
"{projectRoot}/src/native/*.cjs",
|
|
20
20
|
"{projectRoot}/src/native/*.mjs",
|
|
21
21
|
"{projectRoot}/src/native/index.d.ts"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"build-native": {
|
|
32
32
|
"outputs": [
|
|
33
33
|
"{projectRoot}/src/native/*.node",
|
|
34
|
-
"{projectRoot}/src/native
|
|
34
|
+
"{projectRoot}/src/native/!(index|browser).js",
|
|
35
35
|
"{projectRoot}/src/native/index.d.ts"
|
|
36
36
|
],
|
|
37
37
|
"executor": "@monodon/rust:napi",
|
package/src/native/index.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
const { join, basename } = require('path');
|
|
2
|
-
const {
|
|
2
|
+
const {
|
|
3
|
+
copyFileSync,
|
|
4
|
+
existsSync,
|
|
5
|
+
mkdirSync,
|
|
6
|
+
renameSync,
|
|
7
|
+
statSync,
|
|
8
|
+
unlinkSync,
|
|
9
|
+
} = require('fs');
|
|
3
10
|
const Module = require('module');
|
|
4
11
|
const { nxVersion } = require('../utils/versions');
|
|
5
12
|
const { getNativeFileCacheLocation } = require('./native-file-cache-location');
|
|
6
13
|
|
|
14
|
+
const MAX_COPY_RETRIES = 3;
|
|
15
|
+
|
|
7
16
|
// WASI is still experimental and throws a warning when used
|
|
8
17
|
// We spawn many many processes so the warning gets printed a lot
|
|
9
18
|
// We have a different warning elsewhere to warn people using WASI
|
|
@@ -56,6 +65,14 @@ const localNodeFiles = [
|
|
|
56
65
|
|
|
57
66
|
const originalLoad = Module._load;
|
|
58
67
|
|
|
68
|
+
function statsOrNull(path) {
|
|
69
|
+
try {
|
|
70
|
+
return statSync(path);
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
59
76
|
// We override the _load function so that when a native file is required,
|
|
60
77
|
// we copy it to a cache directory and require it from there.
|
|
61
78
|
// This prevents the file being loaded from node_modules and causing file locking issues.
|
|
@@ -83,22 +100,45 @@ Module._load = function (request, parent, isMain) {
|
|
|
83
100
|
);
|
|
84
101
|
// This is the path that will get loaded
|
|
85
102
|
const tmpFile = join(nativeFileCacheLocation, nxVersion + '-' + fileName);
|
|
103
|
+
const expectedFileSize = statSync(nativeLocation).size;
|
|
104
|
+
const existingFileStats = statsOrNull(tmpFile);
|
|
86
105
|
|
|
87
106
|
// If the file to be loaded already exists, just load it
|
|
88
|
-
if (
|
|
107
|
+
if (existingFileStats?.size === expectedFileSize) {
|
|
89
108
|
return originalLoad.apply(this, [tmpFile, parent, isMain]);
|
|
90
109
|
}
|
|
91
110
|
if (!existsSync(nativeFileCacheLocation)) {
|
|
92
111
|
mkdirSync(nativeFileCacheLocation, { recursive: true });
|
|
93
112
|
}
|
|
94
|
-
// First copy to a unique location for each process
|
|
95
|
-
copyFileSync(nativeLocation, tmpTmpFile);
|
|
96
113
|
|
|
97
|
-
//
|
|
98
|
-
|
|
114
|
+
// Retry copying up to 3 times, validating after each copy
|
|
115
|
+
for (let attempt = 1; attempt <= MAX_COPY_RETRIES; attempt++) {
|
|
116
|
+
// First copy to a unique location for each process
|
|
117
|
+
copyFileSync(nativeLocation, tmpTmpFile);
|
|
118
|
+
|
|
119
|
+
// Validate the copy - check file size matches expected
|
|
120
|
+
const copiedFileStats = statsOrNull(tmpTmpFile);
|
|
121
|
+
if (copiedFileStats?.size === expectedFileSize) {
|
|
122
|
+
// Copy succeeded, rename to final location and load
|
|
123
|
+
renameSync(tmpTmpFile, tmpFile);
|
|
124
|
+
return originalLoad.apply(this, [tmpFile, parent, isMain]);
|
|
125
|
+
}
|
|
99
126
|
|
|
100
|
-
|
|
101
|
-
|
|
127
|
+
// Copy failed validation, clean up the malformed file
|
|
128
|
+
try {
|
|
129
|
+
unlinkSync(tmpTmpFile);
|
|
130
|
+
} catch {
|
|
131
|
+
// Ignore cleanup errors
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// All retries failed - warn and load from original location
|
|
136
|
+
console.warn(
|
|
137
|
+
`Warning: Failed to copy native module to cache after ${MAX_COPY_RETRIES} attempts. ` +
|
|
138
|
+
`Loading from original location instead. ` +
|
|
139
|
+
`This may cause file locking issues on Windows.`
|
|
140
|
+
);
|
|
141
|
+
return originalLoad.apply(this, [nativeLocation, parent, isMain]);
|
|
102
142
|
} else {
|
|
103
143
|
// call the original _load function for everything else
|
|
104
144
|
return originalLoad.apply(this, arguments);
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yarn-parser.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/plugins/js/lock-file/yarn-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,yBAAyB,EAE1B,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAEL,YAAY,EACZ,wBAAwB,EAEzB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AA0C3E,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,qBAAqB,GACjC;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IAChD,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;CAC/C,CAYA;AAED,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,yBAAyB,EAC9B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,+BAa9C;
|
|
1
|
+
{"version":3,"file":"yarn-parser.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/plugins/js/lock-file/yarn-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,yBAAyB,EAE1B,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAEL,YAAY,EACZ,wBAAwB,EAEzB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AA0C3E,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,qBAAqB,GACjC;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IAChD,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;CAC/C,CAYA;AAED,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,yBAAyB,EAC9B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,+BAa9C;AA6QD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,YAAY,EACnB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,qBAAqB,GACjC,MAAM,CA8BR"}
|
|
@@ -105,7 +105,12 @@ function getNodes(dependencies, packageJson, isBerry) {
|
|
|
105
105
|
});
|
|
106
106
|
const externalNodes = {};
|
|
107
107
|
for (const [packageName, versionMap] of nodes.entries()) {
|
|
108
|
-
|
|
108
|
+
// If there's only one version of a package, treat it as hoisted
|
|
109
|
+
// This ensures deterministic hashing across environments for packages
|
|
110
|
+
// like optional platform-specific dependencies (e.g., @nx/nx-darwin-arm64)
|
|
111
|
+
const hoistedNode = versionMap.size === 1
|
|
112
|
+
? versionMap.values().next().value
|
|
113
|
+
: findHoistedNode(packageName, versionMap, combinedDeps);
|
|
109
114
|
if (hoistedNode) {
|
|
110
115
|
hoistedNode.name = `npm:${packageName}`;
|
|
111
116
|
}
|
package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explicit-project-dependencies.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EACL,yBAAyB,EAE1B,MAAM,iDAAiD,CAAC;AAGzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA+BhE,wBAAgB,mCAAmC,CACjD,GAAG,EAAE,yBAAyB,EAC9B,oBAAoB,EAAE,oBAAoB,GACzC,yBAAyB,EAAE,
|
|
1
|
+
{"version":3,"file":"explicit-project-dependencies.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EACL,yBAAyB,EAE1B,MAAM,iDAAiD,CAAC;AAGzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA+BhE,wBAAgB,mCAAmC,CACjD,GAAG,EAAE,yBAAyB,EAC9B,oBAAoB,EAAE,oBAAoB,GACzC,yBAAyB,EAAE,CAmF7B"}
|
|
@@ -33,11 +33,8 @@ function buildExplicitTypeScriptDependencies(ctx, targetProjectLocator) {
|
|
|
33
33
|
'.mjs',
|
|
34
34
|
'.cjs',
|
|
35
35
|
'.cts',
|
|
36
|
+
'.vue',
|
|
36
37
|
];
|
|
37
|
-
// TODO: This can be removed when vue is stable
|
|
38
|
-
if (isVuePluginInstalled()) {
|
|
39
|
-
moduleExtensions.push('.vue');
|
|
40
|
-
}
|
|
41
38
|
for (const [project, fileData] of Object.entries(ctx.filesToProcess.projectFileMap)) {
|
|
42
39
|
filesToProcess[project] ??= [];
|
|
43
40
|
for (const { file } of fileData) {
|
|
@@ -76,13 +73,3 @@ function buildExplicitTypeScriptDependencies(ctx, targetProjectLocator) {
|
|
|
76
73
|
}
|
|
77
74
|
return res;
|
|
78
75
|
}
|
|
79
|
-
function isVuePluginInstalled() {
|
|
80
|
-
try {
|
|
81
|
-
// nx-ignore-next-line
|
|
82
|
-
require.resolve('@nx/vue');
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ProjectGraphExternalNode, ProjectGraphProjectNode } from '../../../../config/project-graph';
|
|
2
|
+
import type { PackageJson } from '../../../../utils/package-json';
|
|
2
3
|
/**
|
|
3
4
|
* The key is a combination of the package name and the workspace relative directory
|
|
4
5
|
* containing the file importing it e.g. `lodash__packages/my-lib`, the value is the
|
|
5
6
|
* resolved external node name from the project graph.
|
|
6
7
|
*/
|
|
7
8
|
type NpmResolutionCache = Map<string, string | null>;
|
|
9
|
+
type PackageJsonResolutionCache = Map<string, PackageJson | null>;
|
|
8
10
|
type PathPattern = {
|
|
9
11
|
pattern: string;
|
|
10
12
|
prefix: string;
|
|
@@ -15,6 +17,7 @@ export declare class TargetProjectLocator {
|
|
|
15
17
|
private readonly nodes;
|
|
16
18
|
private readonly externalNodes;
|
|
17
19
|
private readonly npmResolutionCache;
|
|
20
|
+
private readonly packageJsonResolutionCache;
|
|
18
21
|
private projectRootMappings;
|
|
19
22
|
private npmProjects;
|
|
20
23
|
private tsConfig;
|
|
@@ -22,7 +25,7 @@ export declare class TargetProjectLocator {
|
|
|
22
25
|
private parsedPathPatterns;
|
|
23
26
|
private typescriptResolutionCache;
|
|
24
27
|
private packagesMetadata;
|
|
25
|
-
constructor(nodes: Record<string, ProjectGraphProjectNode>, externalNodes?: Record<string, ProjectGraphExternalNode>, npmResolutionCache?: NpmResolutionCache);
|
|
28
|
+
constructor(nodes: Record<string, ProjectGraphProjectNode>, externalNodes?: Record<string, ProjectGraphExternalNode>, npmResolutionCache?: NpmResolutionCache, packageJsonResolutionCache?: PackageJsonResolutionCache);
|
|
26
29
|
/**
|
|
27
30
|
* Resolve any workspace or external project that matches the given import expression,
|
|
28
31
|
* originating from the given filePath.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"target-project-locator.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"target-project-locator.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,kCAAkC,CAAC;AAO1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAYlE;;;;GAIG;AACH,KAAK,kBAAkB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AACrD,KAAK,0BAA0B,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC;AAElE,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAcF,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAGjE;AAED,qBAAa,oBAAoB;IAc7B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAI9B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,0BAA0B;IAnB7C,OAAO,CAAC,mBAAmB,CAAyC;IACpE,OAAO,CAAC,WAAW,CAAkD;IACrE,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,KAAK,CAAgD;IAC7D,OAAO,CAAC,kBAAkB,CAA6B;IACvD,OAAO,CAAC,yBAAyB,CAAoC;IACrE,OAAO,CAAC,gBAAgB,CAItB;gBAGiB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,EAC9C,aAAa,GAAE,MAAM,CACpC,MAAM,EACN,wBAAwB,CACpB,EACW,kBAAkB,GAAE,kBAA8C,EAClE,0BAA0B,GAAE,0BAA8D;IA8B7G;;;;;;OAMG;IACH,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAsEnE;;;;;;OAMG;IACH,wBAAwB,CACtB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,IAAI;IAoEhB;;;;OAIG;IACH,SAAS,CAAC,oBAAoB,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;IAmB7D,iBAAiB,CACf,UAAU,EAAE,MAAM,GACjB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,SAAS;IA6B/D,6BAA6B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAehE,iCAAiC,CAC/B,eAAe,EAAE,MAAM,EACvB,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,MAAM,GACrB,MAAM,GAAG,IAAI;IAgDhB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,UAAU;IAuBlB,OAAO,CAAC,2BAA2B;IAqDnC,OAAO,CAAC,wBAAwB;IAYhC,OAAO,CAAC,2BAA2B;IAsBnC,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,wBAAwB;IAKhC;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe;CA0DxB"}
|
|
@@ -16,16 +16,18 @@ const typescript_1 = require("../../utils/typescript");
|
|
|
16
16
|
* Use a shared cache to avoid repeated npm package resolution work within the TargetProjectLocator.
|
|
17
17
|
*/
|
|
18
18
|
const defaultNpmResolutionCache = new Map();
|
|
19
|
+
const defaultPackageJsonResolutionCache = new Map();
|
|
19
20
|
const experimentalNodeModules = new Set(['node:sqlite']);
|
|
20
21
|
function isBuiltinModuleImport(importExpr) {
|
|
21
22
|
const packageName = (0, get_package_name_from_import_path_1.getPackageNameFromImportPath)(importExpr);
|
|
22
23
|
return (0, node_module_1.isBuiltin)(packageName) || experimentalNodeModules.has(packageName);
|
|
23
24
|
}
|
|
24
25
|
class TargetProjectLocator {
|
|
25
|
-
constructor(nodes, externalNodes = {}, npmResolutionCache = defaultNpmResolutionCache) {
|
|
26
|
+
constructor(nodes, externalNodes = {}, npmResolutionCache = defaultNpmResolutionCache, packageJsonResolutionCache = defaultPackageJsonResolutionCache) {
|
|
26
27
|
this.nodes = nodes;
|
|
27
28
|
this.externalNodes = externalNodes;
|
|
28
29
|
this.npmResolutionCache = npmResolutionCache;
|
|
30
|
+
this.packageJsonResolutionCache = packageJsonResolutionCache;
|
|
29
31
|
this.projectRootMappings = (0, find_project_for_path_1.createProjectRootMappings)(this.nodes);
|
|
30
32
|
this.tsConfig = this.getRootTsConfig();
|
|
31
33
|
this.paths = this.tsConfig.config?.compilerOptions?.paths;
|
|
@@ -375,10 +377,18 @@ class TargetProjectLocator {
|
|
|
375
377
|
// The package.json is directly resolvable
|
|
376
378
|
const packageJsonPath = (0, resolve_relative_to_dir_1.resolveRelativeToDir)((0, node_path_1.join)(packageName, 'package.json'), relativeToDir);
|
|
377
379
|
if (packageJsonPath) {
|
|
380
|
+
if (this.packageJsonResolutionCache.has(packageJsonPath)) {
|
|
381
|
+
return this.packageJsonResolutionCache.get(packageJsonPath);
|
|
382
|
+
}
|
|
378
383
|
const parsedPackageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
|
|
379
384
|
if (parsedPackageJson.name && parsedPackageJson.version) {
|
|
385
|
+
this.packageJsonResolutionCache.set(packageJsonPath, parsedPackageJson);
|
|
380
386
|
return parsedPackageJson;
|
|
381
387
|
}
|
|
388
|
+
else {
|
|
389
|
+
this.packageJsonResolutionCache.set(packageJsonPath, null);
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
382
392
|
}
|
|
383
393
|
try {
|
|
384
394
|
// Resolve the main entry point of the package
|
|
@@ -386,15 +396,23 @@ class TargetProjectLocator {
|
|
|
386
396
|
let dir = (0, node_path_1.dirname)(pathOfFileInPackage);
|
|
387
397
|
while (dir !== (0, node_path_1.dirname)(dir)) {
|
|
388
398
|
const packageJsonPath = (0, node_path_1.join)(dir, 'package.json');
|
|
399
|
+
if (this.packageJsonResolutionCache.has(packageJsonPath)) {
|
|
400
|
+
return this.packageJsonResolutionCache.get(packageJsonPath);
|
|
401
|
+
}
|
|
389
402
|
try {
|
|
390
403
|
const parsedPackageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
|
|
391
404
|
// Ensure the package.json contains the "name" and "version" fields
|
|
392
405
|
if (parsedPackageJson.name && parsedPackageJson.version) {
|
|
406
|
+
this.packageJsonResolutionCache.set(packageJsonPath, parsedPackageJson);
|
|
393
407
|
return parsedPackageJson;
|
|
394
408
|
}
|
|
409
|
+
else {
|
|
410
|
+
this.packageJsonResolutionCache.set(packageJsonPath, null);
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
395
413
|
}
|
|
396
414
|
catch {
|
|
397
|
-
// Package.json
|
|
415
|
+
// Package.json is invalid, keep traversing
|
|
398
416
|
}
|
|
399
417
|
dir = (0, node_path_1.dirname)(dir);
|
|
400
418
|
}
|