C
C
Caretaker2019-04-10 16:54:54
Debugging
Caretaker, 2019-04-10 16:54:54

How to make Visual Code debugger friendly with an Electron application?

Greetings.
Here we inherited an application written in Electron + React + Redux. To say that they transferred the project disgustingly is to say nothing (only complete obscene language in my head):

  • there is no documentation for the application at all, even the basic technical specifications, not to mention the description of the architecture
  • there are no comments in the code, where and where the legs grow from is not clear, there is no verbal information either, and there is no connection with the developers
  • it turned out that there are at least three versions of the application, and during the mutation process, the extra code was not removed, and now there is not the slightest idea what is used and what is superfluous

In order to somehow understand where the legs grow from and what to do with all this and how to fix bugs, I wanted to go through the working functions using the debugger. But I can't make friends with the Visual Code IDE with the application itself. The difficulty lies in the fact that the code uses ES6 directives (aka babel) and, among other things, debugging must be carried out "from the entry point" to the application, and not just connect to an already running process (at startup, a number of procedures are performed, which are suspected in baguness).
I managed to find information on how to separately make friends with the debugger with ES6 code or Electron, but in such a way as to combine - I went through the whole day - the result is zero.
Managed to find the closest "fish"https://www.oodlestechnologies.com/blogs/CreateDe... . Before switching to debugging "handicrafts", I try to set up step-by-step debugging on this "fish".
Added. The most "sane" error occurs at:
launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug Main 1",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
      "windows": {
        "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
      },
      "program": "${workspaceRoot}/app/main.dev.js",
      "protocol": "inspector",
    },
  ]
}

error text
App threw an error during load
/home/zloy/Projects/test-aaa/app/main.dev.js:13
import { app, BrowserWindow } from 'electron';
       ^
SyntaxError: Unexpected token {
    at new Script (vm.js:79:7)
    at createScript (vm.js:251:10)
    at Object.runInThisContext (vm.js:303:10)
    at Module._compile (internal/modules/cjs/loader.js:660:28)
    ...
}

main.dev.js
import { app, BrowserWindow } from 'electron';
import { autoUpdater } from 'electron-updater';
import log from 'electron-log';
import MenuBuilder from './menu';

........

I would be extremely grateful for any help!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question