iterate app load order tweaks

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2020-04-04 23:42:19 +01:00
parent 37ed89c25f
commit 4b6164d823
2 changed files with 8 additions and 6 deletions

View File

@ -53,12 +53,18 @@ async function start() {
await settled(rageshakePromise); // give rageshake a chance to load/fail
await loadSkin();
// Finally, load the app. All of the other react-sdk imports are in this file which causes the skinner to
// run on the components. We use `require` here to make sure webpack doesn't optimize this into an async
// import and thus running before the skin can load.
await loadApp();
}
start().catch(err => {
// try show the error in React
console.log("Show React error page");
console.error(err);
}).catch(err => {
// fall back to showing the error in an alert
console.log("Show fallback error page");
console.error(err);
});

View File

@ -121,6 +121,7 @@ export async function loadSkin() {
// Ensure the skin is the very first thing to load for the react-sdk. We don't even want to reference
// the SDK until we have to in imports.
console.log("Loading skin...");
// load these async so that its code is not executed immediately and we can catch any exceptions
const [sdk, skin] = await Promise.all([
import(
/* webpackChunkName: "matrix-react-sdk" */
@ -136,15 +137,10 @@ export async function loadSkin() {
}
export async function loadApp() {
// Finally, load the app. All of the other react-sdk imports are in this file which causes the skinner to
// run on the components. We use `require` here to make sure webpack doesn't optimize this into an async
// import and thus running before the skin can load.
// load app.js async so that its code is not executed immediately and we can catch any exceptions
const module = await import(
/* webpackChunkName: "riot-web-app" */
/* webpackPreload: true */
"./app");
await module.loadApp();
}
// throw new Error("foobar");
window.Map = undefined;