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

Ability to use in webcontainers #368

Open
benmccann opened this issue Aug 25, 2022 · 8 comments
Open

Ability to use in webcontainers #368

benmccann opened this issue Aug 25, 2022 · 8 comments

Comments

@benmccann
Copy link
Collaborator

benmccann commented Aug 25, 2022

It appears next/image can use squoosh or sharp. It would be nice if imagetools could as well. The motivation for this is that I'd love to include imagetools in the default SvelteKit template. However, sharp would not work with StackBlitz and so right now if I were to include imagetools in the template it would break https://node.new/sveltekit

We might want it to be an option as sharp is much faster and would probably be preferred for most users: https://sharp.pixelplumbing.com/performance

@JonasKruckenberg
Copy link
Owner

Interesting idea 🤔 which library would one use for this? And how would we allow users to choose which "backend" to use?

@benmccann
Copy link
Collaborator Author

The alternate library is called squoosh. I was thinking the option could be passed to the plugin during initialization

@benmccann
Copy link
Collaborator Author

Better might be if we could get a wasm version of sharp: stackblitz/webcontainer-core#147 (comment)

@JonasKruckenberg
Copy link
Owner

Better might be if we could get a wasm version of sharp: stackblitz/webcontainer-core#147 (comment)

I looked into warm builds of sharp at the beginning of this projects (actually for being able to create an interactive demo website) and IMO this would be the best option.

@benmccann
Copy link
Collaborator Author

Hmm, looks like squoosh is no longer maintained: https://www.npmjs.com/package/@squoosh/lib

@benmccann benmccann changed the title Option to use squoosh Ability to use in webcontainers Jan 15, 2023
@JonasKruckenberg
Copy link
Owner

Ouf that's tough, so the only way forward here would be a wasm build of sharp I guess

@benmccann
Copy link
Collaborator Author

Figured out how to detect if we're running on webcontainers: https://github.com/stackblitz/viteconf/blob/main/nuxt.config.ts#L7-L17

Potentially we could use this to automatically choose another backend or just disable the plugin while logging a warning that we're doing so

@lovell
Copy link

lovell commented Jul 12, 2024

As of v0.33.0+ sharp provides prebuilt WebAssembly binaries and should Just Work on webcontainers (although there is a further possible improvement detailed at stackblitz/webcontainer-core#1236).

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

No branches or pull requests

3 participants