sharp icon indicating copy to clipboard operation
sharp copied to clipboard

WASM Support

Open ghostdevv opened this issue 1 year ago • 5 comments

Feature request

What are you trying to achieve?

In order for sharp to run on something like Stackblitz wasm support is needed, looking through all the various issues about it the main concern has been the lack of support from vips but that seems to be resolved now (https://github.com/libvips/libvips/issues/192#issuecomment-684847123)

Related: #2863 #1476 #1510 #2208 #2436

ghostdevv avatar Aug 14 '22 21:08 ghostdevv

Hi, it looks you've already found https://github.com/kleisauke/wasm-vips - does that work for you?

lovell avatar Aug 14 '22 22:08 lovell

My main goal is to get it working on stackblitz, I am not 100% sure what is needed for that so asked some people who do!

ghostdevv avatar Aug 22 '22 21:08 ghostdevv

For StackBlitz, did you see https://github.com/stackblitz/webcontainer-core/issues/147 ?

lovell avatar Aug 23 '22 08:08 lovell

FYI on the StackBlitz side our polyfill is basically just a no-op, so having Sharp itself as a Wasm is still very much needed and we'd love to help in any way we can @ghostdevv @lovell 🙏

EricSimons avatar Aug 30 '22 16:08 EricSimons

I'm currently trying to give this a shot! As far as I can see, many APIs depend on Napi (which is expected) but I don't think WASM can skip them, so they are an issue for compiling to WASM!

What we can do is create a fork of sharp, which removes those Napi values and just exports the WASM build. And the second solution is we re-create some files in the repo so we make them platform agnostic and then use them in two type of files, one for napi and one for wasm which makes it so much harder and risky for a project at that scale.

Aslemammad avatar Sep 08 '22 12:09 Aslemammad

One of the few image libs that did support wasm (squoosh) is now deprecated and doesn't support node 18.

So it would be great to get wasm support in sharp 🙂

Did anyone start a branch or fork yet?

styfle avatar Oct 31 '22 20:10 styfle