Skip to content

Commit 3dc324f

Browse files
committed
updated doc
1 parent 4253a84 commit 3dc324f

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

packages/svelte-timeseries/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,48 @@ npm install @qtsurfer/svelte-timeseries
5454
yarn add @qtsurfer/svelte-timeseries
5555
```
5656

57+
**Vite / SvelteKit configuration**
58+
59+
This library uses DuckDB-WASM under the hood, which relies on Web Workers and WASM binaries.
60+
To ensure proper behavior in development and SSR (Server-Side Rendering), you must update your Vite configuration.
61+
62+
Add the following to your vite.config.ts (or vite.config.js):
63+
64+
```ts
65+
import { sveltekit } from '@sveltejs/kit/vite';
66+
import { defineConfig } from 'vite';
67+
68+
export default defineConfig({
69+
plugins: [sveltekit()],
70+
71+
ssr: {
72+
// Prevent SvelteKit from externalizing this library during SSR.
73+
// This ensures Vite processes special imports like `...?url`
74+
// which are required for DuckDB worker files.
75+
noExternal: ['@qtsurfer/svelte-timeseries']
76+
},
77+
78+
optimizeDeps: {
79+
// Avoid pre-bundling these packages with esbuild.
80+
// esbuild cannot handle WASM + Web Worker imports used by DuckDB.
81+
exclude: ['@qtsurfer/svelte-timeseries', '@duckdb/duckdb-wasm']
82+
}
83+
});
84+
```
85+
86+
**Explanation**
87+
88+
Forces Vite to include this library in the SSR build pipeline.
89+
90+
- `ssr.noExternal`\
91+
This allows Vite to correctly transform imports like:\
92+
\
93+
`import worker from '...worker.js?url'`\
94+
which DuckDB uses for its Web Worker runtime.
95+
96+
- `optimizeDeps.exclude`\
97+
Prevents Vite from trying to pre-bundle this library and DuckDB-WASM using esbuild. esbuild does not understand WASM and Worker imports, so excluding these packages avoids “Cannot read file ...?url” and similar errors.
98+
5799
Requirements:
58100

59101
- SvelteKit project with TypeScript enabled.

0 commit comments

Comments
 (0)