Skip to content

Commit 7a1713b

Browse files
committed
fix: resolve main build issues
1 parent 05b9a09 commit 7a1713b

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

src/main/services/recording.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,29 @@ import {
1212
TASK_EXTRACTION_PROMPT,
1313
} from "./transcription-prompts.js";
1414

15-
let FileConstructor: typeof File;
16-
try {
17-
const { File: NodeFile } = await import("node:buffer");
18-
FileConstructor = NodeFile as typeof File;
19-
} catch {
20-
FileConstructor = class File extends Blob {
21-
name: string;
22-
lastModified: number;
23-
24-
constructor(bits: BlobPart[], name: string, options?: FilePropertyBag) {
25-
super(bits, options);
26-
this.name = name;
27-
this.lastModified = options?.lastModified ?? Date.now();
28-
}
29-
} as typeof File;
30-
}
15+
const fallbackFile = class File extends Blob {
16+
name: string;
17+
lastModified: number;
18+
19+
constructor(bits: BlobPart[], name: string, options?: FilePropertyBag) {
20+
super(bits, options);
21+
this.name = name;
22+
this.lastModified = options?.lastModified ?? Date.now();
23+
}
24+
} as typeof File;
3125

32-
if (!globalThis.File) {
33-
globalThis.File = FileConstructor;
34-
}
26+
(async () => {
27+
let FileConstructor: typeof File;
28+
try {
29+
FileConstructor = (await import("node:buffer")).File as typeof File;
30+
} catch {
31+
FileConstructor = fallbackFile;
32+
}
33+
34+
if (!globalThis.File) {
35+
globalThis.File = FileConstructor;
36+
}
37+
})();
3538

3639
interface RecordingSession {
3740
id: string;

vite.main.config.mts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { copyFileSync, mkdirSync } from "node:fs";
2-
import { join } from "node:path";
2+
import path, { join } from "node:path";
3+
import { fileURLToPath } from "node:url";
34
import { defineConfig, type Plugin } from "vite";
45

6+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
7+
58
/**
69
* Custom Vite plugin to fix circular __filename references in bundled ESM packages.
710
*
@@ -56,6 +59,15 @@ function copyAgentTemplates(): Plugin {
5659

5760
export default defineConfig({
5861
plugins: [fixFilenameCircularRef(), copyAgentTemplates()],
62+
resolve: {
63+
alias: {
64+
"@": path.resolve(__dirname, "./src"),
65+
"@main": path.resolve(__dirname, "./src/main"),
66+
"@renderer": path.resolve(__dirname, "./src/renderer"),
67+
"@shared": path.resolve(__dirname, "./src/shared"),
68+
"@api": path.resolve(__dirname, "./src/api"),
69+
},
70+
},
5971
build: {
6072
target: "node18",
6173
minify: false, // Disable minification to prevent variable name conflicts

0 commit comments

Comments
 (0)