1
1
import { RollupError } from 'rollup' ;
2
- import { Warning } from './options' ;
2
+ import { ResolvedOptions , Warning } from './options' ;
3
3
import { buildExtendedLogMessage } from './log' ;
4
4
import { PartialMessage } from 'esbuild' ;
5
5
@@ -8,15 +8,15 @@ import { PartialMessage } from 'esbuild';
8
8
* @param error a svelte compiler error, which is a mix of Warning and an error
9
9
* @returns {RollupError } the converted error
10
10
*/
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 ;
13
13
const rollupError : RollupError = {
14
14
name, // needed otherwise sveltekit coalesce_to_error turns it into a string
15
15
id : filename ,
16
16
message : buildExtendedLogMessage ( error ) , // include filename:line:column so that it's clickable
17
17
frame : formatFrameForVite ( frame ) ,
18
18
code,
19
- stack : ''
19
+ stack : options . isBuild || options . isDebug || ! frame ? stack : ''
20
20
} ;
21
21
if ( start ) {
22
22
rollupError . loc = {
@@ -33,8 +33,8 @@ export function toRollupError(error: Warning & Error): RollupError {
33
33
* @param error a svelte compiler error, which is a mix of Warning and an error
34
34
* @returns {PartialMessage } the converted error
35
35
*/
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 ;
38
38
const partialMessage : PartialMessage = {
39
39
text : buildExtendedLogMessage ( error )
40
40
} ;
@@ -46,6 +46,9 @@ export function toESBuildError(error: Warning & Error): PartialMessage {
46
46
lineText : lineFromFrame ( start . line , frame ) // needed to get a meaningful error message on cli
47
47
} ;
48
48
}
49
+ if ( options . isBuild || options . isDebug || ! frame ) {
50
+ partialMessage . detail = stack ;
51
+ }
49
52
return partialMessage ;
50
53
}
51
54
0 commit comments