Skip to content

Instantly share code, notes, and snippets.

@green3g
Last active February 19, 2017 12:08
Show Gist options
  • Save green3g/4dce79f9bffe74b99a6a6cea3f44604f to your computer and use it in GitHub Desktop.
Save green3g/4dce79f9bffe74b99a6a6cea3f44604f to your computer and use it in GitHub Desktop.
SystemJS Dojo Loader
exports = {
fetch: function(load, fetch) {
console.log('load', load);
let module = load.name.split('!')[0];
return new Promise(function(resolve) {
//use dojo's require and then register the module
window.require([module], function(mod) {
System.register(module, [], function(exp, idObj) {
var result = {
setters: [],
execute: function() {
//Make the name 'default' here as there is only one export per module so it is technically the default.
//Import using a default import statement - eg: import Map from 'esri/Map'
//It's possible this may only compile using 'system' module type in some IDEs using the official typings file though.
exp("default", mod);
}
};
return result;
});
});
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment