Socket
Socket
Sign inDemoInstall

broccoli-es6-npm-compiler

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-es6-npm-compiler

Compile ES6 modules along with npm dependencies


Version published
Weekly downloads
15
increased by1400%
Maintainers
1
Weekly downloads
 
Created
Source

broccoli-es6-npm-compiler

Broccoli plugin that compiles ES6 modules along with npm dependencies into a single UMD bundle using Browserify. The plugin looks for the jsnext:main property in your package.json, compiles any ES6 modules to CommonJS modules, browserifies them, and saves the whole thing as single file based on the main property of the package.json.

For importing npm modules in your ES6 code, use the npm: prefix. For instance, if you wanted to use the RSVP promise library, you would import it like so:

import npmModule from 'npm:rsvp';

// Use regular syntax for local modules
import myLocalModule from './lib/my-local-module';

This prefix, as well as the entire plugin, was inspired by ember-browserify.

Example

Let's say your package.json looks something like this:

// package.json
{
  "name": "MyModule",
  "main": "exports/my-module.js",
  "jsnext:main": "lib/index.js",
  //...
}

Now just add this to your Brocfile:

//Brocfile.js
var compileEs6 = require('broccoli-es6-npm-compiler');
var options = {
  globalName: 'MyLibrary',
  amdModuleId: 'MyLibrary'
};
var outputTree = compileEs6(options);

Yea, it's that simple. Using lib/index.js as the root ES6 module, the plugin will bundle your ES6 code into a file named my-module.js in the dist output folder when you run Broccoli.

Options

globalName - Name of global module variable exported via UMD. In other words, window[globalName]. Defaults to name in package.json.

amdModuleId - Module ID of exported AMD module. If undefined, AMD module will be anonymous.

Keywords

FAQs

Package last updated on 21 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc