Skip to content

Commit 380a39f

Browse files
committed
fix: include wasm file in build output
1 parent 7358dd4 commit 380a39f

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Nuxt dev/build outputs
2+
.netlify
23
.output
34
.data
45
.nuxt

nuxt.config.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { join } from "node:path";
2-
import { normalizePath } from "vite";
3-
import { viteStaticCopy } from "vite-plugin-static-copy";
1+
// import { join } from "node:path";
2+
// import { normalizePath } from "vite";
3+
// import { viteStaticCopy } from "vite-plugin-static-copy";
44

55
/* eslint-disable perfectionist/sort-objects */
66
// https://nuxt.com/docs/api/configuration/nuxt-config
@@ -24,17 +24,17 @@ export default defineNuxtConfig({
2424
debug: true,
2525
},
2626
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-
],
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, "server/assets")),
35+
// },
36+
// ],
37+
// }),
38+
// ],
3939
},
4040
});

server/utils/sqlite.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ export const loadDatabase = async (
1111
): Promise<Database> => {
1212
try {
1313
console.log("Initializing SQL...");
14-
const SQL = await initSqlJs({
15-
locateFile: () => origin + "/sql-wasm.wasm",
16-
});
14+
const SQL = await initSqlJs();
1715
console.log("SQL initialized");
1816
const db = new SQL.Database(data);
1917
console.log("Database loaded");
18+
if (!db) {
19+
// @ts-expect-error - SQL.js is a module that is not typed.
20+
await import("sql.js/dist/sql-wasm.wasm");
21+
}
2022
return db;
2123
} catch (e) {
2224
console.error(e);

0 commit comments

Comments
 (0)