11/* eslint-disable no-console */
2- import { MergedRollupOptions , rollup } from 'rollup' ;
2+ import { InputPluginOption , rollup , type RollupOptions } from 'rollup' ;
33
44import { GENERATED_DIR } from './constants' ;
55
66async function getBatchBuildOptions (
77 batch : Array < string > ,
8- ) : Promise < Array < MergedRollupOptions > > {
8+ ) : Promise < Array < RollupOptions > > {
99 const { constructUMDGlobalName } = await import (
1010 '@lg-tools/build/config/utils/constructUMDGlobalName.mjs'
1111 ) ;
@@ -21,11 +21,11 @@ async function getBatchBuildOptions(
2121 {
2222 ...esmConfig ,
2323 input : batch . map ( icon => `${ GENERATED_DIR } /${ icon } .tsx` ) ,
24- output : [ esmConfig . output ] ,
24+ output : esmConfig . output ,
2525 plugins : [
2626 // Ensure @emotion packages are externalized (not bundled into icons)
2727 nodeExternals ( { deps : true , include : [ / @ e m o t i o n / ] } ) ,
28- ...esmConfig . plugins ,
28+ ...( esmConfig . plugins as Array < InputPluginOption > ) ,
2929 ] ,
3030 } ,
3131 // UMD builds need a single input file
@@ -43,7 +43,7 @@ async function getBatchBuildOptions(
4343 plugins : [
4444 // Ensure @emotion packages are externalized (not bundled into icons)
4545 nodeExternals ( { deps : true , include : [ / @ e m o t i o n / ] } ) ,
46- ...umdConfig . plugins ,
46+ ...( umdConfig . plugins as Array < InputPluginOption > ) ,
4747 ] ,
4848 } ;
4949 } ) ,
@@ -64,7 +64,14 @@ export async function buildBatch(
6464 for ( const config of rollupConfigs ) {
6565 const bundle = await rollup ( config ) ;
6666
67- await Promise . all ( config . output . map ( bundle . write ) ) ;
67+ if ( config . output ) {
68+ const outputs = Array . isArray ( config . output )
69+ ? config . output
70+ : [ config . output ] ;
71+
72+ await Promise . all ( outputs . map ( bundle . write ) ) ;
73+ }
74+
6875 await bundle . close ( ) ;
6976 }
7077 } catch ( e ) {
0 commit comments