You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// For backward-compat with Babel 6, we allow sync transformation when
49
-
// no callback is given. Will be dropped in some future Babel major version.
50
48
if(callback===undefined){
51
-
returntransformFromAstRunner.sync(ast,code,opts);
49
+
if(process.env.BABEL_8_BREAKING){
50
+
thrownewError(
51
+
"Starting from Babel 8.0.0, the 'transformFromAst' function expects a callback. If you need to call it synchronously, please use 'transformFromAstSync'.",
52
+
);
53
+
}else{
54
+
// console.warn(
55
+
// "Starting from Babel 8.0.0, the 'transformFromAst' function will expect a callback. If you need to call it synchronously, please use 'transformFromAstSync'.",
`"Asynchronous function called without callback"`,
237
+
);
238
+
});
192
239
193
240
it("transformFileSync",function(){
194
241
constoptions={
@@ -201,10 +248,23 @@ describe("api", function () {
201
248
expect(options).toEqual({babelrc: false});
202
249
});
203
250
204
-
it("transformFromAst should not mutate the AST",function(){
251
+
(process.env.BABEL_8_BREAKING ? it : it.skip)(
252
+
"transformFromAst throws on undefined callback",
253
+
()=>{
254
+
constprogram="const identifier = 1";
255
+
constnode=parseSync(program);
256
+
expect(()=>
257
+
transformFromAst(node,program),
258
+
).toThrowErrorMatchingInlineSnapshot(
259
+
`"Starting from Babel 8.0.0, the 'transformFromAst' function expects a callback. If you need to call it synchronously, please use 'transformFromAstSync'."`,
260
+
);
261
+
},
262
+
);
263
+
264
+
it("transformFromAstSync should not mutate the AST",function(){
205
265
constprogram="const identifier = 1";
206
-
constnode=parse(program);
207
-
const{ code }=transformFromAst(node,program,{
266
+
constnode=parseSync(program);
267
+
const{ code }=transformFromAstSync(node,program,{
208
268
plugins: [
209
269
function(){
210
270
return{
@@ -225,10 +285,10 @@ describe("api", function () {
225
285
);
226
286
});
227
287
228
-
it("transformFromAst should mutate the AST when cloneInputAst is false",function(){
288
+
it("transformFromAstSync should mutate the AST when cloneInputAst is false",function(){
'function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }',
0 commit comments