Babel 中文文档
  • 印记中文
  • 文档
  • 配置
  • 试用
  • 视频
  • 博客
  • 赞助
  • 团队
  • GitHub

›TC39 提案

扩展

  • React Plugin
  • Flow Plugin
  • Typescript Plugin

模块

  • AMD
  • Common JS
  • SystemJS
  • UMD

TC39 提案

  • async-do-expressions
  • decorators
  • do-expressions
  • export-default-from
  • function-bind
  • function-sent
  • partial-application
  • pipeline-operator
  • private-methods
  • record-and-tuple
  • throw-expressions

@babel/preset-env

    ES2022

    • class-properties
    • class-static-block
    • private-property-in-object
    • syntax-top-level-await

    ES2021

    • logical-assignment-operators
    • numeric-separator

    ES2020

    • export-namespace-from
    • nullish-coalescing-operator
    • optional-chaining
    • syntax-bigint
    • syntax-dynamic-import
    • syntax-import-meta

    ES2019

    • optional-catch-binding
    • json-strings

    ES2018

    • async-generator-functions
    • object-rest-spread
    • unicode-property-regex
    • dotall-regex
    • named-capturing-groups-regex

    ES2017

    • async-to-generator

    ES2016

    • exponentiation-operator

    ES2015

    • arrow-functions
    • block-scoping
    • classes
    • computed-properties
    • destructuring
    • duplicate-keys
    • for-of
    • function-name
    • instanceof
    • literals
    • new-target
    • object-super
    • parameters
    • shorthand-properties
    • spread
    • sticky-regex
    • template-literals
    • typeof-symbol
    • unicode-escapes
    • unicode-regex

    ES5

    • property-mutators

    ES3

    • member-expression-literals
    • property-literals
    • reserved-words
Edit

@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. 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.

// Status quo
console.log(
  chalk.dim(
    `$ ${Object.keys(envars)
      .map(envar => `${envar}=${envars[envar]}`)
      .join(' ')}`,
    'node',
    args.join(' ')
  )
);

// With pipes
Object.keys(envars)
  .map(envar => `${envar}=${envars[envar]}`)
  .join(' ')
  |> `$ ${^^}`
  |> chalk.dim(^^, 'node', args.join(' '))
  |> console.log(^^);

From jquery/src/core/init.js.

// Status quo
jQuery.merge( this, jQuery.parseHTML(
  match[ 1 ],
  context && context.nodeType ? context.ownerDocument || context : document,
  true
) );

// With pipes
context
  |> (^^ && ^^.nodeType ? ^^.ownerDocument || ^^ : document)
  |> jQuery.parseHTML(match[1], ^^, true)
  |> jQuery.merge(^^);

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

With a configuration file (recommended)

With ^^ topic token:

{
  "plugins": [
    ["@babel/plugin-proposal-pipeline-operator", { "topicToken": "^^" }]
  ]
}

With @@ topic token:

{
  "plugins": [
    ["@babel/plugin-proposal-pipeline-operator", { "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

With ^^ topic token:

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

With @@ topic token:

require("@babel/core").transformSync("code", {
  plugins: [
    [ "@babel/plugin-proposal-pipeline-operator", { topicToken: "@@" } ],
  ],
});
← partial-applicationprivate-methods →
  • Installation
  • Usage
    • Examples
    • With a configuration file (recommended)
    • Via CLI
    • Via Node API
Babel 中文文档
文档
学习 ES2015
社区
视频用户Stack OverflowSlack 频道Twitter
更多
博客GitHub 组织GitHub 仓库Website 仓库旧版网址 6.x旧版网址 5.x