-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
mapRoot/sourceRoot write sourcemaps using absolute local paths, not URIs #25587
Comments
The paths are indeed now not absolute paths, but I'm not sure whether they are right. I'm not sure what's expected. Let me know if you'd prefer that I fork this to a new issue. Using the same example from above, I get
and
But since these are relative paths, I think I expect |
the sourceRoot / mapRoot are used verbatim. so you can have in there whatever you want, the compiler does not really change these. so you can use |
I see, I basically get the behavior I expect without those options or just with |
We set up our build process leveraging the absolute paths provided by this feature. Since we build our libraries (individual packages) and then move them to other node_modules folders, the absolute paths worked great. That is until we needed to develop/debug on OSX. The source-map-loader webpack loader does not appear to be able to differentiate between an absolute and relative path on a unix style OS like OSX. While investigating this, we found that if you set the sourceRoot from the command line, it works completely differently than if you set it in the tsconfig.json file. We are still on tsc version 2.6.2. The only way to get the absolute path when setting sourceRoot from the command is to pass it in as "$pwd/src". There appears to be no way to not have the sourceRoot produce a non absolute path if you set sourceRoot in the tsconfig.json file. Through experimentation, we have found a work around to this. But it is a bit quirky. We need to write a post processor for each map file so after it is copied to its target location, the sourceRoot or sources are modified so they work in their new location. In an ideal world:
If you already addressed these items, thank you. If not, hopefully this additional scenario will help. |
From microsoft/vscode#54026
./src/hello.ts
existsActual
I run
tsc
and get:hello.js:
hello.map.js:
Expected
This stuff is not clearly spec'd but my understanding is that sourceMappingURL and sourceRoot should be URIs or relative paths, not local absolute paths. In a browser, a path starting with / should be interpreted as relative to the webserver root.
In Node, Chrome Devtools handles this on Mac, but on Windows, it can't handle a sourceMappingUrl or sourceRoot as a windows-style absolute path. That is what convinces me that this is worth fixing on TS's end.
In vscode, I plan to try to support this scenario somehow, since it previously worked.
The text was updated successfully, but these errors were encountered: