Skip to content

New plugin for pipeline operator proposal#3159

Closed
gilbert wants to merge 1 commit intobabel:masterfrom
gilbert:pipeline-operator
Closed

New plugin for pipeline operator proposal#3159
gilbert wants to merge 1 commit intobabel:masterfrom
gilbert:pipeline-operator

Conversation

@gilbert
Copy link
Copy Markdown
Contributor

@gilbert gilbert commented Dec 12, 2015

First let me say I am not suggesting this be merged in as a stage 0 plugin. I only want others to have the ability to try out (via an explicit flag) an ES.next proposal that has clear interest in the community, via everyone's favorite JavaScript compiler.

At the very least, perhaps this PR can open the discussion topic, "what can Babel do to support plugins like this one as standalone plugins?"

Thanks for reading.

@jamiebuilds
Copy link
Copy Markdown
Contributor

I'm against merging this into Babel until the proposal progresses further. I would like to see this end up in https://github.com/tc39/ecma262/blob/master/stage0.md first.

Until then, I'm happy to leave this one open.

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.

Normally this would be path.replaceWith(t.callExpression(path.node.right, [path.node.left]));

@gilbert
Copy link
Copy Markdown
Contributor Author

gilbert commented Dec 12, 2015

@loganfsmyth Updated. Thanks for the code review :)

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.

of -> of the? to be consistent with Allow parsing of the pipeline operator in the package.json description?

@gilbert
Copy link
Copy Markdown
Contributor Author

gilbert commented Dec 13, 2015

@hzoo Oh hmm, could you explain the relationship between plugins and babel's versioning?

@loganfsmyth
Copy link
Copy Markdown
Member

@mindeavor Just to be clear, I don't support landing this PR until it has an official proposal, I just reviewed it so it's consistent if we di land it in the future.

To answer your question, all Babel 6 plugins in code and currently compiled using Babel 5, that means that they all depend on [email protected].

@sebmck
Copy link
Copy Markdown
Contributor

sebmck commented Dec 14, 2015

I haven't reviewed the code but this isn't going to be merged until it has a TC39 champion and has been or is going to be presented to the committee. If in the future there's no signs of the committee ever accepting this then it'll be closed. Nonetheless, thanks for doing this! Just wanted to be explicit so there's no surprises down the line.

@gilbert
Copy link
Copy Markdown
Contributor Author

gilbert commented Dec 14, 2015

Understandable. For the record, is it accurate to say there is no way for others to try out the proposal other than forking babel or using / writing another transpiler?

@hzoo
Copy link
Copy Markdown
Member

hzoo commented Dec 14, 2015

You can publish the plugins standalone on npm but would also need to publish a new babylon version for the parser changes

@sebmck
Copy link
Copy Markdown
Contributor

sebmck commented Jan 6, 2016

Has there been any progress in getting a TC39 champion? If not this will be closed.

@KiaraGrouwstra
Copy link
Copy Markdown

I'm curious, did TC39 members turn out reluctant or was there no good place to pitch them ideas?

Edit: I just realized there is esdiscuss, though I haven't seen a corresponding thread on there. Had you considered this, @mindeavor?

@tlvenn
Copy link
Copy Markdown

tlvenn commented Sep 22, 2016

Hi @kittens, I totally understand why you dont want to merge this PR but at the very least, I believe it's reasonable to ask that the parser should be enhanced so that both |> and <| can be matched and used by any plugin.

If anything, Babel should help people be creative and experiment ideas...

@TehShrike
Copy link
Copy Markdown

@tlvenn you can feel free to discuss the left-facing operator at tc39/proposal-pipeline-operator#3 - I personally don't feel it's necessary, but that's no reason not to make an argument for it.

@tlvenn
Copy link
Copy Markdown

tlvenn commented Sep 22, 2016

Hi @TehShrike, I am not trying to debate here on the semantic of what that operator should or should not do, I am just trying to argue that Babel should let people use it, the way they want, if they wish to. And by using it, I mean developing a plugin that would match on that operator and do something.

@tlvenn
Copy link
Copy Markdown

tlvenn commented Sep 22, 2016

Just for reference, right now, people end up overloading existing operators such as | and >> which is far from ideal.

@hzoo
Copy link
Copy Markdown
Member

hzoo commented Sep 26, 2016

Going to close for now, (also babylon moved out to another repo in the meantime)

@hzoo hzoo closed this Sep 26, 2016
@loganfsmyth
Copy link
Copy Markdown
Member

@tlvenn

I am just trying to argue that Babel should let people use it, the way they want, if they wish to. And by using it, I mean developing a plugin that would match on that operator and do something.

