-
-
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
Debugging in VS Code and Chrome not working with TypeScript #2897
Comments
Any idea, friends? |
This comment has been minimized.
This comment has been minimized.
I was able to set breakpoints directly in Chrome by going to Sources, webpack://. and this would work, but is definitely suboptimal. Are there perhaps any better options? |
Well, what we are looking for is setting breakpoints directly in vs code, not in Chrome. What @AidanGG did work but it's not practical at all. |
This comment has been minimized.
This comment has been minimized.
Can the team reproduce the isssue? Might be cool to have this feature working :) |
Jetbrains is tracking this issue also reported for webstorm here: https://youtrack.jetbrains.com/issue/WEB-34557 Is there anything I can do to help resolve? |
Just noticed this tonight when I was following the instructions on debugging using VS Code, which do not work for Vue TS projects. |
This {
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "vuejs: chrome",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}",
"breakOnLoad": true,
"sourceMaps": true,
"disableNetworkCache": true,
"sourceMapPathOverrides": {
"webpack:///*": "${webRoot}/*",
"webpack:///./*": "${webRoot}/*",
"webpack:///src/*": "${webRoot}/src/*"
}
}
]
} |
@ffxsam when you write "works" - are you able to set breakpoints in vue files? I am only able to debug ts files. |
@jschoedt Yep, breakpoints in vue files works great. The only thing that doesn't seem to work with the debugger is when you hit async functions. Things really fall apart then. |
Is this isolated to TypeScript? I am not using typescript and I've found that my breakpoints in async functions are hit but it falls apart when the first await is executed; the debugger gets lost and can't step past that line. |
Here's a slight variant to the example that @ffxsam provided. This configuration is working decently for us with Vue Cli 4.2.3 and TypeScript: {
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "vuejs: chrome",
"url": "http://localhost:8080",
"webRoot":"${workspaceFolder}",
"breakOnLoad": true,
"sourceMapPathOverrides": {
"webpack:///./*": "${webRoot}/*"
},
"skipFiles": [
"${workspaceFolder}/node_modules/**/*"
]
}
]
} So far we haven't seemed to need the other I also want to reiterate the strangeness with trying to debug some await someAsyncThing() // Can't add breakpoint here
console.log('stop here') // Can add breakpoint here |
Greetings all. I am using @vue/cli version 4.2.3 and breakpoints do not work in JetBrains IDE's when using TS + Vue SFC's. We just want to know what is root of the issue so maybe we can help with workarounds? |
@geekox86 I'm not sure if anyone has a very clear understanding of the "root" of the issue except that it seems like varying the source map paths can make it better or worse. But none of the configurations listed here seem to completely fix the problem. Even the example configuration that I posted above has not been working quite as smoothly as I initially thought. And even when I thought it was working well, it still was very broken when debugging async/await code. I'm curious if anyone has tried debugging a Vue+TS project using the new JavaScript Debugger extension that VSCode mentioned in its March update |
@rdhelms I just tried it on the mentioned new JS debugger and I can confirm that issue still exists. Debugging TS code however is much better however. |
hello, 你好,在断点过程中,我遇到了同样的问题,请问有没有解决办法。 methods: {
handleTest(){
console.log(this) // VueComponent
},
async handleTest2(){
console.log(this) // undefined
}
} |
@zhaitianye Still no solution that I'm aware of 🙁 |
methods: {
handleTest(){
console.log(this) // VueComponent
},
async handleTest2(){
console.log(this) // undefined
let that = this
console.log(that) // VueComponent
}
} This is the temporary solution I know of. IN Google Chrome Debug |
using vue/cli 4.4.6 no solution works for me! |
This is what we currently use. It seems to allow setting breakpoints with mostly successful results. Trying to use VS Code's "step over" functionality pretty much always ends up either jumping to the top of the component Also note that in order for this to work, {
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "vuejs: chrome",
"url": "http://localhost:8080",
"webRoot":"${workspaceFolder}",
"sourceMapPathOverrides": {
"webpack:///./*": "${webRoot}/*"
},
"skipFiles": [
"${workspaceFolder}/node_modules/**/*"
]
}
]
} Incidentally, I'm not actually sure if the |
Greetings all. Any progress on this long standing issue? |
I've spent quite a while trying to get IDE debugger support working correctly in Vue 2 and Vue 3 apps and have found some settings that seem to work, vue-loader >= 16 TS source maps compiled with I've provided an example of such compilation below, please note that these screenshots were taken using vue 2 (vue-loader 15) and vue 3 (vue-loader 16) respectively so there are some minor changes between the files: I have a PR open in const CompilerSfc = require('@vue/compiler-sfc')
const parse = CompilerSfc.parse
CompilerSfc.parse = (source, options) => {
return parse(source, Object.assign({ pad: true }, options))
} vue 2 specific notes vue 3 specific notes vue 3 vs code notes (maybe applicable to vue 2) output: {
path: path.join(path.resolve(`${__dirname}/../..`), 'build/public'),
publicPath: '/',
filename: 'bundles/[name]' + ( ! isDev ? '.[chunkhash:7]' : '') + '.js',
chunkFilename: 'bundles/[name]' + ( ! isDev ? '.[chunkhash:7]' : '') + '.js',
devtoolModuleFilenameTemplate: info => {
if (info.allLoaders === '') {
// when allLoaders is an empty string the file is the original source
// file and will be prefixed with src:// to provide separation from
// modules transpiled via webpack
const filenameParts = ['src://']
if (info.namespace) {
filenameParts.push(info.namespace + '/')
}
filenameParts.push(info.resourcePath.replace(/^\.\//, ''))
return filenameParts.join('')
} else {
// otherwise we have a webpack module
const filenameParts = ['webpack://']
if (info.namespace) {
filenameParts.push(info.namespace + '/')
}
filenameParts.push(info.resourcePath.replace(/^\.\//, ''))
const isVueScript = info.resourcePath.match(/\.vue$/) &&
info.query.match(/\btype=script\b/) &&
! info.allLoaders.match(/\bts-loader\b/)
if ( ! isVueScript) {
filenameParts.push('?' + info.hash)
}
return filenameParts.join('')
}
},
}, This assumes that there is a maximum of one |
I'm sorry if this seems like it's just a shameless plug, but I actually just wrote a blog about this. My method is not an official fix per-se, although it will fix the problem. It's more of a patch that you apply at the end of the build process by doing some manual Source Map manipulation. I can confirm that it will work with non class-based TypeScript Single File Components, however, I haven't tested it with class-based TypeScript SFCs. The blog was written based on Vue 3, but you probably could adapt it to work with Vue 2. @andrewmackrodt seems to have a pretty good solution above as well, so definitely take a look at his post. |
work for me.
|
@fearnycompknowhow your solution worked for me on Vue2 and Chrome dev tools but I had to remove the |
@fearnycompknowhow: I have got mixed results with your solution when using Vue 3 SFCs. I'm using TypeScript with I haven't been able to identify any relation between the offset value and the vue file contents so far. |
+1, and how to solve it now? 😥 |
Version
3.1.1
Reproduction link
https://github.com/YoannBureau/vuejs-vscode-ts-ko
Node and OS info
NPM 6.4.1
Steps to reproduce
What is expected?
Breakpoint should be hit
What is actually happening?
Breakpoint is not hit
It's working great with Js, but ko with Ts
The text was updated successfully, but these errors were encountered: