Skip to content

Commit

Permalink
fix(index): detect System or require api and load appropriately
Browse files Browse the repository at this point in the history
This fixes #110
  • Loading branch information
EisenbergEffect committed Jun 9, 2015
1 parent 7e40d93 commit 2fa4d3e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,19 @@ function ready(global) {

function ensureLoader(){
if(!window.AureliaLoader){
return System.normalize('aurelia-bootstrapper').then(function(bootstrapperName){
return System.normalize('aurelia-loader-default', bootstrapperName).then(function(loaderName){
return System.import(loaderName);
})
});
if(window.System){
return System.normalize('aurelia-bootstrapper').then(bootstrapperName => {
return System.normalize('aurelia-loader-default', bootstrapperName).then(loaderName => {
return System.import(loaderName);
})
});
} else if(window.require){
return new Promise((resolve, reject) => {
require(['aurelia-loader-default'], resolve, reject);
});
}else{
throw new Error('No window.AureliaLoader is defined and there is neither a System API (ES6) or a Require API (AMD) available to load your app.')
}
}

return Promise.resolve();
Expand Down

0 comments on commit 2fa4d3e

Please sign in to comment.