Skip to content

Commit

Permalink
pass loader to bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
obedm503 committed Mar 24, 2018
1 parent 18e61b8 commit a573444
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 41 deletions.
38 changes: 0 additions & 38 deletions src/bootstrap.ts

This file was deleted.

30 changes: 30 additions & 0 deletions src/bootstrapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { PLATFORM } from 'aurelia-pal';
import { initialize } from 'aurelia-pal-browser';
import { Loader } from 'aurelia-loader';
import { Aurelia } from 'aurelia-framework';

const global: Window = PLATFORM.global;

function ready() {
if (!global.document || global.document.readyState === 'complete') {
return Promise.resolve();
}

return new Promise(resolve => {
function done() {
global.document.removeEventListener('DOMContentLoaded', done);
global.removeEventListener('load', done);
resolve();
}
global.document.addEventListener('DOMContentLoaded', done);
global.addEventListener('load', done);
});
}

export async function bootstrap(host: Element, loader: Loader) {
await ready();
await initialize();
const aurelia = new Aurelia(loader);
aurelia.host = host;
return aurelia;
}
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'reflect-metadata';
import 'aurelia-loader-webpack';
import { WebpackLoader } from 'aurelia-loader-webpack';
import { Aurelia, PLATFORM } from 'aurelia-framework';

import { bootstrap } from './bootstrap';
import { bootstrap } from './bootstrapper';
import { App } from 'app/app';

async function start() {
const host = document.getElementById('root');
const aurelia: Aurelia = await bootstrap(host);
const aurelia: Aurelia = await bootstrap(host, new WebpackLoader());

aurelia.use
// add plugins here
Expand Down

0 comments on commit a573444

Please sign in to comment.