0.2.2 • Published 11 years ago

node-amd-require v0.2.2

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

node-amd-require

node-amd-require is a small script which adds AMD-style path resolution and define support to node's require() function. It can be used as an AMD loader or to add path configuration support to CommonJS modules.

Installation

Using npm:

npm install node-amd-require

Usage

require node-amd-require in your project's main entry point and call with your desired AMD-style configuration. Supports baseUrl, paths, and packages. Also supports the mainConfigFile property recursively.

/* [your index.js file or similar] */

require('node-amd-require')({
	//configuration from https://github.com/zship/deferreds.js
	baseUrl: '.',
	paths: {
		"deferreds": "src",
		"mout": "lib/mout",
	}
});

var path = require('path');
var fs = require('fs');
//...

Or pass a path to a .json file containing your configuration:

/* [your index.js file or similar] */

require('node-amd-require')('/path/to/config.json');

var path = require('path');
var fs = require('fs');
//...

Features

  • Adds AMD configuration-based path resolution to require for AMD and/or CommonJS modules
  • Adds define and RequireJS loader plugin support to require via amdefine and the require.extensions mechanism.
  • Unlike requirejs in node, node-amd-require can support downstream scripts which directly call require on your possibly-AMD-format scripts (such as grunt and mocha). More on that is in this requirejs issue.
  • Does not clobber external libraries (symlinks too)
    • AMD-style path resolution only happens when require is called from your project
    • define (AMD module support) is only added when require is called to your project (any file calls `require("/file/inside/your/project.js"))

License

Released under the MIT License.

0.2.2

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.5

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago