malaporte / nashorn-commonjs-modules

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

Bug When module.exports is a function #8

Closed mfreeman-xtivia closed 8 years ago

mfreeman-xtivia commented 8 years ago

There appears to be a bug that triggers an NPE when the module.exports is a function (and not an object with members). To recreate define a module (math.js) with syntax like:

module.exports = function(a,b) { return a+b; }

and then use it as follows in a client module:

var sum = require('./math.js'); var x = sum(2,4);

The problem goes away (and code works) if I change the definition to module.exports.somefunc = .... and the invocation to var x.somefunc = sum(2,4);

mfreeman-xtivia commented 8 years ago

NM. Looks like its fixed in 1.04 which I pulled down and used in source form. Latest available from Maven repo was 1.0.3 which didn't have the fix. Nice work, really nice.

malaporte commented 8 years ago

Yes, this was reported and fixed a while ago (#3), but for some reason I totally forgot to push a new release until a few days ago.

malaporte commented 8 years ago

Wait - for some reason it seems my latest version didn't make it to Maven Central. I'll look into this.

mfreeman-xtivia commented 8 years ago

Thanks. And again my compliments on the outstanding work--you have no idea how long I've been waiting for something like this, esp with Nashorn.....I assume from the blog article that got me here that you guys are using this successfully in a multi-threaded, server-side environment?

malaporte commented 8 years ago

There, the deploy to Maven Central finally passed through.

As for your question, yes we're indeed using this on servers getting quite a bit of traffic.