From df0db6a9094f91291cd5048319906fb1d80cc06e Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 16 Jan 2024 21:47:46 +0900 Subject: [PATCH] fix(vitest): simplify hoist transform check regex to avoid expensive regex match (#4974) --- packages/vitest/src/node/hoistMocks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vitest/src/node/hoistMocks.ts b/packages/vitest/src/node/hoistMocks.ts index 1f7527c86c5e..e9ba9cd819b8 100644 --- a/packages/vitest/src/node/hoistMocks.ts +++ b/packages/vitest/src/node/hoistMocks.ts @@ -60,7 +60,7 @@ export function getBetterEnd(code: string, node: Node) { return end } -const regexpHoistable = /[ \t]*\b(vi|vitest)\s*\.\s*(mock|unmock|hoisted)\(/ +const regexpHoistable = /\b(vi|vitest)\s*\.\s*(mock|unmock|hoisted)\(/ const hashbangRE = /^#!.*\n/ export function hoistMocks(code: string, id: string, parse: PluginContext['parse'], colors?: Colors) {