From 22959fe2a72fc7c8d52ea22c6d92df9706272f25 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Fri, 22 May 2020 21:45:47 +0800 Subject: [PATCH 1/6] fix: correctly calculate if a custom polyfill is required with the given targets partially fixed the problem mentioned in #5507 --- packages/@vue/babel-preset-app/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/@vue/babel-preset-app/index.js b/packages/@vue/babel-preset-app/index.js index f199db12c0..cffc2f284c 100644 --- a/packages/@vue/babel-preset-app/index.js +++ b/packages/@vue/babel-preset-app/index.js @@ -9,12 +9,12 @@ const defaultPolyfills = [ // this is needed for object rest spread support in templates // as vue-template-es2015-compiler 1.8+ compiles it to Object.assign() calls. 'es.object.assign', - // #2012 es6.promise replaces native Promise in FF and causes missing finally + // #2012 es.promise replaces native Promise in FF and causes missing finally 'es.promise.finally' ] function getPolyfills (targets, includes, { ignoreBrowserslistConfig, configPath }) { - const getTargets = require('@babel/helper-compilation-targets').default + const { default: getTargets, isRequired } = require('@babel/helper-compilation-targets') const builtInTargets = getTargets(targets, { ignoreBrowserslistConfig, configPath }) // if no targets specified, include all default polyfills @@ -22,8 +22,8 @@ function getPolyfills (targets, includes, { ignoreBrowserslistConfig, configPath return includes } - const { list } = require('core-js-compat')({ targets: builtInTargets }) - return includes.filter(item => list.includes(item)) + const compatData = require('core-js-compat').data + return includes.filter(item => isRequired(item, builtInTargets, { compatData })) } module.exports = (context, options = {}) => { @@ -108,6 +108,7 @@ module.exports = (context, options = {}) => { } } else if (process.env.VUE_CLI_MODERN_BUILD) { // targeting browsers that support