File tree 2 files changed +24
-2
lines changed
packages/@vue/babel-preset-app
2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -125,3 +125,16 @@ test('jsx options', () => {
125
125
expect ( code ) . not . toMatch ( `var h = arguments[0]` )
126
126
expect ( code ) . toMatch ( `return h("div", ["bar"])` )
127
127
} )
128
+
129
+ test ( 'disable absoluteRuntime' , ( ) => {
130
+ const { code } = babel . transformSync ( `
131
+ const a = [...arr]
132
+ ` . trim ( ) , {
133
+ babelrc : false ,
134
+ presets : [ [ preset , {
135
+ absoluteRuntime : false
136
+ } ] ]
137
+ } )
138
+
139
+ expect ( code ) . toMatch ( 'import _toConsumableArray from "@babel/runtime-corejs2/helpers/esm/toConsumableArray"' )
140
+ } )
Original file line number Diff line number Diff line change @@ -51,7 +51,15 @@ module.exports = (context, options = {}) => {
51
51
shippedProposals,
52
52
forceAllTransforms,
53
53
decoratorsBeforeExport,
54
- decoratorsLegacy
54
+ decoratorsLegacy,
55
+
56
+ // Undocumented option of @babel /plugin-transform-runtime.
57
+ // When enabled, an absolute path is used when importing a runtime helper atfer tranforming.
58
+ // This ensures the transpiled file always use the runtime version required in this package.
59
+ // However, this may cause hash inconsitency if the project is moved to another directory.
60
+ // So here we allow user to explicit disable this option if hash consistency is a requirement
61
+ // and the runtime version is sure to be correct.
62
+ absoluteRuntime = path . dirname ( require . resolve ( '@babel/runtime/package.json' ) )
55
63
} = options
56
64
57
65
// resolve targets
@@ -146,7 +154,8 @@ module.exports = (context, options = {}) => {
146
154
corejs : ( useBuiltIns === 'usage' && ! process . env . VUE_CLI_MODERN_BUILD ) ? 2 : false ,
147
155
helpers : useBuiltIns === 'usage' ,
148
156
useESModules : ! process . env . VUE_CLI_BABEL_TRANSPILE_MODULES ,
149
- absoluteRuntime : path . dirname ( require . resolve ( '@babel/runtime/package.json' ) )
157
+
158
+ absoluteRuntime
150
159
} ] )
151
160
152
161
return {
You can’t perform that action at this time.
0 commit comments