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

Suggestion: add debug information for VSCode #25

Open
TiagoSilvaPereira opened this issue Sep 22, 2022 · 1 comment
Open

Suggestion: add debug information for VSCode #25

TiagoSilvaPereira opened this issue Sep 22, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@TiagoSilvaPereira
Copy link
Contributor

Hi @Deluze would it be possible to include the VSCode debug files (launch.json and tasks.json) in the template? If not, do you have any recommendations on how to create them?

Thank you very much in advance!

@Deluze Deluze added the enhancement New feature or request label Sep 22, 2022
@TiagoSilvaPereira
Copy link
Contributor Author

@Deluze, I managed to make debug partially work with the following launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Electron: Main",
            "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
            "runtimeArgs": [
                "--remote-debugging-port=9223",
                "."
            ],
            "windows": {
                "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
            },
            "program": "${workspaceFolder}/src/main.ts",
        },
        {
            "name": "Electron: Renderer",
            "type": "chrome",
            "request": "attach",
            "port": 9223,
            "webRoot": "${workspaceFolder}/src/renderer",
            "timeout": 5000
        }
    ],
    "compounds": [
        {
            "name": "Electron: All",
            "configurations": [
                "Electron: Main",
                "Electron: Renderer"
            ]
        }
    ]
}

The Main process breakpoints are working well with this setup, after adding sourceMap: true to the src/main/tsconfig.json file (and running yarn run dev to compile the code and generate the source-maps). Maybe adding a command to only compile the code, instead of serving it may help, and we could add a task and use preLaunchTask to compile it before starting the debugger.

But I could not make the debugger run with the renderer process. I think the problem is that the renderer window directly uses the file renderer/index.html, which imports main.ts directly. Seems a way to solve it is always to compile the renderer/main.ts to JavaScript, generating the sourcemap and a separate index.html on the build directory, similar to that generated when we run yarn run build, and use this when starting the renderer window.

I hope it helps to add the debug layer to the template.

Best regards

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

No branches or pull requests

2 participants