Skip to content

Commit 46d5e67

Browse files
antfusapphi-red
andauthoredMay 13, 2022
feat: enable generatedCode: 'es2015' for rollup build (#5018)
Co-authored-by: sapphi-red <green@sapphi.red>
1 parent 4c325f6 commit 46d5e67

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed
 

‎packages/vite/src/node/build.ts

+1
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ async function doBuild(
426426
exports: ssr ? 'named' : 'auto',
427427
sourcemap: options.sourcemap,
428428
name: libOptions ? libOptions.name : undefined,
429+
generatedCode: 'es2015',
429430
entryFileNames: ssr
430431
? `[name].js`
431432
: libOptions

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

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

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

‎playground/lib/__tests__/lib.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe.runIf(isBuild)('build', () => {
3131
'utf-8'
3232
)
3333
// esbuild helpers are injected inside of the IIFE wrapper
34-
expect(code).toMatch(/^var MyLib=function\(\){"use strict";/)
34+
expect(code).toMatch(/^const MyLib=function\(\){"use strict";/)
3535
})
3636

3737
test('Library mode does not include `preload`', async () => {

0 commit comments

Comments
 (0)