Skip to content

Commit

Permalink
fix: dts may lost if another dts has error in last time (#717)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript authored Sep 19, 2023
1 parent 25086fa commit af0dbd5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/builder/bundless/dts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ export default async function getDeclarations(
],
});

// save cache
// why save cache before check compile error?
// because ts compiler will compile files incrementally in the next time, so the correct d.ts files may lost if not save cache
// and don't worry the wrong d.ts save to cache, it will be override by the new content in the next time
Object.keys(cacheRets).forEach((key) => cache.setSync(key, cacheRets[key]));

// check compile error
// ref: https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler
const diagnostics = ts
Expand Down Expand Up @@ -251,9 +257,6 @@ export default async function getDeclarations(
});
throw new Error('Declaration generation failed.');
}

// save cache
Object.keys(cacheRets).forEach((key) => cache.setSync(key, cacheRets[key]));
}

return output;
Expand Down

0 comments on commit af0dbd5

Please sign in to comment.