crypto-js-wasm icon indicating copy to clipboard operation
crypto-js-wasm copied to clipboard

Support cloudflare worker runtime

Open enpitsuLin opened this issue 11 months ago • 0 comments

Currently, the WASM files are embedded as gzipped base64 strings in the module. However, this approach is not compatible with Cloudflare Workers runtime and causes errors when using Wrangler.

image

Cloudflare Workers only supports direct WASM imports. https://github.com/cloudflare/workers-sdk/issues/1366

As a workaround, I've implemented a solution by:

  1. Dumping WASM from hardcoded values
  2. Adding a polyfill for loadWasm logic

like: image

While this works for basic WASM modules, it doesn't work properly for RSA implementations that depend on rsa_bg.js. I haven't found a solution for this besides using package patches.

Would it be possible to provide the raw WASM files instead of embedding them as gzipped base64 strings? This would improve compatibility with bundlers that support WASM directly.

enpitsuLin avatar Dec 01 '24 15:12 enpitsuLin