@babel/plugin-syntax-bigint
info
这个插件包含在 @babel/preset-env 中,在 ES2020 中
note
仅语法
🌐 Syntax only
这个插件只启用对这个功能的解析。Babel 不支持转换 BigInt。一个建议是使用 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
- Yarn
- pnpm
- Bun
npm install --save-dev @babel/plugin-syntax-bigint
yarn add --dev @babel/plugin-syntax-bigint
pnpm add --save-dev @babel/plugin-syntax-bigint
bun add --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