Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit c8cecff

Browse files
authored
refactor: remove usage of deprecated babel functions, preparing for babel 8 (vuejs#5133)
* refactor: use babel.loadPartialConfigSync (added in babel 7.8) As planned in babel/babel#10746, in babel 8 the old `loadPartialConfig` can't be used synchronously. * refactor: remove dependence on internal babel files, preparing for babel 8 See babel/babel#10746 babel/babel#10899
1 parent da43343 commit c8cecff

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ const defaultPolyfills = [
1414
]
1515

1616
function getPolyfills (targets, includes, { ignoreBrowserslistConfig, configPath }) {
17-
const { isPluginRequired } = require('@babel/preset-env')
18-
const builtInsList = require('core-js-compat/data')
19-
const getTargets = require('@babel/preset-env/lib/targets-parser').default
20-
const builtInTargets = getTargets(targets, {
21-
ignoreBrowserslistConfig,
22-
configPath
23-
})
17+
const getTargets = require('@babel/helper-compilation-targets').default
18+
const builtInTargets = getTargets(targets, { ignoreBrowserslistConfig, configPath })
19+
20+
// if no targets specified, include all default polyfills
21+
if (!targets && !Object.keys(builtInTargets).length) {
22+
return includes
23+
}
2424

25-
return includes.filter(item => {
26-
return isPluginRequired(builtInTargets, builtInsList[item])
27-
})
25+
const { list } = require('core-js-compat')({ targets: builtInTargets })
26+
return includes.filter(item => list.includes(item))
2827
}
2928

3029
module.exports = (context, options = {}) => {

packages/@vue/babel-preset-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"homepage": "https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/babel-preset-app#readme",
2424
"dependencies": {
2525
"@babel/core": "^7.8.4",
26+
"@babel/helper-compilation-targets": "^7.8.4",
2627
"@babel/helper-module-imports": "^7.8.3",
2728
"@babel/plugin-proposal-class-properties": "^7.8.3",
2829
"@babel/plugin-proposal-decorators": "^7.8.3",

packages/@vue/cli-plugin-babel/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = (api, options) => {
2626
// there will be a VUE_CLI_TRANSPILE_BABEL_RUNTIME env var set.
2727
// the `filename` field is required
2828
// in case there're filename-related options like `ignore` in the user config
29-
babel.loadPartialConfig({ filename: api.resolve('src/main.js') })
29+
babel.loadPartialConfigSync({ filename: api.resolve('src/main.js') })
3030

3131
api.chainWebpack(webpackConfig => {
3232
webpackConfig.resolveLoader.modules.prepend(path.join(__dirname, 'node_modules'))

0 commit comments

Comments
 (0)