From 2fa4d3e7a6f525912ed1384c6eab33ff34960eb0 Mon Sep 17 00:00:00 2001 From: Rob Eisenberg Date: Tue, 9 Jun 2015 12:49:14 -0400 Subject: [PATCH] fix(index): detect System or require api and load appropriately This fixes #110 --- src/index.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index e5cbf8e..0a63f2e 100644 --- a/src/index.js +++ b/src/index.js @@ -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();