optimized-images-loader icon indicating copy to clipboard operation
optimized-images-loader copied to clipboard

Add an opt in option to use imagemin instead of wasm libs

Open andreisergiu98 opened this issue 4 years ago • 4 comments

Trying to fix https://github.com/cyrilwanner/next-optimized-images/issues/195 i ended up patching the loader to use image-min so i can build the images, so i was thinking maybe we could add an opt in option to use system libs instead of wasm, it should be a little bit faster and it can use as much memory as the system has. I am willing to make a PR, but i wanted to check in with you first to discuss about the configuration structure. When i have time i'll make a proposal :).

andreisergiu98 avatar Aug 25 '20 12:08 andreisergiu98

Since you are talking about memory problems I guess you had the same RangeError: WebAssembly.Memory(): could not allocate memory? Would be really happy to see your proposal :)

tilman avatar Sep 09 '20 09:09 tilman

@andreisergiu98 Do you mind sharing your solution? I am stuck. My prod used to work with the previous version (though slow). When I migrated to canary v10, my 2G RAM VPS is not able to build site that has only 4 images! Now I am stuck and I don't want to roll back. BTW, works perfectly fine on my laptop with plenty of RAM.

semyou avatar Sep 14 '20 20:09 semyou

@semyou I cloned this repository and replaced wasm-codecs from src/optimize/jpeg.ts and src/optimize/png.ts with imagemin (with mozjpeg and pngquant plugins), then i added it into the project as a yarn workspace. I think yarn resolution would also work.

andreisergiu98 avatar Sep 16 '20 07:09 andreisergiu98

Also need a solution for RangeError: WebAssembly.Memory(): could not allocate memory, subscribing.

Nadav42 avatar Oct 06 '20 20:10 Nadav42