0.3.2 • Published 11 years ago

rex-cli v0.3.2

Weekly downloads
74
License
-
Repository
github
Last release
11 years ago

Rex

Rex is "commonjs in the browser".

It's available through npm:

npm install rex

There is also a cli program available

npm install -g rex-cli
rex --help

Usage is simple:

var rex = require('rex');
var parse = rex();

parse('test.js', function(err, compiled) {
	// this outputs test.js compiled for browser usage
	console.log(compiled);
});

Your browserside javascript can now use require to require other modules and exports and module.exports just like in node.js. Additionally if your module exports a global variable with the same name as your module require will still work!
If you require a module like require('my-module') rex will look for it in the nearest browser_modules or node_modules folder. If rex can't resolve a module name, no error is raised, instead require returns null on runtime.

// browserside code
var foo = require('./foo'); // will look for foo.js in the same folder
var bar = require('bar');   // will look for bar.js or bar/index.js in 
                            // the nearest browser_modules or node_modules folder

module.exports = function() { // will export a function
	return 'hello from module';
};

Options

You can pass a set of options with rex(options). They include:

  • base: Specify a base js file. Rex will now assume that base's dependencies are loaded for all other requests.
  • dependencies: A map of global dependencies to be loaded in the client. This could be jQuery from a cdn i.e. {jQuery:'http://cdn.com/jQuery.js'}.

License

MIT

0.3.2

11 years ago

0.3.0

11 years ago

0.2.5

11 years ago

0.2.4

12 years ago

0.2.3

12 years ago

0.2.2

12 years ago

0.2.1

12 years ago

0.1.5

12 years ago

0.1.4

12 years ago

0.1.3

12 years ago

0.1.2

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago

0.0.2

12 years ago