Skip to content

Commit 6affa5a

Browse files
committed
perf: replace picomatch with path.matchesGlob
1 parent 3293a28 commit 6affa5a

4 files changed

Lines changed: 6 additions & 28 deletions

File tree

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@
8181
"birpc": "catalog:prod",
8282
"dts-resolver": "catalog:prod",
8383
"get-tsconfig": "catalog:prod",
84-
"obug": "catalog:prod",
85-
"picomatch": "catalog:prod"
84+
"obug": "catalog:prod"
8685
},
8786
"devDependencies": {
8887
"@babel/types": "catalog:",
@@ -91,7 +90,6 @@
9190
"@sxzz/prettier-config": "catalog:",
9291
"@sxzz/test-utils": "catalog:",
9392
"@types/node": "catalog:",
94-
"@types/picomatch": "catalog:",
9593
"@typescript/native-preview": "catalog:",
9694
"@volar/typescript": "catalog:",
9795
"@vue/language-core": "catalog:",

pnpm-lock.yaml

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

pnpm-workspace.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ catalog:
88
'@sxzz/prettier-config': ^2.3.1
99
'@sxzz/test-utils': ^0.5.18
1010
'@types/node': ^25.6.0
11-
'@types/picomatch': ^4.0.3
1211
'@typescript/native-preview': 7.0.0-dev.20260430.1
1312
'@volar/typescript': ^2.4.28
1413
'@vue/language-core': ^3.2.7
@@ -38,7 +37,6 @@ catalogs:
3837
dts-resolver: ^2.1.3
3938
get-tsconfig: ^5.0.0-beta.5
4039
obug: ^2.1.1
41-
picomatch: ^4.0.4
4240

4341
allowBuilds:
4442
esbuild: false

src/generate.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { readFile, rm } from 'node:fs/promises'
44
import path from 'node:path'
55
import { parse } from '@babel/parser'
66
import { createDebug } from 'obug'
7-
import picomatch from 'picomatch'
87
import { isolatedDeclarationSync } from 'rolldown/experimental'
98
import {
109
filename_to_dts,
@@ -83,12 +82,12 @@ export function createGeneratePlugin({
8382
| 'emitJs'
8483
| 'sourcemap'
8584
>): Plugin {
85+
const entryIncludes = entry?.filter((p) => p[0] !== '!')
86+
const entryIgnores = entry?.filter((p) => p[0] === '!').map((p) => p.slice(1))
8687
const entryMatcher = entry
87-
? picomatch(entry, {
88-
ignore: entry
89-
.filter((p: string) => p.startsWith('!'))
90-
.map((p: string) => p.slice(1)),
91-
})
88+
? (file: string) =>
89+
entryIncludes!.some((p) => path.matchesGlob(file, p)) &&
90+
!entryIgnores!.some((p) => path.matchesGlob(file, p))
9291
: undefined
9392
const dtsMap: DtsMap = new Map<string, TsModule>()
9493

0 commit comments

Comments
 (0)