xcambar / shepherd-js

ES:Harmony compliant module loader and module maker that fits nicely with each and every JS file you can have to work with.
http://xcambar.github.com/shepherd-js/
MIT License
45 stars 0 forks source link

Is it / will it be possible to dynamically load modules from URIs? #4

Open cristiano-belloni opened 11 years ago

cristiano-belloni commented 11 years ago

The question can be rephrased as: will you ever implement a loader in Sheperd? Be it a watered-down Harmony modules loader or something fancy like this pseudocode:

var modules = [name: 'plugin_one', url: 'http://example.com/plugin_one.js',
                       name: 'plugin_two', url: 'http://example.com/plugin_two.js'];

for (var i = 0; i < modules.length; i+=1) {
    var module_obj  = module(modules[i].name).at(modules[i].url);
    // The modules have a common interface and will export the function doSomething
    module_obj.doSomething ();
}
xcambar commented 11 years ago

It's already possible when you run Shepherd from a Node.js environment, see https://github.com/xcambar/shepherd-js/blob/master/test/spec/nodeJSSpec.js#L58

In the browser, it requires a lot more work to do it securely.

guybedford commented 11 years ago

@xcambar I'm wondering what you are referring to here about security.

I have implemented an XHR & eval-based approach to the loader polyfill here - https://github.com/guybedford/es6-loader. I'd be interested to hear your thoughts.