Vue SFC package (de.h-dv.vue): template like Svelte, <script setup> through embedded-region dispatch (#275) #331

Closed
opened 2026-10-07 09:33:46 +02:00 by buildagent · 1 comment
Member

This comes from a field report by zammad-dev on #328. A Zammad 7.0.2 fork has 531 Vue single-file components (SFCs), and Vue is the main frontend language there. Today .vue files are indexed as text only, so they have no symbols and no references.

Why this is two pieces

Most of a Vue SFC's value is in <script setup lang="ts">, which is TypeScript or JavaScript. Packages cannot see inside a file that mixes languages: there is one grammar per package and no injection (#275), and EMBEDDED_DISPATCH_SEMANTICS_VERSION = 0 (#119). The existing Svelte package (de.h-dv.svelte) covers only the template half for that reason.

  1. Template half: a package, built like de.h-dv.svelte.
    • The component symbol is named after the file (TAG_SYMBOL_BASENAME, #229).
    • Template references: component tags such as <LoginFooter>, v-bind / v-on expressions, and {{ }} mustaches.
    • No host change is needed.
  2. Script half: host infrastructure, which is #275.
    • A package declares its embedded regions, for example "this <script lang=ts> range is TypeScript".
    • The host dispatches each region to the owner of that language, which is the TS/JS package or the builtin, with line and column offsets mapped back to the file.
    • This is generic. The same mechanism serves the Svelte <script> blocks, ERB (.html.erb: Ruby inside HTML, also in Zammad), .eco (CoffeeScript inside markup), and HTML <script> blocks.

Order

#275's region dispatch first, because it is the generic piece and unblocks four formats. Then the Vue package uses it for the script half and does the template half itself.

Acceptance

  • On Zammad 7.0.2, symbols are extracted from <script setup>.
  • find_callers reaches a composable called from a .vue file.
  • Component references from templates bind to their files.
  • Phantom audit on a sample of binds.
  • Cold-index cost is measured.
This comes from a field report by zammad-dev on #328. A Zammad 7.0.2 fork has 531 Vue single-file components (SFCs), and Vue is the main frontend language there. Today `.vue` files are indexed as text only, so they have no symbols and no references. ## Why this is two pieces Most of a Vue SFC's value is in `<script setup lang="ts">`, which is TypeScript or JavaScript. Packages cannot see inside a file that mixes languages: there is one grammar per package and no injection (#275), and `EMBEDDED_DISPATCH_SEMANTICS_VERSION = 0` (#119). The existing Svelte package (`de.h-dv.svelte`) covers only the template half for that reason. 1. **Template half: a package, built like `de.h-dv.svelte`.** - The component symbol is named after the file (`TAG_SYMBOL_BASENAME`, #229). - Template references: component tags such as `<LoginFooter>`, `v-bind` / `v-on` expressions, and `{{ }}` mustaches. - No host change is needed. 2. **Script half: host infrastructure, which is #275.** - A package declares its embedded regions, for example "this `<script lang=ts>` range is TypeScript". - The host dispatches each region to the owner of that language, which is the TS/JS package or the builtin, with line and column offsets mapped back to the file. - This is generic. The same mechanism serves the Svelte `<script>` blocks, ERB (`.html.erb`: Ruby inside HTML, also in Zammad), `.eco` (CoffeeScript inside markup), and HTML `<script>` blocks. ## Order #275's region dispatch first, because it is the generic piece and unblocks four formats. Then the Vue package uses it for the script half and does the template half itself. ## Acceptance - On Zammad 7.0.2, symbols are extracted from `<script setup>`. - `find_callers` reaches a composable called from a `.vue` file. - Component references from templates bind to their files. - Phantom audit on a sample of binds. - Cold-index cost is measured.
Author
Member

Released in v0.35.0 (https://git.h-dv.de/h-dv/code-index/releases/tag/v0.35.0) as de.h-dv.vue 0.1.0, via PR #351.

What it indexes:

  • <script> and <script setup> blocks, through embedded regions.
  • From templates: component tags, handlers and interpolations.

Measured on Zammad 7.0.2: 525 .vue files went from 0 to 5,472 symbols, and resolved refs went up by 7,331.

Not yet: a template ref binding to a symbol in the same file's script. That needs a cross-language tier.

Released in v0.35.0 (https://git.h-dv.de/h-dv/code-index/releases/tag/v0.35.0) as de.h-dv.vue 0.1.0, via PR #351. **What it indexes:** - `<script>` and `<script setup>` blocks, through embedded regions. - From templates: component tags, handlers and interpolations. **Measured on Zammad 7.0.2:** 525 `.vue` files went from 0 to 5,472 symbols, and resolved refs went up by 7,331. **Not yet:** a template ref binding to a symbol in the same file's script. That needs a cross-language tier.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
h-dv/code-index#331
No description provided.