@@ -12,7 +12,7 @@ import svg from './plugins/svg';
1212import replace from './plugins/replace' ;
1313import loop_protect from './plugins/loop-protect' ;
1414import type { Plugin , RollupCache , TransformResult } from '@rollup/browser' ;
15- import type { BundleMessageData , BundleOptions } from '../workers' ;
15+ import type { BundleMessageData , BundleOptions , BundleResult } from '../workers' ;
1616import type { Warning } from '../../types' ;
1717import type { CompileError , CompileResult } from 'svelte/compiler' ;
1818import type { File } from '../../Workspace.svelte' ;
@@ -427,16 +427,14 @@ async function get_bundle(
427427 } ;
428428}
429429
430- export type BundleResult = ReturnType < typeof bundle > ;
431-
432430async function bundle (
433431 svelte : typeof import ( 'svelte/compiler' ) ,
434432 svelte_version : string ,
435433 uid : number ,
436434 files : File [ ] ,
437435 options : BundleOptions ,
438436 can_use_experimental_async : boolean
439- ) {
437+ ) : Promise < BundleResult > {
440438 if ( ! DEV ) {
441439 console . clear ( ) ;
442440 console . log ( `running Svelte compiler version %c${ svelte . VERSION } ` , 'font-weight: bold' ) ;
@@ -547,27 +545,24 @@ async function bundle(
547545
548546 return {
549547 uid,
548+ error : null ,
550549 client : client_result ,
551550 server : server_result ,
552551 tailwind : client . tailwind ,
553- imports : client . imports ,
554- // Svelte 5 returns warnings as error objects with a toJSON method, prior versions return a POJO
555- // TODO are bundler warnings even used anywhere?
556- warnings : client . warnings . map ( ( w : any ) => w . toJSON ?.( ) ?? w ) ,
557- error : null
552+ imports : client . imports
558553 } ;
559554 } catch ( err ) {
560555 console . error ( err ) ;
561556
562- const e = err as CompileError ;
557+ const e = err as CompileError ; // TODO could be a non-Svelte error?
563558
564559 return {
565560 uid,
561+ error : { ...e , message : e . message } , // not all Svelte versions return an enumerable message property
566562 client : null ,
567563 server : null ,
568- imports : null ,
569- warnings : [ ] ,
570- error : { ...e , message : e . message } // not all Svelte versions return an enumerable message property
564+ tailwind : null ,
565+ imports : null
571566 } ;
572567 }
573568}
0 commit comments