EclairJS / eclairjs-nashorn

JavaScript API for Apache Spark
Apache License 2.0
94 stars 11 forks source link

require should be able to load from URL #316

Closed billreed63 closed 8 years ago

billreed63 commented 8 years ago

require should be able to load from http I can load a javascript from:

load('https://raw.githubusercontent.com/janl/mustache.js/master/mustache.js');

but when attempting to load with require

require('https://raw.githubusercontent.com/janl/mustache.js/master/mustache.js');

I get the following error

javax.script.ScriptException: Error: Cannot load module https://raw.githubusercontent.com/janl/mustache.js/master/mustache.js in src/main/resources/eclairjs/jvm-npm/jvm-npm.js at line number 202 at column number 8

Here is example code:

    require('https://raw.githubusercontent.com/janl/mustache.js/master/mustache.js');
   //load('https://raw.githubusercontent.com/janl/mustache.js/master/mustache.js');
    var view = {
        title: "Joe",
        calc: function () {
            return 2 + 4;
        }
    };
    var output = Mustache.render("{{title}} spends {{calc}}", view);
    print("output " + output);

@jtbarbetta

jtbarbetta commented 8 years ago

Looking at this now.

jtbarbetta commented 8 years ago

I think I have a fix for this but it appears that remoteCluster module loading is broken again (I stashed my changes after trying w/remote cluster and tried again). Looking into this before committing changes.

jtbarbetta commented 8 years ago

I fixed the issue with remote cluster loading for external sources (it was just external sources so included in commit for this issue). Commit: 6f2d88f159d3c7db88e6d698e21b64f72c9f28f5.