11import { RollupError } from 'rollup' ;
2- import { Warning } from './options' ;
2+ import { ResolvedOptions , Warning } from './options' ;
33import { buildExtendedLogMessage } from './log' ;
44import { PartialMessage } from 'esbuild' ;
55
@@ -8,15 +8,15 @@ import { PartialMessage } from 'esbuild';
88 * @param error a svelte compiler error, which is a mix of Warning and an error
99 * @returns {RollupError } the converted error
1010 */
11- export function toRollupError ( error : Warning & Error ) : RollupError {
12- const { filename, frame, start, code, name } = error ;
11+ export function toRollupError ( error : Warning & Error , options : ResolvedOptions ) : RollupError {
12+ const { filename, frame, start, code, name, stack } = error ;
1313 const rollupError : RollupError = {
1414 name, // needed otherwise sveltekit coalesce_to_error turns it into a string
1515 id : filename ,
1616 message : buildExtendedLogMessage ( error ) , // include filename:line:column so that it's clickable
1717 frame : formatFrameForVite ( frame ) ,
1818 code,
19- stack : ''
19+ stack : options . isBuild || options . isDebug || ! frame ? stack : ''
2020 } ;
2121 if ( start ) {
2222 rollupError . loc = {
@@ -33,8 +33,8 @@ export function toRollupError(error: Warning & Error): RollupError {
3333 * @param error a svelte compiler error, which is a mix of Warning and an error
3434 * @returns {PartialMessage } the converted error
3535 */
36- export function toESBuildError ( error : Warning & Error ) : PartialMessage {
37- const { filename, frame, start } = error ;
36+ export function toESBuildError ( error : Warning & Error , options : ResolvedOptions ) : PartialMessage {
37+ const { filename, frame, start, stack } = error ;
3838 const partialMessage : PartialMessage = {
3939 text : buildExtendedLogMessage ( error )
4040 } ;
@@ -46,6 +46,9 @@ export function toESBuildError(error: Warning & Error): PartialMessage {
4646 lineText : lineFromFrame ( start . line , frame ) // needed to get a meaningful error message on cli
4747 } ;
4848 }
49+ if ( options . isBuild || options . isDebug || ! frame ) {
50+ partialMessage . detail = stack ;
51+ }
4952 return partialMessage ;
5053}
5154
0 commit comments