-
-
Notifications
You must be signed in to change notification settings - Fork 88
refactor(devtools-vite): migrate from Babel to oxc-parser + MagicString #397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AlemTuzlak
merged 11 commits into
TanStack:main
from
dake3601:feat/oxc-parser-migration
May 13, 2026
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5ea4817
refactor(devtools-vite): migrate from Babel to oxc-parser + MagicString
dake3601 d395c26
changeset+knip fix
dake3601 17ac9df
docs update
dake3601 9b1b486
ci: apply automated fixes
autofix-ci[bot] b40fea5
refactor(devtools-vite): address CodeRabbit feedback on oxc migration
AlemTuzlak 6fae8fd
chore(deps): bump oxc-parser to ^0.120.0
AlemTuzlak 6f5fc05
Merge remote-tracking branch 'origin/main' into feat/oxc-parser-migra…
AlemTuzlak e5041c0
ci: apply automated fixes
autofix-ci[bot] 856f02b
fix(devtools-vite): emit correct source positions for enhanced logs
AlemTuzlak 30db612
fix(devtools): snapshot data-tsd-source before mutating click state
AlemTuzlak 5d3b420
ci: apply automated fixes
autofix-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| --- | ||
| '@tanstack/devtools-vite': minor | ||
| --- | ||
|
|
||
| migrate from Babel to oxc-parser + MagicString |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,54 @@ | ||
| import type { Node } from 'oxc-parser' | ||
|
|
||
| /** | ||
| * Cache of keys that hold child nodes (objects/arrays) per AST node type. | ||
| * Since oxc-parser produces AST via JSON.parse, every instance of a given | ||
| * node type has the same set of keys, so we only need to discover them once. | ||
| */ | ||
| const childKeysCache = new Map<string, Array<string>>() | ||
|
|
||
| function getChildKeys(node: Node): Array<string> { | ||
| let keys = childKeysCache.get(node.type) | ||
| if (keys) return keys | ||
|
|
||
| keys = [] | ||
| for (const key in node) { | ||
| if (key === 'type' || key === 'start' || key === 'end') continue | ||
| // typeof null === 'object', so nullable node fields get cached too | ||
| if (typeof (node as any)[key] === 'object') { | ||
| keys.push(key) | ||
| } | ||
| } | ||
| childKeysCache.set(node.type, keys) | ||
| return keys | ||
| } | ||
|
|
||
| /** | ||
| * Iterate over the direct child nodes of an AST node. | ||
| * Uses a per-type cache of which keys hold child nodes to avoid | ||
| * allocating Object.entries() arrays on every call. | ||
| */ | ||
| export function forEachChild(node: Node, callback: (child: Node) => void) { | ||
| const keys = getChildKeys(node) | ||
| for (const key of keys) { | ||
| const value = (node as any)[key] | ||
| if (value === null) continue | ||
| if (Array.isArray(value)) { | ||
| for (const item of value) { | ||
| if (typeof item === 'object' && item !== null && 'type' in item) { | ||
| callback(item) | ||
| } | ||
| } | ||
| } else if ('type' in value) { | ||
| callback(value as Node) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Recursively walk AST nodes, calling `visitor` for each node with a `type`. | ||
| */ | ||
| export function walk(node: Node, visitor: (node: Node) => void) { | ||
| visitor(node) | ||
| forEachChild(node, (child) => walk(child, visitor)) | ||
| } |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: TanStack/devtools
Length of output: 189
Consider updating
oxc-parserto a more recent version.While
magic-string@^0.30.0is current (latest is 0.30.21),oxc-parser@0.72.0is significantly outdated; the latest version is 0.120.0. Check the changelog between 0.72.0 and a more recent release to ensure no critical fixes, breaking changes, or performance improvements are missed. If 0.72.0 is intentionally pinned for compatibility, document the rationale.🤖 Prompt for AI Agents