@babel/preset-stage-3
🌐 For upgrade instructions, see the README. :::
第三阶段的要点是:
🌐 The gist of Stage 3 is:
阶段 3:候选阶段
它是什么? 这个提案大部分已经完成,现在需要实现者和用户的反馈才能进一步推进。
要求是什么? 规范文本必须完整。指定的审阅者(由 TC39 任命,而不是由发起人指定)以及 ECMAScript 规范编辑必须批准规范文本。必须至少有两个符合规范的实现(不需要默认启用)。
接下来呢? 从现在起,修改只应针对实现及其使用中提出的关键问题进行。
安装
🌐 Install
- npm
- Yarn
- pnpm
- Bun
npm install --save-dev @babel/preset-stage-3
yarn add --dev @babel/preset-stage-3
pnpm add --save-dev @babel/preset-stage-3
bun add --dev @babel/preset-stage-3
用法
🌐 Usage
使用配置文件(推荐)
🌐 With a configuration file (Recommended)
babel.config.json
{
"presets": ["@babel/preset-stage-3"]
}
通过 CLI
🌐 Via CLI
Shell
babel script.js --presets @babel/preset-stage-3
通过 Node API
🌐 Via Node API
JavaScript
require("@babel/core").transformSync("code", {
presets: ["@babel/preset-stage-3"]
});
选项
🌐 Options
loose
boolean,默认值为 false。
为这个预设中允许的任何插件启用“宽松”转换。
🌐 Enable "loose" transformations for any plugins in this preset that allow them.
useBuiltIns
boolean,默认值为 false。
会使用原生内置功能,而不是为任何需要它的插件尝试填补行为。
🌐 Will use the native built-in instead of trying to polyfill behavior for any plugins that require one.
你可以在这里阅读更多关于配置预设选项的信息
参考
🌐 References
- Axel Rauschmayer 在《探索 ES2016 和 ES2017》中的《ECMAScript 特性的 TC39 流程》一章