Skip to content

Commit

Permalink
feat: enable generatedCode: 'es2015' for rollup build (#5018)
Browse files Browse the repository at this point in the history
Co-authored-by: sapphi-red <green@sapphi.red>
  • Loading branch information
antfu and sapphi-red committed May 13, 2022
1 parent 4c325f6 commit 46d5e67
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/vite/src/node/build.ts
Expand Up @@ -426,6 +426,7 @@ async function doBuild(
exports: ssr ? 'named' : 'auto',
sourcemap: options.sourcemap,
name: libOptions ? libOptions.name : undefined,
generatedCode: 'es2015',
entryFileNames: ssr
? `[name].js`
: libOptions
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/esbuild.ts
Expand Up @@ -27,7 +27,7 @@ import { searchForWorkspaceRoot } from '..'
const debug = createDebugger('vite:esbuild')

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

Expand Down
2 changes: 1 addition & 1 deletion playground/lib/__tests__/lib.spec.ts
Expand Up @@ -31,7 +31,7 @@ describe.runIf(isBuild)('build', () => {
'utf-8'
)
// esbuild helpers are injected inside of the IIFE wrapper
expect(code).toMatch(/^var MyLib=function\(\){"use strict";/)
expect(code).toMatch(/^const MyLib=function\(\){"use strict";/)
})

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

0 comments on commit 46d5e67

Please sign in to comment.