Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ripe-olives-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/devtools-vite': patch
---

improve open-source by using a 3rd party package
3 changes: 1 addition & 2 deletions docs/vite-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ export default {

### editor

> [!IMPORTANT] `editor` is only needed for editors that are NOT VS Code, by default this works OOTB with VS Code. If you don't have `code` available in your terminal you need to set it up though, if you don't know how to do that you can follow this guide: https://stackoverflow.com/questions/29955500/code-is-not-working-in-on-the-command-line-for-visual-studio-code-on-os-x-ma

> [!IMPORTANT] `editor` is used as an escape hatch to implement your own go-to-source functionality if your system/editor does not work OOTB. We use `launch-editor` under the hood which supports a lot of editors but not all. If your editor is not supported you can implement your own version here. Here is the list of supported editors: https://github.com/yyx990803/launch-editor?tab=readme-ov-file#supported-editors

The open in editor configuration which has two fields, `name` and `open`,
`name` is the name of your editor, and `open` is a function that opens the editor with the given file and line number. You can implement your version for your editor as follows:
Expand Down
3 changes: 2 additions & 1 deletion packages/devtools-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"@babel/traverse": "^7.28.3",
"@babel/types": "^7.28.2",
"@tanstack/devtools-event-bus": "workspace:*",
"chalk": "^5.6.0"
"chalk": "^5.6.0",
"launch-editor": "^2.11.1"
},
"devDependencies": {
"@types/babel__core": "^7.20.5",
Expand Down
10 changes: 7 additions & 3 deletions packages/devtools-vite/src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ export type EditorConfig = {
export const DEFAULT_EDITOR_CONFIG: EditorConfig = {
name: 'VSCode',
open: async (path, lineNumber, columnNumber) => {
const { exec } = await import('node:child_process')
exec(
`code -g "${path.replaceAll('$', '\\$')}${lineNumber ? `:${lineNumber}` : ''}${columnNumber ? `:${columnNumber}` : ''}"`,
const launch = (await import('launch-editor')).default
launch(
`${path.replaceAll('$', '\\$')}${lineNumber ? `:${lineNumber}` : ''}${columnNumber ? `:${columnNumber}` : ''}`,
undefined,
(filename, err) => {
console.warn(`Failed to open ${filename} in editor: ${err}`)
},
)
},
}
Expand Down
19 changes: 19 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading