Skip to content

⚡️ A blazing-fast tool for generating isolated declarations, powered by Oxc!

License

Notifications You must be signed in to change notification settings

unplugin/unplugin-isolated-decl

Repository files navigation

unplugin-isolated-decl npm

Unit Test

⚡️ A blazing-fast tool for generating isolated declarations, powered by Oxc!

Features

  • 🚀 Fast: Generates .d.ts files significantly faster than tsc.
  • 🎨 Transformer: Support Oxc, SWC, and TypeScript transformer.
  • 📦 Zero Config: No configuration required, works out of the box.
  • Bundler Support: Works with Vite, Rollup, and esbuild.

Installation

npm i -D unplugin-isolated-decl

Usage

Vite
// vite.config.ts
import UnpluginIsolatedDecl from 'unplugin-isolated-decl/vite'

export default defineConfig({
  plugins: [UnpluginIsolatedDecl()],
})


Rollup
// rollup.config.js
import UnpluginIsolatedDecl from 'unplugin-isolated-decl/rollup'

export default {
  plugins: [UnpluginIsolatedDecl()],
}


Rolldown
// rolldown.config.js
import UnpluginIsolatedDecl from 'unplugin-isolated-decl/rolldown'

export default {
  plugins: [UnpluginIsolatedDecl()],
}


esbuild
// esbuild.config.js
import { build } from 'esbuild'

build({
  plugins: [require('unplugin-isolated-decl/esbuild')()],
})


Options

export interface Options {
  include?: FilterPattern
  exclude?: FilterPattern
  enforce?: 'pre' | 'post' | undefined
  /**
   * If you use swc or typescript, you need to install `@swc/core` or `typescript` yourself.
   * @default oxc
   */
  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'

Sponsors

License

MIT License © 2024-PRESENT 三咲智子


About

⚡️ A blazing-fast tool for generating isolated declarations, powered by Oxc!

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project