Unfortunately that is much easier said than done. Keep in mind the request here isn't just "add this operator", it's "add this operator and support it from now on", which isn't something we generally do until something is officially stage 0.

Alternatively "support a framework for third-party plugins" sounds awesome, but unless you can tell me a way to do with without severely hindering out ability to maintain Babel as a whole, it won't happen any time soon.

@tlvenn
Copy link
Copy Markdown

tlvenn commented Sep 27, 2016

Hi @loganfsmyth, like i said above, i totally agree that the current PR cant be merged and the issue should be closed. However I do believe it highlights one issue with the parser given it cant properly parse |> at the moment and that is something that should be addressed.

Thanks for pointing out that the parser now lives in its own repo @hzoo , I guess it makes things even easier.

@mindeavor would you mind creating a PR on the babylon repo in order to allow it to properly parse both <| and |> ?

@loganfsmyth
Copy link
Copy Markdown
Member

i totally agree that the current PR cant be merged

would you mind creating a PR on the babylon

Those are conflicting statements. The parser is a different repo, but the policy is still the same.

@tlvenn
Copy link
Copy Markdown

tlvenn commented Sep 27, 2016

I fail to see how it's a conflicting statement ? I am only asking that the parser can properly match on |> with no behaviour whatsoever...

So that the community can be free of creating babel plugins that can use |> as an operator for whatever transformation they want.

@hzoo
Copy link
Copy Markdown
Member

hzoo commented Sep 27, 2016

I think it would be because

I am only asking that the parser can properly match on |> with no behaviour whatsoever...

Asking that the parser match on it is the same thing as supporting it. It should error because it's not valid javascript or a stage-0 proposal.

Workaround is to use overload currently valid symbols like mentioned or do make a syntax extension yourself by forking babylon atm.

@jamiebuilds
Copy link
Copy Markdown
Contributor

Babel/Babylon has a certain responsibility to limit the scope of what we allow to be parsed. Babel has found itself as part of the standards process and used by tens of thousands of developers. If we add lots of different grammars that are unstandardized we can quickly find ourselves in a bad place where we have to make breaking changes to Babel in order to keep up with diverging standards.

This may seem hypocritical because we support for JSX and Flow. However, both of those are so mainstream that the TC39 would already have to consult the creators and consider them as part of the standards process if they were to ever try to standardize them. Luckily the people who created JSX and Flow are on TC39.

I understand that people want to use Babel for experimentation. It's how Babel was born to begin with. However, you're encouraged to fork Babel and/or Babylon and experiment on your own. We can't burden the community with every grammar idea that people come up with.

@tlvenn
Copy link
Copy Markdown

tlvenn commented Sep 27, 2016

Thanks for taking the time to elaborate and clarify on where Babel stands @thejameskyle.

It's a little bit sad to hear because making it easy for people to prototype and share potential future javascript syntax improvements seemed like part of the core goals of Babel initially and it has been lost along the way.

The sharing part is the missing piece right now and it would be great if Babel would at the very least, make it easy to plug a custom parser / a fork of babylon.

@loganfsmyth
Copy link
Copy Markdown
Member

Keep in mind that we're generally willing to accept someone once it is officially stage 0. There aren't a lot of requirements for that, https://tc39.github.io/process-document/, but it does mean that there there needs to be some kind of indication that it would be considered as possible for the language. The syntax doesn't need to be perfect, but if it can't get to stage 0, there is little chance of it making it into the language, and if that's the case, adding it to Babylon would mean we're essentially maintaining a fork of JS indefinitely.

People can absolutely use Babel as a testbed for new features so that people making proposals can validate their ideas, and that's exactly what this PR is, which is awesome. At the moment though, we're not aiming to be a perfectly pluggable system for entirely arbitrary syntax. Maybe one day, but we've got enough bugs with the system as it is, trying to maintain a syntax plugin system on top of that would likely to too much for us at this point.

@hzoo
Copy link
Copy Markdown
Member

hzoo commented Sep 27, 2016

@tlvenn with #3561 you can pass a different parser/generator

@tlvenn
Copy link
Copy Markdown

tlvenn commented Sep 27, 2016

@loganfsmyth Ya issue is as someone pointed out on twitter recently if you're on tc39, almost any idea you have can be stage0. not on tc39, huge uphill just to get to stage0. Even being "proposed" is a big step, since u have to get a champion. most ideas struggle there. huge member advantage.

@hzoo Thanks for the PR link, exactly what I was looking for !

@jridgewell jridgewell mentioned this pull request Sep 29, 2017
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 7, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: experimental outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: New Feature 🚀 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants