-
Notifications
You must be signed in to change notification settings - Fork 0
/
dojo.js
34 lines (32 loc) · 1.04 KB
/
dojo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
exports.fetch = function(load) {
var name = load.name;
return new Promise(function(resolve) {
var dojoName = convertToDojoModule(name);
window.require([dojoName], function(mod) {
SystemJS.register(dojoName, [], function (exp, idObj) {
return {
setters: [],
execute: function() {
exp("default", mod);
}
};
});
resolve('');
});
});
};
exports.instantiate = function (load) {
var name = load.name.split('!')[0];
var dojoName = convertToDojoModule(name);
return new Promise(function (resolve) {
// Since module is loaded by fetch, just require it again,
// dojo require does not load the module again.
window.require([dojoName], function (module) {
resolve(module);
});
});
};
function convertToDojoModule(module) {
// we just replace SystemJS.baseURL with '';
return module.replace(SystemJS.baseURL, '');
}