From 4b6164d823cf53667fab2a15b8496934e597c50d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 4 Apr 2020 23:42:19 +0100 Subject: [PATCH] iterate app load order tweaks Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/vector/index.js | 6 ++++++ src/vector/init.ts | 8 ++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/vector/index.js b/src/vector/index.js index 44c82772..a919cefe 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -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); }); diff --git a/src/vector/init.ts b/src/vector/init.ts index f53b9231..2344a938 100644 --- a/src/vector/init.ts +++ b/src/vector/init.ts @@ -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;