Skip to content

Commit

Permalink
fix(init): move initTchap to dynamic import for browser feature check
Browse files Browse the repository at this point in the history
  • Loading branch information
marc.sirisak committed Aug 1, 2024
1 parent 7698735 commit 8bfab1a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
8 changes: 8 additions & 0 deletions src/tchap/app/initTchap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,11 @@ export function saveAppVersionInLocalStorage() {
export function registerExpiredAccountListener() {
ExpiredAccountHandler.register();
}

export default {
registerExpiredAccountListener,
saveAppVersionInLocalStorage,
queueOverideUserSettings,
queueClearCacheAndReload,
needsRefreshForVersion4
}
22 changes: 14 additions & 8 deletions src/vector/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ import { shouldPolyfill as shouldPolyFillIntlSegmenter } from "@formatjs/intl-se
// These are things that can run before the skin loads - be careful not to reference the react-sdk though.
import { parseQsFromFragment } from "./url_utils";
import "./modernizr";
// eslint-disable-next-line max-len
import {
queueClearCacheAndReload,
queueOverideUserSettings,
needsRefreshForVersion4,
saveAppVersionInLocalStorage,
registerExpiredAccountListener,
} from "../tchap/app/initTchap";

// Make setImmediate available in bundle
import "setimmediate";
Expand Down Expand Up @@ -150,6 +142,20 @@ async function start(): Promise<void> {
/* webpackPreload: true */
"./init"
);

// :TCHAP: load initTchap.ts async so that its code is not executed immediately and we can catch any exceptions
const {
registerExpiredAccountListener,
saveAppVersionInLocalStorage,
queueOverideUserSettings,
queueClearCacheAndReload,
needsRefreshForVersion4
} = await import(
/* webpackChunkName: "initTchap" */
/* webpackPreload: true */
"../tchap/app/initTchap"
);
// end :TCHAP:

// Now perform the next stage of initialisation. This has its own try/catch in which we render
// a react error page on failure.
Expand Down

0 comments on commit 8bfab1a

Please sign in to comment.