I'm looking for a module system for Nashorn. From what I can tell, CommonJS is the way to go concerning modules for JS. I have looked through the list (here and here) and have found little in the way of a CommonJS implementation for Java.
Narwhal is no longer active and it's documentation is no longer hosted on GitHub. Is there an existing CommonJS implementation which supports Java or should I start a new project?
I asked a very similar question on the Nashorn mailing list a little while back, here's Sundar's (Nashorn Engineer) reply:
From: A. Sundararajan
To: nashorn-dev@openjdk.java.net
I forgot to add. Nashorn does not contain any builtin module system. But, if a module system is pure JS + Java, it must be possible to run on nashorn.
Nashorn supports "load" (loads scripts from URL, File, resources) and "loadWithNewGlobal" (loads script but into a fresh global scope) primitives in addition to the good old 'eval'. So, it should be possible for any module system to be implemented on top of nashorn in pure JS or perhaps with a bit of Java code.
-Sundar