From 3b2941c7d54d2a3a7c723d172ce75ca8b655fe9f Mon Sep 17 00:00:00 2001 From: "dobby-yivi-agent[bot]" <275734547+dobby-yivi-agent[bot]@users.noreply.github.com> Date: Fri, 3 Jul 2026 17:12:59 +0000 Subject: [PATCH] fix(pg-wasm): omit default-module-path in web wasm-bindgen glue (#153) wasm-pack's `--target web` output emitted an unreachable default-module-path branch (`module_or_path = new URL('index_bg.wasm', import.meta.url)`) in __wbg_init. Webpack 5 statically resolves `new URL(..., import.meta.url)` as an asset import at build time even though the branch never fires for callers that always pass `module_or_path` (e.g. @e4a/pg-js, which inlines the wasm as base64), so downstream consumers hit `Module not found: Can't resolve 'index_bg.wasm'`. Enable wasm-bindgen's --omit-default-module-path via wasm-pack's release-profile metadata so the branch is never generated. This is the issue's preferred fix and lives in the crate manifest, so no fragile post-build regex strip is needed. The bundler target is unaffected (static `import * as wasm from './index_bg.wasm'`, no init function). Callers that pass module_or_path explicitly are unchanged; a caller passing nothing now errors at instantiate time, exactly as the flag intends. Fixes #153 Co-Authored-By: Claude Opus 4.8 --- pg-wasm/Cargo.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pg-wasm/Cargo.toml b/pg-wasm/Cargo.toml index a34e1c3..b0cbbff 100644 --- a/pg-wasm/Cargo.toml +++ b/pg-wasm/Cargo.toml @@ -35,3 +35,13 @@ web-sys = { version = "0.3", features = ["console", "Window", "Performance"] } [package.metadata.wasm-pack.profile.release] wasm-opt = ["-Os"] + +# Pass wasm-bindgen's --omit-default-module-path so the generated `--target web` +# glue does not emit the unreachable `new URL('index_bg.wasm', import.meta.url)` +# default-module-path branch. Webpack 5 statically resolves that `new URL(..., +# import.meta.url)` as an asset import at build time even though the branch never +# fires for callers that always pass `module_or_path` (e.g. @e4a/pg-js), so +# downstream consumers otherwise hit `Module not found: Can't resolve +# 'index_bg.wasm'`. See #153. +[package.metadata.wasm-pack.profile.release.wasm-bindgen] +omit-default-module-path = true