Skip to content
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

Cannot change SourceMaps path if esbuild is not used #8081

Closed
7 tasks done
croban opened this issue May 9, 2022 · 8 comments
Closed
7 tasks done

Cannot change SourceMaps path if esbuild is not used #8081

croban opened this issue May 9, 2022 · 8 comments
Labels

Comments

@croban
Copy link

croban commented May 9, 2022

Describe the bug

For the dev mode, I am using Babel for transpiling typescript and not esbuild which is turned off inside vite.config.
In that case all sourcemaps (..."sources":["app.ts"]) have only relative paths and not absolute path as they have when esbuild is used. It seems that default rollup sourcemap settings are used because exactly the same output I am getting using only rollup.
There is not way to create sourceMaps with absolute path or maybe I miss something.
e.g.

sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => {
            // will replace relative paths with absolute paths
            return path.resolve(
              path.dirname(sourcemapPath),
              relativeSourcePath
            );
},

Reproduction

https://stackblitz.com/edit/vitejs-vite-kn5643?file=vite.config.js

System Info

npx envinfo --system --npmPackages '{vite,@vitejs/*}' --binaries --browsers

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

What is the reason you want to change sourcemap paths during dev?

@croban
Copy link
Author

croban commented May 19, 2022

What is the reason you want to change sourcemap paths during dev?

Because breakpoints and debugging within vscode don't work.

@sapphi-red
Copy link
Member

Then, I think if #2950 is implemented, it is possible to solve with sourceMapPathOverrides.
https://github.com/microsoft/vscode-chrome-debug/blob/master/README.md#sourcemaps

@croban
Copy link
Author

croban commented May 19, 2022

That would also solve my problem, just I don't have any patter which I could replace.
All SourceMap paths ends up with just filename.js without any paths (relative or absolute).
e.g.
src/components/fileone.js
src/lib/filetwo.js
src/file.js
ends with sources like ... ["sources":["filewhatever.js"]].

I could solved those paths problems on my side by using custom createBabelInputPluginFactory after that I had still problems with svelte which I solved with using experimental: dynamicCompileOptions. That experience was painful.

It would be great if default sourcemapPathTransform from rollup could be changed for vite dev.

@TFTomSun
Copy link

TFTomSun commented Jan 4, 2023

I stumbled over the same issue but with a different use case. I have some folders linked into the workspace using symbolic links. For some reasons, that breakpoint resolution within symlinked files is not working (Windows) so I tried out using sourceMapPathOverrides option to workaround it. It took me a couple of hours until I found out that the sources are just plain file names without any path information. This also prevents me from using sourceMapPathOverrides to point to the symlinked files so that the breakpoints get resolved.

With some hardcoded mapping (e.g. "myfile.ts": "<path-to-the-same-symlinked-filed") works

Is there any workaround to get path information into the source map file information?

@bluedusk
Copy link

is this solved ? I still can not debug Vite+React+TS. the breakpoints just dont hit

@mengdu
Copy link

mengdu commented Apr 20, 2023

Got the same problem while debugging ssrLoadModule in VSCode

@sapphi-red
Copy link
Member

Closing as the VSCode debugger should work with JS files by #13514

@sapphi-red sapphi-red added the feat: sourcemap Sourcemap support label Sep 4, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants