sharp
sharp copied to clipboard
WASM Support
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
Hi, it looks you've already found https://github.com/kleisauke/wasm-vips - does that work for you?
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!
For StackBlitz, did you see https://github.com/stackblitz/webcontainer-core/issues/147 ?
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 🙏
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.
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?