-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #817 from xddq/add-typescript-example
add example for testing typescript code with vscode-js-debug
- Loading branch information
Showing
7 changed files
with
118 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist | ||
node_modules | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"configurations": { | ||
"run - js-debug": { | ||
"adapter": "js-debug", | ||
"filetypes": [ "javascript", "typescript" ], | ||
"configuration": { | ||
"request": "launch", | ||
"program": "${workspaceRoot}/src/index.ts", | ||
"cwd": "${workspaceRoot}", | ||
"stopOnEntry": false, | ||
"type": "pwa-node" | ||
}, | ||
// 'breakpoints' is an optional part. This is a way to configure exception | ||
// breakpoints. You can leave this out or set as you prefer. | ||
"breakpoints": { | ||
"exception": { | ||
"all": "N", | ||
"uncaught": "N" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Howto | ||
|
||
This example shows you how to use vimspector with | ||
[vscode-js-debug](https://github.com/microsoft/vscode-js-debug). For all | ||
available options see | ||
[here](https://github.com/microsoft/vscode-js-debug/blob/main/OPTIONS.md#node-launch). | ||
|
||
## Prerequisites | ||
|
||
- Have nodejs installed (was tested with 18 and 20). | ||
- Ensure you have vscode-js-debug installed, check installation guides for | ||
nodejs of the vimspector repo on how to do so. | ||
- Install dependencies `npm i`. | ||
|
||
## Debugging | ||
|
||
- Build the project `npm run build` | ||
- Open the typescript file with vim `vim ./src/index.ts` | ||
- Set breakpoints at line 2 and 3 (standard key mapping is F9) | ||
- Run debugging (standard key mapping is F5) | ||
- Press F5 once again (you should see console log output) | ||
- Press F5 once again (you should see another console log output) | ||
- Done🎉 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "vimspector-typescript-test", | ||
"author": "Pierre Dahmani <hi@pierre-dev.com>", | ||
"version": "1.0.0", | ||
"main": "dist/index.js", | ||
"license": "Apache-2.0", | ||
"scripts": { | ||
"build": "tsc" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@tsconfig/node18": "2.0.0", | ||
"typescript": "5.3.3", | ||
"@types/node": "18.16.8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const main = () => { | ||
console.log(new Date().toISOString() + " Debugging typescript with vimspector🎉") | ||
console.log(new Date().toISOString() + " Done!") | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "@tsconfig/node18/tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "dist", | ||
"sourceMap": true, | ||
"baseUrl": "." | ||
}, | ||
"include": ["src", "test"], | ||
"exclude": ["dist", "bundle", "node_modules"] | ||
} | ||
|