@babel/plugin-proposal-record-and-tuple

Installation

  1. $ npm install --save-dev @babel/plugin-proposal-record-and-tuple

Usage

  1. {
  2. "plugins": ["@babel/plugin-proposal-record-and-tuple"]
  3. }

Via CLI

  1. $ babel --plugins @babel/plugin-proposal-record-and-tuple script.js

Via Node API

  1. require("@babel/core").transformSync("code", {
  2. plugins: [["@babel/plugin-proposal-record-and-tuple"]],
  3. });

Options

importPolyfill

boolean, defaults to false.

By default this plugin only transforms the proposal syntax, using the Record and Tuple globals:

  1. let a = #[1, 2, 3];
  2. // ⬇ ⬇ ⬇ ⬇ ⬇ ⬇ ⬇ ⬇ ⬇ ⬇
  3. let a = Tuple(1, 2, 3);

You either need to load a polyfill, or you can pass the "importPolyfill": true option to inject imports to @bloomberg/record-tuple-polyfill, maintained by the proposal authors:

  1. {
  2. "plugins": [
  3. [
  4. "@babel/plugin-proposal-record-and-tuple",
  5. {
  6. "importPolyfill": true
  7. }
  8. ]
  9. ]
  10. }
  1. let a = #[1, 2, 3];
  2. // ⬇ ⬇ ⬇ ⬇ ⬇ ⬇ ⬇ ⬇ ⬇ ⬇
  3. import { Tuple as _Tuple } from "@bloomberg/record-tuple-polyfill";
  4. let a = _Tuple(1, 2, 3);

Don’t forget to add @bloomberg/record-tuple-polyfill to your dependencies!

polyfillModuleName

string, defaults to "@bloomberg/record-tuple-polyfill".

If you wish to inject imports to a polyfill different from @bloomberg/record-tuple-polyfill, you can use this option to specify its name.