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

Unable to bind breakpoint in package in monorepo #1390

Closed
azzlack opened this issue Sep 8, 2022 · 2 comments · Fixed by #1410
Closed

Unable to bind breakpoint in package in monorepo #1390

azzlack opened this issue Sep 8, 2022 · 2 comments · Fixed by #1410
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@azzlack
Copy link

azzlack commented Sep 8, 2022

Describe the bug
When using a monorepo, binding breakpoints in a package does not work.
Breakpoints in the main app works as they should.

See sample repository for reproducable setup.

This could of course also just be a misconfiguration, but I cannot find any good documentation on how this should be set up.

To Reproduce
Steps to reproduce the behavior:

  1. Start project by running pnpm dev in the root folder.
  2. Attach VSCode by using the included launch.json config
  3. Set a breakpoint in apps/web/pages/api/hello.ts on line 9.
  4. Set a breakpoint in packages/lib/src/HelloWorld.ts on line 2.
  5. Open http://localhost:3000/api/hello in a browser
  6. Observe that the breakpoint in apps/web/pages/api/hello.ts is hit, while the one in packages/lib/src/HelloWorld.ts is not

Log File
vscode-debugadapter-acbac098.json.zip

VS Code Version: 1.71.0

Tech Stack in Sample

  • Next.js
  • Turbo
  • tsup
  • TypeScript
  • pnpm

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "Attach: Web",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "cwd": "${workspaceFolder}/apps/web",
            "trace": true,
        }
    ]
}

package.json (web)

{
  "name": "web",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "cross-env NODE_OPTIONS='--inspect' next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "next": "12.2.5",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "lib": "workspace:^1.0.0"
  },
  "devDependencies": {
    "@types/node": "18.7.16",
    "@types/react": "18.0.18",
    "@types/react-dom": "18.0.6",
    "eslint": "8.23.0",
    "eslint-config-next": "12.2.5",
    "tsconfig": "workspace:^1.0.0",
    "typescript": "^4.8.2",
    "cross-env": "^7.0.3"
  }
}

package.json (lib)

{
  "name": "lib",
  "version": "1.0.0",
  "description": "",
  "private": true,
  "main": "./dist/index.js",
  "module": "./dist/index.mjs",
  "types": "./dist/index.d.ts",
  "source": "./index.ts",
  "files": ["dist", "src", "index.ts"],
  "scripts": {
    "build": "tsup --treeshake",
    "dev": "tsup --watch",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
    "tsconfig": "workspace:^1.0.0",
    "tsup": "^6.2.2"
  },
}

Output from Debug Diagnostics
CleanShot 2022-09-08 at 16 43 23

@azzlack azzlack added the bug Issue identified by VS Code Team member as probable bug label Sep 8, 2022
@connor4312
Copy link
Member

connor4312 commented Oct 4, 2022

This has generally required creating a custom webpack config with next.js and telling it to use the webpack source-map-loader, since at the moment source resolution stops with index.js.

However I have put in a change to support this scenario automatically in #1410. You will be able to use this in the nightly extension: https://github.com/microsoft/vscode-js-debug#nightly-extension

@Daydreamer-riri
Copy link

Hi @connor4312 , I think Nightly-EXTENSION has no effect. Breakpoints in 'https://github.com/azzlack/vscode-monorepo-debug' still does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants