From 9ec2d34e652e4a7cdb9c8c956a4d67a5ea91af92 Mon Sep 17 00:00:00 2001 From: Yingya Zhang Date: Mon, 6 Jan 2020 16:11:03 +0800 Subject: [PATCH] feat: specify babel runtime version (#4959) --- packages/@vue/babel-preset-app/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/@vue/babel-preset-app/index.js b/packages/@vue/babel-preset-app/index.js index 72f77c68f2..45003c800c 100644 --- a/packages/@vue/babel-preset-app/index.js +++ b/packages/@vue/babel-preset-app/index.js @@ -53,6 +53,7 @@ module.exports = (context, options = {}) => { } const runtimePath = path.dirname(require.resolve('@babel/runtime/package.json')) + const runtimeVersion = require('@babel/runtime/package.json').version const { polyfills: userPolyfills, loose = false, @@ -78,7 +79,13 @@ module.exports = (context, options = {}) => { // However, this may cause hash inconsistency if the project is moved to another directory. // So here we allow user to explicit disable this option if hash consistency is a requirement // and the runtime version is sure to be correct. - absoluteRuntime = runtimePath + absoluteRuntime = runtimePath, + + // https://babeljs.io/docs/en/babel-plugin-transform-runtime#version + // By default transform-runtime assumes that @babel/runtime@7.0.0-beta.0 is installed, which means helpers introduced later than 7.0.0-beta.0 will be inlined instead of imported. + // See https://github.com/babel/babel/issues/10261 + // And https://github.com/facebook/docusaurus/pull/2111 + version = runtimeVersion } = options // resolve targets @@ -180,7 +187,9 @@ module.exports = (context, options = {}) => { helpers: useBuiltIns === 'usage', useESModules: !process.env.VUE_CLI_BABEL_TRANSPILE_MODULES, - absoluteRuntime + absoluteRuntime, + + version }]) return {