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

Source maps in VSCode not working for debug vite.config.ts #19191

Closed
7 tasks done
thy486 opened this issue Jan 13, 2025 · 6 comments
Closed
7 tasks done

Source maps in VSCode not working for debug vite.config.ts #19191

thy486 opened this issue Jan 13, 2025 · 6 comments

Comments

@thy486
Copy link

thy486 commented Jan 13, 2025

Describe the bug

Debug vite.config.ts failed.

Because temporary file ${workspaceFolder}/vite.config.ts.timestamp-xxx.mjs now is move to ${workspaceFolder}/node_modules/.vite-temp/vite.config.ts.timestamp-xxx.mjs

Relevant

#17894

nodejs/node#45196

Impact

Expect FunctionLocation in debugger: ${workspaceFolder}/vite.config.ts

Actual FunctionLocation in debugger: ${workspaceFolder}/node_modules/.vite-temp/vite.config.ts.timestamp-xxx.mjs

Suggestion

Make temporary filepath for 'vite.config.ts' configurable or add document to explain how to debug

Reproduction

https://stackblitz.com/edit/vitejs-vite-w1tz8u4r?file=index.html&terminal=dev

Steps to reproduce

node --inspect ${workspaceFolder}/node_modules/vite/bin/vite
// or run in javascript debugger terminal
npx vite

System Info

System:
    OS: macOS 15.2
    CPU: (10) arm64 Apple M4
    Memory: 133.61 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.12.0 - ~/.local/state/fnm_multishells/67195_1736746164855/bin/node
    npm: 11.0.0 - ~/.local/state/fnm_multishells/67195_1736746164855/bin/npm
    pnpm: 9.14.2 - ~/.local/state/fnm_multishells/31840_1736503379186/bin/pnpm
    bun: 1.1.42 - ~/.bun/bin/bun
  Browsers:
    Chrome: 131.0.6778.265
    Safari: 18.2
  npmPackages:
    vite: ^6.0.6 => 6.0.7

Used Package Manager

pnpm

Logs

No response

Validations

@hi-ogawa
Copy link
Collaborator

It's likely a duplicate of #19110. Can you try this .vscode/settings.json #19110 (comment)?

@thy486
Copy link
Author

thy486 commented Jan 13, 2025

它可能与#19110重复。您可以尝试这个.vscode/settings.json #19110 (评论)吗?

Got it! I will close it. But I still hope the above suggestions can be optimized.

@thy486 thy486 closed this as completed Jan 13, 2025
@hi-ogawa
Copy link
Collaborator

I was thinking that running debugger on vite.config.ts is not so common, but maybe I'm wrong. If users often get caught by this, we can mention the workaround on documentation.

@thy486
Copy link
Author

thy486 commented Jan 13, 2025

I was thinking that running debugger on vite.config.ts is not so common, but maybe I'm wrong. If users often get caught by this, we can mention the workaround on documentation.

When developing the vite plugin, it seems that the plugin code (in the project) cannot be mapped back(
setting.json has been set correctly according to the above suggestion and vite.config.ts has been successfully mapped). But revert this commit(#18833 ) can be mapped back, but the mapped file path is ${workspaceFolder}/node_modules/.vite-temp/src/xxx.

If you use the commented code, you can map successfully

Reproduction

https://stackblitz.com/edit/vitejs-vite-uk5hhx86?file=index.mjs

Steps to reproduce

// javascript debugger terminal
node index.mjs

@hi-ogawa
Copy link
Collaborator

@thy486 This looks like a slightly different issue and more complicated. Probably vscode got confused with plugin/index.ts's source map coming from vite.config.ts bundling and ssrLoadModule.

I'm not sure how this setup was working on Vite 5. Can you create a new issue for this?

@thy486
Copy link
Author

thy486 commented Jan 14, 2025

@thy486 This looks like a slightly different issue and more complicated. Probably vscode got confused with plugin/index.ts's source map coming from vite.config.ts bundling and ssrLoadModule.

I'm not sure how this setup was working on Vite 5. Can you create a new issue for this?

I seem to know why, it should be the sourcemap of these two modules
points to the same file.

I think this is just a phenomenon, haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants