@@ -34,6 +34,9 @@ export interface BundleEntryPointsOutput {
3434
3535 /** Map of entry point names to their bundle results containing bundled module IDs. */
3636 bundleResults : Map < string , BundleResult > ;
37+
38+ /** Warning messages emitted during bundling. */
39+ warnings : string [ ] ;
3740}
3841
3942/**
@@ -65,6 +68,9 @@ interface MultiBundleOutput {
6568
6669 /** Map of bundle entry names to the set of virtual module IDs included in the bundle. */
6770 moduleIdsByBundle : Map < string , Set < string > > ;
71+
72+ /** Warning messages emitted during the bundle invocation. */
73+ warnings : string [ ] ;
6874}
6975
7076/**
@@ -85,7 +91,7 @@ export async function bundleEntryPoints(
8591) : Promise < BundleEntryPointsOutput > {
8692 const bundleResults = new Map < string , BundleResult > ( ) ;
8793 if ( items . length === 0 ) {
88- return { filesToEmit : [ ] , bundleResults } ;
94+ return { filesToEmit : [ ] , bundleResults, warnings : [ ] } ;
8995 }
9096
9197 const esmEntryPoints : NormalizedEntryPoint [ ] = [ ] ;
@@ -122,6 +128,7 @@ export async function bundleEntryPoints(
122128 return {
123129 filesToEmit : [ ...esmOutput . filesToEmit , ...dtsOutput . filesToEmit ] ,
124130 bundleResults,
131+ warnings : [ ...esmOutput . warnings , ...dtsOutput . warnings ] ,
125132 } ;
126133}
127134
@@ -228,7 +235,10 @@ function createMemoryFileLoaderPlugin(
228235 * @param dir The destination output directory prefix.
229236 * @returns The processed multi-bundle output.
230237 */
231- function processRolldownOutput ( output : RolldownOutput [ 'output' ] , dir : string ) : MultiBundleOutput {
238+ function processRolldownOutput (
239+ output : RolldownOutput [ 'output' ] ,
240+ dir : string ,
241+ ) : Pick < MultiBundleOutput , 'filesToEmit' | 'moduleIdsByBundle' > {
232242 const filesToEmit : MemoryOutputFile [ ] = [ ] ;
233243 const moduleIdsByBundle = new Map < string , Set < string > > ( ) ;
234244 const chunksByFileName = new Map < string , OutputChunk > ( ) ;
@@ -317,6 +327,7 @@ async function executeMultiBundle(
317327 sourcemap = true ;
318328 }
319329
330+ const warnings : string [ ] = [ ] ;
320331 const bundle = await rolldown ( {
321332 context : 'this' ,
322333 input,
@@ -325,6 +336,11 @@ async function executeMultiBundle(
325336 treeshake : false ,
326337 resolve : { symlinks : ! preserveSymlinks } ,
327338 checks : { circularDependency : false } ,
339+ onLog ( level , log ) {
340+ if ( level === 'warn' ) {
341+ warnings . push ( log . message ) ;
342+ }
343+ } ,
328344 experimental : {
329345 attachDebugInfo : 'none' ,
330346 } ,
@@ -341,7 +357,10 @@ async function executeMultiBundle(
341357 comments : { jsdoc : isDts , legal : true , annotation : true } ,
342358 } ) ;
343359
344- return processRolldownOutput ( output , dir ) ;
360+ return {
361+ ...processRolldownOutput ( output , dir ) ,
362+ warnings,
363+ } ;
345364 } finally {
346365 await bundle . close ( ) ;
347366 }
@@ -361,7 +380,7 @@ async function bundleAllEsm(
361380 options : NormalizedLibraryOptions ,
362381) : Promise < MultiBundleOutput > {
363382 if ( entryPoints . length === 0 ) {
364- return { filesToEmit : [ ] , moduleIdsByBundle : new Map ( ) } ;
383+ return { filesToEmit : [ ] , moduleIdsByBundle : new Map ( ) , warnings : [ ] } ;
365384 }
366385
367386 return executeMultiBundle (
@@ -386,7 +405,7 @@ async function bundleAllDts(
386405 options : NormalizedLibraryOptions ,
387406) : Promise < MultiBundleOutput > {
388407 if ( entryPoints . length === 0 ) {
389- return { filesToEmit : [ ] , moduleIdsByBundle : new Map ( ) } ;
408+ return { filesToEmit : [ ] , moduleIdsByBundle : new Map ( ) , warnings : [ ] } ;
390409 }
391410
392411 const dtsSourcemap = options . declarationMap ;
0 commit comments