Skip to content

Commit 6e0c0d2

Browse files
committed
fix(rolldown): correct exported type for Rolldown plugin
Closes #470 - Mark pluginFactory's Nested generic as false since it always returns a single plugin, never an array. - Cast createRolldownPlugin result to Plugin<any> to fix Rolldown config type checking (the unplugin adapter's distributive conditional types produce Plugin | Plugin[] otherwise).
1 parent d4e41d2 commit 6e0c0d2

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

packages/unplugin-dts/src/core/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const jsRE = /\.([cm])?jsx?$/
3232
export const tsRE = /\.([cm])?tsx?$/
3333
export const dtsRE = /\.d\.([cm])?tsx?$/
3434
export const tjsRE = /\.([cm])?([jt])sx?$/
35+
// e.g. .ts .tsx .js .jsx .mts .mjs .cts .cjs
3536
export const mtjsRE = /\.m([jt])sx?$/
3637
export const ctjsRE = /\.c([jt])sx?$/
3738
export const fullRelativeRE = /^\.\.?\//

packages/unplugin-dts/src/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import type { Logger } from './core'
3333
const pluginName = 'unplugin:dts'
3434
const logPrefix = cyan(`[${pluginName}]`)
3535

36-
export const pluginFactory: UnpluginFactory<PluginOptions | undefined> = /* #__PURE__ */ (
36+
export const pluginFactory: UnpluginFactory<PluginOptions | undefined, false> = /* #__PURE__ */ (
3737
options = {},
3838
meta,
3939
) => {
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { createRolldownPlugin } from 'unplugin'
22
import { pluginFactory } from './plugin'
33

4-
export default createRolldownPlugin(pluginFactory)
4+
import type { Plugin } from 'rolldown'
5+
import type { PluginOptions } from './types'
6+
7+
export default createRolldownPlugin(pluginFactory) as (options?: PluginOptions) => Plugin<any>

0 commit comments

Comments
 (0)