Skip to main content

@babel/plugin-syntax-bigint

信息

此插件包含在 @babel/preset-env 中,在 ES2020

¥This plugin is included in @babel/preset-env, in ES2020

注意

仅语法

¥Syntax only

此插件仅启用对此功能的解析。Babel 不支持转换 BigInts。一个建议是使用 JSBI 库并最终运行 babel-plugin-transform-jsbi-to-bigint 以在将来将其代码修改为 BigInt。

¥This plugin only enables parsing of this feature. Babel doesn't support transforming BigInts. One recommendation is to use the JSBI library and eventually run babel-plugin-transform-jsbi-to-bigint to codemod it to BigInt in the future.

安装

¥Installation

npm install --save-dev @babel/plugin-syntax-bigint

用法

¥Usage

¥With a configuration file (Recommended)

babel.config.json
{
"plugins": ["@babel/plugin-syntax-bigint"]
}

通过 CLI

¥Via CLI

Shell
babel --plugins @babel/plugin-syntax-bigint script.js

通过 Node API

¥Via Node API

JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-syntax-bigint"],
});

参考

¥References