denoland / vscode_deno

Visual Studio Code plugin for Deno
https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno
MIT License
1.5k stars 146 forks source link

Debug Auto Attach Support #1193

Open Malix-Labs opened 4 weeks ago

Malix-Labs commented 4 weeks ago

image

Workaround

I did succeed to make a custom launch.json to launch a chrome dev window and attach the vscode debugger to it

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Chrome",
            "request": "launch",
            "type": "chrome",
            "url": "http://localhost:5173",
            "webRoot": "${workspaceFolder}/src",
            "preLaunchTask": "deno: dev (parallel)"
        }
    ]
}

But at this point, there stil is a problem in that preLaunchTask does wait for the task to finish, but the usual deno: dev / deno run dev task which binds to vite dev is long-lived (meaning it should stay alive during the debugging session). See my feature request to make it allowed to be a background task instead : https://github.com/microsoft/vscode/issues/232200

A workaround for this second issue is to make a custom user task of the deno provided deno: dev task :

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "deno",
            "command": "task",
            "args": [
                "dev"
            ],
            "problemMatcher": [
                "$deno"
            ],
            "label": "deno: dev (parallel)",
            "detail": "$ vite dev",
            "isBackground": true
        }
    ]
}   

Now, it should work reliably, but it is far from working out of the box nor auto attaching automatically