Towards plugin 1.0.0: BABLR as the Babel core #16302
Replies: 1 comment 1 reply
-
This proposal is very ambitious -- from your description it sounds like a complete rewrite of Babel. There have already been other attempts for tools that aim at doing "everything" (formatting, linting, transpilation), so I recommend taking a look at them if you haven't yet: https://biomejs.dev/, https://deno.com/. Given the complexity that this fundamental rewrite would bring, and that it would basically "reset" the project maturity/stability, I'm not convinced that this should be done as part of Babel and not as a separate project. There have already been multiple attempts at rewriting Babel (https://swc.rs/, https://sucrase.io/), and some of them have been moderately successful. That said, I also have some more specific questions:
The DOM is a (mutable) tree that can be accessed and modified with various utilities. It only conveys information about the code meaning, and not about how it's styled/formatted. Isn't the tree that
Note that TC39 already tried to standardize a tree format to represent code (https://github.com/tc39/proposal-binary-ast), but there has been a strong pushback to the idea of standardizing a different representation for JS.
Yeah I agree that this is a pain point. There is actually a way to use Babel for codemods (https://github.com/nicolo-ribaudo/codemods), but we should make it more official/accessible.
What do you mean by this? |
Beta Was this translation helpful? Give feedback.
-
Babel has several significant architectural problems that this proposal aims to address together:
@babel/traverse
API isn't semver-stable (1.0.0), so neither are pluginsI have attempted to address these issues by creating a new core architecture to replace
@babel/traverse
and ESTree. One of my goals is to create a complete new interoperability layer that will unify the core architecture of Babel, Prettier and ESLint.Since I'm suggesting a truly massive breaking change, I'm well aware that I would have to be offering a similarly huge expansion in capability and ease of use: people would have to want (badly) to migrate across such a breaking change. To do this I envision a complete new role for the combined tools: they would become your IDE! That is to say, your IDE's source of truth for the code on screen would actually be the exact same immutable tree structure used by Prettier and Babel. This code pattern is currently most well known for holding up the entire internet: it's the DOM.
So the proposal is this: give Babel a DOM layer, and design it so well that it's suitable to be shared between several tools and may even eventually be suitable for standardization by TC39.
Because my design was inspired by Babel for its inception, I chose the name BABLR as a mashup of Babel and ANTLR. To me it stands for Babel Ass-Backwards for Language Recognition, in honor of it's rather different control flow strategy: an inversion of Babel's. I've been working on this full time for two years now, and have been building the underlying OSS libraries like iter-tools (and the accompanying streaming regex engine) for even longer.
Beta Was this translation helpful? Give feedback.
All reactions