jsfuse

0.9.12 • Public • Published

Jsfuse

Simple CommonJS-based JavaScript distribution builder.

Replaces require('...') with the files they require. This makes it easy to create distributions for frontend packages. It's like browserify or webpack, only it produces smaller files and doesn't support circular dependencies.

$ npm install -g jsfuse
$ jsfuse your_file.js

Example

// index.js
alert(require('./foo'));
 
// foo.js
module.exports = "Hello";

Then run:

jsfuse index.js

This will replace require('./foo') with the exports of foo.js, which yields something to the effect of:

alert((function(){
 var module={exports:{}},exports=module.exports;
 (function(){ module.exports = "Hello"; })();
 return module.exports;
}()));

Which is functionally-equivalent to: (and in fact will compile down to via closure compiler)

alert("Hello");

Why?

It's great for making frontend libraries, which usually are distributed as a single .js file. When using browserify to build the final file, you'll get an entire working CommonJS loader embedded into it, which may be unnecessary bloat.

Jsfuse allows you to bake smaller files by assuming some limitations:

  • circular dependencies are not allowed.
  • requiring a dependency more than once will bloat up your file size.
  • doesn't support node_modules.

Thanks

Jsfuse © 2014, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors.

ricostacruz.com  ·  GitHub @rstacruz  ·  Twitter @rstacruz

Status npm version

Package Sidebar

Install

npm i jsfuse

Weekly Downloads

2

Version

0.9.12

License

MIT

Last publish

Collaborators

  • rstacruz