@@ -223,6 +223,8 @@ async function terserMinify(
223223
224224 // Redefine the comments function to extract and preserve
225225 // comments according to the two conditions
226+ const seenComments = new Set ( extractedComments ) ;
227+
226228 return ( astNode , comment ) => {
227229 if (
228230 /** @type {{ extract: ExtractCommentsFunction } } */
@@ -234,7 +236,8 @@ async function terserMinify(
234236 : `//${ comment . value } ` ;
235237
236238 // Don't include duplicate comments
237- if ( ! extractedComments . includes ( commentText ) ) {
239+ if ( ! seenComments . has ( commentText ) ) {
240+ seenComments . add ( commentText ) ;
238241 extractedComments . push ( commentText ) ;
239242 }
240243 }
@@ -477,6 +480,8 @@ async function uglifyJsMinify(
477480
478481 // Redefine the comments function to extract and preserve
479482 // comments according to the two conditions
483+ const seenComments = new Set ( extractedComments ) ;
484+
480485 return ( astNode , comment ) => {
481486 if (
482487 /** @type {{ extract: ExtractCommentsFunction } } */
@@ -488,7 +493,8 @@ async function uglifyJsMinify(
488493 : `//${ comment . value } ` ;
489494
490495 // Don't include duplicate comments
491- if ( ! extractedComments . includes ( commentText ) ) {
496+ if ( ! seenComments . has ( commentText ) ) {
497+ seenComments . add ( commentText ) ;
492498 extractedComments . push ( commentText ) ;
493499 }
494500 }
0 commit comments