unplugin-isolated-decl
v0.7.2
Published
A blazing-fast tool for generating isolated declarations.
Downloads
4,753
Maintainers
Readme
unplugin-isolated-decl
⚡️ A blazing-fast tool for generating isolated declarations.
Features
- 🚀 Fast: Generates
.d.ts
files significantly faster thantsc
. - 🎨 Transformer: Support Oxc, SWC, and TypeScript transformer.
- 📦 Zero Config: No configuration required, works out of the box.
- ✨ Bundler Support: Works with Vite, Rollup, esbuild and Farm. (PR of Webpack/Rspack support is welcome)
Installation
# npm
npm i -D unplugin-isolated-decl
# jsr
npx jsr add -D @unplugin/isolated-decl
Usage
// vite.config.ts
import UnpluginIsolatedDecl from 'unplugin-isolated-decl/vite'
export default defineConfig({
plugins: [UnpluginIsolatedDecl()],
})
// rollup.config.js
import UnpluginIsolatedDecl from 'unplugin-isolated-decl/rollup'
export default {
plugins: [UnpluginIsolatedDecl()],
}
// rolldown.config.js
import UnpluginIsolatedDecl from 'unplugin-isolated-decl/rolldown'
export default {
plugins: [UnpluginIsolatedDecl()],
}
// esbuild.config.js
import { build } from 'esbuild'
build({
plugins: [require('unplugin-isolated-decl/esbuild')()],
})
// farm.config.ts
import UnpluginIsolatedDecl from 'unplugin-isolated-decl/farm'
export default defineConfig({
plugins: [UnpluginIsolatedDecl()],
})
Options
export interface Options {
include?: FilterPattern
exclude?: FilterPattern
enforce?: 'pre' | 'post' | undefined
/**
* You need to install one of the supported transformers yourself.
* @default typescript
*/
transformer?: 'oxc' | 'swc' | 'typescript'
/** Only for typescript transformer */
transformOptions?: TranspileOptions
ignoreErrors?: boolean
/** An extra directory layer for output files. */
extraOutdir?: string
/** Automatically add `.js` extension to resolve in `Node16` + ESM mode. */
autoAddExts?: boolean
}
autoAddExts
Automatically add .js
extension to resolve in Node 16+ ESM mode.
// index.d.ts
import {} from './foo'
With autoAddExts
, it will be transformed to:
// index.d.ts
import {} from './foo.js'
patchCjsDefaultExport
Patch export default
in .d.cts
to export =
[!NOTE] For the exhaustive set of options check options