Skip to content

Commit 3b2cc6b

Browse files
committed
feat: apply minimal transpilation when building as web component
1 parent ddf9c36 commit 3b2cc6b

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

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

+24-5
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,30 @@ module.exports = (context, options = {}) => {
4848
decoratorsLegacy
4949
} = options
5050

51-
const targets = process.env.VUE_CLI_BABEL_TARGET_NODE
52-
? { node: 'current' }
53-
: process.env.VUE_CLI_MODERN_BUILD
54-
? { esmodules: true }
55-
: rawTargets
51+
// resolve targets
52+
let targets
53+
if (process.env.VUE_CLI_BABEL_TARGET_NODE) {
54+
// running tests in Node.js
55+
targets = { node: 'current' }
56+
} else if (process.env.VUE_CLI_BUILD_TARGET === 'wc' || process.env.VUE_CLI_BUILD_TARGET === 'wc-async') {
57+
// targeting browsers that at least support ES2015 classes
58+
// https://github.com/babel/babel/blob/master/packages/babel-preset-env/data/plugins.json#L52-L61
59+
targets = {
60+
browsers: [
61+
'Chrome >= 49',
62+
'Firefox >= 45',
63+
'Safari >= 10',
64+
'Edge >= 13',
65+
'iOS >= 10',
66+
'Electron >= 0.36'
67+
]
68+
}
69+
} else if (process.env.VUE_CLI_MODERN_BUILD) {
70+
// targeting browsers that support <script type="module">
71+
targets = { esmodules: true }
72+
} else {
73+
targets = rawTargets
74+
}
5675

5776
// included-by-default polyfills. These are common polyfills that 3rd party
5877
// dependencies may rely on (e.g. Vuex relies on Promise), but since with

0 commit comments

Comments
 (0)