Skip to content

Commit be2a3aa

Browse files
committed
refactor: use @rolldown/pluginutils
1 parent 443ea51 commit be2a3aa

File tree

4 files changed

+15
-32
lines changed

4 files changed

+15
-32
lines changed

packages/plugin-vue-jsx/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"dependencies": {
3838
"@babel/core": "^7.26.10",
3939
"@babel/plugin-transform-typescript": "^7.27.0",
40+
"@rolldown/pluginutils": "1.0.0-beta.9",
4041
"@vue/babel-plugin-jsx": "^1.4.0"
4142
},
4243
"devDependencies": {

packages/plugin-vue-jsx/src/filterUtils.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/plugin-vue-jsx/src/index.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ import jsx from '@vue/babel-plugin-jsx'
66
import { createFilter, normalizePath } from 'vite'
77
import type { ComponentOptions } from 'vue'
88
import type { Plugin } from 'vite'
9+
import {
10+
exactRegex,
11+
makeIdFiltersToMatchWithQuery,
12+
} from '@rolldown/pluginutils'
913
import type { Options } from './types'
10-
import { exactRegex, matchWithQuery } from './filterUtils'
1114

1215
export * from './types'
1316

@@ -107,10 +110,8 @@ function vueJsxPlugin(options: Options = {}): Plugin {
107110
transform: {
108111
filter: {
109112
id: {
110-
include: ensureArray(include!).map(matchWithQuery),
111-
exclude: exclude
112-
? ensureArray(exclude).map(matchWithQuery)
113-
: undefined,
113+
include: include ? makeIdFiltersToMatchWithQuery(include) : undefined,
114+
exclude: exclude ? makeIdFiltersToMatchWithQuery(exclude) : undefined,
114115
},
115116
},
116117
async handler(code, id, opt) {
@@ -340,8 +341,4 @@ function getHash(text: string) {
340341
return hash('sha256', text, 'hex').substring(0, 8)
341342
}
342343

343-
function ensureArray<T>(value: T | readonly T[]): readonly T[] {
344-
return Array.isArray(value) ? value : ([value] as readonly T[])
345-
}
346-
347344
export default vueJsxPlugin

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)