Skip to content

Commit 8abab23

Browse files
committed
Added clarity on bundler vs non-bundler imports + vite link
1 parent 3987d4f commit 8abab23

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

packages/sse/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,11 @@ You also need the companion handler script that runs inside the Worker:
343343
import "@solid-primitives/sse/worker-handler";
344344
```
345345

346-
Load it via your bundler's `new URL(…, import.meta.url)` syntax to get a correctly resolved URL at build time.
346+
To get the correct URL for the handler at runtime you have a few options depending on your setup:
347+
348+
- **Bundler (Vite, Webpack, Rollup, etc.)** — use `new URL(…, import.meta.url)`. The bundler resolves the specifier to the output asset path at build time. See the [Vite static asset docs](https://vite.dev/guide/assets#importing-asset-as-url) for details; other bundlers work the same way.
349+
- **Import maps (no bundler)** — add an entry for `@solid-primitives/sse/worker-handler` pointing to the CDN or local path of the file, then use a plain string URL: `new Worker("/path/to/worker-handler.js", { type: "module" })`.
350+
- **Node / Deno / Bun with a file URL**`new URL("./node_modules/@solid-primitives/sse/dist/worker-handler.js", import.meta.url)` works if you reference the built output directly.
347351

348352
### Dedicated Worker
349353

0 commit comments

Comments
 (0)