babel / website

:globe_with_meridians: The Babel documentation website
https://babeljs.io/docs/en/index.html
MIT License
749 stars 1.3k forks source link

REPL confusingly lists deprecated stage-x presets, stage-2 selected by default #2814

Open karyon opened 11 months ago

karyon commented 11 months ago

I've been confused again just now by stage-2 being selected by default. I'm wondering why is that even part of the REPL UI, given that these presets have been deprecated for five years now?

Backstory: Suppose I'm using preset-env with the default targets as recommended by the docs and want to quickly check how e.g. class properties are transpiled, so I go to https://babeljs.io/repl. I see that my class properties are transpiled, which is weird because they are not transpiled in my project. I notice the "presets" section lists some stage presets that I have never heard of, and stage-2 is enabled by default. Removing it makes the REPL work like I would expect. I wonder, maybe I should be using the stage-2 preset if it's the default in the REPL? I google it and find https://www.npmjs.com/package/@babel/preset-stage-2, which says "As of v7.0.0-beta.55, we've removed Babel's Stage presets. Please consider reading our blog post", and the blog post is from July 2018 and is all about why those stage-x presets shouldn't be used and are not shipped anymore. I wonder, maybe they didn't get around updating the website, but don't find any issue even talking about this, and I'm left very confused as to what is going on?

babel-bot commented 11 months ago

Hey @karyon! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

JLHwung commented 11 months ago

I agree that it could be confusing to users. Here I provide some context:

The current REPL was designed when stage-x presets were still a thing. Later we deprecated the preset in favor of preset-env but we didn't figure out a way to demonstrate Babel's ability to transform many ES proposals on REPL: So the stage-2 preset, as well as other stage presets become convenient toggles on REPL: They let you see how Babel transforms ES proposals like decorators, pipeline operators, records and tuples and so on, since they will not be covered by preset-env until they are advanced to stage 4.

karyon commented 11 months ago

I see. So first I thought that class fields were transpiled because the stage-x presets wasn't updated in five years, as the npm package turned up by the google search suggested. Your comment sounds like they are actually still updated with new proposals. Which made me wonder again, why are class fields transpiled even though they are in stage 4 by now? Looking at the code, it seems like proposals cannot be removed from the stage-x presets because that would be a breaking change, which is understandable but does not make sense in the context of the REPL and adds to the confusion there.

So I see multiple ways to fix my source of confusion:

If the stage-x presets are kept, what would also help: