@@ -312,8 +312,11 @@ export function update_svelte_file(file_path, transform_script_code, transform_s
312
312
}
313
313
) ;
314
314
fs . writeFileSync ( file_path , transform_svelte_code ( updated , file_path ) , 'utf-8' ) ;
315
- } catch ( e ) {
316
- console . error ( `Error updating ${ file_path } :` , e ) ;
315
+ } catch ( err ) {
316
+ // TODO: change to import('svelte/compiler').Warning after upgrading to Svelte 5
317
+ const e = ( /** @type {any } */ ( err ) ) ;
318
+ console . warn ( buildExtendedLogMessage ( e ) , e . frame ) ;
319
+ console . info ( e . stack ) ;
317
320
}
318
321
}
319
322
@@ -327,11 +330,34 @@ export function update_js_file(file_path, transform_code) {
327
330
const content = fs . readFileSync ( file_path , 'utf-8' ) ;
328
331
const updated = transform_code ( content , file_path . endsWith ( '.ts' ) , file_path ) ;
329
332
fs . writeFileSync ( file_path , updated , 'utf-8' ) ;
330
- } catch ( e ) {
331
- console . error ( `Error updating ${ file_path } :` , e ) ;
333
+ } catch ( err ) {
334
+ // TODO: change to import('svelte/compiler').Warning after upgrading to Svelte 5
335
+ const e = ( /** @type {any } */ ( err ) ) ;
336
+ console . warn ( buildExtendedLogMessage ( e ) , e . frame ) ;
337
+ console . info ( e . stack ) ;
332
338
}
333
339
}
334
340
341
+ /**
342
+ * @param {any } w
343
+ */
344
+ export function buildExtendedLogMessage ( w ) {
345
+ const parts = [ ] ;
346
+ if ( w . filename ) {
347
+ parts . push ( w . filename ) ;
348
+ }
349
+ if ( w . start ) {
350
+ parts . push ( ':' , w . start . line , ':' , w . start . column ) ;
351
+ }
352
+ if ( w . message ) {
353
+ if ( parts . length > 0 ) {
354
+ parts . push ( ' ' ) ;
355
+ }
356
+ parts . push ( w . message ) ;
357
+ }
358
+ return parts . join ( '' ) ;
359
+ }
360
+
335
361
/**
336
362
* Updates the tsconfig/jsconfig.json file with the provided function.
337
363
* @param {(content: string) => string } update_tsconfig_content
0 commit comments