Skip to content

Commit d6b4753

Browse files
committed
Updated README for June 2021
1 parent 4354dc1 commit d6b4753

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

README.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ The aim of this repository is to help setting up Visual Studio Code for developm
55
Visual Studio Code comes with Electron support and Typescript support out of the box, but bringing the two together requires some advanced knowledge of the available configuration options. The repository contains a README with step by step instructions and an example project to demonstrate how Visual Studio Code, Node, Electron and Typescript must be configured to work together.
66

77
The latest example project has been created and tested on Linux with
8-
- Node v16.1.0
9-
- Electron v12.0.7
10-
- Typescript v4.2.4
11-
- Visual Studio Code v1.56.0
12-
- Debugger for Chrome extension v4.12.12
8+
- Node v16.3.0
9+
- Electron v13.1.2
10+
- Typescript v4.3.2
11+
- Visual Studio Code v1.57.0
1312

1413
## Install application
1514
```sh
@@ -28,35 +27,37 @@ npm start
2827

2928
## Set up Visual Studio Code and start debugging
3029

31-
1) Install the "Debugger for Chrome" extension.
32-
33-
It is required for debugging renderer processes.
34-
35-
![Debugger for Chrome](./docs/media/install_debugger_for_chrome.png)
30+
1) Set a breakpoint in `src/main.ts` and `src/renderer.ts`
3631

3732
1) In the Run view, select the "Electron: All" configuration.
3833

3934
This is a compound configuration that will start both the "Electron: Main" and "Electron: Renderer" configurations.
4035

4136
![Select configuration](./docs/media/select_configuration.png)
42-
43-
1) Set a breakpoint in `src/main.ts` and `src/renderer.ts`
4437

45-
1) Run the "Run" -> "Start Debugging" command (<kbd>F5</kbd>)
38+
1) Click the green arrow next to the "Electron: All" configuration, or run the "Run" -> "Start Debugging" command (<kbd>F5</kbd>)
4639
- The breakpoint in the `main.ts` will be hit.
4740
- Click Continue (<kbd>F5</kbd>)
4841
- In the Electron example app, click the "Turn page red" button.
49-
- The breakpoint in `renderer.ts` should be hit.
50-
51-
- If the breakpoint is not hit and marked as unbound instead:
42+
- The breakpoint in `renderer.ts` will be hit.
43+
44+
---
45+
**Troubleshooting**
46+
47+
If you are using Visual Studio Code v1.56.x or older, you may find that the breakpoint in `renderer.ts` is not hit and marked as unbound instead:
5248
![Unbound Breakpoint](./docs/media/unbound_breakpoint.png)
5349

54-
you have likely come across a [bug](https://github.com/microsoft/vscode/issues/123420) in the new JavaScript debugger for Node.js and Chrome, which is currently in preview and enabled by default. The bugfix will probably be released in Visual Studio Code v1.57. As a temporary workaround, disable the preview debugger.
55-
- Open Settings (<kbd>Ctrl+,</kbd>)
56-
- Search for `debug.javascript.usePreview`
57-
- Set option to false
58-
![Disable Preview JavaScript Debugger](./docs/media/disable_preview_javascript_debugger.png)
59-
- Run the "Electron: All" configuration again
50+
This is because of a [bug](https://github.com/microsoft/vscode/issues/123420) in the internal JavaScript debugger. As a workaround, you can either update to the latest version of Visual Studio Code, or use the "Debugger for Chrome" extension:
51+
- Install the "Debugger for Chrome" extension v4.12.12
52+
![Debugger for Chrome](./docs/media/install_debugger_for_chrome.png)
53+
- In `.vscode/launch.json`, change the renderer configuration type from `pwa-chrome` to `chrome`
54+
- Change settings to prevent the "Debugger for Chrome" extension from using the internal Javascript debugger:
55+
- Open Settings (<kbd>Ctrl+,</kbd>)
56+
- Search for `debug.javascript.usePreview`
57+
- Set option to false
58+
![Disable Preview JavaScript Debugger](./docs/media/disable_preview_javascript_debugger.png)
59+
60+
When you run the "Electron: All" configuration the next time, the breakpoint should be hit.
6061

6162

6263

@@ -65,7 +66,7 @@ npm start
6566
Electron has two kinds of processes: a main process and renderer processes (one for each tab). They need different launch configurations, which are shown below. The code snippets are taken from the [launch configuration](.vscode/launch.json).
6667

6768
### Main process
68-
The main process can be debugged with the pwa-node debugger that ships with Visual Studio Code.
69+
The main process can be debugged with the pwa-node debugger, that ships with Visual Studio Code.
6970

7071
The launch configuration looks like this:
7172

@@ -94,12 +95,12 @@ In the `sourceMaps` and `resolveSourceMapLocations` sections, we enable the crea
9495
In the `runtimeArgs` section, we open a port for the renderer process. There is a counterpart defined in the renderer process configuration as shown below.
9596

9697
### Renderer process
97-
Debugging a renderer process requires the "Debugger for Chrome" extension.
98+
A renderer process can be debugged with the pwa-chrome debugger, that ships with Visual Studio Code.
9899

99100
```jsonc
100101
{
101102
"name": "Electron: Renderer",
102-
"type": "chrome", //use the Debugger for Chrome (extension)
103+
"type": "pwa-chrome", //use the Chrome debugger that comes with VS Code
103104
"request": "attach",
104105
"port": 9223, //use debug port opened in Electron: Main configuration
105106
"webRoot": "${workspaceFolder}",

0 commit comments

Comments
 (0)