Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7e2167d

Browse files
committed
fix: handle sourcemap with empty script code
refvitejs/vite-plugin-vue@7f73970
1 parent0500fba commit7e2167d

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

‎src/core/main.ts‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,23 @@ export async function transformMain(
193193

194194
letresolvedMap:RawSourceMap|undefined=undefined
195195
if(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+
constfrom=scriptMap??{
201+
file:filename,
202+
sourceRoot:'',
203+
version:3,
204+
sources:[],
205+
sourcesContent:[],
206+
names:[],
207+
mappings:'',
208+
}
200209
constgen=fromMap(
201210
// version property of result.map is declared as string
202211
// but actually it is `3`
203-
scriptMapasOmit<RawSourceMap,'version'>asTraceEncodedSourceMap,
212+
fromasOmit<RawSourceMap,'version'>asTraceEncodedSourceMap,
204213
)
205214
consttracer=newTraceMap(
206215
// same above
@@ -228,8 +237,7 @@ export async function transformMain(
228237
// of the main module compile result, which has outdated sourcesContent.
229238
resolvedMap.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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp