Repository navigation
Conversation
.vue files were dispatched to extract_js, which feeds the whole SFC to the JavaScript tree-sitter grammar. A .vue file is not valid JS (it is <template>/<script>/<style>), so the parser produces a top-level ERROR node and the import_statement nodes inside <script>/<script setup> are never reached -- imports are silently dropped, leaving .vue files as disconnected nodes in the graph. This is the same problem already solved for .svelte (Graphify-Labs#713) via a regex rescue over each <script> block. Add extract_vue that reuses that recovery and route .vue to it.
safishamsi
left a comment
There was a problem hiding this comment.
Good bug fix — the diagnosis is correct and reusing extract_svelte is the right call since it already does regex rescue of <script> blocks rather than relying on tree-sitter.
Two things before merge:
1. Drop the wrapper function — dispatch directly
# Instead of:
def extract_vue(path: Path) -> dict:
return extract_svelte(path)
# ...
".vue": extract_vue,
# Prefer:
".vue": extract_svelte,The wrapper adds a stack frame and a maintenance point with no benefit. If you anticipate Vue-specific behaviour diverging from Svelte in future, a comment at the dispatch entry is enough to signal that.
2. Beef up the test coverage
The current test only covers a <script setup> static import. Please add:
- A
dynamic import()case (e.g.const m = await import('./utils.js')inside a<script>) - A
lang="ts"attribute case (TypeScript SFC — the regex matches<script[^>]*>so it should work, but worth asserting)
Also worth noting: extract.py:7256 explicitly excludes .vue from the JS symbol-resolution bypass (path.suffix != ".vue" guard). This is intentional and unaffected by your change, but a one-line comment at the dispatch entry would help future readers understand why .vue and .svelte are routed identically here but differ elsewhere in the pipeline.
…ctly Per review feedback: drop the extract_vue wrapper and dispatch .vue straight to extract_svelte (the wrapper added no behavior), with a comment at the dispatch entry explaining the shared-SFC rationale and the intentional .vue divergence at the JS symbol-resolution bypass. Add dynamic import() and lang="ts" SFC test coverage.
Summary
.vuefiles were dispatched toextract_js, which feeds the whole Single-File Component to the JavaScript tree-sitter grammar. A.vuefile is not valid JS — it is<template>/<script>/<style>— so the parser produces a top-levelERRORnode and theimport_statementnodes inside<script>/<script setup>are never reached. The imports are silently dropped, leaving.vuefiles as disconnected nodes in the knowledge graph.This is the same problem already solved for
.svelte(#713): the JS grammar fed a full.sveltefile also produces an ERROR root, soextract_svelterecovers imports with a regex pass over each<script>block (plus dynamicimport()). The maintainer awareness is already in the code —_get_extractor/symbol-resolution treats.vueas non-JS atextract.py(path.suffix != ".vue"guard) — but the main extraction path still fed the whole SFC to the JS grammar.Fix
Add
extract_vue, which reuses the Svelte SFC recovery (<script>-block static imports + dynamicimport()) since a Vue SFC has the identical structure, and route.vueto it.Verification
Added
tests/test_vue_extraction.py(modeled ontests/test_astro_extraction.py): a.vueSFC whose<script setup>statically imports a sibling.vuecomponent is extracted through the real dispatch (_get_extractor) and the import edge is asserted. Verified it fails before the fix (the import is dropped) and passes after.tests/test_astro_extraction.py,tests/test_js_import_resolution.py, andtests/test_import_extension_resolution.pyremain green (the fix is additive —extract_svelteis unchanged);ruff checkclean.