Skip to content

Add Svelte and Vue single-file component support#59

Open
janrito wants to merge 1 commit into
scss-lessfrom
svelte-vue
Open

Add Svelte and Vue single-file component support#59
janrito wants to merge 1 commit into
scss-lessfrom
svelte-vue

Conversation

@janrito

@janrito janrito commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Add Svelte and Vue single-file component support.

An SFC packs several languages into one file — <template>, <script>,
<style> — and was previously indexed as opaque text, so a component's script
definitions were unsearchable. The plugin uses the engine's injection
mechanism to delegate the <script> and <style> blocks to their embedded
language (JS/TS, CSS/SCSS) at real line numbers, and emits the template markup
as a searchable host chunk; one plugin covers both Svelte and Vue since their
block node shapes are identical. Svelte uses the standalone
tree-sitter-svelte grammar; Vue has no standalone Python binding so it comes
from tree-sitter-language-pack, which is hermetic — grammars are compiled
into the wheel, no runtime download. Because that package hands back a ready
Language, this adds a grammar_factory registration hook (the usual
Language(entry()) path double-wraps and fails).

It also fixes a delegation bug surfaced by SFCs: the pipeline overwrote every
chunk's language with the host file's, which broke edge resolution for
delegated chunks (a <script> TS import to a sibling .ts no longer
resolved); the host language is now filled in only when the chunker left it
blank. Finally, it adds the invariant that every registered language ships a
committed sample, so no future plugin lands untested.

Pinned by svelte/vue sample snapshots (including a cross-block script-import
edge) and the multi-language markdown sample.


Stacked PRs (merge bottom → top): #54 · #55 · #56 · #57 · #58 · #59 · #60

Add the SFC plugin, which delegates each block (template, script, and
style) to its embedded language through injection, with svelte and vue
samples and a multi-language markdown sample. Assert that every
registered language ships a committed sample.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant