Created
December 2, 2011 10:42
-
-
Save autre/1422762 to your computer and use it in GitHub Desktop.
rhino relative module resolution bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lib/bar.js | |
var puts; | |
try { | |
puts = require('system').puts; // rhino | |
} catch (e) { | |
puts = require('util').puts; // node | |
} | |
exports.say_hi = function() { | |
puts('hai from rel module lib/bar'); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lib/foo.js | |
var puts; | |
try { | |
puts = require('system').puts; // rhino | |
} catch (e) { | |
puts = require('util').puts; // node | |
} | |
var indirect = require('./bar'); | |
exports.say_hi = function() { | |
indirect.say_hi(); | |
puts('hai from lib/foo'); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = require('foo'); | |
foo.say_hi(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /tmp/abs/bar.js | |
var puts; | |
try { | |
puts = require('system').puts; // rhino | |
} catch (e) { | |
puts = require('util').puts; // node | |
} | |
puts('hai from absolute module bar'); | |
exports.not_the_one_you_expect = function() { | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /tmp/system.js | |
exports.puts = function(s) { | |
print(s); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment