Generate declarations fast using isolated declarations
npm install esbuild-isolated-dts

⚡ Generate declaration files (.d.ts) and declaration maps (.d.ts.map) much faster than tsc.
Your project must meet these requirements:
1. Have typescript 5.5+ installed - uses transpileDeclaration API from TypeScript.
2. Have isolatedDeclarations set to true in tsconfig.json.
3. Follow the isolated declarations rule.
``bash`npm
npm install esbuild-isolated-dts --save-devpnpm
pnpm install esbuild-isolated-dts --save-devyarn
yarn add esbuild-isolated-dts --save-dev
To generate .d.ts and .d.ts.map files together with transpiling entire directory to .js simply do the following, declaration maps are generated by default:
`typescript
import * as esbuild from 'esbuild';
import { isoldatedDtsPlugin } from 'esbuild-isolated-dts';
await esbuild.build({
entryPoints: ['src/*/.ts'],
format: 'esm',
target: 'es2017',
outdir: 'dist',
plugins: [isoldatedDtsPlugin()],
});
`
- Type: stringprocess.cwd()
- Default:
Overrides outdir in esbuild config for outputting type declaration. Allows outputting type declarations to a different directory.
Note: If outfile in esbuild config is used, outdir overrides the directory part of outfile.
- Type: typescript.TranspileOptions | undefinedundefined
- Default:
Typescript configuration. For example you can turn off outputting declaration maps like this:
`typescript
import * as esbuild from 'esbuild';
import { isoldatedDtsPlugin } from 'esbuild-isolated-dts';
await esbuild.build({
entryPoints: ['src/*/.ts'],
format: 'esm',
target: 'es2017',
outdir: 'dist',
plugins: [
isoldatedDtsPlugin({
transpileOptions: {
compilerOptions: {
declarationMap: false,
},
},
}),
],
});
`
Note: rootDir and outDir can't be directly modified, because these fields are necessary for correct declaration map output.
- Type: string[]['ts', 'tsx']
- Default:
Generate declarations only for files with the extension in exts.
- Type: booleanfalse
- Default:
Doesn't ouput any files, useful together with logLevel: 'debug'
- Type: 'debug' | 'silent''silent'
- Default:
Outputs extra information when set to 'debug'`
Inspired by/alternative: unplugin-isolated-decl
MIT