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

How do you use this extension to debug a vite app? #18

Open
TechWatching opened this issue Jan 11, 2022 · 8 comments
Open

How do you use this extension to debug a vite app? #18

TechWatching opened this issue Jan 11, 2022 · 8 comments

Comments

@TechWatching
Copy link

I cannot see how to break on breakpoints in the components code ? Is it possible with this extension ? Is there some configuration to add to vscode ?

@shanecav
Copy link

shanecav commented Mar 21, 2022

I've been trying to figure this out as well. Based on looking into the vscode-browse-lite that this extension depends on, I tried adding a configuration in launch.json that uses:

{
  "type": "browse-lite",
  "name": "Browse Lite: Attach",
  "request": "attach",
  "port": 9222
}

but it gives me the error:

Couldn't find a debug adapter descriptor for debug type 'chrome' (extension might have failed to activate).

I'm wondering if the values here need to be updated to "pwa-chrome" instead of "chrome". This is just a wild guess, I really don't know much about this.

@genericGenie
Copy link

In reality, you don't need this extension to perform debugging in VSCode.
I used a Vite+React+Yarn project
VSCode debugging is an annoying 3 step process. I wish there was just one button press after setting the break-point.

First save the launch.json file with the following:

{
    "type": "pwa-chrome",
    "request": "launch",
    "name": "open chrome debug",
    "url": "http://localhost:3000"
}
  1. From the command line, run yarn dev
  2. Place a break-point somewhere in your code.
  3. Within VSCode, press the green arrow start debugging button or press F5 on the keyboard

@shanecav
Copy link

That launch.json config will open a new Chrome window (outside of VS Code), correct? I think the intention of this issue is to figure out how to attach the debugger to the embedded browser that this plugin opens within VS Code. The benefit being that you can interact with the app within the embedded browser to trigger breakpoints, etc.

@genericGenie
Copy link

yes, that will open a new external chrome browser window outside of VS Code.
When you run your Vite project by command line, npm start or yarn dev, the Vite project will default to localhost:3000
Having set the url to localhost:3000 within the launch.json file, the VS Code debugger will auto-attach itself.

@shanecav
Copy link

I think we're talking about two different things 😄

The process you're describing is a way to attach a VS Code debugger to an external Chrome window, which is unrelated to this plugin.

But the question is, how do we attach the VS Code debugger to the embedded Chrome window that this plugin opens within a VS Code panel? That's a separate situation and requires a different launch.json config. My first comment covers my attempt to get that to work, but I haven't been successful.

(To be clear, the process you described is a great approach if you don't care about using this plugin. It's what I'm currently doing, too. But I'm still curious whether it's possible to attach the VS Code debugger to the embedded browser this plugin opens.)

@genericGenie
Copy link

I also couldn't attach the VS Code debugger to the embedded window.
I think only the developer of the plugin will know how to properly configure the launch.json file.

@tim-hilt
Copy link

tim-hilt commented Sep 22, 2022

@antfu this might be very easy to answer for you!

I wasn't satisfied with the debugging-experience of the MS Edge Devtools Extension and came to vscode-vite to find a better experience. I'm sure this is possible, but I don't know how to configure my launch.json to do the right thing!

I'm getting the same error as @genericGenie:

Couldn't find a debug adapter descriptor for debug type 'chrome' (extension might have failed to activate).

with this as my launch.json (default-generated of browse-lite-extension):

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "browse-lite",
      "name": "Browse Lite: Attach",
      "request": "attach"
    },
    {
      "type": "browse-lite",
      "request": "launch",
      "name": "Browse Lite: Launch",
      "url": "http://localhost:4000"
    }
  ]
}

I've tested it with:

~ 
λ code --version
1.71.2
74b1f979648cc44d385a2286793c226e611f59e7
x64

~ 
λ code-insiders --version
1.72.0-insider
ba515cdbb48470c116884deb6de17981d341ec06
x64

@elloza
Copy link

elloza commented Feb 15, 2023

Same here. Please @antfu, any suggestions on which launch.js to use?

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

No branches or pull requests

5 participants