fix: fix Promise.finally missing in Firefox

fix #2012
This commit is contained in:
Evan You
2018-08-03 13:35:07 -07:00
parent 356eef6100
commit b20f624c32
3 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -76,7 +76,7 @@ See [@babel/preset-env docs](https://new.babeljs.io/docs/en/next/babel-preset-en
### polyfills
- Default: `['es6.promise', 'es6.array.iterator']`
- Default: `['es6.array.iterator', 'es6.promise', 'es7.promise.finally']`
A list of [core-js](https://github.com/zloirock/core-js) polyfills to pre-include when using `useBuiltIns: 'usage'`. **These polyfills are automatically excluded if they are not needed for your target environments**.
+5 -2
View File
@@ -1,10 +1,13 @@
const path = require('path')
const defaultPolyfills = [
'es6.promise',
// promise polyfill alone doesn't work in IE,
// needs this as well. see: #1642
'es6.array.iterator'
'es6.array.iterator',
// this is required for webpack code splitting, vuex etc.
'es6.promise',
// #2012 es6.promise replaces native Promise in FF and causes missing finally
'es7.promise.finally'
]
function getPolyfills (targets, includes, { ignoreBrowserslistConfig, configPath }) {
@@ -13,7 +13,8 @@ module.exports = ({ types }) => {
const { polyfills } = state.opts
const { createImport } = require('@babel/preset-env/lib/utils')
polyfills.forEach(p => {
// imports are injected in reverse order
polyfills.slice().reverse().forEach(p => {
createImport(path, p)
})
}