malaporte / nashorn-commonjs-modules

CommonJS modules support for Nashorn
MIT License
108 stars 31 forks source link

Allow registering the `require` function in a specific binding, to allow re-using a ScriptEngine across multiple threads. #19

Closed malaporte closed 7 years ago

malaporte commented 7 years ago

As explained in #12, it's sometimes desirable to re-use the same Script Engine in multiple threads, with each thread having it's own Bindings defining the global scope. I added an overload to Require that does just this. The Module still gets passed the NashornScriptEngine reference, but I think that's OK since it only uses it to access engine scope and create a few standard JS objects.

kipz commented 7 years ago

LGTM