fix(js): use uuid when generating tmp tsconfig (#30118)

## Current Behavior
When multiple processes/tasks are running in parallel for a single
project that produce tmp tsconfig files for buildable libraries, they
can clobber each other.
 

## Expected Behavior
Ensure the config file is generated with a unique id to prevent
clobbering
This commit is contained in:
Colum Ferry 2025-02-20 20:53:44 +00:00 committed by GitHub
parent a90de969ab
commit 46e5dcefb0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 8 deletions

View File

@ -19,6 +19,7 @@ import { output } from 'nx/src/utils/output';
import { dirname, join, relative, extname, resolve } from 'path';
import type * as ts from 'typescript';
import { readTsConfigPaths } from './typescript/ts-config';
import { randomUUID } from 'crypto';
function isBuildable(target: string, node: ProjectGraphProjectNode): boolean {
return (
@ -443,7 +444,7 @@ export function createTmpTsConfig(
'tmp',
projectRoot,
process.env.NX_TASK_TARGET_TARGET ?? 'build',
'tsconfig.generated.json'
`tsconfig.generated.${randomUUID()}.json`
);
if (tsconfigPath === tmpTsConfigPath) {
return tsconfigPath;

View File

@ -80,6 +80,7 @@ export function nxViteTsPaths(options: nxViteTsPathsOptions = {}) {
projectRoot = config.root;
const projectRootFromWorkspaceRoot = relative(workspaceRoot, projectRoot);
let foundTsConfigPath = getTsConfig(
process.env.NX_TSCONFIG_PATH ??
join(
workspaceRoot,
'tmp',