Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: dts 的增量特性被破坏 #744

Open
ninesunsabiu opened this issue Mar 7, 2024 · 1 comment
Open

bug: dts 的增量特性被破坏 #744

ninesunsabiu opened this issue Mar 7, 2024 · 1 comment

Comments

@ninesunsabiu
Copy link

Version

4.4.0

OS Version

14.3.1 (23D60)

Node.js Version

v18.12.1

Link to minimal reproduction

https://github.com/ninesunsabiu/father

Steps to reproduce

  1. 安装依赖
  2. 边跟 examples/normal/tsconfig.json 中设定 "incremental": true 但是没有设定 tsBuildInfoFile
  3. normal 运行 father dev

What is expected?

项目根目录下的 tsconfig.tsbuildinfo 正常更新 增量行为能保持 tsc 的行为

What is actually happening?

项目根目录下的 tsconfig.tsbuildinfo 不再生成(不再更新)

Any additional comments? (optional)

No response

@ninesunsabiu
Copy link
Author

dts/index 中 如果工程中已有配置了 incremental 了,会跳过 tsBuildInfoFile 的赋值

// enable incremental for cache
if (enableCache && typeof tsconfig.options.incremental === 'undefined') {
tsconfig.options.incremental = true;
tsconfig.options.tsBuildInfoFile = path.join(
tscCacheDir,
'dts.tsbuildinfo',
);
}

以至于 ts.writeFile 中对 tsBuildInfoFile 的写入判断 fileName === tsconfig.options.tsBuildInfoFile(undefined) 为假值,不再写入 ts 输出的 tsBuildInfoFile 到磁盘,而且也没有其他的机会再写入了

tsHost.writeFile = (fileName, content, _a, _b, sourceFiles) => {
const sourceFile = sourceFiles?.[0].fileName;
if (fileName === tsconfig.options.tsBuildInfoFile) {
// save incremental cache
fsExtra.writeFileSync(tsconfig.options.tsBuildInfoFile, content);
} else if (sourceFile) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant