fix(vscode): use tsx for 'Run Current File' debug configuration#25220
fix(vscode): use tsx for 'Run Current File' debug configuration#25220AjayBora002 wants to merge 5 commits intogoogle-gemini:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request improves the developer experience in VS Code by enabling direct execution of TypeScript files through the debugger. By switching from direct Node.js execution to using 'tsx', the configuration now correctly handles TypeScript files, resolving issues where the debugger would fail to run them. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request adds a new VS Code launch configuration, 'CLI: Run Current File', to facilitate running and debugging individual files. Feedback was provided regarding the use of npm exec as the runtime executable, which interferes with the debugger's ability to attach. The reviewer suggested using node with the --import tsx flag for better performance and debugging support, along with configuring the integrated terminal for correct CLI output rendering.
Note: Security Review has been skipped due to the limited scope of the PR.
| "name": "CLI: Run Current File", | ||
| "type": "node", | ||
| "request": "launch", | ||
| "name": "Launch Program", | ||
| "runtimeExecutable": "npm", | ||
| "runtimeArgs": ["exec", "tsx", "--", "${file}"], | ||
| "cwd": "${workspaceFolder}", | ||
| "skipFiles": ["<node_internals>/**"], | ||
| "program": "${file}", | ||
| "outFiles": ["${workspaceFolder}/**/*.js"] | ||
| "outFiles": ["${workspaceFolder}/**/*.js"], | ||
| "env": { | ||
| "NODE_ENV": "development" | ||
| } |
There was a problem hiding this comment.
Using npm exec as the runtimeExecutable in a launch.json configuration is problematic for debugging. VS Code's Node.js debugger attempts to inject debugging flags (such as --inspect-brk) into the runtimeExecutable. Since npm does not recognize these flags, it will likely fail to start or ignore them, preventing the debugger from attaching to the actual script process. This means breakpoints will not work as expected.
Additionally, npm exec introduces significant startup overhead. Since this project uses Node.js 20 (recommended ~20.19.0 per the repository style guide), the preferred approach is to use node directly with the --import tsx flag.
Furthermore, since this is a CLI project using Ink, you should set "console": "integratedTerminal" to ensure the output is rendered correctly in a TTY-enabled environment, consistent with other configurations in this file (e.g., lines 15, 72, 90).
| "name": "CLI: Run Current File", | |
| "type": "node", | |
| "request": "launch", | |
| "name": "Launch Program", | |
| "runtimeExecutable": "npm", | |
| "runtimeArgs": ["exec", "tsx", "--", "${file}"], | |
| "cwd": "${workspaceFolder}", | |
| "skipFiles": ["<node_internals>/**"], | |
| "program": "${file}", | |
| "outFiles": ["${workspaceFolder}/**/*.js"] | |
| "outFiles": ["${workspaceFolder}/**/*.js"], | |
| "env": { | |
| "NODE_ENV": "development" | |
| } | |
| "name": "CLI: Run Current File", | |
| "type": "node", | |
| "request": "launch", | |
| "program": "${file}", | |
| "runtimeArgs": ["--import", "tsx"], | |
| "cwd": "${workspaceFolder}", | |
| "console": "integratedTerminal", | |
| "skipFiles": ["<node_internals>/**"], | |
| "env": { | |
| "NODE_ENV": "development" | |
| } |
References
- The project recommends Node.js ~20.19.0 for development, which supports the
--importflag for loaders. (link)
e24f86d to
62b8f0e
Compare
The 'Launch Program' debug configuration used program: , which fails for .ts/.tsx files since Node.js cannot execute TypeScript natively. Updated to use pm exec tsx which leverages the project's existing tsx dependency for runtime transpilation. Fixes google-gemini#22844
62b8f0e to
890946c
Compare
The 'Launch Program' debug configuration used program: , which fails for .ts/.tsx files since Node.js cannot execute TypeScript natively. Updated to use pm exec tsx which leverages the project's existing tsx dependency for runtime transpilation.
Fixes #22844
Summary
Updated the VS Code debug configuration so you can actually hit F5 on a
.tsfile and have it run without blowing up.
Details
The old config had
"program": "${file}"which just hands the file to Node.jsdirectly. That works for
.jsfiles but not for TypeScript.The fix swaps it to use
tsx(which is already in the project's devDependenciesat
^4.20.3and is used by several npm scripts). I also addedcwdandNODE_ENV=developmentto keep it consistent with the other debug configs inthe file.
Related Issues
Fixes #22844
How to Validate
.tsfile (e.g. something underpackages/cli/src/)Pre-Merge Checklist