Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.
/ moduleify Public archive

UNMAINTAINED. A browserify transform for shimming globals-polluting libraries.

License

Notifications You must be signed in to change notification settings

pluma/moduleify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NOTE: This package is no longer being maintained. If you are interested in taking over as maintainer or are interested in the npm package name, get in touch by creating an issue.

Synopsis

moduleify is a browserify transform for shimming globals-polluting libraries.

stability 3 - stable license - Unlicense Flattr this

Build Status Coverage Status Dependencies

NPM status

Install

Node.js

With NPM

npm install moduleify

From source

git clone https://github.com/pluma/moduleify.git
cd moduleify
npm install
make test

Basic usage example

example/vendor/angular.js

angular = {awesome: true};
// No CommonJS export, just a global

example/app.js

var ng = require('./vendor/angular');
console.log(ng); // {awesome: true}

Usage

var browserify = require('browserify'),
    moduleify = require('moduleify'),
    b = browserify();

b.transform(moduleify({
    "vendor/angular.js": "angular"
}));
b.add('./app.js');
b.bundle().pipe(require('fs').createWriteStream('bundle.js'));

API

moduleify(rules):transform

Creates a browserify transform that will append module.exports statements to all matching files.

If rules is an object, each filename will be checked against its keys. If one of the keys is contained in the filename, the global with the name matching the value the key is mapped to will be exported.

moduleify({
    "vendor/angular.js": "angular",
    "jquery": "$"
});

Alternatively rules can be an array containing tuples of paths and names. Each filename will be checked against each path. The path can either be a string to be found in the filename or a regular expression to test against.

In either case path separators in the filename will be converted to slashes before testing for matches.

moduleify([
    ["vendor/angular", "angular"],
    [/vendor\/jquery(-\d+(\.\d+)+)?\.js$/, "$"]
]);

Unlicense

This is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.

About

UNMAINTAINED. A browserify transform for shimming globals-polluting libraries.

Resources

License

Stars

Watchers

Forks

Packages

No packages published