Skip to content

Commit 4f07c25

Browse files
committed
wasm loading docs
1 parent f97b0e1 commit 4f07c25

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

LOADING_WASM.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
### ⚙️ TL;DR — Serving the `.wasm` File
2+
3+
The core issue isn’t the library — it’s that the **`.wasm` file lives in `node_modules` and isn’t automatically served** by Next.js, Webpack, or Turbopack.
4+
You just need to make sure it’s fetchable at runtime.
5+
6+
#### ✅ Easiest Fix
7+
8+
Copy the `.wasm` file once and serve it from `/public`:
9+
10+
```bash
11+
cp node_modules/libpg-query/wasm/libpg-query.wasm public/
12+
```
13+
14+
#### ⚠️ Why
15+
16+
Bundlers don’t emit `.wasm` files by default — they stay inside `node_modules`, so the runtime can’t fetch them.
17+
18+
#### 🧩 Workarounds
19+
20+
* **Next.js + Webpack:** Add a `.wasm` asset rule or use the copy method.
21+
* **Turbopack:** Only the copy method works for now.
22+
* **Dev mode:** Optionally use a watcher script to auto-copy on rebuilds.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ pnpm run test
185185
- Ensure Emscripten SDK is properly installed and configured
186186
- Check that all required build dependencies are available
187187

188+
**`.wasm` not found**
189+
- Usually occurs in Next.js/Webpack/Turbopack
190+
- see **[LOADING_WASM.md](./LOADING_WASM.md)**
191+
188192
### Template System
189193

190194
To avoid duplication across PostgreSQL versions, common files are maintained in the `templates/` directory:

0 commit comments

Comments
 (0)