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.
22 lines
1020 B
JavaScript
22 lines
1020 B
JavaScript
import { createRequire } from 'node:module';
|
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
try {
|
|
const { default: sharp } = await import('sharp');
|
|
if (process.argv.includes('--require-source') && !Object.keys(require.cache).some(file => /sharp[/\\]src[/\\]build[/\\]Release[/\\].+\.node$/.test(file))) {
|
|
throw new Error('Expected the source-built Sharp binding; refusing to use a prebuilt fallback');
|
|
}
|
|
for (const format of ['jpeg', 'png', 'webp']) {
|
|
const input = await sharp({ create: { width: 8, height: 8, channels: 3, background: '#336699' } }).toFormat(format).toBuffer();
|
|
const metadata = await sharp(input).metadata();
|
|
if (metadata.format !== format || metadata.width !== 8 || metadata.height !== 8) {
|
|
throw new Error(`${format} encode/decode verification failed`);
|
|
}
|
|
}
|
|
console.log(`Sharp ${sharp.versions.sharp}, libvips ${sharp.versions.vips}: JPEG, PNG and WebP passed.`);
|
|
} catch (error) {
|
|
console.error('Sharp image runtime failed:', error);
|
|
process.exit(1);
|
|
}
|