Skip to content

Commit

Permalink
perf(lib): improve helper inject regex (#8741)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Jun 23, 2022
1 parent 2ae269e commit 19fc7e5
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 19fc7e5

Please sign in to comment.