Skip to content

Commit 7860594

Browse files
committed
fix: correctly bundle sql.js
1 parent 10247f2 commit 7860594

File tree

5 files changed

+91
-1
lines changed

5 files changed

+91
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ coverage/
2929
# Playwright
3030
playwright-report/
3131
test-results/
32+
33+
# Generated files
34+
public/sql-wasm.wasm

nuxt.config.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import { join } from "node:path";
2+
import { normalizePath } from "vite";
3+
import { viteStaticCopy } from "vite-plugin-static-copy";
4+
15
/* eslint-disable perfectionist/sort-objects */
26
// https://nuxt.com/docs/api/configuration/nuxt-config
37
export default defineNuxtConfig({
@@ -19,4 +23,18 @@ export default defineNuxtConfig({
1923
storage: "localStorage",
2024
debug: true,
2125
},
26+
vite: {
27+
plugins: [
28+
viteStaticCopy({
29+
targets: [
30+
{
31+
src: normalizePath(
32+
join(__dirname, "node_modules/sql.js/dist/sql-wasm.wasm"),
33+
),
34+
dest: normalizePath(join(__dirname, "public")),
35+
},
36+
],
37+
}),
38+
],
39+
},
2240
});

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
"lint-staged": "^16.2.7",
6262
"playwright-core": "^1.58.1",
6363
"typescript": "^5.9.3",
64+
"vite": "^7.3.1",
65+
"vite-plugin-static-copy": "^3.2.0",
6466
"vitest": "^3.2.4",
6567
"vue-tsc": "^3.2.4"
6668
},

pnpm-lock.yaml

Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/utils/sqlite.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ export const loadDatabase = async (
99
data: ArrayLike<number> | Buffer,
1010
): Promise<Database> => {
1111
console.debug(`Loading database from data...`);
12-
const SQL = await initSqlJs();
12+
const SQL = await initSqlJs({
13+
locateFile: () =>
14+
new URL("./../../public/sql-wasm.wasm", import.meta.url).toString(),
15+
});
1316
const db = new SQL.Database(data);
1417
return db;
1518
};

0 commit comments

Comments
 (0)