-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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: use relative path for sources field #14247
fix: use relative path for sources field #14247
Conversation
Run & review this pull request in StackBlitz Codeflow. |
Should I do a build or will there be another beta any soon? Or do you have a nightly perhaps? Or is it possible to grab the built asset from the CI runs maybe? |
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.
Have a question below, but using path.basename
makes sense to me.
@@ -69,7 +70,11 @@ export function send( | |||
content = getCodeWithSourcemap( | |||
type, | |||
content.toString(), | |||
ms.generateMap({ source: urlWithoutTimestamp, hires: 'boundary' }), | |||
ms.generateMap({ |
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.
Unrelated, but a question: Since #13514, if the JS code has no sourcemap (map
is falsy), we're still creating a fallback sourcemap here.
If there's no sourcemap, shouldn't we don't need to do anything?
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.
Unfortunately, to make dev tools happy, we'll always have to generate a sourcemap (#13514 (comment)).
Just in case, we are skipping sourcemap generation for { "mappings": "" }
because it indicates generating a sourcemap is meaningless.
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.
Hmm, thats feels like unnecessary overhead if the user never debugs a file, but good to know that it's needed for cases like this.
@BenceSzalai at the moment you'd need to clone Vite locally and build it to test it out |
@BenceSzalai Sorry I forgot to reply, as bluwy said you'd need to build. Our CI don't upload the built files. |
Hi! Didn't really have the spare time to grab the repo and run a new build, but since Great news, thank you everyone! |
@BenceSzalai Thanks for testing it out! But that's interesting, this PR isn't included in beta.1. |
Okay. So first things first, I was sloppy testing this out, because I should have created multiple files with similar path and name to see if the IDE finds the right one, but did not, so it found one out of one, but that was working even with the first version of the fix, my bad. So before moving on I've made two files with the same path and name in two different folders to make sure the issue is still there, and sure it is with As per the build you have provided, it looks like to me it behaves slightly better. Test case1:
Test case 2:
My theory is that the IDE understands the content of As a sidenote: There is a possibility in IntelliJ to explicitly map folders of the local filesystem to the URLs server by vite (dev mode). If I put that in place, debugging is perfect with both the old and the new patch. This was not the case before the first patch, because we need two things for debugging: 1.) was possible by configuring IntelliJ options, even without changes to Vite, and I remember someone mentioned the last time we tried to fix this that such mapping is also possible in VSCode, although I've never tried to figure that one out. 2.) is however we need Vite to provide the sourcemaps. Now 2.) is fulfilled by both this version and the previous patch. What the new patch gives on top: The matching of the right source file succeeds in more edge cases without explicitly mapping the URLs to the filesystem (same filename in different folders). Regarding adding |
@BenceSzalai Thank you for testing this out! |
Hello, @sapphi-red! import {count, increment} from "./log-counter.js";
export function log(value) {
increment();
console.log(`[${count}] ${value}`)
} If I start vite, attach with debugger (Chrome), then I'll get the following source: import {count, increment} from "/src/log-counter.js";
export function log(value) {
increment();
console.log(`[${count}] ${value}`)
} For comparison, imports are preserved in TypeScript: import {count, increment} from "./log-counter.ts";
export function log(value: any) {
increment();
console.log(`[${count}] ${value}`)
} Source received by debugger: import {count, increment} from "./log-counter.ts";
export function log(value: any) {
increment();
console.log(`[${count}] ${value}`)
} |
Description
Follow up to #13514
#7767 (comment)
@BenceSzalai Thanks for the detailed comment! Would you try this PR if it fixes the bug you described?
fixes #7767
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).