@babel/preset-stage-0

中文文档
7.8.3发布于 2020/01/14MITCommonJS零依赖近 30 天下载 27.9万

Babel preset for stage 0 plugins

原始使用文档

@babel/preset-stage-0

As of v7.0.0-beta.55, we've removed Babel's Stage presets. Please consider reading our blog post on this decision for more details. TL;DR is that it's more beneficial in the long run to explicitly add which proposals to use.


For a more automatic migration, we have updated babel-upgrade to do this for you (you can run npx babel-upgrade).

If you want the same configuration as before:

{
  "plugins": [
    // Stage 0
    "@babel/plugin-proposal-function-bind",

    // Stage 1
    "@babel/plugin-proposal-export-default-from",
    "@babel/plugin-proposal-logical-assignment-operators",
    ["@babel/plugin-proposal-optional-chaining", { "loose": false }],
    ["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }],
    ["@babel/plugin-proposal-nullish-coalescing-operator", { "loose": false }],
    "@babel/plugin-proposal-do-expressions",

    // Stage 2
    ["@babel/plugin-proposal-decorators", { "legacy": true }],
    "@babel/plugin-proposal-function-sent",
    "@babel/plugin-proposal-export-namespace-from",
    "@babel/plugin-proposal-numeric-separator",
    "@babel/plugin-proposal-throw-expressions",

    // Stage 3
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-syntax-import-meta",
    ["@babel/plugin-proposal-class-properties", { "loose": true }],
    "@babel/plugin-proposal-json-strings"
  ]
}

If you're using the same configuration across many separate projects, keep in mind that you can also create your own custom presets with whichever plugins and presets you're looking to use.

module.exports = function() {
  return {
    plugins: [
      require("@babel/plugin-syntax-dynamic-import"),
      [require("@babel/plugin-proposal-decorators"), { "legacy": true }],
      [require("@babel/plugin-proposal-class-properties"), { "loose": true }],
    ],
    presets: [
      // ...
    ],
  };
};

NOTE: Compatibility between @babel/plugin-proposal-class-properties and @babel/plugin-proposal-decorators If you are including your plugins manually and using @babel/plugin-proposal-class-properties, make sure that @babel/plugin-proposal-decorators comes before @babel/plugin-proposal-class-properties.

When using the legacy: true option of @babel/plugin-proposal-decorators, @babel/plugin-proposal-class-properties must be used in loose: true mode.

If you are not using @babel/plugin-proposal-decorators, loose mode is not needed.

版本与发布记录

@babel/preset-stage-0 共发布 36 个版本,首次发布于 2017/10/31;过去 12 个月发布了 0 个版本。

版本发布日期距今
7.8.3latest2020/01/146 年前
7.8.02020/01/126 年前
7.0.02018/08/288 年前
7.0.0-rc.42018/08/288 年前
7.0.0-rc.32018/08/258 年前
7.0.0-rc.22018/08/228 年前

关于 @babel/preset-stage-0 的常见问题

@babel/preset-stage-0 是什么?

Babel preset for stage 0 plugins

如何安装 @babel/preset-stage-0?

在项目目录运行 npm install @babel/preset-stage-0,或使用 pnpm add / yarn add / bun add。

@babel/preset-stage-0 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/babel__preset-stage-0 是否存在。

@babel/preset-stage-0 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@babel/preset-stage-0 可以商用吗?

@babel/preset-stage-0 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@babel/preset-stage-0 的下载量有多少?

根据 npm 官方下载统计,@babel/preset-stage-0 在 2026/10/08 – 2026/11/06 这 30 天内被下载 279,428 次,日均约 9,314 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@babel/preset-stage-0 还在维护吗?

最新版本 7.8.3 发布于 2020/01/14(6 年前);至今共发布 36 个版本,其中过去 12 个月发布了 0 个;首次发布于 2017/10/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。