File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
packages/core/src/node/mdx Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -54,16 +54,23 @@ export default async function mdxLoader(
5454 } catch ( e ) {
5555 if ( e instanceof Error ) {
5656 // Enhance the message with filepath context for better error reporting
57- e . message = `MDX compile error: ${ e . message } in ${ filepath } ` ;
57+ const message = `MDX compile error: ${ e . message } in ${ filepath } ` ;
58+ let stack : string | undefined = e . stack ;
5859 // Truncate stack trace to first 10 lines for better readability
59- if ( e . stack ) {
60- const stackLines = e . stack . split ( '\n' ) ;
60+ if ( stack ) {
61+ const stackLines = stack . split ( '\n' ) ;
6162 if ( stackLines . length > 10 ) {
62- e . stack =
63- stackLines . slice ( 0 , 10 ) . join ( '\n' ) + '\n ... (truncated)' ;
63+ stack = stackLines . slice ( 0 , 10 ) . join ( '\n' ) + '\n ... (truncated)' ;
6464 }
6565 }
66- callback ( e ) ;
66+ // why not `callback(e)` ?
67+ // https://github.com/web-infra-dev/rspack/issues/12080
68+ callback ( {
69+ message,
70+ ...( stack ? { stack } : { } ) ,
71+ name : e . name ,
72+ cause : e . cause ,
73+ } as Error ) ;
6774 }
6875 }
6976}
You can’t perform that action at this time.
0 commit comments