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

fix(babel): set useBuiltins to false during MODERN_BUILD #1758

Merged
merged 3 commits into from Jul 8, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions packages/@vue/babel-preset-app/__tests__/babel-preset.spec.js
Expand Up @@ -35,6 +35,38 @@ test('polyfill detection', () => {
expect(code).toMatch(`import "core-js/modules/es6.map"`)
})

test('modern mode always skips polyfills', () => {
process.env.VUE_CLI_MODERN_BUILD = true
let { code } = babel.transformSync(`
const a = new Map()
`.trim(), {
babelrc: false,
presets: [[preset, {
targets: { ie: 9 },
useBuiltIns: 'usage'
}]]
})
// default includes
expect(code).not.toMatch(`import "core-js/modules/es6.promise"`)
// usage-based detection
expect(code).not.toMatch(`import "core-js/modules/es6.map"`)

;({ code } = babel.transformSync(`
const a = new Map()
`.trim(), {
babelrc: false,
presets: [[preset, {
targets: { ie: 9 },
useBuiltIns: 'entry'
}]]
}))
// default includes
expect(code).not.toMatch(`import "core-js/modules/es6.promise"`)
// usage-based detection
expect(code).not.toMatch(`import "core-js/modules/es6.map"`)
delete process.env.VUE_CLI_MODERN_BUILD
})

test('object spread', () => {
const { code } = babel.transformSync(`
const a = { ...b }
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/babel-preset-app/index.js
Expand Up @@ -42,7 +42,7 @@ module.exports = (context, options = {}) => {
modules = false,
targets: rawTargets,
spec,
ignoreBrowserslistConfig,
ignoreBrowserslistConfig = !!process.env.VUE_CLI_MODERN_BUILD,
configPath,
include,
exclude,
Expand Down