Skip to content

Commit 5615e1b

Browse files
committed
feat: specify babel runtime version
1 parent 4087220 commit 5615e1b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

+11-2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ module.exports = (context, options = {}) => {
5353
}
5454

5555
const runtimePath = path.dirname(require.resolve('@babel/runtime/package.json'))
56+
const runtimeVersion = require('@babel/runtime/package.json').version
5657
const {
5758
polyfills: userPolyfills,
5859
loose = false,
@@ -78,7 +79,13 @@ module.exports = (context, options = {}) => {
7879
// However, this may cause hash inconsistency if the project is moved to another directory.
7980
// So here we allow user to explicit disable this option if hash consistency is a requirement
8081
// and the runtime version is sure to be correct.
81-
absoluteRuntime = runtimePath
82+
absoluteRuntime = runtimePath,
83+
84+
// https://babeljs.io/docs/en/babel-plugin-transform-runtime#version
85+
// 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.
86+
// See https://github.com/babel/babel/issues/10261
87+
// And https://github.com/facebook/docusaurus/pull/2111
88+
version = runtimeVersion
8289
} = options
8390

8491
// resolve targets
@@ -180,7 +187,9 @@ module.exports = (context, options = {}) => {
180187
helpers: useBuiltIns === 'usage',
181188
useESModules: !process.env.VUE_CLI_BABEL_TRANSPILE_MODULES,
182189

183-
absoluteRuntime
190+
absoluteRuntime,
191+
192+
version
184193
}])
185194

186195
return {

0 commit comments

Comments
 (0)