Skip to content

Commit 98398a2

Browse files
committed
fix: native filter detection
1 parent 0c0eec7 commit 98398a2

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/rollup/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function toRollupPlugin(plugin: UnpluginOptions, key: 'rollup' | 'rolldow
2727

2828
replaceHookHandler('resolveId', resolveIdHook, function (...args) {
2929
const [id] = args
30-
const supportFilter = supportNativeFilter(this)
30+
const supportFilter = supportNativeFilter(this, key)
3131
if (!supportFilter && !filter(id))
3232
return
3333

@@ -47,7 +47,7 @@ export function toRollupPlugin(plugin: UnpluginOptions, key: 'rollup' | 'rolldow
4747
if (plugin.loadInclude && !plugin.loadInclude(id))
4848
return
4949

50-
const supportFilter = supportNativeFilter(this)
50+
const supportFilter = supportNativeFilter(this, key)
5151
if (!supportFilter && !filter(id))
5252
return
5353

@@ -67,7 +67,7 @@ export function toRollupPlugin(plugin: UnpluginOptions, key: 'rollup' | 'rolldow
6767
if (plugin.transformInclude && !plugin.transformInclude(id))
6868
return
6969

70-
const supportFilter = supportNativeFilter(this)
70+
const supportFilter = supportNativeFilter(this, key)
7171
if (!supportFilter && !filter(id, code))
7272
return
7373

@@ -94,7 +94,16 @@ export function toRollupPlugin(plugin: UnpluginOptions, key: 'rollup' | 'rolldow
9494
}
9595
}
9696

97-
function supportNativeFilter(context: any) {
97+
function supportNativeFilter(context: any, framework: 'rollup' | 'rolldown' | 'vite' | 'unloader') {
98+
if (framework === 'unloader')
99+
return false
100+
101+
if (framework === 'vite')
102+
return !!context?.meta?.viteVersion // since Vite v7
103+
104+
if (framework === 'rolldown')
105+
return true // always supported
106+
98107
const rollupVersion: string | undefined = context?.meta?.rollupVersion
99108
if (!rollupVersion)
100109
return false

0 commit comments

Comments
 (0)