Skip to content

Commit 04d848f

Browse files
committed
Use electron-vite's ?modulePath instead of tsx for workers
electron-vite has a `?modulePath` vite plugin that compiles the import and returns an absolute path, so we don't need to use tsx to compile and execute the typescript directly. Vanilla vite has a `?worker` plugin but that's only for webworkers; support for node workers is stalled (vitejs/vite#3932).
1 parent 5fbc02d commit 04d848f

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

app/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"jsdom": "^26.1.0",
6464
"prettier": "3.6.0",
6565
"testcontainers": "^11.2.1",
66-
"tsx": "^4.20.5",
6766
"typescript": "~5.8.3",
6867
"typescript-eslint": "^8.35.0",
6968
"vite": "^7.0.0",

app/pnpm-lock.yaml

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/index.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type {
2020
SyncMetadataRequest,
2121
} from "../types";
2222
import { syncMetadata } from "./sync";
23+
import workerPath from "./fetch/worker?modulePath";
2324

2425
const db = new DB();
2526

@@ -59,16 +60,7 @@ function createWindow(): void {
5960
}
6061

6162
function spawnFetchWorker(): Worker {
62-
const scriptPath = join(
63-
app.getAppPath(),
64-
"src",
65-
"main",
66-
"fetch",
67-
"worker.ts",
68-
);
69-
const worker = new Worker(scriptPath, {
70-
execArgv: ["--require", "tsx"],
71-
});
63+
const worker = new Worker(workerPath);
7264

7365
worker.on("message", (result) => {
7466
console.log("Result from worker: ", result);

0 commit comments

Comments
 (0)