Skip to content

Fix import extraction for Svelte and Vue script blocks #223

@jmcmacnz

Description

@jmcmacnz

Summary

Svelte and Vue files are discovered and parsed, but imports inside their <script> blocks are not extracted into IMPORTS edges.

Root cause

cbm_extract_imports() only routes JavaScript, TypeScript, and TSX through the ES import walker. Svelte and Vue parse to a markup-oriented AST at the root, where imports live inside document -> script_element -> raw_text, so they never reach the normal ES import extraction path.

Proposed fix

  • add a Svelte/Vue-specific import extractor in internal/cbm/extract_imports.c
  • find script_element -> raw_text
  • re-parse the embedded script text with the JavaScript grammar
  • run the existing ES import walker on that sub-tree
  • add regression tests for .svelte and .vue import extraction

Validation

I verified this against a downstream Svelte repo after building the local branch:

  • before the fix: src/App.svelte had zero outgoing IMPORTS edges
  • after the fix: src/App.svelte produced 7 IMPORTS edges to relative imports such as:
    • src/components/TopNavigation.svelte
    • src/components/TreeView.svelte
    • src/components/AdCanvas.svelte

Alias imports like $lib/... and @/... still do not resolve, but that is a separate pipeline concern and not part of this fix.

Scope

This issue is only about extracting imports from embedded script blocks in .svelte / .vue files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions