Skip to content

Commit 4f8cb24

Browse files
committed
fix: support vite & rolldown
1 parent af720e4 commit 4f8cb24

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/index.ts

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import { isolatedDeclaration } from 'oxc-transform'
88
import { createFilter } from '@rollup/pluginutils'
99
import { type Options, resolveOptions } from './core/options'
10+
import type { Plugin } from 'rollup'
1011

1112
declare module 'unplugin' {
1213
interface UnpluginBuildContext {
@@ -27,6 +28,24 @@ export const plugin: UnpluginInstance<Options | undefined, false> =
2728
const contexts: Context[] = []
2829
let id = 0
2930

31+
const rollup: Partial<Plugin> = {
32+
options(rollupOptions) {
33+
let outBase = ''
34+
let input = rollupOptions.input
35+
input = typeof input === 'string' ? [input] : input
36+
if (Array.isArray(input)) {
37+
outBase = lowestCommonAncestor(...input)
38+
}
39+
40+
if (!contexts.length) contexts.push({} as any)
41+
contexts[0] = {
42+
outExt: options.outExt,
43+
outDir: options.outDir,
44+
outBase,
45+
}
46+
},
47+
}
48+
3049
return {
3150
name: 'unplugin-isolated-decl',
3251

@@ -100,23 +119,9 @@ export const plugin: UnpluginInstance<Options | undefined, false> =
100119
},
101120
},
102121

103-
rollup: {
104-
options(rollupOptions) {
105-
let outBase = ''
106-
let input = rollupOptions.input
107-
input = typeof input === 'string' ? [input] : input
108-
if (Array.isArray(input)) {
109-
outBase = lowestCommonAncestor(...input)
110-
}
111-
112-
if (!contexts.length) contexts.push({} as any)
113-
contexts[0] = {
114-
outExt: options.outExt,
115-
outDir: options.outDir,
116-
outBase,
117-
}
118-
},
119-
},
122+
rollup,
123+
rolldown: rollup,
124+
vite: rollup,
120125
}
121126
})
122127

0 commit comments

Comments
 (0)