diff --git a/packages/vite/src/node/plugins/esbuild.ts b/packages/vite/src/node/plugins/esbuild.ts
index 9a95c1be816580..c88d9a4210433d 100644
--- a/packages/vite/src/node/plugins/esbuild.ts
+++ b/packages/vite/src/node/plugins/esbuild.ts
@@ -27,7 +27,7 @@ import { searchForWorkspaceRoot } from '..'
const debug = createDebugger('vite:esbuild')
const INJECT_HELPERS_IIFE_RE =
- /^(.*)((?:const|var) [^\s]+=function\([^)]*?\){"use strict";)/s
+ /^(.*)((?:var) [^\s]+=function\([^)]*?\){"use strict";)/s
const INJECT_HELPERS_UMD_RE =
/^(.*)(\(function\([^)]*?\){.+amd.+function\([^)]*?\){"use strict";)/s
diff --git a/playground/lib/__tests__/lib.spec.ts b/playground/lib/__tests__/lib.spec.ts
index 9046097f7e8375..b8143de14fdb81 100644
--- a/playground/lib/__tests__/lib.spec.ts
+++ b/playground/lib/__tests__/lib.spec.ts
@@ -23,7 +23,7 @@ describe.runIf(isBuild)('build', () => {
expect(await page.textContent('.iife')).toBe('It works')
const code = readFile('dist/my-lib-custom-filename.iife.js')
// esbuild helpers are injected inside of the IIFE wrapper
- expect(code).toMatch(/^const MyLib=function\(\){"use strict";/)
+ expect(code).toMatch(/^var MyLib=function\(\){"use strict";/)
})
test('Library mode does not include `preload`', async () => {
diff --git a/playground/lib/index.dist.html b/playground/lib/index.dist.html
index 99f08c73396fea..fd96f56ce0d651 100644
--- a/playground/lib/index.dist.html
+++ b/playground/lib/index.dist.html
@@ -27,11 +27,11 @@