httptoolkit / brotli-wasm

A reliable compressor and decompressor for Brotli, supporting node & browsers via wasm
Apache License 2.0
264 stars 21 forks source link

Fails on Cloudflare Workers build #6

Open derekperkins opened 3 years ago

derekperkins commented 3 years ago

The browser version relies on document (not available) The node version relies on the core util module (not available)

cc @tannerlinsley

pimterry commented 2 years ago

Interesting! I wasn't aware of this, I haven't used Cloudflare Workers at all.

I'd happily support Cloudflare Workers if possible, but I'm not sure exactly what environment checks would work for that case. Could you look into it, and open a PR?

nickbabcock commented 2 years ago

The good news is that it's not too difficult. Library authors just need to expose an API entry point where one can pass in a WebAssembly.Module. You can see a cloudflare worker that brotli compresses in a sample project of mine: https://github.com/nickbabcock/cloud-functions/tree/a44260fdbdeab4edda3ca8c84227217bd9dbfb3d/src/brotli

(I'm not a user of this library, but I just happened to see this issue and know of a solution).