Package Exports
- node-amd
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-amd) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
node-amd
Aim of this project is to make AMD modules usable with nodejs. Useful for unit testing or reusing client-side data model code on the server-side.
Why do I not use amdefine?
amdefine forces one to add this -> if (typeof define !== 'function') { var define = require('amdefine')(module) } to each module, which is inconvenient. node-amd declares globals.
Usage
npm install node-amdrequire('node-amd');
requirejs.config({
baseUrl: '../../www/', //path relative to current script (__dirname).
paths: {
jquery: 'lib/jquery/dist/jquery'
}
});
define(['web/model/BaseModel', 'jquery'], function (BaseModel, $) {
//...
});Configuration support
At the moment only baseUrl and paths configuration options are supported.
Plugin support
node-amd has partial support for plugins. Only plugin.load() function is supported, and plugin should be added to paths config.
Existing plugins won't work without modification, since most plugins use XHR. On node, node-amd expect requirejs plugins to synchronously load and return output. Example:
var fs = require('fs');
define({
load: function (path, req, onload) {
//asynchronous API like fs.readFile() cannot be used.
onload(fs.readFileSync(req.toUrl(path), 'utf8'));
}
});Not supported yet
- Full requirejs configuration options.
- http/https URLs in dependencies.
- CommonJS Wrapper style.
- Full plugin API
Ping me if you want support for them.