@@ -14,11 +14,11 @@ export interface BatchWarnings {
1414
1515export default function batchWarnings ( ) : BatchWarnings {
1616 let count = 0 ;
17- let deferredWarnings = new Map < keyof typeof deferredHandlers , RollupWarning [ ] > ( ) ;
17+ const deferredWarnings = new Map < keyof typeof deferredHandlers , RollupWarning [ ] > ( ) ;
1818 let warningOccurred = false ;
1919
2020 return {
21- add : ( warning : RollupWarning ) => {
21+ add ( warning : RollupWarning ) {
2222 count += 1 ;
2323 warningOccurred = true ;
2424
@@ -48,7 +48,7 @@ export default function batchWarnings(): BatchWarnings {
4848 return count ;
4949 } ,
5050
51- flush : ( ) => {
51+ flush ( ) {
5252 if ( count === 0 ) return ;
5353
5454 const codes = Array . from ( deferredWarnings . keys ( ) ) . sort (
@@ -59,7 +59,7 @@ export default function batchWarnings(): BatchWarnings {
5959 deferredHandlers [ code ] ( deferredWarnings . get ( code ) ! ) ;
6060 }
6161
62- deferredWarnings = new Map ( ) ;
62+ deferredWarnings . clear ( ) ;
6363 count = 0 ;
6464 } ,
6565
@@ -72,7 +72,7 @@ export default function batchWarnings(): BatchWarnings {
7272const immediateHandlers : {
7373 [ code : string ] : ( warning : RollupWarning ) => void ;
7474} = {
75- MISSING_NODE_BUILTINS : warning => {
75+ MISSING_NODE_BUILTINS ( warning ) {
7676 title ( `Missing shims for Node.js built-ins` ) ;
7777
7878 stderr (
@@ -82,7 +82,7 @@ const immediateHandlers: {
8282 ) ;
8383 } ,
8484
85- UNKNOWN_OPTION : warning => {
85+ UNKNOWN_OPTION ( warning ) {
8686 title ( `You have passed an unrecognized option` ) ;
8787 stderr ( warning . message ) ;
8888 }
@@ -138,7 +138,7 @@ const deferredHandlers: {
138138 }
139139 } ,
140140
141- MIXED_EXPORTS : warnings => {
141+ MIXED_EXPORTS ( warnings ) {
142142 title ( 'Mixing named and default exports' ) ;
143143 info ( `https://rollupjs.org/guide/en/#outputexports` ) ;
144144 stderr ( bold ( 'The following entry modules are using named and default exports together:' ) ) ;
@@ -204,9 +204,7 @@ const deferredHandlers: {
204204 title ( `Broken sourcemap` ) ;
205205 info ( 'https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect' ) ;
206206
207- const plugins = [
208- ...new Set ( warnings . map ( warning => warning . plugin ) . filter ( Boolean ) )
209- ] as string [ ] ;
207+ const plugins = [ ...new Set ( warnings . map ( ( { plugin } ) => plugin ) . filter ( Boolean ) ) ] as string [ ] ;
210208 stderr (
211209 `Plugins that transform code (such as ${ printQuotedStringList (
212210 plugins
@@ -224,13 +222,12 @@ const deferredHandlers: {
224222 title ( 'Unresolved dependencies' ) ;
225223 info ( 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency' ) ;
226224
227- const dependencies = new Map ( ) ;
225+ const dependencies = new Map < string , string [ ] > ( ) ;
228226 for ( const warning of warnings ) {
229- getOrCreate ( dependencies , warning . source , ( ) => [ ] ) . push ( warning . importer ) ;
227+ getOrCreate ( dependencies , warning . source , ( ) => [ ] ) . push ( warning . importer ! ) ;
230228 }
231229
232- for ( const dependency of dependencies . keys ( ) ) {
233- const importers = dependencies . get ( dependency ) ;
230+ for ( const [ dependency , importers ] of dependencies ) {
234231 stderr ( `${ bold ( dependency ) } (imported by ${ importers . join ( ', ' ) } )` ) ;
235232 }
236233 } ,
@@ -243,7 +240,7 @@ const deferredHandlers: {
243240 ' imported from external module "' +
244241 warning . source +
245242 '" but never used in ' +
246- printQuotedStringList ( ( warning . sources as string [ ] ) . map ( id => relativeId ( id ) ) )
243+ printQuotedStringList ( warning . sources ! . map ( id => relativeId ( id ) ) )
247244 ) ;
248245 }
249246 }
0 commit comments