# @buxlabs/amd-to-es6 中文文档

规范地址：https://npmcn.com/package/%40buxlabs/amd-to-es6/

版本：0\.16\.4
npm 元数据更新时间：2025-12-02T07:25:26.817Z
中文译文更新时间：2026-11-08T20:42:32.024Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40buxlabs/amd-to-es6
原文对照：https://npmcn.com/package/%40buxlabs/amd-to-es6/?lang=original
项目主页：https://github.com/buxlabs/amd-to-es6#readme
源码仓库：https://github.com/buxlabs/amd-to-es6

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：31.7 kB，34 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- Node.js 要求：\>=14\.15\.0
- 运行依赖：5 个
- 首次发布：2016-11-26T17:39:10.237Z
- 最新版本发布：2025-12-02T07:25:26.493Z
- 近 30 天下载量：21916（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：37（近 12 个月 1 个）

## 中文简介

转换为 es6

## 安装

```sh
npm install @buxlabs/amd-to-es6
```

也可以使用：`pnpm add @buxlabs/amd-to-es6`、`yarn add @buxlabs/amd-to-es6`、`bun add @buxlabs/amd-to-es6`

## README

# AMD 到 ES 转换器

![npm](https://img.shields.io/npm/v/@buxlabs/amd-to-es6.svg) [![Codeship](https://img.shields.io/codeship/f6299130-6721-0134-f3f9-02d00f1d3243/master.svg)](https://app.codeship.com/projects/176125)

> AMD(同步模块定义)到ES(EcmaScript)模块转换器

## 目录

-   [背景情况](https://npmcn.com/package/%40buxlabs/amd-to-es6/#readme-background)
-   [安装](https://npmcn.com/package/%40buxlabs/amd-to-es6/#readme-install)
-   [使用量](https://npmcn.com/package/%40buxlabs/amd-to-es6/#readme-usage)
-   [实例](https://npmcn.com/package/%40buxlabs/amd-to-es6/#readme-examples)
-   [维护者](https://npmcn.com/package/%40buxlabs/amd-to-es6/#readme-maintainers)
-   [捐款](https://npmcn.com/package/%40buxlabs/amd-to-es6/#readme-contributing)
-   [贷项](https://npmcn.com/package/%40buxlabs/amd-to-es6/#readme-credits)
-   [许可证](https://npmcn.com/package/%40buxlabs/amd-to-es6/#readme-license)

## 背景情况

AMD非常受欢迎,并被用在全世界许多大应用中. ES模块标准是后来创建的,随着各种捆绑器和转接器的兴起,能够用更简洁的语法来写出现代代码. 这个工具是用来填补迁移空白的,因为其他工具没有处理一些边缘案件。 它应该处理框外的大部分现有代码.

该工具既暴露了cli,也暴露了程序界面.

## 安装

`npm install -g @buxlabs/amd-to-es6`

## 使用量

### 语气

将单个文件转换为 :

`amdtoes6 app.js > app-es6.js`

在给定目录中转换多个文件为 :

`amdtoes6 --src=src --dest=build`

以给定目录递归方式转换多个文件 :

`amdtoes6 --src=src --dest=build --glob=**/*.js`

转换多个文件并替换为:

`amdtoes6 --src=src --replace`

### 选项

```sh

  Usage: amdtoes6 [options]

  Options:

    -s, --src <dirname>     Directory of the source files
    -d, --dest <dirname>    Directory of the destination files
    -g, --glob [glob]       Glob pattern for the src to match for input files
    -r, --recursive         Set glob pattern to **/*.js with no hassle
    -b, --beautify          Beautify the output
    --replace           Replace the input files with results
    --suffix <string>   Replace suffix of the files
    --quotes            Single, double or auto quotes in the output

```

### 节点

将单个文件转换为 :

```javascript
const amdtoes6 = require('@buxlabs/amd-to-es6');
const source = 'define({ hello: 'world' });';
const result = amdtoes6(source); // export default { hello: 'world' };
```

## 实例

**AMD (英语)**

```javascript
define([
    'core/view',
    'subapp/hello/template/layout'
], function (View, template) {
    'use strict';

    return View.extend({
        template: template
    });

});
```

**欧语**

```javascript
import View from 'core/view';
import template from 'subapp/hello/template/layout';

export default View.extend({
    template: template
});
```

**AMD (英语)**

```javascript
define(function (require) {
    'use strict';

    var Marionette = require('marionette');

    return Marionette.Object.extend({
        initialize: function () {
            console.log('hello world');
        }
    });
});
```

**欧语**

```javascript
import Marionette from 'marionette';

export default Marionette.Object.extend({
    initialize: function () {
        console.log('hello world');
    }
});
```

测试/ 固定目录中的例子更多

## 维护者

[@emilos (西班牙语)](https://github.com/emilos)。 。 。 .

## 捐款

所有的贡献都受到高度赞赏! 打开一个问题或提交公关.

Lib遵循tdd方法,预计将具有高码覆盖.

## 贷项

[https://github.com/jonbretman/amd-to-as6 (中文(简体) )](https://github.com/jonbretman/amd-to-as6)

## 许可证

麻省理工学院

## 常见问题

### @buxlabs/amd-to-es6 是什么？

转换为 es6

### 如何安装 @buxlabs/amd-to-es6？

在项目目录运行 npm install @buxlabs/amd-to-es6，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 amdtoes6，可以用 npx amdtoes6 直接运行。

### @buxlabs/amd-to-es6 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/buxlabs\_\_amd-to-es6 是否存在。

### @buxlabs/amd-to-es6 支持 ESM 还是 CommonJS？

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

### @buxlabs/amd-to-es6 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=14\.15\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @buxlabs/amd-to-es6 可以商用吗？

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

### @buxlabs/amd-to-es6 的下载量有多少？

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

### @buxlabs/amd-to-es6 还在维护吗？

最新版本 0\.16\.4 发布于 2025/12/02（11 个月前）；至今共发布 37 个版本，其中过去 12 个月发布了 1 个；首次发布于 2016/11/27。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

