11import type { LoaderContext } from 'webpack'
22import loaderUtils from 'loader-utils'
3- import sharp from 'sharp'
3+ import { sharp , type Sharp } from 'sharp'
44
55const MIMES = {
66 jpeg : 'image/jpeg' ,
@@ -170,7 +170,7 @@ export default async function loader(this: LoaderContext<LoaderOptions>, buffer:
170170
171171async function createFiles (
172172 context : LoaderContext < LoaderOptions > ,
173- image : sharp . Sharp ,
173+ image : Sharp ,
174174 options : { formats : SupportedOutputTypes [ ] ; sizes : number [ ] } ,
175175) : Promise < OutputDataForFormat [ ] > {
176176 const formats : OutputDataForFormat [ ] = [ ]
@@ -186,12 +186,12 @@ async function createFiles(
186186
187187async function processImage (
188188 context : LoaderContext < LoaderOptions > ,
189- image : sharp . Sharp ,
189+ image : Sharp ,
190190 size : number ,
191191 format : SupportedOutputTypes ,
192192) : Promise < SrcSetData > {
193193 const resized = image . resize ( size )
194- let output : sharp . Sharp
194+ let output : Sharp
195195 switch ( format ) {
196196 case 'jpeg' :
197197 output = resized . jpeg ( { quality : 75 , progressive : size > 500 } )
@@ -231,11 +231,11 @@ function emitFile(
231231 return '__webpack_public_path__' + path
232232}
233233
234- async function toBase64Lqip ( image : sharp . Sharp , format : LqipFormat ) {
234+ async function toBase64Lqip ( image : Sharp , format : LqipFormat ) {
235235 const settings = typeof format === 'string' ? { format } : format
236236 const mimeType = MIMES [ settings . format ]
237237 const resized = image . resize ( settings . size ?? 16 )
238- let output : sharp . Sharp
238+ let output : Sharp
239239 switch ( mimeType ) {
240240 case 'image/jpeg' :
241241 output = resized . jpeg ( { quality : settings . quality ?? 20 } )
0 commit comments