-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(sourcemap): sourcemap is incorrect when sourcemap has sources: [null]
#14588
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you merge this playground to js-sourcemap playground to reduce the number of playgrounds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
combinedMap = combineSourcemaps(cleanUrl(this.filename), [ | ||
m as RawSourceMap, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the second one definitely have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
).