feat: apply minimal transpilation when building as web component

This commit is contained in:
Evan You
2018-06-13 15:37:41 -04:00
parent ddf9c36218
commit 3b2cc6bd30

View File

@@ -48,11 +48,30 @@ module.exports = (context, options = {}) => {
decoratorsLegacy
} = options
const targets = process.env.VUE_CLI_BABEL_TARGET_NODE
? { node: 'current' }
: process.env.VUE_CLI_MODERN_BUILD
? { esmodules: true }
: rawTargets
// resolve targets
let targets
if (process.env.VUE_CLI_BABEL_TARGET_NODE) {
// running tests in Node.js
targets = { node: 'current' }
} else if (process.env.VUE_CLI_BUILD_TARGET === 'wc' || process.env.VUE_CLI_BUILD_TARGET === 'wc-async') {
// targeting browsers that at least support ES2015 classes
// https://github.com/babel/babel/blob/master/packages/babel-preset-env/data/plugins.json#L52-L61
targets = {
browsers: [
'Chrome >= 49',
'Firefox >= 45',
'Safari >= 10',
'Edge >= 13',
'iOS >= 10',
'Electron >= 0.36'
]
}
} else if (process.env.VUE_CLI_MODERN_BUILD) {
// targeting browsers that support <script type="module">
targets = { esmodules: true }
} else {
targets = rawTargets
}
// included-by-default polyfills. These are common polyfills that 3rd party
// dependencies may rely on (e.g. Vuex relies on Promise), but since with