Skip to content

Commit

Permalink
fix(gui): manually copy better_sqlite3.node to gui build
Browse files Browse the repository at this point in the history
  • Loading branch information
bambanah committed Oct 22, 2024
1 parent b8f0eb6 commit e411bda
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-mugs-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"deemix-gui": patch
---

Fix missing sqlite library causing crash
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
]
},
"dependencies": {
"better-sqlite3": "^11.3.0"
"better-sqlite3": "^11.4.0"
},
"devDependencies": {
"@yao-pkg/pkg": "^5.15.0",
Expand Down
1 change: 1 addition & 0 deletions gui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/better_sqlite3.node
3 changes: 2 additions & 1 deletion gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
"@types/yargs": "^17.0.32",
"electron": "32.0.2",
"esbuild": "^0.23.1",
"esbuild-plugin-copy": "^2.1.1",
"node-gyp": "^10.2.0",
"tsup": "^8.2.4"
},
"dependencies": {
"better-sqlite3": "^11.3.0",
"better-sqlite3": "^11.4.0",
"deemix-webui": "workspace:*",
"electron-context-menu": "^4.0.4",
"electron-squirrel-startup": "^1.0.1",
Expand Down
20 changes: 17 additions & 3 deletions gui/scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as esbuild from "esbuild";
import copy from "esbuild-plugin-copy";
import fsp from "node:fs/promises";
import { createRequire } from "node:module";
import path from "node:path";
import url from "node:url";
import { getArg, hasArg, log } from "./utils.js";

import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
const packageJson = require("../package.json");

Expand Down Expand Up @@ -53,17 +54,29 @@ async function main(argv) {
outfile: "./dist/main.js",
target: "esnext",
format: "esm",
external: ["electron", "lightningcss", "better-sqlite3"],
external: ["electron", "lightningcss"],
define: {
"process.env.NODE_ENV": JSON.stringify(BUILD_MODE),
"process.env.GUI_VERSION": JSON.stringify(packageJson.version),
"process.env.USE_DEEZER_CACHE": "false",
},
loader: {
".node": "copy",
".png": "file",
},
plugins: [log],
plugins: [
log,
copy({
assets: [
{
from: "./node_modules/better-sqlite3/build/Release/better_sqlite3.node",
to: "../build/better_sqlite3.node",
},
],
}),
],
};

if (IS_WATCH) {
await esbuild.context(options).then((ctx) => ctx.watch());
} else {
Expand All @@ -85,6 +98,7 @@ async function main(argv) {
sourcemap: true,
plugins: [log],
};

if (IS_WATCH) {
await esbuild.context(options).then((ctx) => ctx.watch());
} else {
Expand Down
36 changes: 26 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e411bda

Please sign in to comment.