@babel/plugin-transform-literals
信息
此插件包含在 @babel/preset-env
中
示例
输入
JavaScript
var b = 0b11; // binary integer literal
var o = 0o7; // octal integer literal
const u = "Hello\u{000A}\u{0009}!"; // unicode string literals, newline and tab
输出
JavaScript
var b = 3; // binary integer literal
var o = 7; // octal integer literal
const u = "Hello\n\t!"; // unicode string literals, newline and tab
安装
- npm
- Yarn
- pnpm
npm install --save-dev @babel/plugin-transform-literals
yarn add --dev @babel/plugin-transform-literals
pnpm add --save-dev @babel/plugin-transform-literals
用法
使用配置文件(推荐)
babel.config.json
{
"plugins": ["@babel/plugin-transform-literals"]
}
通过 CLI
Shell
babel --plugins @babel/plugin-transform-literals script.js
通过 Node API
JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-transform-literals"],
});