ES (EcmaScript) Module to AMD (Asynchronous Module Definition) converter
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.
npm install @buxlabs/es6-to-amd
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' });
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.
All contributions are highly appreciated! Open an issue or submit a PR.
MIT © buxlabs