Disallow babel.transformFromAst synchronously#11110
Conversation
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
Could you also update the other functions, like transformFile?
| // For backward-compat with Babel 6, we allow sync transformation when | ||
| // no callback is given. Will be dropped in some future Babel major version. | ||
| if (callback === undefined) { | ||
| return transformFromAstRunner.sync(ast, code, opts); |
There was a problem hiding this comment.
Maybe we could throw a nice error message, like Starting from Babel 8.0.0, the 'transformFromAst' function expects a callback. If you need to call it synchronously, please use 'transformFromAstSync' instead..
There was a problem hiding this comment.
How does this look?
if (callback === undefined) {
throw new Error(
"Starting from Babel 8.0.0, the 'transformFromAst' function expects a callback. If you
need to call it synchronously, please use 'transformFromAstSync",
);
}
I'll push the changes once you approve.
|
Yeah! Sure, just wanted to check if this is the right way to go? |
|
Going ahead with doing the same procedure for the other functions. |
841eb89 to
e309c5d
Compare
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
I have rebased your branch on the latest next-8-dev. Please run git fetch && git reset --hard origin/next-8-dev before doing any change!
| transformFileRunner.errback(code, opts, callback); | ||
| }: Function); | ||
|
|
||
| export const transformFile: TransformFile = transformFileRunner.errback; |
There was a problem hiding this comment.
Can you delete this line? Otherwise transformFile is declared twice.
Allows babel.transformFromAst to run only asynchronously by removing the part of the code required for running it synchronously i.e. with callback functions.