Skip to content

Commit 17ac9df

Browse files
committed
docs update
1 parent d395c26 commit 17ac9df

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

_artifacts/domain_map.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ skills:
231231

232232
- mistake: 'Source injection on spread props elements'
233233
mechanism: >
234-
The Babel transform skips elements with {...props} spread to avoid
234+
The AST transform skips elements with {...props} spread to avoid
235235
overwriting dynamic attributes. Agent might not realize source
236236
inspector wont work on those elements.
237237
source: 'packages/devtools-vite/src/inject-source.ts'

docs/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ Adapters do not re-implement the devtools UI, manage settings, handle events, or
194194
`@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:
195195

196196
### Source injection (`@tanstack/devtools:inject-source`)
197-
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.
198198

199199
### Server event bus (`@tanstack/devtools:custom-server`)
200200
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).

docs/source-inspector.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ The feature only works in development. In production builds, source attributes a
1818

1919
```mermaid
2020
flowchart LR
21-
A["Your JSX/TSX files"] -- "Babel transform" --> B["data-tsd-source<br/>attributes injected"]
21+
A["Your JSX/TSX files"] -- "AST transform" --> B["data-tsd-source<br/>attributes injected"]
2222
B -- "Hold inspect hotkey<br/>+ click element" --> C["Devtools reads<br/>data-tsd-source"]
2323
C -- "HTTP request" --> D["Vite dev server"]
2424
D -- "launch-editor" --> E["Opens file in editor<br/>at exact line"]
2525
```
2626

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`.
2828

2929
## Activating the Inspector
3030

docs/vite-plugin.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ The Vite plugin is composed of several sub-plugins, each handling a specific con
209209
```mermaid
210210
graph TD
211211
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>"]
213213
vite --> server["Server Event Bus<br/><i>WebSocket + SSE transport</i>"]
214214
vite --> strip["Production Stripping<br/><i>Remove devtools on build</i>"]
215215
vite --> pipe["Console Piping<br/><i>Client ↔ Server logs</i>"]
@@ -220,7 +220,7 @@ graph TD
220220

221221
### Go to Source
222222

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.
224224

225225
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.
226226

packages/devtools-vite/skills/devtools-vite-plugin/SKILL.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,21 @@ From `packages/devtools-vite/src/index.ts`:
6767

6868
| Sub-plugin name | What it does | When active |
6969
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------- |
70-
| `@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` |
7171
| `@tanstack/devtools:config` | Reserved for future config modifications | serve command only |
7272
| `@tanstack/devtools:custom-server` | Starts ServerEventBus, registers middleware for open-source/console-pipe endpoints | dev mode |
7373
| `@tanstack/devtools:remove-devtools-on-build` | Strips devtools imports/JSX from production bundles | build command or production mode + `removeDevtoolsOnBuild` |
7474
| `@tanstack/devtools:event-client-setup` | Marketplace: listens for install/add-plugin events via devtoolsEventClient | dev mode + serve + not CI |
7575
| `@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` |
7777
| `@tanstack/devtools:inject-plugin` | Detects which file imports TanStackDevtools (for marketplace injection) | dev mode + serve |
7878
| `@tanstack/devtools:connection-injection` | Replaces `__TANSTACK_DEVTOOLS_PORT__`, `__TANSTACK_DEVTOOLS_HOST__`, `__TANSTACK_DEVTOOLS_PROTOCOL__` placeholders | dev mode + serve |
7979

8080
## Subsystem Details
8181

8282
### Source Injection
8383

84-
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.
8585

8686
**Key behaviors:**
8787

@@ -137,7 +137,7 @@ devtools({
137137

138138
### Enhanced Logging
139139

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.
141141

142142
The transform inserts a spread of a conditional expression: `...(typeof window === 'undefined' ? serverLogMessage : browserLogMessage)` as the first argument of the console call.
143143

@@ -261,7 +261,7 @@ Source injection, console piping, enhanced logging, the server event bus, and th
261261

262262
### 4. Source injection on spread-props elements (MEDIUM)
263263

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.
265265

266266
```tsx
267267
// 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):
301301
## Key Source Files
302302

303303
- `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
306306
- `packages/devtools-vite/src/remove-devtools.ts` -- Production stripping transform
307307
- `packages/devtools-vite/src/virtual-console.ts` -- Console pipe runtime code generator
308308
- `packages/devtools-vite/src/editor.ts` -- Editor config type and launch-editor integration

packages/devtools-vite/skills/devtools-vite-plugin/references/vite-options.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ declare function defineDevtoolsConfig(
4343

4444
## `injectSource`
4545

46-
Controls source injection -- the Babel transform that adds `data-tsd-source` attributes to JSX elements for the "Go to Source" feature.
46+
Controls source injection -- the AST transform that adds `data-tsd-source` attributes to JSX elements for the "Go to Source" feature.
4747

4848
| Field | Type | Default | Description |
4949
| ------------------- | ------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -117,7 +117,7 @@ devtools({
117117

118118
## `enhancedLogs`
119119

120-
Controls the Babel transform that prepends source location information to `console.log()` and `console.error()` calls.
120+
Controls the AST transform that prepends source location information to `console.log()` and `console.error()` calls.
121121

122122
| Field | Type | Default | Description |
123123
| --------- | --------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

packages/devtools-vite/src/offset-to-loc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export interface Loc {
2-
/** 1-based line number (matches Babel convention) */
2+
/** 1-based line number */
33
line: number
4-
/** 0-based column offset (matches Babel convention) */
4+
/** 0-based column offset */
55
column: number
66
}
77

packages/devtools/skills/devtools-marketplace/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ The auto-install pipeline lives in `packages/devtools-vite/src/inject-plugin.ts`
222222

223223
1. **Package installation** -- The Vite plugin detects the project's package manager and runs the appropriate install command.
224224
2. **File detection** -- It scans project files for imports from `@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.
226226
4. **Import insertion** -- It adds `import { <importName> } from '<packageName>'` after the last existing import.
227227
5. **Plugin injection** -- Based on `pluginImport.type`:
228228
- `'function'`: Appends `ImportName()` directly to the plugins array

packages/devtools/skills/devtools-production/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ TanStack Devtools has two independent mechanisms for keeping devtools out of pro
3131

3232
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`.
3333

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:
3535

3636
- `@tanstack/react-devtools`
3737
- `@tanstack/preact-devtools`
@@ -452,7 +452,7 @@ For staging/preview environments where you want devtools but not in the final pr
452452
## Key Source Files
453453

454454
- `packages/devtools-vite/src/plugin.ts` -- Vite plugin entry, `removeDevtoolsOnBuild` option, sub-plugin registration
455-
- `packages/devtools-vite/src/remove-devtools.ts` -- AST-based stripping logic (Babel parse, traverse, codegen)
455+
- `packages/devtools-vite/src/remove-devtools.ts` -- AST-based stripping logic (oxc-parser + MagicString)
456456
- `packages/devtools/package.json` -- Conditional exports (`browser.development` -> `dev.js`, `browser` -> `index.js`, `node`/`workerd` -> `server.js`)
457457
- `packages/devtools/tsup.config.ts` -- Build config producing `dev.js`, `index.js`, `server.js` via `tsup-preset-solid`
458458
- `packages/devtools-utils/src/react/plugin.tsx` -- `createReactPlugin` returning `[Plugin, NoOpPlugin]`

0 commit comments

Comments
 (0)