@atom/babel7-transpiler

中文文档
1.0.0-1发布于 2019/02/26MITCommonJS近 30 天下载 2101

A transpiler for Atom packages that processes code with Babel 7

原始使用文档
文档目录5 节
  1. Usage
  2. Options
  3. Other Details
  4. Source Maps
  5. Babel Environment

atom-babel7-transpiler

This project implements an Atom package transpiler that transpiles your package's files with Babel 7.

Usage

  1. Install the package
  2. Add an atomTranspilers entry to your package.json
  3. Install Babel presets and plugins, and configure Babel as you wish

In detail:

1. First, install the package from the npm registry:

npm install --save @atom/babel7-transpiler

2. Next, modify your package.json to include a reference to the transpiler for any files you want Babel to process as described in the Atom Flight Manual. For example, to process every file ending in .js in your package, you could use:

{
  ...
  "atomTranspilers": [
    {
      "glob": "**/*.js",
      "transpiler": "@atom/babel7-transpiler"
    }
  ]
}

3. Finally, install Babel and all the presets and plugins you want to use as normal. For a simple example, if you wanted to use the ES2015 and React presets, you might run:

npm install --save babel-preset-env babel-preset-react

and then create a .babelrc file to configure Babel to use them:

{
  "presets": ["env", "react"]
}

You may also specify options in your package.json inside the optional options object; the subkey babel, if it exists, will be passed as options to babel.transformSync. Note that if you don't want Babel to search up the directory hierarchy for a .babelrc file, you need to add the "babelrc": false option to the settings. Otherwise Babel may mistakenly use a user's .babelrc from elsewhere on the filesystem when trying to build your package.

{
  // ...
  "atomTranspilers": [
    {
      "glob": "**/*.js",
      "transpiler": "@atom/babel7-transpiler",
      "options": {
        "babel": {
          "presets": ["es2015", "react"],
          "babelrc": false
        }
      }
    }
  ]
}

Options

You may specify the following options as values of the options object in your package.json:

OptionDefaultDescription
setBabelEnvfalse, true or a stringSets the BABEL_ENV environment variable. When true, sets it to "development" when atom.inDevMode() or atom.inSpecMode() is true and "production" otherwise. When given as a string, uses the value of the environment variable of that name instead. The feature returns BABEL_ENV to its prior value after transpilation finishes.
babel{}Options to pass as the second argument to babel.transform (the same options you can put in a .babelrc).
cacheKeyFiles[]An array of files to include when determining whether or not to use the cache. For example, to force a recompile anytime your .babelrc changes, add .babelrc to this array.

Other Details

Source Maps

To enable source maps within Atom, set the Babel sourceMaps option to "inline" in your Babel configuration.

Babel Environment

Babel supports an option called env that allows you to configure Babel on a per-environment basis. The Babel environment is controlled via an environment variable called BABEL_ENV; this module automatically sets the environment variable to "development" if Atom is in dev mode (atom.inDevMode() returns true) and "production" otherwise.

版本与发布记录

@atom/babel7-transpiler 共发布 2 个版本,首次发布于 2019/02/26;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.0-1latest2019/02/267 年前
1.0.0-02019/02/267 年前

关于 @atom/babel7-transpiler 的常见问题

@atom/babel7-transpiler 是什么?

A transpiler for Atom packages that processes code with Babel 7

如何安装 @atom/babel7-transpiler?

在项目目录运行 npm install @atom/babel7-transpiler,或使用 pnpm add / yarn add / bun add。

@atom/babel7-transpiler 支持 TypeScript 吗?

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

@atom/babel7-transpiler 支持 ESM 还是 CommonJS?

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

@atom/babel7-transpiler 可以商用吗?

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

@atom/babel7-transpiler 的下载量有多少?

根据 npm 官方下载统计,@atom/babel7-transpiler 在 2026/10/07 – 2026/11/05 这 30 天内被下载 2,101 次,日均约 70 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@atom/babel7-transpiler 还在维护吗?

最新版本 1.0.0-1 发布于 2019/02/26(7 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/02/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。