fix(argent): ship tree-sitter so react-profiler-component-source finds components#363
Draft
latekvo wants to merge 2 commits into
Draft
fix(argent): ship tree-sitter so react-profiler-component-source finds components#363latekvo wants to merge 2 commits into
latekvo wants to merge 2 commits into
Conversation
…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
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
react-profiler-component-sourcereturnsfound:falsefor every component in a standard TS/TSX project. Root cause:@swmansion/argentnever declaredtree-sitter/tree-sitter-typescriptas runtime deps, so the bundle'srequire("tree-sitter")throws, the error is swallowed, and the AST index is always empty.Verified on the shipped 0.12.0 bundle:
tree-sitterandtree-sitter-typescriptareMODULE_NOT_FOUNDfrom the installed tool-server.Fix
dependenciesof@swmansion/argentand mark themexternalin the tools bundle (native.nodeaddons can't be inlined by esbuild; they must resolve from the install at runtime).memo()/forwardRef()/React.memo()component declarations (their value node is acall_expression, previously skipped entirely — and profiler-flagged components are disproportionately memo-wrapped).Verification
LoggedOut → LoggedOut.tsx:35,SplashScreen → SplashScreen.tsx:23,Button,Textall now resolve (werefound:falsefor all).ast-indexunit test covers plain/default/arrow + memo/forwardRef/React.memo/nested forms and guardstreeSitterAvailable.tsc --buildclean, 1254 tool-server tests pass, eslint + prettier clean.Supersedes #287 (that branch was based on a much older
mainand could not be rebased cleanly through thebundle-tools.cjsrewrite). Closes #287.