broccoli-es6modules

raw JSON →
1.2.3 verified Fri May 01 auth: no javascript abandoned

A broccoli filter that transpiles ES6 modules to AMD, CJS, or UMD formats. It supports both 1-to-1 (per-file) and n-to-1 (bundled) transpilation using the esperanto library. Version 1.2.3 is the latest release, but the project is unmaintained as the Ember CLI team has moved to broccoli-babel-transpiler and ember-cli-babel. Key differentiator: it was designed specifically for the broccoli build tool and provides a simple API for ES6 module transpilation, though it lacks ongoing support and may not work with modern Node versions.

error Error: Cannot find module 'broccoli-es6modules'
cause Package not installed or not in node_modules.
fix
Run npm install broccoli-es6modules --save-dev
error TypeError: ES6Modules is not a constructor
cause Incorrect import syntax (destructured import) when using require.
fix
Use const ES6Modules = require('broccoli-es6modules');
error Error: umd format requires bundleOptions (entry & name)
cause Using UMD format without specifying bundleOptions.
fix
Add bundleOptions: { entry: 'main.js', name: 'myLib' } to options.
deprecated This project is no longer maintained by the Ember CLI team.
fix Migrate to broccoli-babel-transpiler or ember-cli-babel.
gotcha UMD format throws an error if used without bundleOptions.
fix Provide bundleOptions with entry and name when using format: 'umd'.
breaking Depends on esperanto, which is no longer actively maintained.
fix Switch to a modern transpiler like Babel.
npm install broccoli-es6modules
yarn add broccoli-es6modules
pnpm add broccoli-es6modules

Shows how to transpile a source tree of ES6 modules to AMD format using broccoli-es6modules.

var broccoli = require('broccoli');
var ES6Modules = require('broccoli-es6modules');
var tree = './src';
var amdFiles = new ES6Modules(tree, { format: 'amd' });
var builder = new broccoli.Builder(amdFiles);
builder.build().then(function(results) {
  console.log('Build output directory:', results.directory);
}).catch(function(err) {
  console.error(err);
});