-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Drop support for Babel AST #20095
Copy link
Copy link
Open
Labels
lang:javascriptIssues affecting JSIssues affecting JSstatus:needs discussionIssues needing discussion and a decision to be made before action can be takenIssues needing discussion and a decision to be made before action can be takentype:refactorIssues about tackling technical debtIssues about tackling technical debt
Milestone
Description
Activity
Metadata
Metadata
Assignees
Labels
lang:javascriptIssues affecting JSIssues affecting JSstatus:needs discussionIssues needing discussion and a decision to be made before action can be takenIssues needing discussion and a decision to be made before action can be takentype:refactorIssues about tackling technical debtIssues about tackling technical debt
Currently, we support both Babel and ESTree AST.
The difference can be found here https://babeljs.io/docs/babel-parser#output
Supporting both AST shapes increases maintenance costs.
For example,
ChainExpressionwas not supported for a long time, it was first transformed to Babel AST.Later, in #15806, we skipped
ChainExpressioneverywhere; the approach doesn't end well, and it caused problems.At last, we brought
ChainExpressionback in #16471 (issue, fixed in multiple PRs), but added lots of code for different ASTs.My idea is to drop support for Babel AST in v4. Not doing this in a minor version since we have
formatAST, this can break it. We also havebabel-flowparser, which is not maintained; we don't want to deal with possible changes to it.If we decide to remove it completely, it will be easier for us to maintain, and since we already tested '__babel_estree' parser, it shouldn't cause problems.
Even if we still want support Babel AST in
formatAST, we can add a layer to transform the Babel AST to ESTree AST; luckily, it's easy to distinguish: in Babel AST the root node isFileandProgramin ESTree.