fix: correct Sharp dynamic import usage for ES modules
Fixed TypeScript compilation error when using Sharp library:
- Changed lib.sharp(buffer) to lib.sharp.default(buffer)
- Dynamic imports return module with .default property
- Affects both WebP conversion and thumbnail generation
Error fixed:
TS2349: This expression is not callable.
Type '{ default: typeof sharp; ... }' has no call signatures.
https://claude.ai/code/session_01FaRqGuPecEyPx1qiuRV8Ye
This commit is contained in:
@@ -133,7 +133,7 @@ const convertToWebP = async (
|
||||
}
|
||||
|
||||
logger?.trace('Converting image to WebP using Sharp')
|
||||
const webpBuffer = await lib.sharp(buffer).webp().toBuffer()
|
||||
const webpBuffer = await lib.sharp.default(buffer).webp().toBuffer()
|
||||
|
||||
return { webpBuffer, isAnimated: false }
|
||||
}
|
||||
@@ -622,8 +622,8 @@ export const prepareStickerPackMessage = async (
|
||||
)
|
||||
}
|
||||
|
||||
thumbnailBuffer = await lib
|
||||
.sharp(coverBuffer)
|
||||
thumbnailBuffer = await lib.sharp
|
||||
.default(coverBuffer)
|
||||
.resize(252, 252, { fit: 'cover', position: 'center' })
|
||||
.jpeg({ quality: 85 })
|
||||
.toBuffer()
|
||||
|
||||
Reference in New Issue
Block a user