@buxlabs/es6-to-amd
v1.2.0
Published
es6 to amd converter
Downloads
31
Readme
ES to AMD converter
ES (EcmaScript) Module to AMD (Asynchronous Module Definition) converter
Table of Contents
Background
The import/export syntax is becoming more and more popular. Given a huge, legacy AMD application it's not trivial to migrate it all at once. The converter can help you transpile the modules into the AMD syntax temporarily for backwards compatibility.
Install
npm install @buxlabs/es6-to-amd
Usage
node
Convert a single file with:
const es6toamd = require('@buxlabs/es6-to-amd');
const source = 'export default { hello: 'world' }';
const result = es6toamd(source); // define({ hello: 'world' });
Examples
ES
import Backbone from 'backbone';
export default Backbone.Model.extend({});
AMD
define(['backbone'], function (Backbone) {
'use strict';
return Backbone.Model.extend({});
});
There are more examples in the test/fixture directory.
Maintainers
Contributing
All contributions are highly appreciated! Open an issue or submit a PR.
License
MIT © buxlabs