You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

unplugin-isolated-decl

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unplugin-isolated-decl

A blazing-fast tool for generating isolated declarations.

Source
npmnpm
Version
0.10.0
Version published
Weekly downloads
15K
-64.8%
Maintainers
1
Weekly downloads
 
Created
Source

unplugin-isolated-decl npm jsr

Unit Test

⚡️ A blazing-fast tool for generating isolated declarations.

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, 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
// 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')()],
})


Farm
// 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.
   * oxc: @oxc/transformer
   * swc: @swc/core
   * typescript: typescript
   *
   * @default typescript
   */
  transformer?: 'oxc' | 'swc' | 'typescript'
  /**
   * Whether to generate declaration source maps.
   *
   * Supported by `typescript` and `oxc` transformer only.
   *
   * @link https://www.typescriptlang.org/tsconfig/#declarationMap
   */
  sourceMap?: boolean

  /** Only for typescript transformer */
  transformOptions?: TranspileOptions
  ignoreErrors?: boolean
  /** An extra directory layer for output files. */
  extraOutdir?: string

  rewriteImports?: (
    id: string,
    importer: string,
  ) => string | void | null | undefined
}

rewriteImports

Rewrite imports in .d.ts files. (esbuild support is not available)

Here is an example of rewriting imports on Rollup:

// rollup.config.js
import alias from '@rollup/plugin-alias'

export default {
  // ...
  plugins: [
    alias({ entries: [{ find: '~', replacement: '.' }] }),
    UnpluginIsolatedDecl({
      rewriteImports(id, importer) {
        if (id[0] === '~') return `.${id.slice(1)}`
      },
    }),
    // ...
  ],
}

patchCjsDefaultExport

Patch export default in .d.cts to export =

[!NOTE] For the exhaustive set of options check options

Sponsors

License

MIT License © 2024-PRESENT 三咲智子

Keywords

unplugin

FAQs

Package last updated on 10 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts