Try to install wasm version of sharp

If CPU is not supported by prebuilt binaries
This commit is contained in:
Chocobozzz
2026-05-26 16:37:21 +02:00
parent ca4c0a7e7f
commit d92f43143b
4 changed files with 33 additions and 4 deletions
+1
View File
@@ -93,6 +93,7 @@
"@aws-sdk/lib-storage": "^3.1043.0",
"@aws-sdk/s3-request-presigner": "^3.1043.0",
"@commander-js/extra-typings": "^14.0.0",
"@img/sharp-wasm32": "^0.34.5",
"@misskey-dev/node-http-message-signatures": "^0.0.10",
"@node-oauth/oauth2-server": "^5.3.0",
"@opentelemetry/api": "^1.9.1",
+8 -4
View File
@@ -12,6 +12,9 @@ patchedDependencies:
'@types/markdown-it':
hash: b68247cf64808c60a86b4f1ee56430de5e1b3d0fb2023e0c82242537f4f27937
path: pnpm-patches/@types__markdown-it.patch
sharp:
hash: 6360e5a7ee3bb2fcc71d0f3c8a8532b01555e32108f8ec2eedcbfaba4ea25704
path: pnpm-patches/sharp.patch
tinykeys:
hash: 6855931e9590b29110de8402432514ff7aa294934a067557e96dc7eb46f365e3
path: pnpm-patches/tinykeys.patch
@@ -35,6 +38,9 @@ importers:
'@commander-js/extra-typings':
specifier: ^14.0.0
version: 14.0.0(commander@14.0.3)
'@img/sharp-wasm32':
specifier: ^0.34.5
version: 0.34.5
'@misskey-dev/node-http-message-signatures':
specifier: ^0.0.10
version: 0.0.10
@@ -322,7 +328,7 @@ importers:
version: 2.1.6(@types/node@22.14.1)(@types/validator@13.15.10)(reflect-metadata@0.2.2)(sequelize@6.37.8(pg@8.20.0))
sharp:
specifier: ^0.34.5
version: 0.34.5
version: 0.34.5(patch_hash=6360e5a7ee3bb2fcc71d0f3c8a8532b01555e32108f8ec2eedcbfaba4ea25704)
short-uuid:
specifier: ^6.0.3
version: 6.0.3
@@ -13103,7 +13109,6 @@ snapshots:
'@emnapi/runtime@1.10.0':
dependencies:
tslib: 2.8.1
optional: true
'@emnapi/runtime@1.9.2':
dependencies:
@@ -13460,7 +13465,6 @@ snapshots:
'@img/sharp-wasm32@0.34.5':
dependencies:
'@emnapi/runtime': 1.10.0
optional: true
'@img/sharp-win32-arm64@0.34.5':
optional: true
@@ -22976,7 +22980,7 @@ snapshots:
safe-buffer: 5.2.1
to-buffer: 1.2.2
sharp@0.34.5:
sharp@0.34.5(patch_hash=6360e5a7ee3bb2fcc71d0f3c8a8532b01555e32108f8ec2eedcbfaba4ea25704):
dependencies:
'@img/colour': 1.1.0
detect-libc: 2.1.2
+23
View File
@@ -0,0 +1,23 @@
diff --git a/lib/sharp.js b/lib/sharp.js
index 1081c9314de1b669b0744a931a3b6b570c9f6609..09aec3fc832cf50ced4457a6d2ba20c71dde165a 100644
--- a/lib/sharp.js
+++ b/lib/sharp.js
@@ -31,10 +31,15 @@ for (path of paths) {
}
if (sharp && path.startsWith('@img/sharp-linux-x64') && !sharp._isUsingX64V2()) {
- const err = new Error('Prebuilt binaries for linux-x64 require v2 microarchitecture');
- err.code = 'Unsupported CPU';
- errors.push(err);
sharp = null;
+
+ try {
+ sharp = require('@img/sharp-wasm32/sharp.node');
+ } catch (err2) {
+ const err = new Error('Prebuilt binaries for linux-x64 require v2 microarchitecture');
+ err.code = 'Unsupported CPU';
+ errors.push(err);
+ }
}
if (sharp) {
+1
View File
@@ -30,5 +30,6 @@ onlyBuiltDependencies:
patchedDependencies:
'@types/markdown-it': pnpm-patches/@types__markdown-it.patch
sharp: pnpm-patches/sharp.patch
tinykeys: pnpm-patches/tinykeys.patch
video.js: pnpm-patches/video.js.patch