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,
|
"noUnusedLocals": false,
|
||||||
"outDir": "out-tsc/my-app",
|
"outDir": "out-tsc/my-app",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
|
"tsBuildInfoFile": "out-tsc/my-app/tsconfig.app.tsbuildinfo",
|
||||||
"types": [
|
"types": [
|
||||||
"node",
|
"node",
|
||||||
],
|
],
|
||||||
|
|||||||
@ -260,6 +260,7 @@ describe('app', () => {
|
|||||||
"moduleResolution": "nodenext",
|
"moduleResolution": "nodenext",
|
||||||
"outDir": "out-tsc/myapp",
|
"outDir": "out-tsc/myapp",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
|
"tsBuildInfoFile": "out-tsc/myapp/tsconfig.app.tsbuildinfo",
|
||||||
"types": [
|
"types": [
|
||||||
"node",
|
"node",
|
||||||
"express",
|
"express",
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import {
|
|||||||
} from '@nx/devkit';
|
} from '@nx/devkit';
|
||||||
import { FsTree } from 'nx/src/generators/tree';
|
import { FsTree } from 'nx/src/generators/tree';
|
||||||
import { isUsingPackageManagerWorkspaces } from '../package-manager-workspaces';
|
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 {
|
export function isUsingTypeScriptPlugin(tree: Tree): boolean {
|
||||||
const nxJson = readNxJson(tree);
|
const nxJson = readNxJson(tree);
|
||||||
@ -141,6 +141,22 @@ export function updateTsconfigFiles(
|
|||||||
...compilerOptions,
|
...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
|
const excludeSet: Set<string> = json.exclude
|
||||||
? new Set(['dist', ...json.exclude, ...exclude])
|
? new Set(['dist', ...json.exclude, ...exclude])
|
||||||
: new Set(exclude);
|
: new Set(exclude);
|
||||||
|
|||||||
@ -286,6 +286,7 @@ describe('application generator', () => {
|
|||||||
"outDir": "out-tsc/myapp",
|
"outDir": "out-tsc/myapp",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"target": "es2021",
|
"target": "es2021",
|
||||||
|
"tsBuildInfoFile": "out-tsc/myapp/tsconfig.app.tsbuildinfo",
|
||||||
"types": [
|
"types": [
|
||||||
"node",
|
"node",
|
||||||
],
|
],
|
||||||
|
|||||||
@ -949,6 +949,7 @@ describe('app (legacy)', () => {
|
|||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
"tsBuildInfoFile": "out-tsc/myapp/tsconfig.tsbuildinfo",
|
||||||
"types": [
|
"types": [
|
||||||
"jest",
|
"jest",
|
||||||
"node",
|
"node",
|
||||||
|
|||||||
@ -662,6 +662,7 @@ describe('app', () => {
|
|||||||
"moduleResolution": "nodenext",
|
"moduleResolution": "nodenext",
|
||||||
"outDir": "out-tsc/myapp",
|
"outDir": "out-tsc/myapp",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
|
"tsBuildInfoFile": "out-tsc/myapp/tsconfig.app.tsbuildinfo",
|
||||||
"types": [
|
"types": [
|
||||||
"node",
|
"node",
|
||||||
],
|
],
|
||||||
|
|||||||
@ -267,6 +267,7 @@ describe('app', () => {
|
|||||||
"outDir": "out-tsc/myapp",
|
"outDir": "out-tsc/myapp",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
|
"tsBuildInfoFile": "out-tsc/myapp/tsconfig.app.tsbuildinfo",
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@ -330,6 +330,7 @@ describe('app', () => {
|
|||||||
"noUnusedLocals": false,
|
"noUnusedLocals": false,
|
||||||
"outDir": "out-tsc/my-app",
|
"outDir": "out-tsc/my-app",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
|
"tsBuildInfoFile": "out-tsc/my-app/tsconfig.app.tsbuildinfo",
|
||||||
"types": [
|
"types": [
|
||||||
"node",
|
"node",
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1331,7 +1331,7 @@ describe('app', () => {
|
|||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"outDir": "out-tsc/myapp",
|
"outDir": "out-tsc/myapp",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
"tsBuildInfoFile": "out-tsc/myapp/tsconfig.app.tsbuildinfo",
|
||||||
"types": [
|
"types": [
|
||||||
"node",
|
"node",
|
||||||
"@nx/react/typings/cssmodule.d.ts",
|
"@nx/react/typings/cssmodule.d.ts",
|
||||||
|
|||||||
@ -508,7 +508,7 @@ describe('hostGenerator', () => {
|
|||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"outDir": "out-tsc/myapp",
|
"outDir": "out-tsc/myapp",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
"tsBuildInfoFile": "out-tsc/myapp/tsconfig.app.tsbuildinfo",
|
||||||
"types": [
|
"types": [
|
||||||
"node",
|
"node",
|
||||||
"@nx/react/typings/cssmodule.d.ts",
|
"@nx/react/typings/cssmodule.d.ts",
|
||||||
|
|||||||
@ -1039,6 +1039,7 @@ module.exports = withNx(
|
|||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"outDir": "out-tsc/mylib",
|
"outDir": "out-tsc/mylib",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
|
"tsBuildInfoFile": "out-tsc/mylib/tsconfig.lib.tsbuildinfo",
|
||||||
"types": [
|
"types": [
|
||||||
"node",
|
"node",
|
||||||
"@nx/react/typings/cssmodule.d.ts",
|
"@nx/react/typings/cssmodule.d.ts",
|
||||||
|
|||||||
@ -206,6 +206,7 @@ describe('application generator', () => {
|
|||||||
"outDir": "out-tsc/test",
|
"outDir": "out-tsc/test",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
|
"tsBuildInfoFile": "out-tsc/test/tsconfig.app.tsbuildinfo",
|
||||||
"types": [
|
"types": [
|
||||||
"vite/client",
|
"vite/client",
|
||||||
],
|
],
|
||||||
|
|||||||
@ -526,6 +526,7 @@ module.exports = [
|
|||||||
"outDir": "out-tsc/my-lib",
|
"outDir": "out-tsc/my-lib",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
|
"tsBuildInfoFile": "out-tsc/my-lib/tsconfig.lib.tsbuildinfo",
|
||||||
"types": [
|
"types": [
|
||||||
"vite/client",
|
"vite/client",
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user