Skip to content

Commit a1b8804

Browse files
author
Terraphim AI
committed
fix(desktop): restore original svelte alias config for HMR
1 parent 72c8938 commit a1b8804

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

desktop/vite.config.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,25 @@ export default defineConfig(({ command, mode }) => {
9191
}
9292
],
9393
resolve: {
94-
alias: [
95-
{ find: '$lib', replacement: fileURLToPath(new URL('./src/lib', import.meta.url)) },
96-
{ find: '$workers', replacement: fileURLToPath(new URL('./src/workers', import.meta.url)) },
94+
alias: {
95+
'$lib': fileURLToPath(new URL('./src/lib', import.meta.url)),
96+
'$workers': fileURLToPath(new URL('./src/workers', import.meta.url)),
97+
98+
// Map specific Svelte sub-paths back to the real runtime so they are **not** redirected to
99+
// our shim (which would cause ENOTDIR errors like svelte-shim.js/store).
100+
'svelte/internal': resolve(__dirname, 'node_modules/svelte/internal'),
101+
'svelte/store': resolve(__dirname, 'node_modules/svelte/store'),
102+
'svelte/transition': resolve(__dirname, 'node_modules/svelte/transition'),
103+
'svelte/animate': resolve(__dirname, 'node_modules/svelte/animate'),
104+
'svelte/easing': resolve(__dirname, 'node_modules/svelte/easing'),
105+
'svelte/motion': resolve(__dirname, 'node_modules/svelte/motion'),
97106

98107
// Real runtime entry alias so the shim can import without causing an alias loop.
99-
{ find: 'svelte-original', replacement: resolve(__dirname, 'node_modules/svelte/src/runtime/index.js') },
108+
'svelte-original': resolve(__dirname, 'node_modules/svelte/index.mjs'),
100109

101-
// Match bare 'svelte' import only (exact match, not sub-paths)
102-
// Sub-path imports like svelte/internal, svelte/store are resolved via package.json exports
103-
{ find: /^svelte$/, replacement: fileURLToPath(new URL('./src/svelte-shim.js', import.meta.url)) },
104-
]
110+
// Any other bare `import "svelte"` should go to our shim that adds mount/unmount.
111+
'svelte': fileURLToPath(new URL('./src/svelte-shim.js', import.meta.url)),
112+
}
105113
},
106114
clearScreen: false,
107115
server: {
@@ -139,7 +147,9 @@ export default defineConfig(({ command, mode }) => {
139147
'vendor-editor': ['svelte-jsoneditor', '@tiptap/core', '@tiptap/starter-kit', 'tiptap-markdown'],
140148
'vendor-charts': ['d3'],
141149
'vendor-atomic': ['@tomic/lib', '@tomic/svelte'],
142-
'vendor-utils': ['comlink-fetch', 'svelte-routing', 'tinro', 'svelte-markdown']
150+
'vendor-utils': ['comlink-fetch', 'svelte-routing', 'tinro', 'svelte-markdown'],
151+
// Large components
152+
'novel-editor': ['@paralect/novel-svelte']
143153
}
144154
}
145155
},

0 commit comments

Comments
 (0)