Last active
February 19, 2017 12:08
-
-
Save green3g/4dce79f9bffe74b99a6a6cea3f44604f to your computer and use it in GitHub Desktop.
SystemJS Dojo Loader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}); | |
}); | |
}); | |
} | |
}; |
It would be something like this:
System.import('esri/map!dojo').then(function(map) {
});
but it doesn't currently work.
https://github.com/systemjs/systemjs/blob/master/docs/creating-plugins.md#sample-coffeescript-plugin
Finally, I have made a systemjs.loader.dojo.js plugin works with Angular v2.4.7 and ArcGIS API for Javascript v4.2, can load ArcGIS API on demand, do not need to load all required modules before the app boot, and there is a demo: ng2-esri-demo
npm package: https://www.npmjs.com/package/systemjs-plugin-dojo
github repo: https://github.com/beginor/systemjs-plugin-dojo
demo repo: https://github.com/beginor/ng2-esri-demo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you provide sample code to use this loader? thanks!