Skip to content
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

[smart pipes] Add support for question-mark tokens #9209

Closed
wants to merge 8 commits into from
Closed

[smart pipes] Add support for question-mark tokens #9209

wants to merge 8 commits into from

Conversation

js-choi
Copy link
Contributor

@js-choi js-choi commented Dec 19, 2018

Q                       A
Fixed Issues? No
Patch: Bug Fix? No
Major: Breaking Change? No
Minor: New Feature? Yes
Tests Added + Pass? Yes
Documentation PR Link [pending on 7.2.0 docs]
Any Dependency Changes? No
License MIT

This pull request builds on #8289, which initially implemented parsing of the stage-0 smart-pipeline proposal. #8289 uses # as its “topic token” (aka the “placeholder token”), but this is only a preliminary choice, and the actual token has not yet been actually decided. This present pull request adds support for switching to the question mark ? as the topic token using a new topicToken configuration option on the pipelineOperator parser plugin. Future pull requests will add support for other good possibilities, namely % and @.

See also #9122 and #9179. CC @mAAdhaTTah, @littledan, @thiagoarrais.

@nicolo-ribaudo nicolo-ribaudo added PR: New Feature 🚀 A type of pull request used for our changelog categories pkg: parser Spec: Pipeline Operator labels Dec 19, 2018
@nicolo-ribaudo nicolo-ribaudo added this to In progress in Pipeline Operator via automation Dec 19, 2018
@thiagoarrais
Copy link
Contributor

You might want to update babel-generator too. It currently hardcodes # as the topic token.

The relevant code is at types.js/PipelinePrimaryTopicReference.

@js-choi
Copy link
Contributor Author

js-choi commented Dec 19, 2018

Will do. Thanks for the heads up.

@js-choi
Copy link
Contributor Author

js-choi commented Dec 19, 2018

On the other hand, it might be worth implementing generator support in a separate pull request, since, to my understanding, babel-generator is decoupled from babel-parser. I’ll work on it later today, in any case.

@js-choi
Copy link
Contributor Author

js-choi commented Dec 20, 2018

How should the configuration option for generated topic tokens (default # but also may be ?) be designed? There doesn’t seem to be a plugin-option system in babel-generator, unlike babel-parser and the transform plugins.

@nicolo-ribaudo
Copy link
Member

You can add a top-level option, like I did for decorators:

decoratorsBeforeExport: !!opts.decoratorsBeforeExport,

I understand that this is sub-optimal, but @babel/generator has just a few options and is almost never used directly, so a plugin system might be overkill.

const pluginConfigurationTopicToken = this.getPluginOption(
"pipelineOperator",
"topicToken",
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a parameter to the getPluginOption function for the default value? Then it would be enough to do

this.getPluginOption("pipelineOperator", "topicToken", "#") !== topicToken

and it wouldn't be necessary to use this separate function (that check could directly go in the if statement).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood; I’ll replace this.

// Returns the value of the pipelineOperator plugin's topicToken configuration option.

getPipelineOperatorPluginTopicTokenOption(): ?string {
return this.getPluginOption("pipelineOperator", "topicToken");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that having functions like this one is overkill: it has a name so long that it doesn't gain anything in readability neither in typing. Also, the name is basically the same as getPluginOption("pipelineOperator", "topicToken") but with less punctation, it doesn't abstract anything more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood; I’ll inline this.

@js-choi
Copy link
Contributor Author

js-choi commented Dec 23, 2018

You can add a top-level option, like I did for decorators:

babel/packages/babel-generator/src/index.js
Line 55 in c586d4e
decoratorsBeforeExport: !!opts.decoratorsBeforeExport,
I understand that this is sub-optimal, but @babel/generator has just a few options and is almost never used directly, so a plugin system might be overkill.

Yes, sounds good. Should I put this functionality in this pull request, or should I put it in a new pull request?

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Dec 23, 2018

Yes please! 👍

EDIT: I just noticed that "Yes" isn't an answer to your question lol. It is ok to put it in this pull request.

@JLHwung
Copy link
Contributor

JLHwung commented May 19, 2021

Closing this as the smart pipeline proposal is not proposed. As of May 2021, the smart pipeline is replaced by hack pipeline. See also #13191.

@JLHwung JLHwung closed this May 19, 2021
Pipeline Operator automation moved this from In progress to Done May 19, 2021
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Aug 24, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: New Feature 🚀 A type of pull request used for our changelog categories Spec: Pipeline Operator
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants