How to use wasm NPM package (pdfium)

I'm trying to use pdfium, but run into errors:

1. import { PDFiumLibrary } from "@hyzyla/pdfium/browser/base64";
Gets me built and deployed, but runtime error of (error) failed to asynchronously prepare wasm: CompileError: WebAssembly.instantiate(): Wasm code generation disallowed by embedder b/c Cloudflare disallows runtime fetching of wasm (even though the base64 is in my code itself).
2. I tried updating
wrangler.jsonc
, but this property is not supported in wrangler:
  "wasm_modules": {
    "pdfium": "node_modules/@hyzyla/pdfium/dist/pdfium.wasm"
  },

3. I've also tried storing the wasm in my public dir and fetching from /pdfium.wasm but that again runs into the same error as attempt 1.
4. Tried vite-plugin-wasm, but get this error:
(error) failed to asynchronously prepare wasm: ReferenceError: XMLHttpRequest is not defined
  (error) warning: Loading from a file URI (file:///pdfium.wasm) is not supported in most browsers


Any ideas?
Was this page helpful?