Interestingly, this works for some libraries but not others. It seems
to be related to how the library interacts with the global namespace.
For example, if I have a library that defines a global var as a pseudo-
namespace it works fine:
var Foo = {}
Foo.someFunction = function() ...;
But other libraries do not. For example, underscore.js does (I think)
some work to check to see if it's running in a CommonJS module
container and defines the '_' differently as a result. Using the slurp
+ eval() trick does not register that in the global namespace, but
using load() does.
Unsure if it's related, but when running in strict mode (with the '-
strict' command-line flag) Rhino issues a number of 'Code has no side
effects' errors when trying to bring in underscore via any means.
Chris
[1]
http://documentcloud.github.com/underscore/