4

Steps to reproduce:

  1. Set a breakpoint in any .tsx file

  2. run my npm script "start": "react-scripts start",

  3. start debugging with F5 or by selecting a configuration from the Run and Debug window in vscode.

Either configuration shown below results in an 'unverified breakpoint' in vscode.

enter image description here

launch.json

    {
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Firefox",
            "request": "launch",
            "type": "firefox",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceFolder}",
            "enableCRAWorkaround": true
        },
        {
            "name": "Launch Firefox",
            "request": "launch",
            "type": "firefox",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceFolder}",
            "enableCRAWorkaround": false
        }
      ]
    }

Description

I am able to debug normal JavaScript and TypeScript projects in vscode without issue. My guess is that I have to change what 'react-scripts start' is doing, or account for where it's going to make .jsx files and sourcemaps in my launch.json. This is the guide I follow to debug TypeScript in vscode. In particular, this section explains what I believe is happening.

If no source map exists for the original source, or if the source map is broken and cannot successfully map between the source and the generated JavaScript, then breakpoints show up as unverified (gray hollow circles).

tsconfig.json

    {
      "compilerOptions": {
        "target": "es5",
        "lib": [
          "dom",
          "dom.iterable",
          "esnext"
        ],
        "allowJs": true,
        "skipLibCheck": true,
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "strict": true,
        "forceConsistentCasingInFileNames": true,
        "noFallthroughCasesInSwitch": true,
        "module": "esnext",
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "isolatedModules": true,
        "noEmit": false, // I've tried this with both false and true (default value)
        "jsx": "react-jsx",
        "sourceMap": true // I've tried with this both true and false (default value)
      },
      "include": [
        "src"
      ]
    }
3

1 Answer 1

0

Maybe this doesn't fix the entire problem but one problem I had was that I missed to use this argument in the launch.json, I compile now without errors and I don't see that the sourcemaps are not found but my breakpoints still don't work.

Since you use ESM and not CommonJS then you need to look at this:

https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_how-do-i-debug-ecmascript-modules

Add

"runtimeArgs": [
                //other args here,
                "--experimental-modules"
            ],

To your launch.json

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.