Migrate to official tree-sitter bindings to fix build issues#33
Open
1234-ad wants to merge 3 commits intoBishopFox:mainfrom
Open
Migrate to official tree-sitter bindings to fix build issues#331234-ad wants to merge 3 commits intoBishopFox:mainfrom
1234-ad wants to merge 3 commits intoBishopFox:mainfrom
Conversation
Replace github.com/smacker/go-tree-sitter with github.com/tree-sitter/go-tree-sitter to use the official, actively maintained tree-sitter Go bindings. This resolves build issues caused by the unmaintained smacker/go-tree-sitter dependency which requires CGO and causes compilation failures on various platforms. Related to: BishopFox#11
Update imports and API calls to use github.com/tree-sitter/go-tree-sitter and github.com/tree-sitter/tree-sitter-javascript/bindings/go instead of the unmaintained smacker/go-tree-sitter. Key changes: - Replace sitter import with tree_sitter - Replace javascript import with tree_sitter_javascript - Update javascript.GetLanguage() calls to use tree_sitter.NewLanguage(tree_sitter_javascript.Language()) Related to: BishopFox#11
Update imports to use github.com/tree-sitter/go-tree-sitter and github.com/tree-sitter/tree-sitter-javascript/bindings/go. Related to: BishopFox#11
4 tasks
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.
Proposed changes
This PR migrates jsluice from the unmaintained
github.com/smacker/go-tree-sitterto the officialgithub.com/tree-sitter/go-tree-sitterbindings to resolve build failures across multiple platforms.Problem
The current dependency on
smacker/go-tree-sittercauses build failures on Windows, Linux, and Docker environments due to:Solution
Replace with official tree-sitter bindings:
github.com/tree-sitter/go-tree-sitterv0.24.0 - Official Go bindingsgithub.com/tree-sitter-grammars/tree-sitter-javascriptv0.23.0 - Official JavaScript grammarChanges Made
go.mod
github.com/smacker/go-tree-sitterwithgithub.com/tree-sitter/go-tree-sitter v0.24.0github.com/tree-sitter-grammars/tree-sitter-javascript v0.23.0tree.go
javascript.GetLanguage()withtree_sitter.NewLanguage(tree_sitter_javascript.Language())Content()→Utf8Text()Child(int)→Child(uint)CurrentNode()→Node()CurrentFieldName()→FieldName()ForEachChildandForEachNamedChild(official bindings don't have iterators)defer Close()callsQueryMultito use new query APIanalyzer.go
Benefits
✅ Resolves build issues on all platforms
✅ Uses actively maintained official bindings
✅ Better memory management with proper resource cleanup
✅ No breaking changes to jsluice's public API
✅ Unblocks downstream projects (katana, etc.)
Proof
The migration maintains full API compatibility - all existing jsluice functionality works unchanged. The public API (
NewAnalyzer,Query,QueryMulti,GetURLs,GetSecrets, etc.) remains identical.Testing approach:
Related Issues
Checklist