Skip to content

Commit ff52281

Browse files
committed
컴파일 되도록 땜질
1 parent bd047bd commit ff52281

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/frontend/src/contexts/DatabaseContext.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import initSqlJs from "sql.js";
88
// https://sql.js.org/#/?id=usage
99
// https://stackoverflow.com/a/75806317
1010
// TODO: 더 멀쩡한 방법 찾아서 교체하기
11-
const sqlJs = await initSqlJs({
12-
locateFile: (file) => `https://sql.js.org/dist/${file}`,
13-
});
11+
const prepareSqlJs = async () => {
12+
const sqlJs = await initSqlJs({
13+
locateFile: (file) => `https://sql.js.org/dist/${file}`,
14+
});
15+
return sqlJs;
16+
};
1417

1518
export interface DatabaseValue {
1619
db: Kysely<Database>;
@@ -30,12 +33,14 @@ const defaultValue: DatabaseValue = {
3033
export const DatabaseContext = createContext(defaultValue);
3134

3235
const createDialect_arrayBuffer = async (buffer: ArrayBuffer) => {
36+
const sqlJs = await prepareSqlJs();
3337
const database = new sqlJs.Database(new Uint8Array(buffer));
3438
const dialect = new SqlJsDialect({ database });
3539
return dialect;
3640
};
3741

3842
const createDialect_blank = async () => {
43+
const sqlJs = await prepareSqlJs();
3944
const database = new sqlJs.Database();
4045
const dialect = new SqlJsDialect({ database });
4146
return dialect;

0 commit comments

Comments
 (0)