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')
|
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 }
|
return { webpBuffer, isAnimated: false }
|
||||||
}
|
}
|
||||||
@@ -622,8 +622,8 @@ export const prepareStickerPackMessage = async (
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
thumbnailBuffer = await lib
|
thumbnailBuffer = await lib.sharp
|
||||||
.sharp(coverBuffer)
|
.default(coverBuffer)
|
||||||
.resize(252, 252, { fit: 'cover', position: 'center' })
|
.resize(252, 252, { fit: 'cover', position: 'center' })
|
||||||
.jpeg({ quality: 85 })
|
.jpeg({ quality: 85 })
|
||||||
.toBuffer()
|
.toBuffer()
|
||||||
|
|||||||
Reference in New Issue
Block a user