mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-18 14:53:14 +00:00
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
/*
|
|
* Script-only addition used for production loader
|
|
*
|
|
*/
|
|
hook('fetch', function(fetch) {
|
|
return function(load) {
|
|
load.metadata.scriptLoad = true;
|
|
// prepare amd define
|
|
if (this.has('@@amd-helpers'))
|
|
this.get('@@amd-helpers').createDefine(this);
|
|
return fetch.call(this, load);
|
|
};
|
|
});
|
|
|
|
// AMD support
|
|
// script injection mode calls this function synchronously on load
|
|
hook('onScriptLoad', function(onScriptLoad) {
|
|
return function(load) {
|
|
onScriptLoad.call(this, load);
|
|
|
|
if (this.has('@@amd-helpers')) {
|
|
var lastModule = this.get('@@amd-helpers').lastModule;
|
|
if (lastModule.anonDefine || lastModule.isBundle) {
|
|
load.metadata.format = 'defined';
|
|
load.metadata.registered = true;
|
|
lastModule.isBundle = false;
|
|
}
|
|
|
|
if (lastModule.anonDefine) {
|
|
load.metadata.deps = load.metadata.deps ? load.metadata.deps.concat(lastModule.anonDefine.deps) : lastModule.anonDefine.deps;
|
|
load.metadata.execute = lastModule.anonDefine.execute;
|
|
lastModule.anonDefine = null;
|
|
}
|
|
}
|
|
};
|
|
}); |