What is @babel/plugin-syntax-bigint?
The @babel/plugin-syntax-bigint package allows Babel to parse code that contains the BigInt syntax. BigInt is a built-in object in JavaScript that provides a way to represent whole numbers larger than 2^53 - 1, which is the largest number JavaScript can reliably represent with the Number primitive. This plugin does not transform BigInt syntax, it only enables the parsing of it.
What are @babel/plugin-syntax-bigint's main functionalities?
BigInt Syntax Parsing
This code demonstrates how a BigInt value is defined using the 'n' suffix. The plugin allows Babel to understand this syntax when parsing the code.
const bigIntValue = 123n;
Other packages similar to @babel/plugin-syntax-bigint
babel-plugin-transform-builtin-extend
This plugin allows Babel to transform the extension of built-in classes, such as Error, Array, and others. While it does not directly deal with BigInt, it is similar in the sense that it extends the capabilities of Babel regarding the handling of built-in features.
@babel/plugin-syntax-bigint
Allow parsing of BigInt literals.
Installation
npm install --save-dev @babel/plugin-syntax-bigint
Usage
Via .babelrc
(Recommended)
.babelrc
{
"plugins": ["@babel/plugin-syntax-bigint"]
}
Via CLI
babel --plugins @babel/plugin-syntax-bigint script.js
Via Node API
require("babel-core").transform("code", {
plugins: ["@babel/plugin-syntax-bigint"]
});