dylibso / observe-sdk

Continuous runtime observablity SDKs to monitor WebAssembly code.
https://dev.dylibso.com/docs/observe/overview
Apache License 2.0
156 stars 7 forks source link

fix: add special target for Cloudflare Workers #151

Closed mhmd-azeez closed 8 months ago

mhmd-azeez commented 8 months ago

Fixes #150

Unfortunately, from what I see it's not possible to have one package that works for boths Cloudflare Workers and other platforms. The problem is, Cloudflare Workers need you to import the wasm statically (dynamic import doesn't work), and the other platforms don't let you import wasm files statically.

chrisdickinson commented 8 months ago

I haven't looked too closely at how observe-sdk is packaged up yet, but from #150 the observe-sdk appears to use wasm-bindgen?

This might retread ground you've already covered, but it looks like Cloudflare has some instructions on how to patch wasm-bindgen output to be used in a worker. Also: I believe that wrangler respects {"exports": {"workerd": {...}} in package.json (like the bun and node mappings in the js-sdk). That might let us unify the packages?

mhmd-azeez commented 8 months ago

@chrisdickinson two great pointers! I will take a look at them both. thank you very much! I was very unhappy with the fact that I had to create new packages, but this gives me a lot of hope

nilslice commented 8 months ago

@mhmd-azeez - nice! were you able to test this on a remote worker deployed in Cloudflare? or only workerd locally?

mhmd-azeez commented 8 months ago

@nilslice I had only tested locally because I assumed that the npm packages would be installed on the server, but it seems like when you do wrangler deploy, it just copies everything. I can confirm that it works on Cloudflare too!