@babel/plugin-proposal-pipeline-operator
Installation
$ npm install --save-dev @babel/plugin-proposal-pipeline-operator
Usage
The pipeline operator has several competing proposals.
Configure which proposal to use with the required "proposal"
option.
Value | Proposal | Version added |
---|---|---|
"minimal" | Minimal F#-style pipes | v7.0.0 |
"fsharp" | F#-style pipes with await | v7.5.0 |
"hack" | Hack-style pipes | v7.15.0 |
"smart" | Smart-mix pipes (deprecated) | v7.3.0 |
If "proposal": "hack"
is used, then a "topicToken": "%"
or "topicToken": "#"
option must also be included.
The "proposal": "smart"
option is deprecated and subject to removal in a future major version.
When TC39 accepts one of the proposals, that proposal will become the default and the "proposal"
option will no longer be required.
Summary of proposals’ behavior
Original expression |
Minimal F# pipes |
F# pipes with |
Hack pipes |
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Not supported |
|
|
|
Not supported | Not supported |
|
With a configuration file (Recommended)
For minimal F# pipes:
{
"plugins": [
["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }]
]
}
For F# pipes with await
:
{
"plugins": [
["@babel/plugin-proposal-pipeline-operator", { "proposal": "fsharp" }]
]
}
For Hack pipes with %
topic token:
{
"plugins": [
["@babel/plugin-proposal-pipeline-operator", { "proposal": "hack", "topicToken": "%" }]
]
}
For Hack pipes with #
topic token:
{
"plugins": [
["@babel/plugin-proposal-pipeline-operator", { "proposal": "hack", "topicToken": "#" }]
]
}
Via CLI
Because this plugin requires a configuration option, it cannot be directly configured from the CLI. Use a config file instead with the CLI, to add and configure this plugin.
Via Node API
For minimal F# pipes{proposal: "minimal"}
:
require("@babel/core").transformSync("code", {
plugins: [
[ "@babel/plugin-proposal-pipeline-operator", { proposal: "minimal" } ],
],
});
For F# pipes with await
:
require("@babel/core").transformSync("code", {
plugins: [
[ "@babel/plugin-proposal-pipeline-operator", { proposal: "fsharp" } ],
],
});
For Hack pipes with %
topic token:
require("@babel/core").transformSync("code", {
plugins: [
[ "@babel/plugin-proposal-pipeline-operator", { proposal: "hack", topicToken: "%" } ],
],
});
For Hack pipes with #
topic token:
require("@babel/core").transformSync("code", {
plugins: [
[ "@babel/plugin-proposal-pipeline-operator", { proposal: "hack", topicToken: "#" } ],
],
});