AMD 到 ES 转换器
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 (中文(简体) )
许可证
麻省理工学院