@nx/js 22.6.0-beta.1 → 22.6.0-beta.11
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 +4 -4
- package/src/generators/library/library.d.ts.map +1 -1
- package/src/generators/library/library.js +0 -7
- package/src/plugins/typescript/plugin.d.ts +1 -0
- package/src/plugins/typescript/plugin.d.ts.map +1 -1
- package/src/plugins/typescript/plugin.js +130 -104
- package/src/utils/typescript/run-type-check.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "22.6.0-beta.
|
|
3
|
+
"version": "22.6.0-beta.11",
|
|
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": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@babel/preset-env": "^7.23.2",
|
|
40
40
|
"@babel/preset-typescript": "^7.22.5",
|
|
41
41
|
"@babel/runtime": "^7.22.6",
|
|
42
|
-
"@nx/devkit": "22.6.0-beta.
|
|
43
|
-
"@nx/workspace": "22.6.0-beta.
|
|
42
|
+
"@nx/devkit": "22.6.0-beta.11",
|
|
43
|
+
"@nx/workspace": "22.6.0-beta.11",
|
|
44
44
|
"@zkochan/js-yaml": "0.0.7",
|
|
45
45
|
"babel-plugin-const-enum": "^1.0.1",
|
|
46
46
|
"babel-plugin-macros": "^3.1.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"tslib": "^2.3.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"nx": "22.6.0-beta.
|
|
63
|
+
"nx": "22.6.0-beta.11"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"verdaccio": "^6.0.5"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAUjB,IAAI,EAKL,MAAM,YAAY,CAAC;AAyCpB,OAAO,KAAK,EAEV,sBAAsB,EACtB,iCAAiC,EAClC,MAAM,UAAU,CAAC;AASlB,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAO/B;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAUjB,IAAI,EAKL,MAAM,YAAY,CAAC;AAyCpB,OAAO,KAAK,EAEV,sBAAsB,EACtB,iCAAiC,EAClC,MAAM,UAAU,CAAC;AASlB,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAO/B;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAqK/B;AA2HD,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,iCAAiC,EAC/B,MAAM,GACN,QAAQ,GACR,aAAa,GACb,gBAAgB,GAChB,IAAI,GACJ,yBAAyB,GACzB,aAAa,GACb,SAAS,GACT,WAAW,GACX,yBAAyB,CAC5B,CAAC;AAEF,wBAAsB,OAAO,CAC3B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CA4G5B;AA6uBD,eAAe,gBAAgB,CAAC"}
|
|
@@ -99,7 +99,6 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
99
99
|
else if (options.unitTestRunner === 'vitest' &&
|
|
100
100
|
options.bundler !== 'vite' // Test would have been set up already
|
|
101
101
|
) {
|
|
102
|
-
const { createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
103
102
|
(0, devkit_1.ensurePackage)('@nx/vitest', versions_1.nxVersion);
|
|
104
103
|
// nx-ignore-next-line
|
|
105
104
|
const { configurationGenerator } = require('@nx/vitest/generators');
|
|
@@ -114,12 +113,6 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
114
113
|
addPlugin: options.addPlugin,
|
|
115
114
|
});
|
|
116
115
|
tasks.push(vitestTask);
|
|
117
|
-
createOrEditViteConfig(tree, {
|
|
118
|
-
project: options.name,
|
|
119
|
-
includeLib: false,
|
|
120
|
-
includeVitest: true,
|
|
121
|
-
testEnvironment: options.testEnvironment,
|
|
122
|
-
}, true);
|
|
123
116
|
}
|
|
124
117
|
if (!schema.skipTsConfig && !options.isUsingTsSolutionConfig) {
|
|
125
118
|
(0, ts_config_1.addTsConfigPath)(tree, options.importPath, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/plugins/typescript/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EAInB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/plugins/typescript/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EAInB,MAAM,YAAY,CAAC;AA+BpB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC1B,SAAS,CAAC,EACN,OAAO,GACP;QACE,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACN,KAAK,CAAC,EACF,OAAO,GACP;QACE,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;IACN,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AA2KD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAEF,eAAO,MAAM,WAAW,sBAAsB,CAAC;AAI/C,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,gBAAgB,CA0FzD,CAAC;AAEF,eAAO,MAAM,WAAW,iCAAgB,CAAC"}
|
|
@@ -5,7 +5,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
6
6
|
const node_fs_1 = require("node:fs");
|
|
7
7
|
const node_path_1 = require("node:path");
|
|
8
|
-
const posix = require("node:path/posix");
|
|
9
8
|
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
10
9
|
const picomatch = require("picomatch");
|
|
11
10
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
@@ -16,8 +15,11 @@ let ts;
|
|
|
16
15
|
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
|
17
16
|
const TSCONFIG_CACHE_VERSION = 1;
|
|
18
17
|
const TS_CONFIG_CACHE_PATH = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, 'tsconfig-files.hash');
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
// Module-level cache store — each invocation gets a unique Symbol key
|
|
19
|
+
const cacheStore = new Map();
|
|
20
|
+
// Shared tsconfig cache — initialized once per batch, persisted to disk
|
|
21
|
+
let tsConfigCacheData = {};
|
|
22
|
+
let tsConfigCacheInitialized = false;
|
|
21
23
|
function readFromCache(cachePath) {
|
|
22
24
|
try {
|
|
23
25
|
return process.env.NX_CACHE_PROJECT_GRAPH !== 'false'
|
|
@@ -64,14 +66,14 @@ function createConfigContext(configFilePath, workspaceRoot, projectContext) {
|
|
|
64
66
|
return {
|
|
65
67
|
originalPath: configFilePath,
|
|
66
68
|
absolutePath,
|
|
67
|
-
relativePath:
|
|
69
|
+
relativePath: posixRelative(workspaceRoot, absolutePath),
|
|
68
70
|
basename: (0, node_path_1.basename)(configFilePath),
|
|
69
71
|
basenameNoExt: (0, node_path_1.basename)(configFilePath, '.json'),
|
|
70
72
|
dirname: (0, node_path_1.dirname)(absolutePath),
|
|
71
73
|
project: projectContext,
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
|
-
function getConfigContext(configPath, workspaceRoot) {
|
|
76
|
+
function getConfigContext(configPath, workspaceRoot, cache) {
|
|
75
77
|
const absolutePath = configPath.startsWith('/') || configPath.startsWith(workspaceRoot)
|
|
76
78
|
? (0, node_path_1.normalize)(configPath)
|
|
77
79
|
: (0, node_path_1.join)(workspaceRoot, configPath);
|
|
@@ -84,7 +86,7 @@ function getConfigContext(configPath, workspaceRoot) {
|
|
|
84
86
|
if (!cache.projectContexts.has(projectRoot)) {
|
|
85
87
|
cache.projectContexts.set(projectRoot, {
|
|
86
88
|
root: projectRoot,
|
|
87
|
-
normalized:
|
|
89
|
+
normalized: (0, devkit_1.normalizePath)(projectRoot),
|
|
88
90
|
absolute: (0, node_path_1.join)(workspaceRoot, projectRoot),
|
|
89
91
|
});
|
|
90
92
|
}
|
|
@@ -107,7 +109,9 @@ exports.createNodesV2 = [
|
|
|
107
109
|
const optionsHash = (0, file_hasher_1.hashObject)(options);
|
|
108
110
|
const targetsCachePath = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `tsc-${optionsHash}.hash`);
|
|
109
111
|
const targetsCache = readFromCache(targetsCachePath);
|
|
110
|
-
|
|
112
|
+
// Each invocation gets a unique Symbol key — guaranteed no collisions
|
|
113
|
+
const cacheKey = Symbol('tsc-invocation');
|
|
114
|
+
cacheStore.set(cacheKey, {
|
|
111
115
|
fileHashes: {},
|
|
112
116
|
rawFiles: {},
|
|
113
117
|
picomatchMatchers: {},
|
|
@@ -115,19 +119,20 @@ exports.createNodesV2 = [
|
|
|
115
119
|
configOwners: new Map(),
|
|
116
120
|
projectContexts: new Map(),
|
|
117
121
|
configContexts: new Map(),
|
|
118
|
-
};
|
|
119
|
-
|
|
122
|
+
});
|
|
123
|
+
const cache = cacheStore.get(cacheKey);
|
|
124
|
+
initializeTsConfigCache(configFilePaths, context.workspaceRoot, cache);
|
|
120
125
|
const normalizedOptions = normalizePluginOptions(options);
|
|
121
|
-
const { configFilePaths: validConfigFilePaths, hashes, projectRoots, } = await resolveValidConfigFilesAndHashes(configFilePaths, normalizedOptions, optionsHash, context);
|
|
126
|
+
const { configFilePaths: validConfigFilePaths, hashes, projectRoots, } = await resolveValidConfigFilesAndHashes(configFilePaths, normalizedOptions, optionsHash, context, cache);
|
|
122
127
|
try {
|
|
123
128
|
return await (0, devkit_1.createNodesFromFiles)((configFilePath, options, context, idx) => {
|
|
124
129
|
const projectRoot = projectRoots[idx];
|
|
125
130
|
const hash = hashes[idx];
|
|
126
|
-
const
|
|
131
|
+
const targetsCacheKey = `${hash}_${configFilePath}`;
|
|
127
132
|
const absolutePath = (0, node_path_1.join)(context.workspaceRoot, configFilePath);
|
|
128
|
-
const configContext = getConfigContext(absolutePath, context.workspaceRoot);
|
|
129
|
-
targetsCache[
|
|
130
|
-
const { targets } = targetsCache[
|
|
133
|
+
const configContext = getConfigContext(absolutePath, context.workspaceRoot, cache);
|
|
134
|
+
targetsCache[targetsCacheKey] ??= buildTscTargets(configContext, options, context, validConfigFilePaths, cache);
|
|
135
|
+
const { targets } = targetsCache[targetsCacheKey];
|
|
131
136
|
return {
|
|
132
137
|
projects: {
|
|
133
138
|
[projectRoot]: {
|
|
@@ -140,13 +145,18 @@ exports.createNodesV2 = [
|
|
|
140
145
|
finally {
|
|
141
146
|
writeToCache(targetsCachePath, targetsCache);
|
|
142
147
|
writeTsConfigCache(toRelativePaths(tsConfigCacheData, context.workspaceRoot));
|
|
143
|
-
//
|
|
144
|
-
|
|
148
|
+
// Delete this invocation's cache — unique Symbol means no cross-invocation impact
|
|
149
|
+
cacheStore.delete(cacheKey);
|
|
150
|
+
// Reset shared tsconfig cache when all invocations are done
|
|
151
|
+
if (cacheStore.size === 0) {
|
|
152
|
+
tsConfigCacheData = {};
|
|
153
|
+
tsConfigCacheInitialized = false;
|
|
154
|
+
}
|
|
145
155
|
}
|
|
146
156
|
},
|
|
147
157
|
];
|
|
148
158
|
exports.createNodes = exports.createNodesV2;
|
|
149
|
-
async function resolveValidConfigFilesAndHashes(configFilePaths, options, optionsHash, context) {
|
|
159
|
+
async function resolveValidConfigFilesAndHashes(configFilePaths, options, optionsHash, context, cache) {
|
|
150
160
|
const lockFileHash = (0, file_hasher_1.hashFile)((0, node_path_1.join)(context.workspaceRoot, (0, lock_file_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)))) ?? '';
|
|
151
161
|
const validConfigFilePaths = [];
|
|
152
162
|
const hashes = [];
|
|
@@ -154,19 +164,20 @@ async function resolveValidConfigFilesAndHashes(configFilePaths, options, option
|
|
|
154
164
|
for await (const configFilePath of configFilePaths) {
|
|
155
165
|
const projectRoot = (0, node_path_1.dirname)(configFilePath);
|
|
156
166
|
const absolutePath = (0, node_path_1.join)(context.workspaceRoot, configFilePath);
|
|
157
|
-
const configContext = getConfigContext(absolutePath, context.workspaceRoot);
|
|
167
|
+
const configContext = getConfigContext(absolutePath, context.workspaceRoot, cache);
|
|
158
168
|
// Skip configs that can't produce any targets based on plugin options
|
|
159
|
-
const isTypecheckConfig = configContext.basename ===
|
|
169
|
+
const isTypecheckConfig = configContext.basename ===
|
|
170
|
+
(options.typecheck ? options.typecheck.configName : 'tsconfig.json');
|
|
160
171
|
const isBuildConfig = options.build && configContext.basename === options.build.configName;
|
|
161
172
|
if (!isTypecheckConfig && !isBuildConfig) {
|
|
162
173
|
continue;
|
|
163
174
|
}
|
|
164
|
-
if (!checkIfConfigFileShouldBeProject(configContext)) {
|
|
175
|
+
if (!checkIfConfigFileShouldBeProject(configContext, cache)) {
|
|
165
176
|
continue;
|
|
166
177
|
}
|
|
167
178
|
projectRoots.push(projectRoot);
|
|
168
179
|
validConfigFilePaths.push(configFilePath);
|
|
169
|
-
hashes.push(await getConfigFileHash(configFilePath, context.workspaceRoot, configContext.project, optionsHash, lockFileHash));
|
|
180
|
+
hashes.push(await getConfigFileHash(configFilePath, context.workspaceRoot, configContext.project, optionsHash, lockFileHash, cache));
|
|
170
181
|
}
|
|
171
182
|
return { configFilePaths: validConfigFilePaths, hashes, projectRoots };
|
|
172
183
|
}
|
|
@@ -182,12 +193,12 @@ async function resolveValidConfigFilesAndHashes(configFilePaths, options, option
|
|
|
182
193
|
* - hash of the plugin options
|
|
183
194
|
* - current config file path
|
|
184
195
|
*/
|
|
185
|
-
async function getConfigFileHash(configFilePath, workspaceRoot, project, optionsHash, lockFileHash) {
|
|
196
|
+
async function getConfigFileHash(configFilePath, workspaceRoot, project, optionsHash, lockFileHash, cache) {
|
|
186
197
|
const fullConfigPath = (0, node_path_1.join)(workspaceRoot, configFilePath);
|
|
187
|
-
const tsConfig = retrieveTsConfigFromCache(fullConfigPath, workspaceRoot);
|
|
188
|
-
const extendedConfigFiles = getExtendedConfigFiles(tsConfig, workspaceRoot);
|
|
189
|
-
const internalReferencedFiles = resolveInternalProjectReferences(tsConfig, workspaceRoot, project);
|
|
190
|
-
const externalProjectReferences = resolveShallowExternalProjectReferences(tsConfig, workspaceRoot, project);
|
|
198
|
+
const tsConfig = retrieveTsConfigFromCache(fullConfigPath, workspaceRoot, cache);
|
|
199
|
+
const extendedConfigFiles = getExtendedConfigFiles(tsConfig, workspaceRoot, cache);
|
|
200
|
+
const internalReferencedFiles = resolveInternalProjectReferences(tsConfig, workspaceRoot, project, cache);
|
|
201
|
+
const externalProjectReferences = resolveShallowExternalProjectReferences(tsConfig, workspaceRoot, project, cache);
|
|
191
202
|
let packageJson = null;
|
|
192
203
|
try {
|
|
193
204
|
packageJson = (0, devkit_1.readJsonFile)((0, node_path_1.join)(workspaceRoot, project.root, 'package.json'));
|
|
@@ -199,14 +210,14 @@ async function getConfigFileHash(configFilePath, workspaceRoot, project, options
|
|
|
199
210
|
...extendedConfigFiles.files.sort(),
|
|
200
211
|
...Object.keys(internalReferencedFiles).sort(),
|
|
201
212
|
...Object.keys(externalProjectReferences).sort(),
|
|
202
|
-
].map((file) => getFileHash(file, workspaceRoot)),
|
|
213
|
+
].map((file) => getFileHash(file, workspaceRoot, cache)),
|
|
203
214
|
...extendedConfigFiles.packages.sort(),
|
|
204
215
|
lockFileHash,
|
|
205
216
|
optionsHash,
|
|
206
217
|
...(packageJson ? [(0, file_hasher_1.hashObject)(packageJson)] : []),
|
|
207
218
|
]);
|
|
208
219
|
}
|
|
209
|
-
function checkIfConfigFileShouldBeProject(config) {
|
|
220
|
+
function checkIfConfigFileShouldBeProject(config, cache) {
|
|
210
221
|
// Do not create a project for the workspace root tsconfig files.
|
|
211
222
|
if (config.project.root === '.') {
|
|
212
223
|
return false;
|
|
@@ -233,16 +244,16 @@ function checkIfConfigFileShouldBeProject(config) {
|
|
|
233
244
|
}
|
|
234
245
|
return true;
|
|
235
246
|
}
|
|
236
|
-
function buildTscTargets(config, options, context, configFiles) {
|
|
247
|
+
function buildTscTargets(config, options, context, configFiles, cache) {
|
|
237
248
|
const targets = {};
|
|
238
249
|
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(config.project.root, context);
|
|
239
|
-
const tsConfig = retrieveTsConfigFromCache(config.absolutePath, context.workspaceRoot);
|
|
250
|
+
const tsConfig = retrieveTsConfigFromCache(config.absolutePath, context.workspaceRoot, cache);
|
|
240
251
|
let internalProjectReferences;
|
|
241
|
-
if (
|
|
242
|
-
options.typecheck &&
|
|
252
|
+
if (options.typecheck &&
|
|
253
|
+
config.basename === options.typecheck.configName &&
|
|
243
254
|
tsConfig.raw?.['nx']?.addTypecheckTarget !== false) {
|
|
244
|
-
internalProjectReferences = resolveInternalProjectReferences(tsConfig, context.workspaceRoot, config.project);
|
|
245
|
-
const externalProjectReferences = resolveShallowExternalProjectReferences(tsConfig, context.workspaceRoot, config.project);
|
|
255
|
+
internalProjectReferences = resolveInternalProjectReferences(tsConfig, context.workspaceRoot, config.project, cache);
|
|
256
|
+
const externalProjectReferences = resolveShallowExternalProjectReferences(tsConfig, context.workspaceRoot, config.project, cache);
|
|
246
257
|
const targetName = options.typecheck.targetName;
|
|
247
258
|
const compiler = options.compiler;
|
|
248
259
|
if (!targets[targetName]) {
|
|
@@ -263,7 +274,7 @@ function buildTscTargets(config, options, context, configFiles) {
|
|
|
263
274
|
const buildConfigPath = (0, devkit_1.joinPathFragments)(config.project.root, options.build.configName);
|
|
264
275
|
if (configFiles.some((f) => f === buildConfigPath) &&
|
|
265
276
|
(options.build.skipBuildCheck ||
|
|
266
|
-
(0, util_1.isValidPackageJsonBuildConfig)(retrieveTsConfigFromCache(buildConfigPath, context.workspaceRoot), context.workspaceRoot, config.project.root))) {
|
|
277
|
+
(0, util_1.isValidPackageJsonBuildConfig)(retrieveTsConfigFromCache(buildConfigPath, context.workspaceRoot, cache), context.workspaceRoot, config.project.root))) {
|
|
267
278
|
dependsOn.unshift(options.build.targetName);
|
|
268
279
|
}
|
|
269
280
|
}
|
|
@@ -272,7 +283,7 @@ function buildTscTargets(config, options, context, configFiles) {
|
|
|
272
283
|
command,
|
|
273
284
|
options: { cwd: config.project.root },
|
|
274
285
|
cache: true,
|
|
275
|
-
inputs: getInputs(namedInputs, config, tsConfig, internalProjectReferences, context.workspaceRoot),
|
|
286
|
+
inputs: getInputs(namedInputs, config, tsConfig, internalProjectReferences, context.workspaceRoot, cache),
|
|
276
287
|
outputs: getOutputs(config, tsConfig, internalProjectReferences, context.workspaceRoot,
|
|
277
288
|
/* emitDeclarationOnly */ true),
|
|
278
289
|
syncGenerators: ['@nx/js:typescript-sync'],
|
|
@@ -294,7 +305,7 @@ function buildTscTargets(config, options, context, configFiles) {
|
|
|
294
305
|
config.basename === options.build.configName &&
|
|
295
306
|
(options.build.skipBuildCheck ||
|
|
296
307
|
(0, util_1.isValidPackageJsonBuildConfig)(tsConfig, context.workspaceRoot, config.project.root))) {
|
|
297
|
-
internalProjectReferences ??= resolveInternalProjectReferences(tsConfig, context.workspaceRoot, config.project);
|
|
308
|
+
internalProjectReferences ??= resolveInternalProjectReferences(tsConfig, context.workspaceRoot, config.project, cache);
|
|
298
309
|
const targetName = options.build.targetName;
|
|
299
310
|
const compiler = options.compiler;
|
|
300
311
|
targets[targetName] = {
|
|
@@ -302,7 +313,7 @@ function buildTscTargets(config, options, context, configFiles) {
|
|
|
302
313
|
command: `${compiler} --build ${options.build.configName}${options.verboseOutput ? ' --verbose' : ''}`,
|
|
303
314
|
options: { cwd: config.project.root },
|
|
304
315
|
cache: true,
|
|
305
|
-
inputs: getInputs(namedInputs, config, tsConfig, internalProjectReferences, context.workspaceRoot),
|
|
316
|
+
inputs: getInputs(namedInputs, config, tsConfig, internalProjectReferences, context.workspaceRoot, cache),
|
|
306
317
|
outputs: getOutputs(config, tsConfig, internalProjectReferences, context.workspaceRoot,
|
|
307
318
|
// should be false for build target, but providing it just in case is set to true
|
|
308
319
|
tsConfig.options.emitDeclarationOnly),
|
|
@@ -325,12 +336,12 @@ function buildTscTargets(config, options, context, configFiles) {
|
|
|
325
336
|
}
|
|
326
337
|
return { targets };
|
|
327
338
|
}
|
|
328
|
-
function getInputs(namedInputs, config, tsConfig, internalProjectReferences, workspaceRoot) {
|
|
339
|
+
function getInputs(namedInputs, config, tsConfig, internalProjectReferences, workspaceRoot, cache) {
|
|
329
340
|
const configFiles = new Set();
|
|
330
341
|
// TODO(leo): temporary disable external dependencies until we support hashing
|
|
331
342
|
// glob patterns from external dependencies
|
|
332
343
|
// const externalDependencies = ['typescript'];
|
|
333
|
-
const extendedConfigFiles = getExtendedConfigFiles(tsConfig, workspaceRoot);
|
|
344
|
+
const extendedConfigFiles = getExtendedConfigFiles(tsConfig, workspaceRoot, cache);
|
|
334
345
|
extendedConfigFiles.files.forEach((configPath) => {
|
|
335
346
|
configFiles.add(configPath);
|
|
336
347
|
});
|
|
@@ -445,10 +456,12 @@ function getInputs(namedInputs, config, tsConfig, internalProjectReferences, wor
|
|
|
445
456
|
if (excludePaths.size) {
|
|
446
457
|
inputs.push(...Array.from(excludePaths).map((p) => `!${pathToInputOrOutput((0, devkit_1.joinPathFragments)(config.project.root, p), workspaceRoot, config.project)}`));
|
|
447
458
|
}
|
|
448
|
-
if (hasExternalProjectReferences(config.originalPath, tsConfig, workspaceRoot, config.project)) {
|
|
449
|
-
//
|
|
459
|
+
if (hasExternalProjectReferences(config.originalPath, tsConfig, workspaceRoot, config.project, cache)) {
|
|
460
|
+
// tsc --build reads .d.ts and .tsbuildinfo files from referenced projects
|
|
450
461
|
// https://www.typescriptlang.org/docs/handbook/project-references.html#what-is-a-project-reference
|
|
451
|
-
inputs.push({
|
|
462
|
+
inputs.push({
|
|
463
|
+
dependentTasksOutputFiles: '**/*.{d.ts,tsbuildinfo}',
|
|
464
|
+
});
|
|
452
465
|
}
|
|
453
466
|
else {
|
|
454
467
|
inputs.push('production' in namedInputs ? '^production' : '^default');
|
|
@@ -456,17 +469,23 @@ function getInputs(namedInputs, config, tsConfig, internalProjectReferences, wor
|
|
|
456
469
|
// inputs.push({ externalDependencies });
|
|
457
470
|
return inputs;
|
|
458
471
|
}
|
|
459
|
-
function getOutputs(config,
|
|
472
|
+
function getOutputs(config, rootTsConfig, internalProjectReferences, workspaceRoot, emitDeclarationOnly) {
|
|
460
473
|
const outputs = new Set();
|
|
461
474
|
// We could have more surgical outputs based on the tsconfig options, but the
|
|
462
475
|
// user could override them through the command line and that wouldn't be
|
|
463
476
|
// reflected in the outputs. So, we just include everything that could be
|
|
464
477
|
// produced by the tsc command.
|
|
465
|
-
[
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
478
|
+
[
|
|
479
|
+
{ configBaseNameNoExt: config.basenameNoExt, tsConfig: rootTsConfig },
|
|
480
|
+
...Object.entries(internalProjectReferences).map(([internalConfigPath, internalConfig]) => ({
|
|
481
|
+
configBaseNameNoExt: (0, node_path_1.basename)(internalConfigPath, '.json'),
|
|
482
|
+
tsConfig: internalConfig,
|
|
483
|
+
})),
|
|
484
|
+
].forEach(({ configBaseNameNoExt, tsConfig }) => {
|
|
485
|
+
if (tsConfig.options.outFile) {
|
|
486
|
+
const outFileName = (0, node_path_1.basename)(tsConfig.options.outFile, '.js');
|
|
487
|
+
const outFileDir = (0, node_path_1.dirname)(tsConfig.options.outFile);
|
|
488
|
+
outputs.add(pathToInputOrOutput(tsConfig.options.outFile, workspaceRoot, config.project));
|
|
470
489
|
// outFile is not be used with .cjs, .mjs, .jsx, so the list is simpler
|
|
471
490
|
const outDir = (0, node_path_1.relative)(workspaceRoot, outFileDir);
|
|
472
491
|
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(outDir, `${outFileName}.js.map`), workspaceRoot, config.project));
|
|
@@ -477,38 +496,36 @@ function getOutputs(config, tsConfig, internalProjectReferences, workspaceRoot,
|
|
|
477
496
|
? pathToInputOrOutput(tsConfig.options.tsBuildInfoFile, workspaceRoot, config.project)
|
|
478
497
|
: pathToInputOrOutput((0, devkit_1.joinPathFragments)(outDir, `${outFileName}.tsbuildinfo`), workspaceRoot, config.project));
|
|
479
498
|
}
|
|
480
|
-
else if (
|
|
499
|
+
else if (tsConfig.options.outDir) {
|
|
481
500
|
if (emitDeclarationOnly) {
|
|
482
|
-
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(
|
|
501
|
+
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, '**/*.d.ts'), workspaceRoot, config.project));
|
|
483
502
|
if (tsConfig.options.declarationMap) {
|
|
484
|
-
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(
|
|
503
|
+
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, '**/*.d.ts.map'), workspaceRoot, config.project));
|
|
485
504
|
}
|
|
486
505
|
}
|
|
487
506
|
else {
|
|
488
|
-
outputs.add(pathToInputOrOutput(
|
|
507
|
+
outputs.add(pathToInputOrOutput(tsConfig.options.outDir, workspaceRoot, config.project));
|
|
489
508
|
}
|
|
490
|
-
if (
|
|
509
|
+
if (tsConfig.options.tsBuildInfoFile) {
|
|
491
510
|
if (emitDeclarationOnly ||
|
|
492
|
-
!(0, node_path_1.normalize)(
|
|
511
|
+
!(0, node_path_1.normalize)(tsConfig.options.tsBuildInfoFile).startsWith(`${(0, node_path_1.normalize)(tsConfig.options.outDir)}${node_path_1.sep}`)) {
|
|
493
512
|
// https://www.typescriptlang.org/tsconfig#tsBuildInfoFile
|
|
494
|
-
outputs.add(pathToInputOrOutput(
|
|
513
|
+
outputs.add(pathToInputOrOutput(tsConfig.options.tsBuildInfoFile, workspaceRoot, config.project));
|
|
495
514
|
}
|
|
496
515
|
}
|
|
497
|
-
else if (
|
|
498
|
-
tsconfig.options.rootDir !== '.') {
|
|
516
|
+
else if (tsConfig.options.rootDir && tsConfig.options.rootDir !== '.') {
|
|
499
517
|
// If rootDir is set, then the tsbuildinfo file will be outside the outDir so we need to add it.
|
|
500
|
-
const relativeRootDir = (0, node_path_1.relative)(
|
|
501
|
-
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(
|
|
518
|
+
const relativeRootDir = (0, node_path_1.relative)(tsConfig.options.rootDir, (0, node_path_1.join)(workspaceRoot, config.project.root));
|
|
519
|
+
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, relativeRootDir, `*.tsbuildinfo`), workspaceRoot, config.project));
|
|
502
520
|
}
|
|
503
521
|
else if (emitDeclarationOnly) {
|
|
504
522
|
// https://www.typescriptlang.org/tsconfig#tsBuildInfoFile
|
|
505
|
-
|
|
506
|
-
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsconfig.options.outDir, `${name}.tsbuildinfo`), workspaceRoot, config.project));
|
|
523
|
+
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, `${configBaseNameNoExt}.tsbuildinfo`), workspaceRoot, config.project));
|
|
507
524
|
}
|
|
508
525
|
}
|
|
509
|
-
else if (
|
|
510
|
-
|
|
511
|
-
(!
|
|
526
|
+
else if (tsConfig.raw?.include?.length ||
|
|
527
|
+
tsConfig.raw?.files?.length ||
|
|
528
|
+
(!tsConfig.raw?.include && !tsConfig.raw?.files)) {
|
|
512
529
|
// tsc produce files in place when no outDir or outFile is set
|
|
513
530
|
outputs.add((0, devkit_1.joinPathFragments)('{projectRoot}', '**/*.js'));
|
|
514
531
|
outputs.add((0, devkit_1.joinPathFragments)('{projectRoot}', '**/*.cjs'));
|
|
@@ -523,10 +540,9 @@ function getOutputs(config, tsConfig, internalProjectReferences, workspaceRoot,
|
|
|
523
540
|
outputs.add((0, devkit_1.joinPathFragments)('{projectRoot}', '**/*.d.cts.map'));
|
|
524
541
|
outputs.add((0, devkit_1.joinPathFragments)('{projectRoot}', '**/*.d.mts.map'));
|
|
525
542
|
// https://www.typescriptlang.org/tsconfig#tsBuildInfoFile
|
|
526
|
-
const name = config.basenameNoExt;
|
|
527
543
|
outputs.add(tsConfig.options.tsBuildInfoFile
|
|
528
544
|
? pathToInputOrOutput(tsConfig.options.tsBuildInfoFile, workspaceRoot, config.project)
|
|
529
|
-
: (0, devkit_1.joinPathFragments)('{projectRoot}', `${
|
|
545
|
+
: (0, devkit_1.joinPathFragments)('{projectRoot}', `${configBaseNameNoExt}.tsbuildinfo`));
|
|
530
546
|
}
|
|
531
547
|
});
|
|
532
548
|
return Array.from(outputs);
|
|
@@ -540,14 +556,14 @@ function pathToInputOrOutput(path, workspaceRoot, project) {
|
|
|
540
556
|
}
|
|
541
557
|
return (0, devkit_1.joinPathFragments)('{projectRoot}', pathRelativeToProjectRoot);
|
|
542
558
|
}
|
|
543
|
-
function getExtendedConfigFiles(tsConfig, workspaceRoot, extendedConfigFiles = new Set(), extendedExternalPackages = new Set()) {
|
|
559
|
+
function getExtendedConfigFiles(tsConfig, workspaceRoot, cache, extendedConfigFiles = new Set(), extendedExternalPackages = new Set()) {
|
|
544
560
|
for (const extendedConfigFile of tsConfig.extendedConfigFiles) {
|
|
545
561
|
if (extendedConfigFile.externalPackage) {
|
|
546
562
|
extendedExternalPackages.add(extendedConfigFile.externalPackage);
|
|
547
563
|
}
|
|
548
564
|
else if (extendedConfigFile.filePath) {
|
|
549
565
|
extendedConfigFiles.add(extendedConfigFile.filePath);
|
|
550
|
-
getExtendedConfigFiles(retrieveTsConfigFromCache(extendedConfigFile.filePath, workspaceRoot), workspaceRoot, extendedConfigFiles, extendedExternalPackages);
|
|
566
|
+
getExtendedConfigFiles(retrieveTsConfigFromCache(extendedConfigFile.filePath, workspaceRoot, cache), workspaceRoot, cache, extendedConfigFiles, extendedExternalPackages);
|
|
551
567
|
}
|
|
552
568
|
}
|
|
553
569
|
return {
|
|
@@ -555,7 +571,7 @@ function getExtendedConfigFiles(tsConfig, workspaceRoot, extendedConfigFiles = n
|
|
|
555
571
|
packages: Array.from(extendedExternalPackages),
|
|
556
572
|
};
|
|
557
573
|
}
|
|
558
|
-
function resolveInternalProjectReferences(tsConfig, workspaceRoot, project, projectReferences = {}) {
|
|
574
|
+
function resolveInternalProjectReferences(tsConfig, workspaceRoot, project, cache, projectReferences = {}) {
|
|
559
575
|
if (!tsConfig.projectReferences?.length) {
|
|
560
576
|
return {};
|
|
561
577
|
}
|
|
@@ -570,16 +586,16 @@ function resolveInternalProjectReferences(tsConfig, workspaceRoot, project, proj
|
|
|
570
586
|
if (!refConfigPath.endsWith('.json')) {
|
|
571
587
|
refConfigPath = (0, node_path_1.join)(refConfigPath, 'tsconfig.json');
|
|
572
588
|
}
|
|
573
|
-
const refContext = getConfigContext(refConfigPath, workspaceRoot);
|
|
574
|
-
if (isExternalProjectReference(refContext, project, workspaceRoot)) {
|
|
589
|
+
const refContext = getConfigContext(refConfigPath, workspaceRoot, cache);
|
|
590
|
+
if (isExternalProjectReference(refContext, project, workspaceRoot, cache)) {
|
|
575
591
|
continue;
|
|
576
592
|
}
|
|
577
|
-
projectReferences[refConfigPath] = retrieveTsConfigFromCache(refConfigPath, workspaceRoot);
|
|
578
|
-
resolveInternalProjectReferences(projectReferences[refConfigPath], workspaceRoot, project, projectReferences);
|
|
593
|
+
projectReferences[refConfigPath] = retrieveTsConfigFromCache(refConfigPath, workspaceRoot, cache);
|
|
594
|
+
resolveInternalProjectReferences(projectReferences[refConfigPath], workspaceRoot, project, cache, projectReferences);
|
|
579
595
|
}
|
|
580
596
|
return projectReferences;
|
|
581
597
|
}
|
|
582
|
-
function resolveShallowExternalProjectReferences(tsConfig, workspaceRoot, project, projectReferences = {}) {
|
|
598
|
+
function resolveShallowExternalProjectReferences(tsConfig, workspaceRoot, project, cache, projectReferences = {}) {
|
|
583
599
|
if (!tsConfig.projectReferences?.length) {
|
|
584
600
|
return projectReferences;
|
|
585
601
|
}
|
|
@@ -594,14 +610,14 @@ function resolveShallowExternalProjectReferences(tsConfig, workspaceRoot, projec
|
|
|
594
610
|
if (!refConfigPath.endsWith('.json')) {
|
|
595
611
|
refConfigPath = (0, node_path_1.join)(refConfigPath, 'tsconfig.json');
|
|
596
612
|
}
|
|
597
|
-
const refContext = getConfigContext(refConfigPath, workspaceRoot);
|
|
598
|
-
if (isExternalProjectReference(refContext, project, workspaceRoot)) {
|
|
599
|
-
projectReferences[refConfigPath] = retrieveTsConfigFromCache(refConfigPath, workspaceRoot);
|
|
613
|
+
const refContext = getConfigContext(refConfigPath, workspaceRoot, cache);
|
|
614
|
+
if (isExternalProjectReference(refContext, project, workspaceRoot, cache)) {
|
|
615
|
+
projectReferences[refConfigPath] = retrieveTsConfigFromCache(refConfigPath, workspaceRoot, cache);
|
|
600
616
|
}
|
|
601
617
|
}
|
|
602
618
|
return projectReferences;
|
|
603
619
|
}
|
|
604
|
-
function hasExternalProjectReferences(tsConfigPath, tsConfig, workspaceRoot, project, seen = new Set()) {
|
|
620
|
+
function hasExternalProjectReferences(tsConfigPath, tsConfig, workspaceRoot, project, cache, seen = new Set()) {
|
|
605
621
|
if (!tsConfig.projectReferences?.length) {
|
|
606
622
|
return false;
|
|
607
623
|
}
|
|
@@ -617,19 +633,19 @@ function hasExternalProjectReferences(tsConfigPath, tsConfig, workspaceRoot, pro
|
|
|
617
633
|
if (!refConfigPath.endsWith('.json')) {
|
|
618
634
|
refConfigPath = (0, node_path_1.join)(refConfigPath, 'tsconfig.json');
|
|
619
635
|
}
|
|
620
|
-
const refContext = getConfigContext(refConfigPath, workspaceRoot);
|
|
621
|
-
if (isExternalProjectReference(refContext, project, workspaceRoot)) {
|
|
636
|
+
const refContext = getConfigContext(refConfigPath, workspaceRoot, cache);
|
|
637
|
+
if (isExternalProjectReference(refContext, project, workspaceRoot, cache)) {
|
|
622
638
|
return true;
|
|
623
639
|
}
|
|
624
|
-
const refTsConfig = retrieveTsConfigFromCache(refConfigPath, workspaceRoot);
|
|
625
|
-
const result = hasExternalProjectReferences(refConfigPath, refTsConfig, workspaceRoot, project, seen);
|
|
640
|
+
const refTsConfig = retrieveTsConfigFromCache(refConfigPath, workspaceRoot, cache);
|
|
641
|
+
const result = hasExternalProjectReferences(refConfigPath, refTsConfig, workspaceRoot, project, cache, seen);
|
|
626
642
|
if (result) {
|
|
627
643
|
return true;
|
|
628
644
|
}
|
|
629
645
|
}
|
|
630
646
|
return false;
|
|
631
647
|
}
|
|
632
|
-
function isExternalProjectReference(refConfig, project, workspaceRoot) {
|
|
648
|
+
function isExternalProjectReference(refConfig, project, workspaceRoot, cache) {
|
|
633
649
|
const owner = cache.configOwners.get(refConfig.relativePath);
|
|
634
650
|
if (owner !== undefined) {
|
|
635
651
|
return owner !== project.normalized;
|
|
@@ -649,34 +665,37 @@ function isExternalProjectReference(refConfig, project, workspaceRoot) {
|
|
|
649
665
|
}
|
|
650
666
|
return false;
|
|
651
667
|
}
|
|
652
|
-
function retrieveTsConfigFromCache(tsConfigPath, workspaceRoot) {
|
|
668
|
+
function retrieveTsConfigFromCache(tsConfigPath, workspaceRoot, cache) {
|
|
653
669
|
const relativePath = posixRelative(workspaceRoot, tsConfigPath);
|
|
654
670
|
// we don't need to check the hash if it's in the cache, because we've already
|
|
655
671
|
// checked it when we initially populated the cache
|
|
656
672
|
return tsConfigCacheData[relativePath]
|
|
657
673
|
? tsConfigCacheData[relativePath].data
|
|
658
|
-
: readTsConfigAndCache(tsConfigPath, workspaceRoot);
|
|
674
|
+
: readTsConfigAndCache(tsConfigPath, workspaceRoot, cache);
|
|
659
675
|
}
|
|
660
|
-
function initializeTsConfigCache(configFilePaths, workspaceRoot) {
|
|
661
|
-
|
|
676
|
+
function initializeTsConfigCache(configFilePaths, workspaceRoot, cache) {
|
|
677
|
+
if (!tsConfigCacheInitialized) {
|
|
678
|
+
tsConfigCacheData = toAbsolutePaths(readTsConfigCacheData(), workspaceRoot);
|
|
679
|
+
tsConfigCacheInitialized = true;
|
|
680
|
+
}
|
|
662
681
|
// ensure hashes are checked and the cache is invalidated and populated as needed
|
|
663
682
|
for (const configFilePath of configFilePaths) {
|
|
664
683
|
const fullConfigPath = (0, node_path_1.join)(workspaceRoot, configFilePath);
|
|
665
|
-
readTsConfigAndCache(fullConfigPath, workspaceRoot);
|
|
684
|
+
readTsConfigAndCache(fullConfigPath, workspaceRoot, cache);
|
|
666
685
|
}
|
|
667
686
|
}
|
|
668
|
-
function readTsConfigAndCache(tsConfigPath, workspaceRoot) {
|
|
687
|
+
function readTsConfigAndCache(tsConfigPath, workspaceRoot, cache) {
|
|
669
688
|
const relativePath = posixRelative(workspaceRoot, tsConfigPath);
|
|
670
|
-
const hash = getFileHash(tsConfigPath, workspaceRoot);
|
|
689
|
+
const hash = getFileHash(tsConfigPath, workspaceRoot, cache);
|
|
671
690
|
let extendedFilesHash;
|
|
672
691
|
if (tsConfigCacheData[relativePath] &&
|
|
673
692
|
tsConfigCacheData[relativePath].hash === hash) {
|
|
674
|
-
extendedFilesHash = getExtendedFilesHash(tsConfigCacheData[relativePath].data.extendedConfigFiles, workspaceRoot);
|
|
693
|
+
extendedFilesHash = getExtendedFilesHash(tsConfigCacheData[relativePath].data.extendedConfigFiles, workspaceRoot, cache);
|
|
675
694
|
if (tsConfigCacheData[relativePath].extendedFilesHash === extendedFilesHash) {
|
|
676
695
|
return tsConfigCacheData[relativePath].data;
|
|
677
696
|
}
|
|
678
697
|
}
|
|
679
|
-
const tsConfig = readTsConfig(tsConfigPath, workspaceRoot);
|
|
698
|
+
const tsConfig = readTsConfig(tsConfigPath, workspaceRoot, cache);
|
|
680
699
|
const extendedConfigFiles = [];
|
|
681
700
|
if (tsConfig.raw?.extends) {
|
|
682
701
|
const extendsArray = typeof tsConfig.raw.extends === 'string'
|
|
@@ -689,7 +708,7 @@ function readTsConfigAndCache(tsConfigPath, workspaceRoot) {
|
|
|
689
708
|
}
|
|
690
709
|
}
|
|
691
710
|
}
|
|
692
|
-
extendedFilesHash ??= getExtendedFilesHash(extendedConfigFiles, workspaceRoot);
|
|
711
|
+
extendedFilesHash ??= getExtendedFilesHash(extendedConfigFiles, workspaceRoot, cache);
|
|
693
712
|
tsConfigCacheData[relativePath] = {
|
|
694
713
|
data: {
|
|
695
714
|
options: tsConfig.options,
|
|
@@ -702,7 +721,7 @@ function readTsConfigAndCache(tsConfigPath, workspaceRoot) {
|
|
|
702
721
|
};
|
|
703
722
|
return tsConfigCacheData[relativePath].data;
|
|
704
723
|
}
|
|
705
|
-
function getExtendedFilesHash(extendedConfigFiles, workspaceRoot) {
|
|
724
|
+
function getExtendedFilesHash(extendedConfigFiles, workspaceRoot, cache) {
|
|
706
725
|
if (!extendedConfigFiles.length) {
|
|
707
726
|
return '';
|
|
708
727
|
}
|
|
@@ -721,22 +740,26 @@ function getExtendedFilesHash(extendedConfigFiles, workspaceRoot) {
|
|
|
721
740
|
hashes.push(extendedConfigFile.externalPackage);
|
|
722
741
|
}
|
|
723
742
|
else if (extendedConfigFile.filePath) {
|
|
724
|
-
hashes.push(getFileHash(extendedConfigFile.filePath, workspaceRoot));
|
|
725
|
-
hashes.push(getExtendedFilesHash(readTsConfigAndCache(extendedConfigFile.filePath, workspaceRoot)
|
|
726
|
-
.extendedConfigFiles, workspaceRoot));
|
|
743
|
+
hashes.push(getFileHash(extendedConfigFile.filePath, workspaceRoot, cache));
|
|
744
|
+
hashes.push(getExtendedFilesHash(readTsConfigAndCache(extendedConfigFile.filePath, workspaceRoot, cache).extendedConfigFiles, workspaceRoot, cache));
|
|
727
745
|
}
|
|
728
746
|
}
|
|
729
747
|
const hash = hashes.join('|');
|
|
730
748
|
cache.extendedFilesHashes.set(cacheKey, hash);
|
|
731
749
|
return hash;
|
|
732
750
|
}
|
|
733
|
-
function readTsConfig(tsConfigPath, workspaceRoot) {
|
|
751
|
+
function readTsConfig(tsConfigPath, workspaceRoot, cache) {
|
|
734
752
|
if (!ts) {
|
|
735
753
|
ts = require('typescript');
|
|
736
754
|
}
|
|
755
|
+
// Normalize to forward slashes for TypeScript compatibility on Windows.
|
|
756
|
+
// TypeScript's parser normalizes paths inconsistently — diagnostics use
|
|
757
|
+
// normalized paths but the source file retains the original, causing
|
|
758
|
+
// assertion failures when backslashes are present.
|
|
759
|
+
tsConfigPath = tsConfigPath.replaceAll('\\', '/');
|
|
737
760
|
const tsSys = {
|
|
738
761
|
...ts.sys,
|
|
739
|
-
readFile: (path) => readFile(path, workspaceRoot),
|
|
762
|
+
readFile: (path) => readFile(path, workspaceRoot, cache),
|
|
740
763
|
readDirectory: () => [],
|
|
741
764
|
};
|
|
742
765
|
const readResult = ts.readConfigFile(tsConfigPath, tsSys.readFile);
|
|
@@ -748,7 +771,9 @@ function normalizePluginOptions(pluginOptions = {}) {
|
|
|
748
771
|
const defaultCompiler = 'tsc';
|
|
749
772
|
const compiler = pluginOptions.compiler ?? defaultCompiler;
|
|
750
773
|
const defaultTypecheckTargetName = 'typecheck';
|
|
774
|
+
const defaultTypecheckConfigName = 'tsconfig.json';
|
|
751
775
|
let typecheck = {
|
|
776
|
+
configName: defaultTypecheckConfigName,
|
|
752
777
|
targetName: defaultTypecheckTargetName,
|
|
753
778
|
};
|
|
754
779
|
if (pluginOptions.typecheck === false) {
|
|
@@ -757,6 +782,7 @@ function normalizePluginOptions(pluginOptions = {}) {
|
|
|
757
782
|
else if (pluginOptions.typecheck &&
|
|
758
783
|
typeof pluginOptions.typecheck !== 'boolean') {
|
|
759
784
|
typecheck = {
|
|
785
|
+
configName: pluginOptions.typecheck.configName ?? defaultTypecheckConfigName,
|
|
760
786
|
targetName: pluginOptions.typecheck.targetName ?? defaultTypecheckTargetName,
|
|
761
787
|
};
|
|
762
788
|
}
|
|
@@ -808,15 +834,15 @@ function resolveExtendedTsConfigPath(tsConfigPath, directory) {
|
|
|
808
834
|
return null;
|
|
809
835
|
}
|
|
810
836
|
}
|
|
811
|
-
function getFileHash(filePath, workspaceRoot) {
|
|
837
|
+
function getFileHash(filePath, workspaceRoot, cache) {
|
|
812
838
|
const relativePath = posixRelative(workspaceRoot, filePath);
|
|
813
839
|
if (!cache.fileHashes[relativePath]) {
|
|
814
|
-
const content = readFile(filePath, workspaceRoot);
|
|
840
|
+
const content = readFile(filePath, workspaceRoot, cache);
|
|
815
841
|
cache.fileHashes[relativePath] = (0, file_hasher_1.hashArray)([content]);
|
|
816
842
|
}
|
|
817
843
|
return cache.fileHashes[relativePath];
|
|
818
844
|
}
|
|
819
|
-
function readFile(filePath, workspaceRoot) {
|
|
845
|
+
function readFile(filePath, workspaceRoot, cache) {
|
|
820
846
|
const relativePath = posixRelative(workspaceRoot, filePath);
|
|
821
847
|
if (!cache.rawFiles[relativePath]) {
|
|
822
848
|
const content = (0, node_fs_1.readFileSync)(filePath, 'utf8');
|
|
@@ -902,5 +928,5 @@ function toRelativePaths(cache, workspaceRoot) {
|
|
|
902
928
|
return updatedCache;
|
|
903
929
|
}
|
|
904
930
|
function posixRelative(workspaceRoot, path) {
|
|
905
|
-
return
|
|
931
|
+
return (0, devkit_1.normalizePath)((0, node_path_1.relative)(workspaceRoot, path));
|
|
906
932
|
}
|