@buxlabs/amd-to-es6

中文文档
0.16.4发布于 2025/12/02MITCommonJS近 30 天下载 2.2万

转换为 es6

中文使用文档
文档目录12 节
  1. 目录
  2. 背景情况
  3. 安装
  4. 使用量
  5. 语气
  6. 选项
  7. 节点
  8. 实例
  9. 维护者
  10. 捐款
  11. 贷项
  12. 许可证

AMD 到 ES 转换器

npm Codeship

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

目录

背景情况

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

选项


  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

节点

将单个文件转换为 :

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

实例

AMD (英语)

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

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

});

欧语

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

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

AMD (英语)

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

    var Marionette = require('marionette');

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

欧语

import Marionette from 'marionette';

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

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

维护者

@emilos (西班牙语)。 。 。 .

捐款

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

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

贷项

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

许可证

麻省理工学院

版本与发布记录

@buxlabs/amd-to-es6 共发布 37 个版本,首次发布于 2016/11/27;过去 12 个月发布了 1 个版本。

版本发布日期距今
0.16.4latest2025/12/0211 个月前
0.16.32022/01/204 年前
0.16.12021/07/155 年前
0.16.02020/11/026 年前
0.15.22020/05/186 年前
0.15.12020/05/186 年前

关于 @buxlabs/amd-to-es6 的常见问题

@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 和提交记录判断。