fix(@jimp/wasm-webp): initialize WebP WASM from disk in Node#1403
Open
Aniketiitk21 wants to merge 1 commit intojimp-dev:mainfrom
Open
fix(@jimp/wasm-webp): initialize WebP WASM from disk in Node#1403Aniketiitk21 wants to merge 1 commit intojimp-dev:mainfrom
Aniketiitk21 wants to merge 1 commit intojimp-dev:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@jimp/wasm-webpin Node by resolving the existing@jsquash/webpWASM files from disk and compiling them directly instead of relying onfetch(file://...)Root Cause
@jsquash/webpinitializes its WASM modules through a fetch-based path that works in browsers, but in Node it resolves to a localfile:URL. Node'sfetch()cannot load that URL, so@jimp/wasm-webpfails during decoder or encoder initialization before any image work can happen.What Changed
For Node only,
@jimp/wasm-webpnow:.wasmassets withModule.createRequire(import.meta.url)node:fs/promisesandWebAssembly.compileImpact
This keeps the existing
@jsquash/webpintegration and public API intact, but makes the package usable in Node again for both decoding and encoding WebP images.Closes #1366
Validation
pnpm --filter @jimp/types buildpnpm --filter @jimp/wasm-webp buildpnpm --filter @jimp/wasm-webp lintpnpm --filter @jimp/wasm-webp test -- --run