Comparing version 0.0.1 to 0.0.2
@@ -17,3 +17,3 @@ var path = require("path"); | ||
var requireModule = module; | ||
var thisModule = module; | ||
@@ -23,8 +23,3 @@ global.define = function (id, injects, factory) { | ||
// infere the module | ||
var module = currentModule; | ||
if (!module) { | ||
module = requireModule; | ||
while (module.parent) | ||
module = module.parent; | ||
} | ||
var module = currentModule || require.main; | ||
@@ -56,3 +51,3 @@ // parse arguments | ||
var req = function(requireModule, relativeId, callback) { | ||
var req = function(module, relativeId, callback) { | ||
if (Array.isArray(relativeId)) { | ||
@@ -69,3 +64,3 @@ // async require | ||
var id = Module._resolveFilename(relativeId, requireModule.parent)[0]; | ||
var id = Module._resolveFilename(relativeId, module)[0]; | ||
@@ -76,3 +71,3 @@ if (prefix && prefix.indexOf("text") !== -1) { | ||
return require(id); | ||
}.bind(this, requireModule); | ||
}.bind(this, module); | ||
@@ -86,2 +81,3 @@ injects.unshift("require", "exports", "module"); | ||
} | ||
var returned = factory.apply(module.exports, injects.map(function (injection) { | ||
@@ -94,11 +90,11 @@ switch (injection) { | ||
default: | ||
// a module dependency | ||
return req(injection); | ||
// a module dependency | ||
return req(injection); | ||
} | ||
})); | ||
if(returned) { | ||
// since AMD encapsulates a function/callback, it can allow the factory to return the exports. | ||
module.exports = returned; | ||
if (returned) { | ||
// since AMD encapsulates a function/callback, it can allow the factory to return the exports. | ||
module.exports = returned; | ||
} | ||
}; |
{ | ||
"name" : "amd-loader", | ||
"version" : "0.0.1", | ||
"version" : "0.0.2", | ||
"description" : "Add the capability to load AMD (Asynchronous Module Definition) modules to node.js", | ||
@@ -19,3 +19,7 @@ "author": "ajax.org B.V. <info@ajax.org>", | ||
"node" : ">= 0.4.11" | ||
} | ||
}, | ||
"licenses" : [{ | ||
"type" : "MIT", | ||
"url" : "http://github.com/ajaxorg/node-amd-loader/raw/master/LICENSE" | ||
}] | ||
} |
@@ -9,3 +9,3 @@ AMD loader for node.js | ||
`node-amd-loader` can be easily installed using (npm)[http://npmjs.org]. | ||
`node-amd-loader` can be easily installed using [npm](http://npmjs.org). | ||
@@ -25,3 +25,3 @@ npm install amd-loader | ||
Load modules which are written using AMD (define)[http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition#define.28.29_function] from node.js node. | ||
Load modules which are written using AMD [define](http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition#define.28.29_function) from node.js node. | ||
@@ -45,3 +45,3 @@ amd.js | ||
From within an AMD modules the async require syntax introduced by (requireJS)[http://requirejs.org] can be used. | ||
From within an AMD modules the async require syntax introduced by [requireJS](http://requirejs.org) can be used. | ||
@@ -65,3 +65,3 @@ ```javascript | ||
(Kris Zip)[https://github.com/kriszyp] came up the the initial (idea)[https://gist.github.com/650000] how to hijack the node module loading. | ||
[Kris Zip](https://github.com/kriszyp) came up the the initial [idea](https://gist.github.com/650000) how to hijack the node module loading. | ||
@@ -68,0 +68,0 @@ License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7004
113