@nx/js 22.7.0-beta.10 → 22.7.0-beta.12
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "22.7.0-beta.
|
|
3
|
+
"version": "22.7.0-beta.12",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
|
|
6
6
|
"repository": {
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@babel/preset-env": "^7.23.2",
|
|
41
41
|
"@babel/preset-typescript": "^7.22.5",
|
|
42
42
|
"@babel/runtime": "^7.22.6",
|
|
43
|
-
"@nx/devkit": "22.7.0-beta.
|
|
44
|
-
"@nx/workspace": "22.7.0-beta.
|
|
43
|
+
"@nx/devkit": "22.7.0-beta.12",
|
|
44
|
+
"@nx/workspace": "22.7.0-beta.12",
|
|
45
45
|
"@zkochan/js-yaml": "0.0.7",
|
|
46
46
|
"babel-plugin-const-enum": "^1.0.1",
|
|
47
47
|
"babel-plugin-macros": "^3.1.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"tslib": "^2.3.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"nx": "22.7.0-beta.
|
|
64
|
+
"nx": "22.7.0-beta.12"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"verdaccio": "^6.0.5"
|
package/src/internal.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { resolveModuleByImport } from './utils/typescript/ast-utils';
|
|
2
|
+
export { walkTsconfigExtendsChain, type RawTsconfigJsonCache, } from './utils/typescript/raw-tsconfig';
|
|
2
3
|
export { registerTsProject, registerTsConfigPaths, } from 'nx/src/plugins/js/utils/register';
|
|
3
4
|
export { TargetProjectLocator, isBuiltinModuleImport, } from 'nx/src/plugins/js/project-graph/build-dependencies/target-project-locator';
|
|
4
5
|
export { findProjectsNpmDependencies } from 'nx/src/plugins/js/package-json/create-package-json';
|
package/src/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../packages/js/src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../packages/js/src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACL,wBAAwB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,2EAA2E,CAAC;AAEnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,oDAAoD,CAAC"}
|
package/src/internal.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findProjectsNpmDependencies = exports.isBuiltinModuleImport = exports.TargetProjectLocator = exports.registerTsConfigPaths = exports.registerTsProject = exports.resolveModuleByImport = void 0;
|
|
3
|
+
exports.findProjectsNpmDependencies = exports.isBuiltinModuleImport = exports.TargetProjectLocator = exports.registerTsConfigPaths = exports.registerTsProject = exports.walkTsconfigExtendsChain = exports.resolveModuleByImport = void 0;
|
|
4
4
|
var ast_utils_1 = require("./utils/typescript/ast-utils");
|
|
5
5
|
Object.defineProperty(exports, "resolveModuleByImport", { enumerable: true, get: function () { return ast_utils_1.resolveModuleByImport; } });
|
|
6
|
+
var raw_tsconfig_1 = require("./utils/typescript/raw-tsconfig");
|
|
7
|
+
Object.defineProperty(exports, "walkTsconfigExtendsChain", { enumerable: true, get: function () { return raw_tsconfig_1.walkTsconfigExtendsChain; } });
|
|
6
8
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
7
9
|
var register_1 = require("nx/src/plugins/js/utils/register");
|
|
8
10
|
Object.defineProperty(exports, "registerTsProject", { enumerable: true, get: function () { return register_1.registerTsProject; } });
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight tsconfig extends walker that does NOT load the `typescript`
|
|
3
|
+
* package. For full TypeScript-aware parsing (compilerOptions resolution,
|
|
4
|
+
* file lists, project references, etc.) see the `@nx/js/typescript` plugin,
|
|
5
|
+
* which uses `ts.parseJsonConfigFileContent` and a persistent cache.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Cache of raw parsed tsconfig JSON contents, keyed by absolute file path.
|
|
9
|
+
* `null` indicates a file that doesn't exist or failed to parse.
|
|
10
|
+
*
|
|
11
|
+
* Instantiate with `new Map()` and reuse across `walkTsconfigExtendsChain`
|
|
12
|
+
* calls within one `createNodes` invocation to dedupe file reads when many
|
|
13
|
+
* starting points share parent tsconfigs.
|
|
14
|
+
*/
|
|
15
|
+
export type RawTsconfigJsonCache = Map<string, unknown | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Walks the `extends` chain of a tsconfig, invoking `visit` for each unique
|
|
18
|
+
* reachable file (entry first, then recursively). Cycle-safe. Files that
|
|
19
|
+
* don't exist or fail to parse are silently skipped.
|
|
20
|
+
*
|
|
21
|
+
* When a tsconfig has multiple `extends` entries they are visited in
|
|
22
|
+
* REVERSE order, so visitors looking for the effective value of an
|
|
23
|
+
* inherited option see the highest-precedence entries first and can
|
|
24
|
+
* return `'stop'` to abort the traversal. Visitors that want to collect
|
|
25
|
+
* every reachable file should always return `'continue'`.
|
|
26
|
+
*
|
|
27
|
+
* @param entryAbsolutePath Absolute, canonical path of the tsconfig to
|
|
28
|
+
* start from. Pass through `path.resolve()` if unsure.
|
|
29
|
+
* @param visit Invoked once per unique reachable tsconfig.
|
|
30
|
+
* @param options.jsonCache Optional shared cache of parsed tsconfig
|
|
31
|
+
* contents. When omitted, the walker uses a fresh internal cache.
|
|
32
|
+
*/
|
|
33
|
+
export declare function walkTsconfigExtendsChain(entryAbsolutePath: string, visit: (absolutePath: string, rawJson: unknown) => 'continue' | 'stop', options?: {
|
|
34
|
+
jsonCache?: RawTsconfigJsonCache;
|
|
35
|
+
}): void;
|
|
36
|
+
//# sourceMappingURL=raw-tsconfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw-tsconfig.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/raw-tsconfig.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC;AAE/D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CACtC,iBAAiB,EAAE,MAAM,EACzB,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,UAAU,GAAG,MAAM,EACtE,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,oBAAoB,CAAA;CAAE,GAC7C,IAAI,CAGN"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.walkTsconfigExtendsChain = walkTsconfigExtendsChain;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
/**
|
|
7
|
+
* Walks the `extends` chain of a tsconfig, invoking `visit` for each unique
|
|
8
|
+
* reachable file (entry first, then recursively). Cycle-safe. Files that
|
|
9
|
+
* don't exist or fail to parse are silently skipped.
|
|
10
|
+
*
|
|
11
|
+
* When a tsconfig has multiple `extends` entries they are visited in
|
|
12
|
+
* REVERSE order, so visitors looking for the effective value of an
|
|
13
|
+
* inherited option see the highest-precedence entries first and can
|
|
14
|
+
* return `'stop'` to abort the traversal. Visitors that want to collect
|
|
15
|
+
* every reachable file should always return `'continue'`.
|
|
16
|
+
*
|
|
17
|
+
* @param entryAbsolutePath Absolute, canonical path of the tsconfig to
|
|
18
|
+
* start from. Pass through `path.resolve()` if unsure.
|
|
19
|
+
* @param visit Invoked once per unique reachable tsconfig.
|
|
20
|
+
* @param options.jsonCache Optional shared cache of parsed tsconfig
|
|
21
|
+
* contents. When omitted, the walker uses a fresh internal cache.
|
|
22
|
+
*/
|
|
23
|
+
function walkTsconfigExtendsChain(entryAbsolutePath, visit, options) {
|
|
24
|
+
const jsonCache = options?.jsonCache ?? new Map();
|
|
25
|
+
walk(entryAbsolutePath, visit, jsonCache, new Set());
|
|
26
|
+
}
|
|
27
|
+
function walk(absolutePath, visit, jsonCache, visited) {
|
|
28
|
+
if (visited.has(absolutePath))
|
|
29
|
+
return 'continue';
|
|
30
|
+
visited.add(absolutePath);
|
|
31
|
+
const json = readCachedJson(absolutePath, jsonCache);
|
|
32
|
+
if (json === null)
|
|
33
|
+
return 'continue';
|
|
34
|
+
if (visit(absolutePath, json) === 'stop')
|
|
35
|
+
return 'stop';
|
|
36
|
+
const extendsField = json.extends;
|
|
37
|
+
if (!extendsField)
|
|
38
|
+
return 'continue';
|
|
39
|
+
const extendsList = Array.isArray(extendsField)
|
|
40
|
+
? extendsField
|
|
41
|
+
: [extendsField];
|
|
42
|
+
// Last entry wins per TypeScript precedence; walk in reverse so
|
|
43
|
+
// precedence-aware visitors see the highest-precedence entries first.
|
|
44
|
+
const fromDir = (0, node_path_1.dirname)(absolutePath);
|
|
45
|
+
for (let i = extendsList.length - 1; i >= 0; i--) {
|
|
46
|
+
const ext = extendsList[i];
|
|
47
|
+
if (typeof ext !== 'string' || !ext)
|
|
48
|
+
continue;
|
|
49
|
+
const childPath = resolveExtendsPath(ext, fromDir);
|
|
50
|
+
if (childPath === null)
|
|
51
|
+
continue;
|
|
52
|
+
if (walk(childPath, visit, jsonCache, visited) === 'stop')
|
|
53
|
+
return 'stop';
|
|
54
|
+
}
|
|
55
|
+
return 'continue';
|
|
56
|
+
}
|
|
57
|
+
function readCachedJson(absolutePath, cache) {
|
|
58
|
+
if (cache.has(absolutePath)) {
|
|
59
|
+
return cache.get(absolutePath) ?? null;
|
|
60
|
+
}
|
|
61
|
+
let parsed;
|
|
62
|
+
try {
|
|
63
|
+
parsed = (0, devkit_1.readJsonFile)(absolutePath);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
parsed = null;
|
|
67
|
+
}
|
|
68
|
+
cache.set(absolutePath, parsed);
|
|
69
|
+
return parsed;
|
|
70
|
+
}
|
|
71
|
+
function resolveExtendsPath(extendsValue, fromDir) {
|
|
72
|
+
try {
|
|
73
|
+
return require.resolve(extendsValue, { paths: [fromDir] });
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|