Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge support? #19

Closed
imownbey opened this issue Apr 6, 2023 · 8 comments · Fixed by #29
Closed

Edge support? #19

imownbey opened this issue Apr 6, 2023 · 8 comments · Fixed by #29

Comments

@imownbey
Copy link

imownbey commented Apr 6, 2023

I think right now this wont support edge based on how it is loading the WASM (and due to dependence on FS although maybe the browser version can be used?). I wondered if somehow using https://vercel.com/docs/concepts/functions/edge-functions/wasm this could be shipped to an edge function, though.

@pomber
Copy link
Contributor

pomber commented Apr 6, 2023

I think I tried it and it works, but I may be wrong. It doesn't use fs if it's not available.

@imownbey
Copy link
Author

imownbey commented Apr 6, 2023

Oh great okay will try!

@pomber
Copy link
Contributor

pomber commented Apr 11, 2023

Oh great okay will try!

let me know how it goes

@imownbey
Copy link
Author

mmm it did not work (at least on vercel) but I dont remember why. Will update this thread when I retry it.

@MaxLeiter
Copy link

MaxLeiter commented May 8, 2023

It doesn't seem to be working for me due to the (node) https module:

- error ./node_modules/.pnpm/@code-hike+lighter@0.6.6/node_modules/@code-hike/lighter/dist/browser.esm.mjs:16:24
Module not found: Can't resolve 'https'

@pomber
Copy link
Contributor

pomber commented May 8, 2023

Strange, it should only import 'https' if 'fetch' isn't available. Conditional imports are a lie.

@tom-sherman
Copy link

In cloudflare workers (and I presume Vercel as well, as they use the cloudflare runtime under the hood) you need to setup a binding to a WASM binary and then reference it.

See https://developers.cloudflare.com/workers/platform/web-assembly/javascript/

So without some bundler magic to replace the WASM import in the lighter code, I don't think it'll work right now.

@pomber
Copy link
Contributor

pomber commented Jul 17, 2023

v0.8.0 should fix this. At least for Vercel's edge.

I had problems with old versions of Next.js (they were ignoring the worker conditional export in lighter's package json), so try updating next.js first if you have problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants