Migrating from Esperanto

Jacob Gillespie edited this page Oct 20, 2015 · 2 revisions

Before there was Rollup, there was Esperanto, which bundled ES6 modules but less efficiently than Rollup (i.e. it includes imported modules in their entirety, not just the code that actually gets used).

The project is now abandoned, because there's no sense in maintaining two libraries that do basically the same thing. If you're an Esperanto user, switching to Rollup is easy:

// Before
var esperanto = require( 'esperanto' );

esperanto.bundle({
  base: 'src',
  entry: 'main.js'
}).then( function ( bundle ) {
  var umd = bundle.toUmd({
    strict: true,
    name: 'myLib',
    names: {
      'other-lib': 'otherLib'
    }
  });

  fs.writeFile( 'bundle.js', umd.code );
});

// After
var rollup = require( 'rollup' );

rollup.rollup({
  // no more `base` – internal module paths
  // should be relative
  entry: 'src/main.js'
}).then( function ( bundle ) {
  bundle.write({
    // you can do `var umd = bundle.generate({...})
    // instead, and write the file yourself if
    // you prefer
    dest: 'bundle.js',

    // use this instead of `toUmd`
    format: 'umd',

    // this is equivalent to `strict: true` -
    // optional, will be auto-detected
    exports: 'named',

    // `name` -> `moduleName`
    moduleName: 'myLib',

    // `names` -> `globals`
    globals: {
      'other-lib': 'otherLib'
    }
  });
});

If you get stuck, raise an issue or holler on Twitter.