payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
24.88k stars 1.58k forks source link

No source map file generate when debug server code #8015

Open smoothdvd opened 2 months ago

smoothdvd commented 2 months ago

Link to reproduction

No response

Environment Info

Binaries:
  Node: 20.17.0
  npm: 10.8.2
  Yarn: N/A
  pnpm: 9.9.0
Relevant Packages:
  payload: 3.0.0-beta.97
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:21 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8103
  Available memory (MB): 8192
  Available CPU cores: 8

Describe the Bug

I want to debug the payload 3.0 project in vscode, using the launch file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Next.js: debug server-side",
            "type": "node-terminal",
            "request": "launch",
            "cwd": "${workspaceFolder}/apps/api",
            "sourceMaps": true,
            "command": "pnpm run dev"
        },
    ]
}   

But there is no source map files generated, so the breakpoint is not be intercepted.

Reproduction Steps

Run with debug in vscode and set a breakpoint at the code in my-route.ts

Screenshot 2024-09-01 at 2 43 11 PM Screenshot 2024-09-01 at 2 42 49 PM

Adapters and Plugins

No response

javierlinked commented 1 month ago

I have been trying for a couple of days with no success on debugging, except for the bare minimum of setting an endpoint in 'tsx' files.

Ideally would be having the 'attach to' possibility since we are preparing migration to version 3, and all our logic is on endpoints/hooks. We are just a service/graphql endpoint.

An example on how to set up debugger would be highly appreciated. I already checked Nextjs docs and https://github.com/payloadcms/payload-3.0-demo this repo. But something is missing in my case.

smoothdvd commented 1 month ago

remove NODE_OPTIONS=--no-deprecation to make the VSCode debugger bind breakpoints correctly

or

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Next.js: debug server-side",
            "type": "node-terminal",
            "request": "launch",
            "cwd": "${workspaceFolder}/apps/api",
            "sourceMaps": true,
            "command": "pnpm exec next dev"
        },
    ]
}