Permalink
Browse files

Properly load for Narwhal

  • Loading branch information...
kriszyp committed Sep 30, 2010
1 parent 5f89352 commit 205183124b6f0498e8721c1b60857bbe63228f91
Showing with 5 additions and 13 deletions.
  1. +5 −13 lib/jsgi/transporter.js
View
@@ -1,8 +1,8 @@
//TODO: optionally write to target file
-require.def||(require.def=function(factory){module.exports=factory(require);});
-require.def(function(require){
-var exports = Transporter;
+require.def||(require.def=function(factory){module.exports=factory(require, exports, module);});
+require.def(function(require, exports, module){
+exports = module.exports ? Transporter : exports;
exports.Transporter = Transporter;
function Transporter(options, app) {
var options = options || {},
@@ -24,15 +24,15 @@ function Transporter(options, app) {
}
}
},
- autoRun = "autoRun" in options ? options.autoRun : true,
+ autoRun = options.autoRun,
excluded = {};
converter = options.converter || exports.CommonJS;
excludeModules.forEach(function(moduleId){
excluded[moduleId] = true;
});
return function(request) {
- var modules, isPaused, path = request.pathInfo;
+ var modules, path = request.pathInfo;
if(path.indexOf(prefix) != 0){
if(app){
return app(request);
@@ -84,9 +84,6 @@ function Transporter(options, app) {
converter.end(write);
}
errors.forEach(write);
- if(isPaused){
- write("require.resume && require.resume();\n");
- }
if(requestedModules.length > 1){
write('require.def("' + requestedModules.join(",") + '", [], function(){});');
}
@@ -109,11 +106,6 @@ function Transporter(options, app) {
};
function loadModule(moduleName, write){
if(modules[moduleName]){
- if(modules[moduleName] === 1 && !isPaused && write && !converter.start){
- // we need to pause to get all the dependencies loaded
- write("require.pause && require.pause();\n");
- isPaused = true;
- }
return true;
}
modules[moduleName] = 1; // in progress

0 comments on commit 2051831

Please sign in to comment.