fix: build image libraries for baseline VPS CPUs
Some checks failed
Test and deploy / Verify production build (push) Failing after 15m48s

Replace the SIMD-dependent WebAssembly fallback with source-built libvips and Sharp. Pin the libvips archive checksum, use baseline x86-64 compiler flags, retain the native binding and runtime libraries, and check JPEG/PNG/WebP processing before compilation and in the runtime image.

Lint, type checking, and content/security tests passed. Full Docker verification was stopped at the user request; production build and baseline CPU runtime verification remain pending.
This commit is contained in:
2026-09-15 23:16:54 +03:30
parent 286c9903b8
commit 1f58461967
7 changed files with 254 additions and 58 deletions

View File

@@ -1,26 +0,0 @@
import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
import test from 'node:test';
test('image processing falls back to WebAssembly without native CPU support', () => {
// Isolate the native-binding simulation from the rest of the test process.
const result = spawnSync(process.execPath, ['-e', `
const Module = require('node:module');
const original = Module._load;
Module._load = function (id, ...args) {
if (id.endsWith('.node') && !id.includes('wasm32')) {
const error = new Error('Simulated unavailable native binding');
error.code = 'MODULE_NOT_FOUND';
throw error;
}
return original.call(this, id, ...args);
};
const sharp = require('sharp');
(async () => {
const image = await sharp({ create: { width: 8, height: 8, channels: 3, background: '#336699' } }).webp().toBuffer();
const metadata = await sharp(image).metadata();
if (metadata.format !== 'webp' || metadata.width !== 8 || metadata.height !== 8) throw new Error('Image round trip failed');
})().catch(error => { console.error(error); process.exitCode = 1; });
`], { encoding: 'utf8', timeout: 30000 });
assert.equal(result.status, 0, result.stderr || result.error?.message);
});