Skip to main content

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

Installation

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

Usage

babel.config.json
{
"plugins": ["@babel/plugin-proposal-record-and-tuple"]
}

Via CLI

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

Via Node API

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

Options

importPolyfill

boolean, defaults to false.

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

JavaScript
let a = #[1, 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:

babel.config.json
{
"plugins": [
[
"@babel/plugin-proposal-record-and-tuple",
{
"importPolyfill": true
}
]
]
}
JavaScript
let a = #[1, 2, 3];

// ⬇ ⬇ ⬇ ⬇ ⬇ ⬇ ⬇ ⬇ ⬇ ⬇

import { Tuple as _Tuple } from "@bloomberg/record-tuple-polyfill";

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.