payloadcms / payload

The best way to build a modern backend + admin UI. No black magic, all TypeScript, and fully open-source, Payload is both an app framework and a headless CMS.
https://payloadcms.com
MIT License
21.04k stars 1.27k forks source link

Can't get VSCode debugging to work #6882

Open adamczykjac opened 1 week ago

adamczykjac commented 1 week ago

Link to reproduction

https://github.com/payloadcms/payload-3.0-demo

Payload Version

3.0.0-beta.52

Node Version

20.15.0

Next.js Version

15.0.0-rc.0

Describe the Bug

Out of the box, I can't possibly get VS Code debugging to work, resulting in unbound breakpoints:

obraz

With the help of this comment, I only managed to prove that there are indeed no project sourcemaps visible in the Debug Diagnostic view (available when in Debugging mode from Command Palette):

obraz

Tried almost everything from this topic - with sourceMapPathOverrides in launch.json, changing cwd. Nothing worked.

Reproduction Steps

  1. Clone Payload 3 demo repo
  2. Go into VSCode debugging view
  3. Put a breakpoint in src/app/(app)/page.tsx:7 or in src/app/my-route/route.ts:13
  4. Run debug session
  5. Reach localhost:3000 or localhost:3000/my-route, respectively to point no. 3
  6. Observe no breakpoint to kick in

Adapters and Plugins

No response

JamesCaldon commented 1 week ago

If you're using the default package.json dev script with cross-env, you may need to pass down the NODE_OPTIONS that VSCode would typically inject when a debugging session is started. e.g. "dev": "cross-env NODE_OPTIONS=\"${NODE_OPTIONS} --no-deprecation\" next dev"

adamczykjac commented 3 days ago

it works as a charm! Would you mind if I create a PR to the Payload 3.0 demo repo with that line changed? I'm stunned that people are not experiencing that too. How do y'all debug your apps at all :D ?