1.1.1 • Published 10 years ago

common.js v1.1.1

Weekly downloads
46
License
MIT
Repository
github
Last release
10 years ago

CommonJS For The Browser

A CommonJS preprocessor that builds you CommonJS style app into code the browser can use.

Install

$ npm install common.js

Usage

Step 1: Write your JavaScript

foo.js
module.exports = function() {
	console.log('foo');
};
bar.js
var foo = require('foo');

exports.doTheThing = function() {
	foo();
};

Step 2: Build you code using commonjs-preprocessor

$ commonjs --src ./path/to/javascripts --dest ./path/to/js --client

Step 3: Include the modules into your app and use them

<script src="js/common.js"></script>
<script src="js/foo.js"></script>
<script src="js/bar.js"></script>
<script>
	var bar = require('bar');

	bar.doTheThing();
</script>

Lazy-loading extra scripts

require.load('/foo', '/bar', '/baz').then(function() {
	var foo = require('foo');
	var bar = require('bar');
	var baz = require('baz');

	foo.doStuffWith(bar.foo(), baz.foo());
});
1.1.1

10 years ago

1.1.0

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.0

10 years ago