@nx/js 19.4.2 → 19.4.3
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": "19.4.
|
|
3
|
+
"version": "19.4.3",
|
|
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": {
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"semver": "^7.5.3",
|
|
59
59
|
"source-map-support": "0.5.19",
|
|
60
60
|
"tslib": "^2.3.0",
|
|
61
|
-
"@nx/devkit": "19.4.
|
|
62
|
-
"@nx/workspace": "19.4.
|
|
63
|
-
"@nrwl/js": "19.4.
|
|
61
|
+
"@nx/devkit": "19.4.3",
|
|
62
|
+
"@nx/workspace": "19.4.3",
|
|
63
|
+
"@nrwl/js": "19.4.3"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"verdaccio": "^5.0.4"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CreateDependencies, type CreateNodes } from '@nx/devkit';
|
|
1
|
+
import { type CreateDependencies, type CreateNodes, type CreateNodesV2 } from '@nx/devkit';
|
|
2
2
|
export interface TscPluginOptions {
|
|
3
3
|
typecheck?: boolean | {
|
|
4
4
|
targetName?: string;
|
|
@@ -8,6 +8,10 @@ export interface TscPluginOptions {
|
|
|
8
8
|
configName?: string;
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
|
|
13
|
+
*/
|
|
11
14
|
export declare const createDependencies: CreateDependencies;
|
|
12
15
|
export declare const PLUGIN_NAME = "@nx/js/typescript";
|
|
16
|
+
export declare const createNodesV2: CreateNodesV2<TscPluginOptions>;
|
|
13
17
|
export declare const createNodes: CreateNodes<TscPluginOptions>;
|
|
@@ -1,65 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNodes = exports.PLUGIN_NAME = exports.createDependencies = void 0;
|
|
3
|
+
exports.createNodes = exports.createNodesV2 = exports.PLUGIN_NAME = exports.createDependencies = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
6
6
|
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
7
|
+
const minimatch_1 = require("minimatch");
|
|
7
8
|
const node_fs_1 = require("node:fs");
|
|
8
9
|
const node_path_1 = require("node:path");
|
|
9
|
-
const
|
|
10
|
+
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
10
11
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
11
12
|
const lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
|
|
12
13
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
13
14
|
const ts_config_1 = require("../../utils/typescript/ts-config");
|
|
14
|
-
|
|
15
|
-
const targetsCache = readTargetsCache();
|
|
16
|
-
function readTargetsCache() {
|
|
15
|
+
function readTargetsCache(cachePath) {
|
|
17
16
|
return (0, node_fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
|
|
18
17
|
}
|
|
19
|
-
function writeTargetsToCache() {
|
|
20
|
-
|
|
21
|
-
(0, devkit_1.writeJsonFile)(cachePath, {
|
|
22
|
-
...oldCache,
|
|
23
|
-
...targetsCache,
|
|
24
|
-
});
|
|
18
|
+
function writeTargetsToCache(cachePath, results) {
|
|
19
|
+
(0, devkit_1.writeJsonFile)(cachePath, results);
|
|
25
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
|
|
23
|
+
*/
|
|
26
24
|
const createDependencies = () => {
|
|
27
|
-
writeTargetsToCache();
|
|
28
25
|
return [];
|
|
29
26
|
};
|
|
30
27
|
exports.createDependencies = createDependencies;
|
|
31
28
|
exports.PLUGIN_NAME = '@nx/js/typescript';
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return {};
|
|
29
|
+
const tsConfigGlob = '**/tsconfig*.json';
|
|
30
|
+
exports.createNodesV2 = [
|
|
31
|
+
tsConfigGlob,
|
|
32
|
+
async (configFilePaths, options, context) => {
|
|
33
|
+
const optionsHash = (0, file_hasher_1.hashObject)(options);
|
|
34
|
+
const cachePath = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `tsc-${optionsHash}.hash`);
|
|
35
|
+
const targetsCache = readTargetsCache(cachePath);
|
|
36
|
+
const normalizedOptions = normalizePluginOptions(options);
|
|
37
|
+
try {
|
|
38
|
+
return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, targetsCache), configFilePaths, normalizedOptions, context);
|
|
43
39
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
!siblingFiles.includes('tsconfig.json')) {
|
|
47
|
-
return {};
|
|
40
|
+
finally {
|
|
41
|
+
writeTargetsToCache(cachePath, targetsCache);
|
|
48
42
|
}
|
|
49
|
-
const nodeHash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, pluginOptions, context, [(0, lock_file_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
|
|
50
|
-
// The hash is calculated at the node/project level, so we add the config file path to avoid conflicts when caching
|
|
51
|
-
const cacheKey = `${nodeHash}_${configFilePath}`;
|
|
52
|
-
targetsCache[cacheKey] ??= buildTscTargets(fullConfigPath, projectRoot, pluginOptions, context);
|
|
53
|
-
return {
|
|
54
|
-
projects: {
|
|
55
|
-
[projectRoot]: {
|
|
56
|
-
projectType: 'library',
|
|
57
|
-
targets: targetsCache[cacheKey],
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
43
|
},
|
|
62
44
|
];
|
|
45
|
+
exports.createNodes = [
|
|
46
|
+
tsConfigGlob,
|
|
47
|
+
async (configFilePath, options, context) => {
|
|
48
|
+
devkit_1.logger.warn('`createNodes` is deprecated. Update your plugin to utilize createNodesV2 instead. In Nx 20, this will change to the createNodesV2 API.');
|
|
49
|
+
const normalizedOptions = normalizePluginOptions(options);
|
|
50
|
+
return createNodesInternal(configFilePath, normalizedOptions, context, {});
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
async function createNodesInternal(configFilePath, options, context, targetsCache) {
|
|
54
|
+
const projectRoot = (0, node_path_1.dirname)(configFilePath);
|
|
55
|
+
const fullConfigPath = (0, devkit_1.joinPathFragments)(context.workspaceRoot, configFilePath);
|
|
56
|
+
// Do not create a project if package.json and project.json isn't there.
|
|
57
|
+
const siblingFiles = (0, node_fs_1.readdirSync)((0, node_path_1.join)(context.workspaceRoot, projectRoot));
|
|
58
|
+
if (!siblingFiles.includes('package.json') &&
|
|
59
|
+
!siblingFiles.includes('project.json')) {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
// Do not create a project if it's not a tsconfig.json and there is no tsconfig.json in the same directory
|
|
63
|
+
if ((0, node_path_1.basename)(configFilePath) !== 'tsconfig.json' &&
|
|
64
|
+
!siblingFiles.includes('tsconfig.json')) {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
const nodeHash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, lock_file_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
|
|
68
|
+
// The hash is calculated at the node/project level, so we add the config file path to avoid conflicts when caching
|
|
69
|
+
const cacheKey = `${nodeHash}_${configFilePath}`;
|
|
70
|
+
targetsCache[cacheKey] ??= buildTscTargets(fullConfigPath, projectRoot, options, context);
|
|
71
|
+
const { targets } = targetsCache[cacheKey];
|
|
72
|
+
return {
|
|
73
|
+
projects: {
|
|
74
|
+
[projectRoot]: {
|
|
75
|
+
projectType: 'library',
|
|
76
|
+
targets,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
63
81
|
function buildTscTargets(configFilePath, projectRoot, options, context) {
|
|
64
82
|
const targets = {};
|
|
65
83
|
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
@@ -105,7 +123,7 @@ function buildTscTargets(configFilePath, projectRoot, options, context) {
|
|
|
105
123
|
outputs: getOutputs(configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot),
|
|
106
124
|
};
|
|
107
125
|
}
|
|
108
|
-
return targets;
|
|
126
|
+
return { targets };
|
|
109
127
|
}
|
|
110
128
|
function getInputs(namedInputs, configFilePath, tsConfig, internalProjectReferences, workspaceRoot, projectRoot) {
|
|
111
129
|
const configFiles = new Set();
|
package/typescript.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createDependencies, createNodes, } from './src/plugins/typescript/plugin';
|
|
1
|
+
export { createDependencies, createNodes, createNodesV2, } from './src/plugins/typescript/plugin';
|
package/typescript.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNodes = exports.createDependencies = void 0;
|
|
3
|
+
exports.createNodesV2 = exports.createNodes = exports.createDependencies = void 0;
|
|
4
4
|
var plugin_1 = require("./src/plugins/typescript/plugin");
|
|
5
5
|
Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return plugin_1.createDependencies; } });
|
|
6
6
|
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
|
|
7
|
+
Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return plugin_1.createNodesV2; } });
|