npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

broccoli-es6modules

v1.2.3

Published

An es6 module transpiler & concatenator for broccoli.

Downloads

5,056

Readme

#broccoli-es6modules

Dependency Status devDependency Status

Unmaintained! This project is no longer being maintained by the Ember CLI team.
Ember CLI has switched over to the broccoli-babel-transpiler and ember-cli-babel plugins.
If you would like to take off maintenance of this project please let us know!

ES6Modules is a broccoli filter that transpiles source code in a project from ES6 modules to ES5 modules in AMD, CJS, or UMD styles.

ES6Modules has two modes of transpilation: 1-to-1 (per-file) and n-to-1 (bundled);

1-to-1 transpiles

1-to-1 mode transpiles every file in a tree from ES6 to the format specified as the format option.

For example, if you have the following directory:

src/
├── lib
│   ├── promise.js
│   ├── rsvp.js
│   └── utils.js
└── main.js

And convert the files using ES6Modules:

var tree = './src';
var ES6Modules = require('broccoli-es6modules');
var amdFiles = new ES6Modules(tree, {
  format: 'amd'
});

You will have the following tree in your compiled output

├── lib
│   ├── promise.js
│   ├── rsvp.js
│   └── utils.js
└── main.js

And each file's contents will be converted from ES6 module syntax to AMD style.

n-to-1 bundled transpiles

n-to-1 mode begins transpiling at a single entry point and walks the dependency graph starting with the imported statements in the entry point.

This will result in a single, bundled file for your library containing any files referenced by import statements. Enable this mode by supplying a bundleOptions option with (at least) a name for your resulting file and a file to be the entry point:

For example, if you have the following directory:

src/
├── lib
│   ├── promise.js
│   ├── rsvp.js
│   └── utils.js
└── main.js

And convert these files using ES6Modules:

var tree = './src';
var ES6Modules = require('broccoli-es6modules');
var amdFiles = new ES6Modules(tree, {
  format: 'amd',
  bundleOptions: {
    entry: 'main.js',
    name: 'myLib'
  }
});

You will have the following tree in your compiled output

└── myLib.js

The contents of that file will be any code imported from main.js's import process.

Options

format

The ES5 module format to convert to. Available options are:

In namedAmd the file path (with '.js' removed) of the file relative to the tree root is used as the module's name.

So, if you have the following tree:


├── inner
│   └── first.js
└── outer.js

You will have the following module names passed to AMD's define call: 'bundle', 'inner/first', and 'outer'.

Because this strategy combined with UMD would result in many properties being set on the window object in the browser, umd format will throw an error if used without also providing bundleOptions.

formatModuleName

An optional function for namedAmd module format to customize the module name passed to esperanto.

For example if you have foo/bar.js:

export default function() {
}

and a formatModuleName option of:

formatModuleName: function(moduleName) {
  return moduleName.replace('foo/', '');
}

Esperanto will give you:

define('bar', ['exports'], function(exports) {

  'use strict';

  exports['default'] = function() {
  }

});

esperantoOptions

ES6Modules wraps the esperanto library. All options described for esperanto can be provided here. All defaults are identical to those used by esperanto.

Because the ES6Modules uses each file's name as its module name, the esperanto amdName and sourceMapSource options are ignored.

bundleOptions

ES6Modules wraps the esperanto library. All options described for esperanto bundling can be provided here. All defaults are identical to those used by esperanto.

The value you provide for esperantoOptions will be passed to result of bundling, resulting in a single output file.