Skip to content

Commit e490abd

Browse files
committed
fix sqljs loader - use script tag for umd module
1 parent 37610ec commit e490abd

File tree

1 file changed

+12
-5
lines changed
  • public/jsonic-bench/src/adapters

1 file changed

+12
-5
lines changed

public/jsonic-bench/src/adapters/sqljs.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,18 @@ export class SQLJSAdapter extends DatabaseAdapter {
2020
}
2121

2222
async init() {
23-
// Load real SQL.js WASM library from CDN
24-
const module = await import('https://cdn.jsdelivr.net/npm/[email protected]/dist/sql-wasm.js');
25-
// Handle both ESM default export and UMD format
26-
const initSqlJs = module.default || module;
27-
const SQL = await initSqlJs({
23+
// Load real SQL.js WASM library using script tag approach (more reliable for UMD modules)
24+
if (!window.initSqlJs) {
25+
await new Promise((resolve, reject) => {
26+
const script = document.createElement('script');
27+
script.src = 'https://cdn.jsdelivr.net/npm/[email protected]/dist/sql-wasm.js';
28+
script.onload = resolve;
29+
script.onerror = reject;
30+
document.head.appendChild(script);
31+
});
32+
}
33+
34+
const SQL = await window.initSqlJs({
2835
locateFile: file => `https://cdn.jsdelivr.net/npm/[email protected]/dist/${file}`
2936
});
3037

0 commit comments

Comments
 (0)