Skip to content

Commit c66ad64

Browse files
committed
perf: prefer native filter
1 parent a01fa3e commit c66ad64

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@
7575
"dependencies": {
7676
"ast-kit": "^2.0.0",
7777
"magic-string-ast": "^0.9.1",
78-
"unplugin": "^2.3.2",
79-
"unplugin-utils": "^0.2.4"
78+
"unplugin": "^2.3.2"
8079
},
8180
"devDependencies": {
8281
"@babel/types": "^7.27.1",

pnpm-lock.yaml

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

src/core/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FilterPattern } from 'unplugin-utils'
1+
import type { FilterPattern } from 'unplugin'
22

33
export interface Options {
44
include?: FilterPattern

src/index.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
import { createUnplugin, type UnpluginInstance } from 'unplugin'
2-
import { createFilter } from 'unplugin-utils'
32
import { transformQuansync } from './core'
43
import { resolveOptions, type Options } from './core/options'
54

65
export const Quansync: UnpluginInstance<Options | undefined, false> =
76
createUnplugin((rawOptions = {}) => {
87
const options = resolveOptions(rawOptions)
9-
const filter = createFilter(options.include, options.exclude)
108

119
const name = 'unplugin-quansync'
1210
return {
1311
name,
1412
enforce: options.enforce,
1513

16-
transformInclude(id) {
17-
return filter(id)
18-
},
19-
20-
transform(code, id) {
21-
if (!code.includes('quansync')) return
22-
return transformQuansync(code, id)
14+
transform: {
15+
filter: {
16+
id: {
17+
include: options.include,
18+
exclude: options.exclude,
19+
},
20+
},
21+
handler(code, id) {
22+
if (!code.includes('quansync')) return
23+
return transformQuansync(code, id)
24+
},
2325
},
2426
}
2527
})

0 commit comments

Comments
 (0)