Skip to content

ES Modules, Export function & Environment support

Compare
Choose a tag to compare
@oligriffiths oligriffiths released this 07 Mar 03:03
· 144 commits to master since this release

This release adds support for several new features.

ES Modules syntax

PR: #385
ES modules syntax is now supported in Broccoli using the esm npm package. You're now free to use this syntax for your Brocfile.js https://github.com/broccolijs/broccoli#using-plugins-in-a-brocfilejs
Welcome to the future!

import merge from 'broccoli-merge-trees';

export default merge(['a', 'b']);

Export function

PR: #386
Broccoli now supports exporting a function from the Brocfile.js, in the same way that Ember-CLI does https://github.com/broccolijs/broccoli#brocfilejs which paves the way for future enhancements to supply build parameters to the pipeline

import merge from 'broccoli-merge-trees';

export default () => {
  return merge(['a', 'b']);
}

Environment

PR: #387
Broccoli now supports --environment,-e,--prod,--dev CLI arguments similar to Ember-CLI. The environment flag is passed to the Brocfile in the options hash { env: ENVIRONMENT } and defaults to development.
Similar to the legacy BROCCOLI_CLI environment variable, this allows a build pipeline to be altered based on the destined environment, for example by minifying files for production.

import merge from 'broccoli-merge-trees';
import uglify from 'broccoli-uglify-js';

export default (options) => {
  let tree = merge(['a', 'b']);
  if (options.environment === 'production') {
    tree = uglify(tree);
  }
  return tree;
}