Skip to content

Commit e788433

Browse files
committed
Combine two async imports into one by way of skin.ts
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
1 parent b157552 commit e788433

2 files changed

Lines changed: 26 additions & 11 deletions

File tree

‎src/vector/init.ts‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,10 @@ export async function loadSkin() {
123123
// the SDK until we have to in imports.
124124
console.log("Loading skin...");
125125
// load these async so that its code is not executed immediately and we can catch any exceptions
126-
const [sdk, skin] = await Promise.all([
127-
import(
128-
/* webpackChunkName: "matrix-react-sdk" */
129-
/* webpackPreload: true */
130-
"matrix-react-sdk"),
131-
import(
132-
/* webpackChunkName: "riot-web-component-index" */
133-
/* webpackPreload: true */
134-
// @ts-ignore - this module is generated so may fail lint
135-
"../component-index"),
136-
]);
126+
const {sdk, skin} = await import(
127+
/* webpackChunkName: "skin" */
128+
/* webpackPreload: true */
129+
"./skin");
137130
sdk.loadSkin(skin);
138131
console.log("Skin loaded!");
139132
}

‎src/vector/skin.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright 2020 New Vector Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import * as sdk from "matrix-react-sdk";
18+
// @ts-ignore - this module is generated so may fail lint
19+
import * as skin from "../component-index";
20+
21+
// we re-export here so that we can async-load this one file and webpack will bundle them together.
22+
export {sdk, skin};

0 commit comments

Comments
 (0)