Skip to content

Commit

Permalink
fix: fix Promise.finally missing in Firefox
Browse files Browse the repository at this point in the history
fix #2012
  • Loading branch information
yyx990803 committed Aug 3, 2018
1 parent 356eef6 commit b20f624
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/@vue/babel-preset-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**.

Expand Down
7 changes: 5 additions & 2 deletions packages/@vue/babel-preset-app/index.js
Original file line number Diff line number Diff line change
@@ -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 }) {
Expand Down
3 changes: 2 additions & 1 deletion packages/@vue/babel-preset-app/polyfillsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down

0 comments on commit b20f624

Please sign in to comment.