Skip to content

Commit df0db6a

Browse files
authoredJan 16, 2024
fix(vitest): simplify hoist transform check regex to avoid expensive regex match (#4974)
1 parent 06bae4d commit df0db6a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎packages/vitest/src/node/hoistMocks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function getBetterEnd(code: string, node: Node) {
6060
return end
6161
}
6262

63-
const regexpHoistable = /[ \t]*\b(vi|vitest)\s*\.\s*(mock|unmock|hoisted)\(/
63+
const regexpHoistable = /\b(vi|vitest)\s*\.\s*(mock|unmock|hoisted)\(/
6464
const hashbangRE = /^#!.*\n/
6565

6666
export function hoistMocks(code: string, id: string, parse: PluginContext['parse'], colors?: Colors) {

0 commit comments

Comments
 (0)
Please sign in to comment.