unbuild
unbuild copied to clipboard
feat: experimental isolated declaration support
Add experimental support for isolated declaration generation powered by OXC and unplugin-isolated-decl by @sxzz ❤️
Read more: https://github.com/microsoft/TypeScript/issues/58944
To opt in:
import { defineBuildConfig } from "unbuild";
export default defineBuildConfig({
rollup: {
// https://github.com/microsoft/TypeScript/issues/58944
// https://github.com/unplugin/unplugin-isolated-decl
isolatedDecl: {
transformer: "oxc",
},
},
});
Tips for migrating the codebase to be ready for isolated declaration support:
ts-fixmight help. (you can try withnpx @pi0/[email protected] -w- see https://github.com/microsoft/ts-fix/issues/29)- Using
@typescript-eslint/explicit-function-return-typeis helpful to find all issues (#412) - Using
transformer: "typescript"might help to find issues easier. Defaultoxcsometimes is crypted about which line.
TODO
Currently plugin generates types to dist/src/**.{mts,cts}. We need to find a way to merge them or at least generate top level declaration in dist/*.{mts,dts} to make it cleaner for package.json exports and avoid requirement of updating it. Also the paths seem relative to root in tsconfig rather than dist!