Skip to content

Commit

Permalink
fix: d.ts may lost if tsconfig changed (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript committed Aug 31, 2023
1 parent 6388306 commit 5fa24e8
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/builder/bundless/dts/index.ts
Expand Up @@ -95,20 +95,18 @@ export default async function getDeclarations(
tsconfig.options.incremental = true;
tsconfig.options.tsBuildInfoFile = path.join(
tscCacheDir,
'tsc.tsbuildinfo',
'dts.tsbuildinfo',
);
}

const tsHost = ts.createIncrementalCompilerHost(tsconfig.options);
const cacheKeys = inputFiles.reduce<Record<string, string>>(
(ret, file) => ({
...ret,
// format: {path:mtime:config}
[file]: [
file,
getContentHash(fs.readFileSync(file, 'utf-8')),
JSON.stringify(tsconfig.options),
].join(':'),
// format: {path:contenthash}
[file]: [file, getContentHash(fs.readFileSync(file, 'utf-8'))].join(
':',
),
}),
{},
);
Expand Down Expand Up @@ -149,7 +147,6 @@ export default async function getDeclarations(
[
sourceFile,
getContentHash(fs.readFileSync(sourceFile, 'utf-8')),
JSON.stringify(tsconfig.options),
].join(':');

cacheRets[cacheKey] ??= [];
Expand All @@ -167,7 +164,7 @@ export default async function getDeclarations(

const incrProgram = ts.createIncrementalProgram({
rootNames: inputFiles,
options: tsconfig.options as any,
options: tsconfig.options,
host: tsHost,
});

Expand Down

0 comments on commit 5fa24e8

Please sign in to comment.