Skip to content

fix(argent): ship tree-sitter so react-profiler-component-source finds components#363

Draft
latekvo wants to merge 2 commits into
mainfrom
fix/component-source-tree-sitter
Draft

fix(argent): ship tree-sitter so react-profiler-component-source finds components#363
latekvo wants to merge 2 commits into
mainfrom
fix/component-source-tree-sitter

Conversation

@latekvo

@latekvo latekvo commented Jun 17, 2026

Copy link
Copy Markdown
Member

Problem

react-profiler-component-source returns found:false for every component in a standard TS/TSX project. Root cause: @swmansion/argent never declared tree-sitter / tree-sitter-typescript as runtime deps, so the bundle's require("tree-sitter") throws, the error is swallowed, and the AST index is always empty.

Verified on the shipped 0.12.0 bundle: tree-sitter and tree-sitter-typescript are MODULE_NOT_FOUND from the installed tool-server.

Fix

  • Declare both as dependencies of @swmansion/argent and mark them external in the tools bundle (native .node addons can't be inlined by esbuild; they must resolve from the install at runtime).
  • Index memo() / forwardRef() / React.memo() component declarations (their value node is a call_expression, previously skipped entirely — and profiler-flagged components are disproportionately memo-wrapped).
  • Surface an actionable message when the parser can't load instead of a misleading "not found".

Verification

  • Installed the two deps into the shipped 0.12.0 package, restarted the tool-server, re-ran the tool: LoggedOut → LoggedOut.tsx:35, SplashScreen → SplashScreen.tsx:23, Button, Text all now resolve (were found:false for all).
  • New ast-index unit test covers plain/default/arrow + memo/forwardRef/React.memo/nested forms and guards treeSitterAvailable.
  • tsc --build clean, 1254 tool-server tests pass, eslint + prettier clean.

Supersedes #287 (that branch was based on a much older main and could not be rebased cleanly through the bundle-tools.cjs rewrite). Closes #287.

latekvo added 2 commits June 17, 2026 19:07
…s components

@swmansion/argent never declared tree-sitter / tree-sitter-typescript as
runtime deps, so the bundle's runtime require("tree-sitter") threw, the
require was swallowed, and the AST index was always empty -> the tool
returned found:false for every component.

- declare both as dependencies of @swmansion/argent and mark them external
  in the tools bundle (native .node addons can't be inlined by esbuild)
- index memo()/forwardRef()/React.memo() component declarations, whose value
  node is a call_expression and were missed entirely
- surface an actionable message when the parser can't load instead of a
  misleading "not found"

Closes #287.
…tree-sitter

# Conflicts:
#	packages/argent/scripts/bundle-tools.cjs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant