-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move stable ECMAScript plugins to @babel/core
#10
base: main
Are you sure you want to change the base?
Conversation
489ec45
to
a9c8ab3
Compare
|
||
We can introduce a new protocol similar to `module:`: | ||
|
||
- `internal:[feature]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it should be builtin:[feature]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To minimize the adoption friction, I propose we implement its opposite: "external:"
, which means always check node modules instead of builtin plugins in @babel/core
.
So, if users upgrade from @babel/core
from 8.x to 8.y, they don't have to modify their config to opt in the builtin plugins. And for some users, their Babel config is inside node_modules which make it harder to edit, and they have to wait for the whole ecosystem to migrate to builtin plugins.
This happens whenever a stage 3 feature gets advanced. Therefore I suggest we implement "external:[feature]"
instead, users can opt out to the builtin features if they strongly prefer the unmaintained archived versions over the built-in version in @babel/core
, but then they have to modify the config or lock the @babel/core
versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I have thought for a while about this, but I still prefer internal:
for a few reasons:
- Completely changing the resolution process for a specific plugin in version can cause confusion: we already have multiple ways of specifying plugins, that are then normalized/resolved, but at least they are deterministic. I would prefer avoiding one that depends on which specific
@babel/core
version. - When a proposal becomes standard, we want to rename it from
-proposal-
to-transform-
. We have not done this in Babel 8 to avoid renaming the package, and it has caused confusion. - I don't think that "being stuck on an older version" is too bad: usually changes to plugins are minimal once they become standard.
- If we want the "automatic migration" to happen, whenever we move a plugin to
@babel/core
we can release a new version of the-proposal-
plugin that starts like this:and we can thus still easily provide the "automatically use the internal plugin" behavior.if (api.version >= 7.x.y) return { inherits: "internal:name-of-the-internal-plugin" };
Here is my comments on this RFC: Also rename plugins to
|
a9c8ab3
to
b29cc12
Compare
b29cc12
to
ec11d33
Compare
I made different updates to the RFC, mostly integrating @JLHwung's feedback and with some additional thoughts I've had during the past year. I force-pushed, but you can see the diff in the first file of I am interested on restarting to work on this RFC. |
I'm starting to work on this, to see how it looks in practice when implemented. Please review this RFC and give your opinion! |
I prefer to keep it as it is now.
👍Looking forward to this very much! As for the others, to be honest, I am not familiar with them, so I cannot comment. |
From @liuxingbaoyu
|
The end goal is to eventually move to a model where, if a user only wants to use standard JavaScript features, they have to install a single package (#3). This may seem like a step back towards what Babel 5 was, except that we still internally maintain the current plugin-based flexibility and we still have all the advantages that the Babel 6 model (when we first split the single big package into many plugins and presets) has. Ideally, users with "standard" setups would only have to install Babel and create a
While it's true that a big part of changes happen in the "it's a proposal" phase, we still actively maintain many plugins for stable features. They are riskier when it comes to backward compat with It's true that TS fixed&features often want newer version of
When a package reaches Stage 4 (and starting from Babel 8), we would simply copy-paste its code into a sub-folder in Hopefully I have clarified some things, I can remove the PR from the 7.21.0 milestone if you want more time to discuss it :) |
This definitely makes sense (maybe it's worth releasing a new package? Not
I am wondering if there is any way to make ts and other plugins also benefit.
I don't want to block it, because it's an improvement anyway, and it seems reasonable to accept it in the absence of a better solution, in my opinion. By the way, I want to keep the layout of the monorepo even if we don't publish them anymore. The current layout is more convenient for development in my opinion. : ) |
I agree. We can mark mature plugin as private and bundle |
It think this proposal risks damaging the stability integrity, and independence of the babel core. Before your incentives were to build a stable independent core that could work equally well for everyone, because that would be the only way for your to ship your own functionality in a stable, sustainable way. Babel would be removing the requirement that it serve everyone else's needs in order to serve its own. Instead of being incentivized to maintain stable core APIs, the project will instead be incentivized to maintain stable core transformation semantics because those are the semantics you'd be (more) committed to not breaking as opposed to the API semantics. I actually already think that Babel's monorepo already exposes it to this problem, as it's trivial to change a definition in core APIs and (seemingly) change all usages as well in a single PR. This leads people not to think about the real relationships between the independent parts as you can always just change everything at once, without even needing to consider the state where the core is ahead of (and incompatible with) the current plugins! |
View Rendered Text
I wrote this RFC as an attempt to solve the "how do we make sure that plugins are compatible with older
@babel/core
versions" problem.This change should be transparent to most of our users, but I decided to open an RFC since it changes our monorepo structure a lot (it would remove about half of the packages).
This is another step towards #3, even if it was not my goal when writing this RFC.