Home

Awesome

module-concat

Fairly lightweight CommonJS module concatenation tool

What is it?

This library exposes a single function and stream API that concatenates CommonJS modules within a project. This can be used to obfuscate an entire project into a single file. It can also be used to write client-side JavaScript code where each file is written just like a Node.js module.

Why?

Because projects like Webpack and Browserify are cool, but they are a little heavy for my taste. I just wanted something to compile CommonJS modules into a single JavaScript file. This project has one dependency: resolve

Install

npm install module-concat

Note: Used to be called node-module-concat but has since been renamed.

Usage

var modConcat = require("module-concat");
var outputFile = "./project/concatenated.js";
modConcat("./project/index.js", outputFile, function(err, stats) {
	if(err) throw err;
	console.log(stats.files.length + " were combined into " + outputFile);
});

API

var modConcat = require("module-concat");

var stream = new modConcat.ModuleConcatStream(entryModulePath [, options])

Constructs a Readable Stream of the concatenated project.

stream.getStats()

Returns an Object containing statistics about the files included in the project. This object is available after the 'end' event is fired and there is no more data to consume. Properties include:

modConcat(entryModule, outputPath, [options, cb])

Helper function that constructs a new ModuleConcatStream (see above) with the following options and pipes the concatenated project to the outputPath.

Known limitations