@@ -27,8 +27,6 @@ export interface SendOptions {
27
27
cacheControl ?: string
28
28
headers ?: OutgoingHttpHeaders
29
29
map ?: SourceMap | { mappings : '' } | null
30
- /** only used when type === 'js' && map == null (when the fallback sourcemap is used) */
31
- originalContent ?: string
32
30
}
33
31
34
32
export function send (
@@ -73,25 +71,23 @@ export function send(
73
71
}
74
72
// inject fallback sourcemap for js for improved debugging
75
73
// https://github.com/vitejs/vite/pull/13514#issuecomment-1592431496
76
- // for { mappings: "" }, we don't inject fallback sourcemap
77
- // because it indicates generating a sourcemap is meaningless
78
- else if ( type === 'js' && map == null ) {
74
+ else if ( type === 'js' && ( ! map || map . mappings !== '' ) ) {
79
75
const code = content . toString ( )
80
76
// if the code has existing inline sourcemap, assume it's correct and skip
81
77
if ( convertSourceMap . mapFileCommentRegex . test ( code ) ) {
82
78
debug ?.( `Skipped injecting fallback sourcemap for ${ req . url } ` )
83
79
} else {
84
80
const urlWithoutTimestamp = removeTimestampQuery ( req . url ! )
85
81
const ms = new MagicString ( code )
86
- const map = ms . generateMap ( {
87
- source : path . basename ( urlWithoutTimestamp ) ,
88
- hires : 'boundary' ,
89
- includeContent : ! options . originalContent ,
90
- } )
91
- if ( options . originalContent != null ) {
92
- map . sourcesContent = [ options . originalContent ]
93
- }
94
- content = getCodeWithSourcemap ( type , code , map )
82
+ content = getCodeWithSourcemap (
83
+ type ,
84
+ code ,
85
+ ms . generateMap ( {
86
+ source : path . basename ( urlWithoutTimestamp ) ,
87
+ hires : 'boundary' ,
88
+ includeContent : true ,
89
+ } ) ,
90
+ )
95
91
}
96
92
}
97
93
0 commit comments