fix(sourcemap): sourcemap is incorrect when sourcemap has sources: [null]#14588
fix(sourcemap): sourcemap is incorrect when sourcemap has sources: [null]#14588patak-cat merged 15 commits intovitejs:mainfrom
sources: [null]#14588Conversation
There was a problem hiding this comment.
Would you merge this playground to js-sourcemap playground to reduce the number of playgrounds?
| combinedMap = combineSourcemaps(cleanUrl(this.filename), [ | ||
| m as RawSourceMap, |
There was a problem hiding this comment.
Does combineSourcemaps work without doing the same normalization (i.e. setting [this.filename]) above? This happens when a module is transformed by a plugin then transformed by another plugin that uses MagicString.
There was a problem hiding this comment.
Sources are absolutely present when entering here Because the first source map has added sources or the sources themselves exist
There was a problem hiding this comment.
combineSourcemaps has two inputs. The second one (combinedMap) wouldn't have sources: ['']. But the first one (m) might have sources: [''], no?
There was a problem hiding this comment.
No, the second one definitely have
There was a problem hiding this comment.
I've actually tested it now by changing the code like below and renaming zoo.js to zoo.ts.
console.log('Before', m, combinedMap)
combinedMap = combineSourcemaps(cleanUrl(this.filename), [
m as RawSourceMap,
combinedMap as RawSourceMap,
]) as SourceMap
console.log('After', combinedMap)I got the following result:
Before SourceMap {
version: 3,
file: undefined,
sources: [ '' ],
sourcesContent: undefined,
names: [],
mappings: 'AAAA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;'
} {
version: 3,
sources: [ 'D:/documents/GitHub/vite/playground/js-sourcemap/zoo.ts' ],
sourcesContent: [ "export const zoo: string = 'zoo'\n" ],
mappings: 'AAAO,aAAM,MAAc;',
names: []
}
After SourceMap {
version: 3,
mappings: 'AAAO,aAAM,MAAc',
names: [],
sourceRoot: undefined,
sources: [ 'D:/documents/GitHub/vite/playground/js-sourcemap/zoo.ts' ],
sourcesContent: [ "export const zoo: string = 'zoo'\n" ],
file: 'D:/documents/GitHub/vite/playground/js-sourcemap/zoo.ts'
}
It seems it works at least for this case.
sources: [null]
Co-authored-by: 翠 / green <green@sapphi.red>
Co-authored-by: 翠 / green <green@sapphi.red>
Description
Fixes: #13657
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).