What's the best way to setup an ES6 library so that it's modular and transpiles into one ES5 UMD file? I looked at the way async.js and lodash do it, but it's hard to understand what's going on.
For example, index.js
:
import doSomething from './doSomething';
class Example {
constructor() {
this.name = 'Example';
}
}
Object.assign(Example.prototype, {
doSomething
});
export default Example;
and doSomething.js
:
export default function doSomething() {
return this.name;
}
So that user can do something like this:
var example = new Example();
example.doSomething(); // Example
I'm having no luck with Babel, as transform-es2015-modules-umd
is not evaluating paths correctly, and Babel's not bundling it all into one ES5 file either. Anyone have a simple example for something like this?