Permalink
Browse files

Changing the context of modules from the global object to exports to …

…mirror modules in nodeJS
  • Loading branch information...
1 parent e215b3f commit 8cf82e4e7726be23d1c72727e0e0c224d17e526d @cpojer committed Jun 12, 2012
Showing with 5 additions and 5 deletions.
  1. +4 −4 assets/modulr.sync.js
  2. +1 −1 assets/modulr.sync.resolved.js
@@ -53,7 +53,7 @@
// `main` isn't defined until we actually require the program's
// entry point.
var r = makeRequire(id, main || mod);
- fn.call(exports, r, mod.exports, mod);
+ fn.call(mod.exports, r, mod.exports, mod);
if (__PERF__) {
_p.right = _pos++;
_p.end = Date.now();
@@ -68,7 +68,7 @@
function resolveIdentifier(identifier, dir) {
var parts, part, path;
-
+
if (!RELATIVE_IDENTIFIER_PATTERN.test(identifier)) {
return identifier;
}
@@ -95,12 +95,12 @@
}
return path.join('/');
}
-
+
function define(id, factory) {
if (__PERF__) { _perf.modules[id] = { count: 0 }; }
_factories[PREFIX + id] = factory;
}
-
+
exports.define = define;
exports.require = makeRequire('');
exports.modulr = modulr;
@@ -45,7 +45,7 @@
// require.main isn't defined until we actually require the program's
// entry point.
if (!require.main) { require.main = mod; }
- fn.call(exports, require, mod.exports, mod);
+ fn.call(mod.exports, require, mod.exports, mod);
if (__PERF__) {
_p.right = _pos++;
_p.end = Date.now();

1 comment on commit 8cf82e4

@tobie
tobie commented on 8cf82e4 Jun 12, 2012

I don't care either way. @voloko asked for that.

Please sign in to comment.