Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable generatedCode: 'es2015' for rollup build #5018

Merged
merged 7 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { searchForWorkspaceRoot } from '..'
const debug = createDebugger('vite:esbuild')

const INJECT_HELPERS_IIFE_RE =
/(.*)(var [^\s]+=function\([^)]*?\){"use strict";)(.*)/
bluwy marked this conversation as resolved.
Show resolved Hide resolved
/(.*)((?: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
Original file line number Diff line number Diff line change
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