()
| 30 | |
| 31 | // Function to initialize tree-sitter |
| 32 | export async function initializeTreeSitter() { |
| 33 | if (!initializedTreeSitter) { |
| 34 | // Initialize directly using the default export or the module itself |
| 35 | await Parser.init() |
| 36 | |
| 37 | // Override the Parser.Language.load to use dist directory |
| 38 | const originalLoad = Language.load |
| 39 | |
| 40 | Language.load = async (wasmPath: string) => { |
| 41 | const filename = path.basename(wasmPath) |
| 42 | const correctPath = path.join(process.cwd(), "dist", filename) |
| 43 | // console.log(`Redirecting WASM load from ${wasmPath} to ${correctPath}`) |
| 44 | return originalLoad(correctPath) |
| 45 | } |
| 46 | |
| 47 | initializedTreeSitter = { Parser, Language } |
| 48 | } |
| 49 | |
| 50 | return initializedTreeSitter |
| 51 | } |
| 52 | |
| 53 | // Test helper for parsing source code definitions |
| 54 | export async function testParseSourceCodeDefinitions( |
no test coverage detected