It seems that the Require.resolve resolution mechanism only works on the file system. Are there any plans for adding support for resolution of provided node modules within a (self-contained) zip archive? This draft diff will make the npm example at https://github.com/vert-x3/vertx-examples/tree/master/core-examples/src/main/js/npm example work if distributed and launched as zip archive:
jvm-npm.js.diff (against version/tag 3.0.0)
78a79
>
248c249,250
< (root ? resolveAsNodeModule(id, new File(root).getParent()) : false);
---
> (root ? resolveAsNodeModule(id, new File(root).getParent()) : false) ||
> resolveAsClasspathNodeModule(id);
290a293,303
> function resolveAsClasspathNodeModule(name) {
> name = 'node_modules/' + name;
> var main = name + '/index.js';
> var classloader = java.lang.Thread.currentThread().getContextClassLoader();
> if (classloader.getResource(name + '/package.json')) {
> var package = JSON.parse(readFile(name + '/package.json', true));
> if (package.main) main = (name + '/' + package.main).replace(/\.\//g,'');
> }
> if (classloader.getResource(main)) return {path: main, core: true};
> }
>
It seems that the Require.resolve resolution mechanism only works on the file system. Are there any plans for adding support for resolution of provided node modules within a (self-contained) zip archive? This draft diff will make the npm example at https://github.com/vert-x3/vertx-examples/tree/master/core-examples/src/main/js/npm example work if distributed and launched as zip archive: jvm-npm.js.diff (against version/tag 3.0.0)