Skip to content

Commit b20f624

Browse files
committed
fix: fix Promise.finally missing in Firefox
fix vuejs#2012
1 parent 356eef6 commit b20f624

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

packages/@vue/babel-preset-app/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ See [@babel/preset-env docs](https://new.babeljs.io/docs/en/next/babel-preset-en
7676

7777
### polyfills
7878

79-
- Default: `['es6.promise', 'es6.array.iterator']`
79+
- Default: `['es6.array.iterator', 'es6.promise', 'es7.promise.finally']`
8080

8181
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**.
8282

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
const path = require('path')
22

33
const defaultPolyfills = [
4-
'es6.promise',
54
// promise polyfill alone doesn't work in IE,
65
// needs this as well. see: #1642
7-
'es6.array.iterator'
6+
'es6.array.iterator',
7+
// this is required for webpack code splitting, vuex etc.
8+
'es6.promise',
9+
// #2012 es6.promise replaces native Promise in FF and causes missing finally
10+
'es7.promise.finally'
811
]
912

1013
function getPolyfills (targets, includes, { ignoreBrowserslistConfig, configPath }) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ module.exports = ({ types }) => {
1313

1414
const { polyfills } = state.opts
1515
const { createImport } = require('@babel/preset-env/lib/utils')
16-
polyfills.forEach(p => {
16+
// imports are injected in reverse order
17+
polyfills.slice().reverse().forEach(p => {
1718
createImport(path, p)
1819
})
1920
}

0 commit comments

Comments
 (0)