feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
15.02k stars 745 forks source link

Add "sourceMap": true to tsconf.json to enable debugging in VSCode for Feathers V5 with typescript #3164

Closed nathanbrizzee-cdcr closed 1 year ago

nathanbrizzee-cdcr commented 1 year ago

Steps to reproduce

1) Use the 5.0.4 CLI to generate a simple application. I chose to not use any databases to make it as simple as possible. 2) Use the generator (npx feathers generate service) to create a basic custom service. I didn't add TypeBox nor any schema to make it as simple as possible. 3) Using VSCode, set a breakpoint in the custom service class file in the Find method and create a launch.json file with VSCode.

Expected behavior

Should be able to set a breakpoint and debug the application

Actual behavior

Debugger crashes with this error:

C:\Program Files\nodejs\node.exe .\src\index.ts
Process exited with code 1
(node:27216) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)

System configuration

Tell us about the applicable parts of your setup.

tsconfig.json needs "sourceMap": true added to it. Would be nice if the setting was in the template used by the generator. Here is my tsconfig (from the generator) with sourceMaps added. This allows me to debug the application.

{
  "ts-node": {
    "files": true
  },
  "compilerOptions": {
    "target": "es2020",
    "module": "commonjs",
    "outDir": "./lib",
    "rootDir": "./src",
    "declaration": true,
    "strict": true,
    "esModuleInterop": true,
    "sourceMap": true
  },
  "include": [
    "src"
  ],
  "exclude": [
    "test"
  ]
}

NodeJS version: Node 18.16.0; npm 9.6.4; pnpm 8.2.0

Operating System: Windows 11 x64

VSCode: -Version: 1.77.3 (user setup) -Commit: 704ed70d4fd1c6bd6342c436f1ede30d1cff4710 -Date: 2023-04-12T09:16:02.548Z -Electron: 19.1.11 -Chromium: 102.0.5005.196 -Node.js: 16.14.2 -V8: 10.2.154.26-electron.0 -OS: Windows_NT x64 10.0.22621 -Sandboxed: Yes

daffl commented 1 year ago

You can edit the tsconfig template at https://github.com/feathersjs/feathers/blob/dove/packages/generators/src/app/templates/tsconfig.json.tpl.ts and submit a pull request