Problem
The unplugin transform currently only processes .ts and .js files. Composables defined inside <script setup> blocks of .vue files are not instrumented.
// unplugin.ts — current filter
if (!id.endsWith('.ts') && !id.endsWith('.js')) return
This means many real-world projects where composables live in .vue files (e.g. useLocalState defined inline) are partially tracked.
Solution
Use @vue/compiler-sfc to parse the <script> / <script setup> block, extract the JS/TS source, run transformComposable on it, then stitch the result back.
Implementation sketch
import { parse } from '@vue/compiler-sfc'
if (id.endsWith('.vue')) {
const { descriptor } = parse(code)
const script = descriptor.scriptSetup ?? descriptor.script
if (!script) return null
const result = transformComposable(script.content, id)
if (!result) return null
// replace script block content with result.code + inject map
}
Acceptance criteria
Problem
The unplugin transform currently only processes
.tsand.jsfiles. Composables defined inside<script setup>blocks of.vuefiles are not instrumented.This means many real-world projects where composables live in
.vuefiles (e.g.useLocalStatedefined inline) are partially tracked.Solution
Use
@vue/compiler-sfcto parse the<script>/<script setup>block, extract the JS/TS source, runtransformComposableon it, then stitch the result back.Implementation sketch
Acceptance criteria
<script setup>are tracked.ts/.jstests still pass.vuetransform