Skip to content

Commit

Permalink
perf(lib): improve helper inject regex
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Jun 23, 2022
1 parent 5dc0f72 commit 708ea77
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/vite/src/node/plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import { searchForWorkspaceRoot } from '..'
const debug = createDebugger('vite:esbuild')

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

let server: ViteDevServer

Expand Down Expand Up @@ -273,7 +273,7 @@ export const buildEsbuildPlugin = (config: ResolvedConfig): Plugin => {
if (injectHelpers) {
res.code = res.code.replace(
injectHelpers,
(_, helpers, header, rest) => header + helpers + rest
(_, helpers, header) => header + helpers
)
}
}
Expand Down

0 comments on commit 708ea77

Please sign in to comment.