@@ -73,6 +73,8 @@ self.addEventListener('message', async (event: MessageEvent<BundleMessageData>)
7373 can_use_experimental_async
7474 ) ;
7575
76+ console . log ( result ) ;
77+
7678 if ( JSON . stringify ( result . error ) === JSON . stringify ( ABORT ) ) return ;
7779 if ( result && uid === current_id ) postMessage ( result ) ;
7880 } ) ;
@@ -372,61 +374,57 @@ async function get_bundle(
372374 }
373375 } ;
374376
375- try {
376- const key = JSON . stringify ( options ) ;
377-
378- bundle = await rollup ( {
379- input : './__entry.js' ,
380- cache : previous ?. key === key && previous . cache ,
381- plugins : [
382- repl_plugin ,
383- commonjs ,
384- json ,
385- svg ,
386- mp3 ,
387- image ,
388- glsl ,
389- loop_protect ,
390- replace ( {
391- 'process.env.NODE_ENV' : JSON . stringify ( 'production' )
392- } ) ,
393- options . tailwind && {
394- name : 'tailwind-extract' ,
395- transform ( code , id ) {
396- // TODO tidy this up
397- if ( id . startsWith ( `${ NPM } /svelte@` ) ) return ;
398- if ( id . startsWith ( `${ NPM } /clsx@` ) ) return ;
399- if ( id === `${ VIRTUAL } /${ ENTRYPOINT } ` ) return ;
400- if ( id === `${ VIRTUAL } /${ STYLES } ` ) return ;
401- if ( id === `${ VIRTUAL } /${ ESM_ENV } ` ) return ;
402- if ( id . endsWith ( '.svelte' ) ) return ;
403-
404- add_tailwind_candidates ( this . parse ( code ) ) ;
405- }
377+ const key = JSON . stringify ( options ) ;
378+
379+ bundle = await rollup ( {
380+ input : './__entry.js' ,
381+ cache : previous ?. key === key && previous . cache ,
382+ plugins : [
383+ repl_plugin ,
384+ commonjs ,
385+ json ,
386+ svg ,
387+ mp3 ,
388+ image ,
389+ glsl ,
390+ loop_protect ,
391+ replace ( {
392+ 'process.env.NODE_ENV' : JSON . stringify ( 'production' )
393+ } ) ,
394+ options . tailwind && {
395+ name : 'tailwind-extract' ,
396+ transform ( code , id ) {
397+ // TODO tidy this up
398+ if ( id . startsWith ( `${ NPM } /svelte@` ) ) return ;
399+ if ( id . startsWith ( `${ NPM } /clsx@` ) ) return ;
400+ if ( id === `${ VIRTUAL } /${ ENTRYPOINT } ` ) return ;
401+ if ( id === `${ VIRTUAL } /${ STYLES } ` ) return ;
402+ if ( id === `${ VIRTUAL } /${ ESM_ENV } ` ) return ;
403+ if ( id . endsWith ( '.svelte' ) ) return ;
404+
405+ add_tailwind_candidates ( this . parse ( code ) ) ;
406406 }
407- ] ,
408- onwarn ( warning ) {
409- all_warnings . push ( {
410- message : warning . message
411- } ) ;
412407 }
413- } ) ;
414-
415- previous = { key, cache : bundle . cache } ;
408+ ] ,
409+ onwarn ( warning ) {
410+ all_warnings . push ( {
411+ message : warning . message
412+ } ) ;
413+ }
414+ } ) ;
416415
417- return {
418- bundle,
419- tailwind : options . tailwind
420- ? ( tailwind ?? ( await init_tailwind ( ) ) ) . build ( tailwind_candidates )
421- : undefined ,
422- imports : Array . from ( imports ) ,
423- error : null ,
424- warnings,
425- all_warnings
426- } ;
427- } catch ( error ) {
428- return { error, imports : null , bundle : null , warnings, all_warnings } ;
429- }
416+ previous = { key, cache : bundle . cache } ;
417+
418+ return {
419+ bundle,
420+ tailwind : options . tailwind
421+ ? ( tailwind ?? ( await init_tailwind ( ) ) ) . build ( tailwind_candidates )
422+ : undefined ,
423+ imports : Array . from ( imports ) ,
424+ error : null ,
425+ warnings,
426+ all_warnings
427+ } ;
430428}
431429
432430export type BundleResult = ReturnType < typeof bundle > ;
@@ -504,20 +502,16 @@ async function bundle(
504502 lookup . set ( file . name , file ) ;
505503 } ) ;
506504
507- let client : Awaited < ReturnType < typeof get_bundle > > = await get_bundle (
508- svelte ,
509- svelte_version ,
510- uid ,
511- 'client' ,
512- lookup ,
513- options ,
514- can_use_experimental_async
515- ) ;
516-
517505 try {
518- if ( client . error ) {
519- throw client . error ;
520- }
506+ let client : Awaited < ReturnType < typeof get_bundle > > = await get_bundle (
507+ svelte ,
508+ svelte_version ,
509+ uid ,
510+ 'client' ,
511+ lookup ,
512+ options ,
513+ can_use_experimental_async
514+ ) ;
521515
522516 const client_result = (
523517 await client . bundle ?. generate ( {
@@ -540,10 +534,6 @@ async function bundle(
540534 )
541535 : null ;
542536
543- if ( server ?. error ) {
544- throw server . error ;
545- }
546-
547537 const server_result = server
548538 ? (
549539 await server . bundle ?. generate ( {
@@ -562,6 +552,7 @@ async function bundle(
562552 tailwind : client . tailwind ,
563553 imports : client . imports ,
564554 // Svelte 5 returns warnings as error objects with a toJSON method, prior versions return a POJO
555+ // TODO are bundler warnings even used anywhere?
565556 warnings : client . warnings . map ( ( w : any ) => w . toJSON ?.( ) ?? w ) ,
566557 error : null
567558 } ;
@@ -575,7 +566,7 @@ async function bundle(
575566 client : null ,
576567 server : null ,
577568 imports : null ,
578- warnings : client . warnings ,
569+ warnings : [ ] ,
579570 error : { ...e , message : e . message } // not all Svelte versions return an enumerable message property
580571 } ;
581572 }
0 commit comments