You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/architecture.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -194,7 +194,7 @@ Adapters do not re-implement the devtools UI, manage settings, handle events, or
194
194
`@tanstack/devtools-vite` is a collection of Vite plugins that enhance the development experience and clean up production builds. It returns an array of Vite plugins, each handling a specific concern:
Uses Babel to parse JSX/TSX files and injects `data-tsd-source` attributes on every JSX element. These attributes encode the file path, line number, and column number of each element in source code, which the source inspector feature uses to implement click-to-open-in-editor.
197
+
Parses JSX/TSX files with oxc-parser and injects `data-tsd-source` attributes on every JSX element via MagicString. These attributes encode the file path, line number, and column number of each element in source code, which the source inspector feature uses to implement click-to-open-in-editor.
198
198
199
199
### Server event bus (`@tanstack/devtools:custom-server`)
200
200
Starts a `ServerEventBus` on the Vite dev server. Also sets up middleware for the go-to-source editor integration and bidirectional console piping (client logs appear in the terminal, server logs appear in the browser).
B -- "Hold inspect hotkey<br/>+ click element" --> C["Devtools reads<br/>data-tsd-source"]
23
23
C -- "HTTP request" --> D["Vite dev server"]
24
24
D -- "launch-editor" --> E["Opens file in editor<br/>at exact line"]
25
25
```
26
26
27
-
The Vite plugin uses Babel to parse your JSX/TSX files during development. It adds a `data-tsd-source="filepath:line:column"` attribute to every JSX element. When you activate the source inspector and click an element, the devtools reads this attribute and sends a request to the Vite dev server. The server then launches your editor at the specified file and line using `launch-editor`.
27
+
The Vite plugin uses oxc-parser to parse your JSX/TSX files during development. It adds a `data-tsd-source="filepath:line:column"` attribute to every JSX element via MagicString. When you activate the source inspector and click an element, the devtools reads this attribute and sends a request to the Vite dev server. The server then launches your editor at the specified file and line using `launch-editor`.
Copy file name to clipboardExpand all lines: docs/vite-plugin.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -209,7 +209,7 @@ The Vite plugin is composed of several sub-plugins, each handling a specific con
209
209
```mermaid
210
210
graph TD
211
211
vite["@tanstack/devtools-vite"]
212
-
vite --> source["Source Injection<br/><i>Babel → data-tsd-source attrs</i>"]
212
+
vite --> source["Source Injection<br/><i>AST → data-tsd-source attrs</i>"]
213
213
vite --> server["Server Event Bus<br/><i>WebSocket + SSE transport</i>"]
214
214
vite --> strip["Production Stripping<br/><i>Remove devtools on build</i>"]
215
215
vite --> pipe["Console Piping<br/><i>Client ↔ Server logs</i>"]
@@ -220,7 +220,7 @@ graph TD
220
220
221
221
### Go to Source
222
222
223
-
The "Go to Source" feature lets you click on any element in your browser and open its source file in your editor at the exact line where it's defined. It works by injecting `data-tsd-source` attributes into your components via a Babel transformation during development. These attributes encode the file path and line number of each element.
223
+
The "Go to Source" feature lets you click on any element in your browser and open its source file in your editor at the exact line where it's defined. It works by injecting `data-tsd-source` attributes into your components via an AST transformation during development. These attributes encode the file path and line number of each element.
224
224
225
225
To use it, activate the source inspector by holding the inspect hotkey (default: Shift+Alt+Ctrl/Meta). An overlay will highlight elements under your cursor and display their source location. Clicking on a highlighted element opens the corresponding file in your editor at the exact line, powered by `launch-editor` under the hood.
|`@tanstack/devtools:inject-source`|Babel transform adding `data-tsd-source` attrs to JSX | dev mode + `injectSource.enabled`|
70
+
|`@tanstack/devtools:inject-source`|AST transform adding `data-tsd-source` attrs to JSX | dev mode + `injectSource.enabled`|
71
71
|`@tanstack/devtools:config`| Reserved for future config modifications | serve command only |
72
72
|`@tanstack/devtools:custom-server`| Starts ServerEventBus, registers middleware for open-source/console-pipe endpoints | dev mode |
73
73
|`@tanstack/devtools:remove-devtools-on-build`| Strips devtools imports/JSX from production bundles | build command or production mode + `removeDevtoolsOnBuild`|
74
74
|`@tanstack/devtools:event-client-setup`| Marketplace: listens for install/add-plugin events via devtoolsEventClient | dev mode + serve + not CI |
75
75
|`@tanstack/devtools:console-pipe-transform`| Injects runtime console-pipe code into entry files | dev mode + serve + `consolePiping.enabled`|
76
-
|`@tanstack/devtools:better-console-logs`|Babel transform prepending source location to `console.log`/`console.error`| dev mode + `enhancedLogs.enabled`|
76
+
|`@tanstack/devtools:better-console-logs`|AST transform prepending source location to `console.log`/`console.error`| dev mode + `enhancedLogs.enabled`|
77
77
|`@tanstack/devtools:inject-plugin`| Detects which file imports TanStackDevtools (for marketplace injection) | dev mode + serve |
Adds `data-tsd-source="<relative-path>:<line>:<column>"` attributes to every JSX opening element via Babel. This powers the "Go to Source" feature -- hold the inspect hotkey (default: Shift+Alt+Ctrl/Meta), hover over elements, click to open in editor.
84
+
Adds `data-tsd-source="<relative-path>:<line>:<column>"` attributes to every JSX opening element via oxc-parser + MagicString. This powers the "Go to Source" feature -- hold the inspect hotkey (default: Shift+Alt+Ctrl/Meta), hover over elements, click to open in editor.
85
85
86
86
**Key behaviors:**
87
87
@@ -137,7 +137,7 @@ devtools({
137
137
138
138
### Enhanced Logging
139
139
140
-
Babel transform that prepends source location info to `console.log()` and `console.error()` calls. In the browser, this renders as a clickable "Go to Source" link. On the server, it shows `LOG <path>:<line>:<column>` in chalk colors.
140
+
AST transform that prepends source location info to `console.log()` and `console.error()` calls. In the browser, this renders as a clickable "Go to Source" link. On the server, it shows `LOG <path>:<line>:<column>` in chalk colors.
141
141
142
142
The transform inserts a spread of a conditional expression: `...(typeof window === 'undefined' ? serverLogMessage : browserLogMessage)` as the first argument of the console call.
143
143
@@ -261,7 +261,7 @@ Source injection, console piping, enhanced logging, the server event bus, and th
261
261
262
262
### 4. Source injection on spread-props elements (MEDIUM)
263
263
264
-
The Babel transform in `inject-source.ts` explicitly skips any JSX element that has a `{...props}` spread where `props` is the component's parameter name. This is intentional -- the spread would overwrite the injected `data-tsd-source` attribute. If source inspection doesn't work for a specific component, check if it spreads its props parameter.
264
+
The AST transform in `inject-source.ts` explicitly skips any JSX element that has a `{...props}` spread where `props` is the component's parameter name. This is intentional -- the spread would overwrite the injected `data-tsd-source` attribute. If source inspection doesn't work for a specific component, check if it spreads its props parameter.
265
265
266
266
```tsx
267
267
// data-tsd-source will NOT be injected on <div> here
@@ -301,8 +301,8 @@ These are registered on the Vite dev server (not the event bus server):
301
301
## Key Source Files
302
302
303
303
-`packages/devtools-vite/src/plugin.ts` -- Main plugin factory with all sub-plugins and config type
304
-
-`packages/devtools-vite/src/inject-source.ts` -- Babel transform for data-tsd-source injection
305
-
-`packages/devtools-vite/src/enhance-logs.ts` -- Babel transform for enhanced console logs
304
+
-`packages/devtools-vite/src/inject-source.ts` -- AST transform for data-tsd-source injection
305
+
-`packages/devtools-vite/src/enhance-logs.ts` -- AST transform for enhanced console logs
306
306
-`packages/devtools-vite/src/remove-devtools.ts` -- Production stripping transform
Copy file name to clipboardExpand all lines: packages/devtools/skills/devtools-marketplace/SKILL.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -222,7 +222,7 @@ The auto-install pipeline lives in `packages/devtools-vite/src/inject-plugin.ts`
222
222
223
223
1.**Packageinstallation**--TheViteplugindetectstheproject's package manager and runs the appropriate install command.
224
224
2.**Filedetection**--Itscansprojectfilesforimportsfrom`@tanstack/react-devtools`, `@tanstack/solid-devtools`, `@tanstack/vue-devtools`, etc.
225
-
3. **AST transformation** -- It parses the file with Babel, finds the `<TanStackDevtools />` JSX element, and modifies the `plugins` prop.
225
+
3. **AST transformation** -- It parses the file with oxc-parser, finds the `<TanStackDevtools />` JSX element, and modifies the `plugins` prop via MagicString.
226
226
4. **Import insertion** -- It adds `import { <importName> } from '<packageName>'` after the last existing import.
227
227
5. **Plugin injection** -- Based on `pluginImport.type`:
Copy file name to clipboardExpand all lines: packages/devtools/skills/devtools-production/SKILL.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ TanStack Devtools has two independent mechanisms for keeping devtools out of pro
31
31
32
32
The `@tanstack/devtools-vite` plugin includes a sub-plugin named `@tanstack/devtools:remove-devtools-on-build`. When `removeDevtoolsOnBuild` is `true` (the default), this plugin runs during `vite build` and any non-`serve` command where the mode is `production`.
33
33
34
-
It uses Babel to parse every source file, find imports from these packages, and remove them along with any JSX elements they produce:
34
+
It uses oxc-parser to parse every source file, find imports from these packages, and remove them along with any JSX elements they produce:
35
35
36
36
-`@tanstack/react-devtools`
37
37
-`@tanstack/preact-devtools`
@@ -452,7 +452,7 @@ For staging/preview environments where you want devtools but not in the final pr
452
452
## Key Source Files
453
453
454
454
-`packages/devtools-vite/src/plugin.ts` -- Vite plugin entry, `removeDevtoolsOnBuild` option, sub-plugin registration
0 commit comments