Skip to content

Commit f32fdae

Browse files
LinusBorgAkryum
authored andcommitted
fix(babel): set useBuiltins to false during MODERN_BUILD (vuejs#1758)
* fix(babel): set useBuiltins to false dring MODERN_BUILD * refactor(babel): use `ignoreBrowserslistConfig` ...instead of deactivating `useBuiltins`. Leaves possibility for future polyfills open. * fix: don't override user options
1 parent d51f08d commit f32fdae

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

packages/@vue/babel-preset-app/__tests__/babel-preset.spec.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,38 @@ test('polyfill detection', () => {
3535
expect(code).toMatch(`import "core-js/modules/es6.map"`)
3636
})
3737

38+
test('modern mode always skips polyfills', () => {
39+
process.env.VUE_CLI_MODERN_BUILD = true
40+
let { code } = babel.transformSync(`
41+
const a = new Map()
42+
`.trim(), {
43+
babelrc: false,
44+
presets: [[preset, {
45+
targets: { ie: 9 },
46+
useBuiltIns: 'usage'
47+
}]]
48+
})
49+
// default includes
50+
expect(code).not.toMatch(`import "core-js/modules/es6.promise"`)
51+
// usage-based detection
52+
expect(code).not.toMatch(`import "core-js/modules/es6.map"`)
53+
54+
;({ code } = babel.transformSync(`
55+
const a = new Map()
56+
`.trim(), {
57+
babelrc: false,
58+
presets: [[preset, {
59+
targets: { ie: 9 },
60+
useBuiltIns: 'entry'
61+
}]]
62+
}))
63+
// default includes
64+
expect(code).not.toMatch(`import "core-js/modules/es6.promise"`)
65+
// usage-based detection
66+
expect(code).not.toMatch(`import "core-js/modules/es6.map"`)
67+
delete process.env.VUE_CLI_MODERN_BUILD
68+
})
69+
3870
test('object spread', () => {
3971
const { code } = babel.transformSync(`
4072
const a = { ...b }

packages/@vue/babel-preset-app/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = (context, options = {}) => {
4242
modules = false,
4343
targets: rawTargets,
4444
spec,
45-
ignoreBrowserslistConfig,
45+
ignoreBrowserslistConfig = !!process.env.VUE_CLI_MODERN_BUILD,
4646
configPath,
4747
include,
4848
exclude,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy