Skip to content

Commit baf4b59

Browse files
committed
fix: resolve production package window fail to open due to broken mermaid import
1 parent fc5bdf5 commit baf4b59

2 files changed

Lines changed: 1 addition & 16 deletions

File tree

electron.vite.config.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,6 @@ import tsconfigPaths from "vite-tsconfig-paths";
1212
// from our electron build
1313
const CHROME = "chrome140";
1414
const NODE = "node22";
15-
const MERMAID_CORE = path.resolve(__dirname, "node_modules/mermaid/dist/mermaid.core.mjs");
16-
17-
function streamdownMermaidFix() {
18-
return {
19-
name: "streamdown-mermaid-fix",
20-
enforce: "pre" as const,
21-
transform(code: string, id: string) {
22-
if (!id.includes("node_modules/streamdown")) return null;
23-
if (!code.includes("import('mermaid')")) return null;
24-
return code.replaceAll("import('mermaid')", `import('/@fs${MERMAID_CORE}')`);
25-
},
26-
};
27-
}
2815

2916
export default defineConfig({
3017
main: {
@@ -43,7 +30,6 @@ export default defineConfig({
4330
resolve: {
4431
alias: {
4532
"@": "frontend",
46-
mermaid: path.resolve(__dirname, "node_modules/mermaid/dist/mermaid.js"),
4733
},
4834
},
4935
server: {
@@ -148,7 +134,6 @@ export default defineConfig({
148134
},
149135
plugins: [
150136
tsconfigPaths(),
151-
streamdownMermaidFix(),
152137
{ ...ViteImageOptimizer(), apply: "build" },
153138
svgr({
154139
svgrOptions: { exportType: "default", ref: true, svgo: false, titleProp: true },

frontend/app/element/markdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ let mermaidInstance: any = null;
3131

3232
const initializeMermaid = async () => {
3333
if (!mermaidInitialized) {
34-
const mermaid = await import("mermaid/dist/mermaid.js");
34+
const mermaid = await import("mermaid");
3535
mermaidInstance = mermaid.default;
3636
mermaidInstance.initialize({ startOnLoad: false, theme: "dark", securityLevel: "strict" });
3737
mermaidInitialized = true;

0 commit comments

Comments
 (0)