@babel/plugin-proposal-pipeline-operator

Installation

  1. $ 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. Its value is "hack" by default.

ValueProposalVersion added
“minimal”Minimal F#-style pipesv7.0.0
“fsharp”F#-style pipes with awaitv7.5.0
“hack”Hack-style pipesv7.15.0
“smart”Smart-mix pipes (deprecated)v7.3.0

If "proposal" is omitted, or if "proposal": "hack" is used, then a "topicToken": "^^", "topicToken": "^", or "topicToken": "#" option must also be included.

The "proposal": "minimal", "fsharp", and "smart" options are deprecated and subject to removal in a future major version.

Examples

The following examples use topicToken: "^^".

From react/scripts/jest/jest-cli.js.

  1. // Status quo
  2. console.log(
  3. chalk.dim(
  4. `$ ${Object.keys(envars)
  5. .map(envar => `${envar}=${envars[envar]}`)
  6. .join(' ')}`,
  7. 'node',
  8. args.join(' ')
  9. )
  10. );
  11. // With pipes
  12. Object.keys(envars)
  13. .map(envar => `${envar}=${envars[envar]}`)
  14. .join(' ')
  15. |> `$ ${^^}`
  16. |> chalk.dim(^^, 'node', args.join(' '))
  17. |> console.log(^^);

From jquery/src/core/init.js.

  1. // Status quo
  2. jQuery.merge( this, jQuery.parseHTML(
  3. match[ 1 ],
  4. context && context.nodeType ? context.ownerDocument || context : document,
  5. true
  6. ) );
  7. // With pipes
  8. context
  9. |> (^^ && ^^.nodeType ? ^^.ownerDocument || ^^ : document)
  10. |> jQuery.parseHTML(match[1], ^^, true)
  11. |> jQuery.merge(^^);

(For a summary of deprecated proposal modes’ behavior, see the pipe wiki’s table of previous proposals.)

With ^^ topic token:

  1. {
  2. "plugins": [
  3. ["@babel/plugin-proposal-pipeline-operator", { "topicToken": "^^" }]
  4. ]
  5. }

With @@ topic token:

  1. {
  2. "plugins": [
  3. ["@babel/plugin-proposal-pipeline-operator", { "topicToken": "@@" }]
  4. ]
  5. }

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

With ^^ topic token:

  1. require("@babel/core").transformSync("code", {
  2. plugins: [
  3. [ "@babel/plugin-proposal-pipeline-operator", { topicToken: "^^" } ],
  4. ],
  5. });

With @@ topic token:

  1. require("@babel/core").transformSync("code", {
  2. plugins: [
  3. [ "@babel/plugin-proposal-pipeline-operator", { topicToken: "@@" } ],
  4. ],
  5. });