Angry Coding: Mozilla Rhino CommonJS module support. Good news, last version of Mozilla Rhino (1.7R3) introduces a fully compliant CommonJS module implementation, and in this blog post I'm going to give you a brief introduction on how to use it in your projects.
Okay, so how do we normally manage dependencies in the JavaScript code that is running under Mozilla Rhino? Normally when you want to include the contents of another JavaScript file (for example some library), you call load() function (provided by Rhino shell) and pass the name of the file that you want to include as an argument: // include XSLTProcessor library load('XLSTProcessor.js');// use XSLTProcessor classvar xsltProcessor = new XSLTProcessor('test.xsl'); In one of my previous blog posts I was looking into RequireJS dependency manager that solves similar problems for the JavaScript code that runs in the web - browser. I've spent about a day of hacking it from both JavaScript or Java side but either way it was very far from ideal.
Rhino Javascript wrapper for Java NIO with node.js-like API (including some benchmarks) : javascript. Rhino - JavaScript for Java.