@@ -193,14 +193,23 @@ export async function transformMain(
193193
194194let resolvedMap :RawSourceMap | undefined = undefined
195195if ( options . sourceMap ) {
196- if ( scriptMap && templateMap ) {
197- // if the template is inlined into the main module (indicated by the presence
198- // of templateMap), we need to concatenate the two source maps.
199-
196+ // the mappings of the source map for the inlined template should be moved
197+ // because the position does not include the script tag part.
198+ // we also concatenate the two source maps while doing that.
199+ if ( templateMap ) {
200+ const from = scriptMap ?? {
201+ file :filename ,
202+ sourceRoot :'' ,
203+ version :3 ,
204+ sources :[ ] ,
205+ sourcesContent :[ ] ,
206+ names :[ ] ,
207+ mappings :'' ,
208+ }
200209const gen = fromMap (
201210// version property of result.map is declared as string
202211// but actually it is `3`
203- scriptMap as Omit < RawSourceMap , 'version' > as TraceEncodedSourceMap ,
212+ from as Omit < RawSourceMap , 'version' > as TraceEncodedSourceMap ,
204213)
205214const tracer = new TraceMap (
206215// same above
@@ -228,8 +237,7 @@ export async function transformMain(
228237// of the main module compile result, which has outdated sourcesContent.
229238resolvedMap . sourcesContent = templateMap . sourcesContent
230239} else {
231- // if one of `scriptMap` and `templateMap` is empty, use the other one
232- resolvedMap = scriptMap ?? templateMap
240+ resolvedMap = scriptMap
233241}
234242}
235243