lovell / lovell/sharp

Auto-detect WASM fallback for unsupported platforms (Termux/Android)

Open
#4,563 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
JavaScript
Stars
32.7k
Forks
1.4k
Avg merge
1d 14h
Merged PRs (30d)
5

Description

## Problem
Sharp v0.35.2 fails to load on Termux (Android ARM64):
```
Error: Could not load the "sharp" module using the android-arm64 runtime
```

No prebuilt binaries exist for `android-arm64v8`.

## Workaround (verified working)
```bash
npm install @img/sharp-wasm32
```

## Proposed Solution
Auto-detect unsupported platforms and fall back to WASM:
```javascript
if (loadError && !process.env.SHARP_IGNORE_WASM_FALLBACK) {
try {
module.exports = require('@img/sharp-wasm32');
return;
} catch (_wasmError) {}
}
```

## Benefits
- Zero-config for unsupported platforms
- WASM is slower but functional
- Opt-out via `SHARP_IGNORE_WASM_FALLBACK=1`

## Related
- #3850, #4324, #4161

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the sharp module-loading path that emits the android-arm64 runtime error, and inspect how unsupported platforms are currently handled. Verify the proposed fallback with the @img/sharp-wasm32 package on Termux/Android, including the SHARP_IGNORE_WASM_FALLBACK opt-out; done means unsupported platforms load successfully without breaking supported ones.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, wasm
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.