@@ -621,7 +621,7 @@ async function imageminGenerate(original, minimizerOptions) {
621
621
const minimizerOptionsNormalized = /** @type {ImageminOptions } */ (
622
622
await imageminNormalizeConfig (
623
623
/** @type {ImageminOptions } */ (
624
- /** @type {? } */ ( minimizerOptions || { } )
624
+ /** @type {? } */ ( minimizerOptions ?? { } )
625
625
) ,
626
626
)
627
627
) ;
@@ -657,7 +657,8 @@ async function imageminGenerate(original, minimizerOptions) {
657
657
658
658
return {
659
659
filename : newFilename ,
660
- data : result ,
660
+ // imagemin@8 returns buffer, but imagemin@9 returns uint8array
661
+ data : ! Buffer . isBuffer ( result ) ? Buffer . from ( result ) : result ,
661
662
warnings : [ ...original . warnings ] ,
662
663
errors : [ ...original . errors ] ,
663
664
info : {
@@ -677,7 +678,7 @@ async function imageminGenerate(original, minimizerOptions) {
677
678
async function imageminMinify ( original , options ) {
678
679
const minimizerOptionsNormalized = /** @type {ImageminOptions } */ (
679
680
await imageminNormalizeConfig (
680
- /** @type {ImageminOptions } */ ( /** @type {? } */ ( options || { } ) ) ,
681
+ /** @type {ImageminOptions } */ ( /** @type {? } */ ( options ?? { } ) ) ,
681
682
)
682
683
) ;
683
684
@@ -718,7 +719,8 @@ async function imageminMinify(original, options) {
718
719
719
720
return {
720
721
filename : original . filename ,
721
- data : result ,
722
+ // imagemin@8 returns buffer, but imagemin@9 returns uint8array
723
+ data : ! Buffer . isBuffer ( result ) ? Buffer . from ( result ) : result ,
722
724
warnings : [ ...original . warnings ] ,
723
725
errors : [ ...original . errors ] ,
724
726
info : {
@@ -790,7 +792,7 @@ async function squooshGenerate(original, minifyOptions) {
790
792
const imagePool = pool || squooshImagePoolCreate ( ) ;
791
793
const image = imagePool . ingestImage ( new Uint8Array ( original . data ) ) ;
792
794
793
- const squooshOptions = /** @type {SquooshOptions } */ ( minifyOptions || { } ) ;
795
+ const squooshOptions = /** @type {SquooshOptions } */ ( minifyOptions ?? { } ) ;
794
796
795
797
const preprocEntries = Object . entries ( squooshOptions ) . filter (
796
798
( [ key , value ] ) => {
@@ -909,7 +911,7 @@ async function squooshMinify(original, options) {
909
911
const isReusePool = Boolean ( pool ) ;
910
912
const imagePool = pool || squooshImagePoolCreate ( ) ;
911
913
const image = imagePool . ingestImage ( new Uint8Array ( original . data ) ) ;
912
- const squooshOptions = /** @type {SquooshOptions } */ ( options || { } ) ;
914
+ const squooshOptions = /** @type {SquooshOptions } */ ( options ?? { } ) ;
913
915
914
916
const preprocEntries = Object . entries ( squooshOptions ) . filter (
915
917
( [ key , value ] ) => {
@@ -1227,8 +1229,7 @@ async function svgoMinify(original, minimizerOptions) {
1227
1229
/** @type {SvgoLib } */
1228
1230
// eslint-disable-next-line node/no-unpublished-require
1229
1231
const { optimize } = require ( "svgo" ) ;
1230
-
1231
- const { encodeOptions } = /** @type {SvgoOptions } */ ( minimizerOptions ) ;
1232
+ const { encodeOptions } = /** @type {SvgoOptions } */ ( minimizerOptions ?? { } ) ;
1232
1233
1233
1234
/** @type {import("svgo").Output } */
1234
1235
let result ;
0 commit comments