Skip to content

Disallow babel.transformFromAst synchronously#11110

Closed
Pranav2612000 wants to merge 2 commits into
babel:next-8-devfrom
Pranav2612000:next-8-dev
Closed

Disallow babel.transformFromAst synchronously#11110
Pranav2612000 wants to merge 2 commits into
babel:next-8-devfrom
Pranav2612000:next-8-dev

Conversation

@Pranav2612000
Copy link
Copy Markdown
Contributor

Q                       A
Fixed Issues? Part of Babel 8 Release plan
Patch: Bug Fix?
Major: Breaking Change? Yes
Minor: New Feature?
Tests Added + Pass? No
Documentation PR Link
Any Dependency Changes? No
License MIT

Allows babel.transformFromAst to run only asynchronously by removing the part of the code required for running it synchronously i.e. with callback functions.

Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good 👍

@nicolo-ribaudo nicolo-ribaudo mentioned this pull request Feb 9, 2020
34 tasks
@Pranav2612000
Copy link
Copy Markdown
Contributor Author

Yeah! Sure, just wanted to check if this is the right way to go?
I'll do the same thing for the other functions and add a appropriate error message. Any other changes I should consider?

@Pranav2612000
Copy link
Copy Markdown
Contributor Author

Going ahead with doing the same procedure for the other functions.

@nicolo-ribaudo nicolo-ribaudo added pkg: core PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release labels Feb 12, 2020
@nicolo-ribaudo nicolo-ribaudo added this to the Babel 8.x milestone Feb 12, 2020
Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you delete this line? Otherwise transformFile is declared twice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Thanks.

@JLHwung JLHwung removed this from the Babel 8.0 milestone Jan 28, 2021
@github-actions github-actions Bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 5, 2022
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: core PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants