Giter Site home page Giter Site logo

node-module-concat's Introduction

node-module-concat

Node.js module concatenation library

What is it?

This library exposes a single function that concatenates Node.js 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.

Install

npm install node-module-concat

Usage

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

API

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

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

  • entryModule - the path to the entry point of the project to be concatenated. This might be an index.js file, for example.
  • outputFile - the path where the concatenated project file will be written.
  • options - Optional. An Object containing any of the following:
    • outputStreamOptions - Options passed to fs.createWriteStream call when the outputFile is opened for writing.

    • excludeFiles - An Array of files that should be excluded from the project even if they were referenced by a require(...).

      Note: These require statements should probably be wrapped in a try, catch block to prevent uncaught exceptions.

    • includeNodeModules - Set to true if node_modules should also be included in the project.

  • cb - Callback of the form cb(err, files, nativeModules) where files is an Array of files that have been included in the project and nativeModules is an Array of native modules that were found (but not included) when scanning the project.

Known limitations

  • Dynamic require() statements don't work (i.e. require("./" + variable))
  • require.resolve calls are not modified
  • require.cache statements are not modified

node-module-concat's People

Contributors

bminer avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.