Skip to content

Commit 19fc7e5

Browse files
authoredJun 23, 2022
perf(lib): improve helper inject regex (#8741)
1 parent 2ae269e commit 19fc7e5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎packages/vite/src/node/plugins/esbuild.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ import { searchForWorkspaceRoot } from '..'
2727
const debug = createDebugger('vite:esbuild')
2828

2929
const INJECT_HELPERS_IIFE_RE =
30-
/(.*)((?:const|var) [^\s]+=function\([^)]*?\){"use strict";)(.*)/s
30+
/^(.*)((?:const|var) [^\s]+=function\([^)]*?\){"use strict";)/s
3131
const INJECT_HELPERS_UMD_RE =
32-
/(.*)(\(function\([^)]*?\){.+amd.+function\([^)]*?\){"use strict";)(.*)/s
32+
/^(.*)(\(function\([^)]*?\){.+amd.+function\([^)]*?\){"use strict";)/s
3333

3434
let server: ViteDevServer
3535

@@ -273,7 +273,7 @@ export const buildEsbuildPlugin = (config: ResolvedConfig): Plugin => {
273273
if (injectHelpers) {
274274
res.code = res.code.replace(
275275
injectHelpers,
276-
(_, helpers, header, rest) => header + helpers + rest
276+
(_, helpers, header) => header + helpers
277277
)
278278
}
279279
}

0 commit comments

Comments
 (0)
Please sign in to comment.