fix(misc): ensure tsBuildInfoFile is generated inside outDir (#29343)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
13ec93c783
commit
99a0e7c5a0
@ -405,6 +405,7 @@ describe('app', () => {
|
||||
"noUnusedLocals": false,
|
||||
"outDir": "out-tsc/my-app",
|
||||
"rootDir": "src",
|
||||
"tsBuildInfoFile": "out-tsc/my-app/tsconfig.app.tsbuildinfo",
|
||||
"types": [
|
||||
"node",
|
||||
],
|
||||
|
||||
@ -260,6 +260,7 @@ describe('app', () => {
|
||||
"moduleResolution": "nodenext",
|
||||
"outDir": "out-tsc/myapp",
|
||||
"rootDir": "src",
|
||||
"tsBuildInfoFile": "out-tsc/myapp/tsconfig.app.tsbuildinfo",
|
||||
"types": [
|
||||
"node",
|
||||
"express",
|
||||
|
||||
@ -10,7 +10,7 @@ import {
|
||||
} from '@nx/devkit';
|
||||
import { FsTree } from 'nx/src/generators/tree';
|
||||
import { isUsingPackageManagerWorkspaces } from '../package-manager-workspaces';
|
||||
import { relative } from 'node:path/posix';
|
||||
import { basename, join, relative } from 'node:path/posix';
|
||||
|
||||
export function isUsingTypeScriptPlugin(tree: Tree): boolean {
|
||||
const nxJson = readNxJson(tree);
|
||||
@ -141,6 +141,22 @@ export function updateTsconfigFiles(
|
||||
...compilerOptions,
|
||||
};
|
||||
|
||||
if (rootDir && rootDir !== '.') {
|
||||
// when rootDir is different from '.', the tsbuildinfo file is output
|
||||
// at `<outDir>/<relative path to config from rootDir>/`, so we need
|
||||
// to set it explicitly to ensure it's output to the outDir
|
||||
// https://www.typescriptlang.org/tsconfig/#tsBuildInfoFile
|
||||
json.compilerOptions.tsBuildInfoFile = join(
|
||||
'out-tsc',
|
||||
projectRoot.split('/').at(-1),
|
||||
basename(runtimeTsconfigFileName, '.json') + '.tsbuildinfo'
|
||||
);
|
||||
} else if (json.compilerOptions.tsBuildInfoFile) {
|
||||
// when rootDir is '.' or not set, it would be output to the outDir, so
|
||||
// we don't need to set it explicitly
|
||||
delete json.compilerOptions.tsBuildInfoFile;
|
||||
}
|
||||
|
||||
const excludeSet: Set<string> = json.exclude
|
||||
? new Set(['dist', ...json.exclude, ...exclude])
|
||||
: new Set(exclude);
|
||||
|
||||
@ -286,6 +286,7 @@ describe('application generator', () => {
|
||||
"outDir": "out-tsc/myapp",
|
||||
"rootDir": "src",
|
||||
"target": "es2021",
|
||||
"tsBuildInfoFile": "out-tsc/myapp/tsconfig.app.tsbuildinfo",
|
||||
"types": [
|
||||
"node",
|
||||
],
|
||||
|
||||
@ -949,6 +949,7 @@ describe('app (legacy)', () => {
|
||||
"resolveJsonModule": true,
|
||||
"rootDir": "src",
|
||||
"strict": true,
|
||||
"tsBuildInfoFile": "out-tsc/myapp/tsconfig.tsbuildinfo",
|
||||
"types": [
|
||||
"jest",
|
||||
"node",
|
||||
|
||||
@ -662,6 +662,7 @@ describe('app', () => {
|
||||
"moduleResolution": "nodenext",
|
||||
"outDir": "out-tsc/myapp",
|
||||
"rootDir": "src",
|
||||
"tsBuildInfoFile": "out-tsc/myapp/tsconfig.app.tsbuildinfo",
|
||||
"types": [
|
||||
"node",
|
||||
],
|
||||
|
||||
@ -267,6 +267,7 @@ describe('app', () => {
|
||||
"outDir": "out-tsc/myapp",
|
||||
"resolveJsonModule": true,
|
||||
"rootDir": "src",
|
||||
"tsBuildInfoFile": "out-tsc/myapp/tsconfig.app.tsbuildinfo",
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
|
||||
@ -330,6 +330,7 @@ describe('app', () => {
|
||||
"noUnusedLocals": false,
|
||||
"outDir": "out-tsc/my-app",
|
||||
"rootDir": "src",
|
||||
"tsBuildInfoFile": "out-tsc/my-app/tsconfig.app.tsbuildinfo",
|
||||
"types": [
|
||||
"node",
|
||||
],
|
||||
|
||||
@ -1331,7 +1331,7 @@ describe('app', () => {
|
||||
"moduleResolution": "bundler",
|
||||
"outDir": "out-tsc/myapp",
|
||||
"rootDir": "src",
|
||||
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
||||
"tsBuildInfoFile": "out-tsc/myapp/tsconfig.app.tsbuildinfo",
|
||||
"types": [
|
||||
"node",
|
||||
"@nx/react/typings/cssmodule.d.ts",
|
||||
|
||||
@ -508,7 +508,7 @@ describe('hostGenerator', () => {
|
||||
"moduleResolution": "bundler",
|
||||
"outDir": "out-tsc/myapp",
|
||||
"rootDir": "src",
|
||||
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
||||
"tsBuildInfoFile": "out-tsc/myapp/tsconfig.app.tsbuildinfo",
|
||||
"types": [
|
||||
"node",
|
||||
"@nx/react/typings/cssmodule.d.ts",
|
||||
|
||||
@ -1039,6 +1039,7 @@ module.exports = withNx(
|
||||
"moduleResolution": "bundler",
|
||||
"outDir": "out-tsc/mylib",
|
||||
"rootDir": "src",
|
||||
"tsBuildInfoFile": "out-tsc/mylib/tsconfig.lib.tsbuildinfo",
|
||||
"types": [
|
||||
"node",
|
||||
"@nx/react/typings/cssmodule.d.ts",
|
||||
|
||||
@ -206,6 +206,7 @@ describe('application generator', () => {
|
||||
"outDir": "out-tsc/test",
|
||||
"resolveJsonModule": true,
|
||||
"rootDir": "src",
|
||||
"tsBuildInfoFile": "out-tsc/test/tsconfig.app.tsbuildinfo",
|
||||
"types": [
|
||||
"vite/client",
|
||||
],
|
||||
|
||||
@ -526,6 +526,7 @@ module.exports = [
|
||||
"outDir": "out-tsc/my-lib",
|
||||
"resolveJsonModule": true,
|
||||
"rootDir": "src",
|
||||
"tsBuildInfoFile": "out-tsc/my-lib/tsconfig.lib.tsbuildinfo",
|
||||
"types": [
|
||||
"vite/client",
|
||||
],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user