Rolldown plugin for Vue Single File Components (SFC)
This plugin extracts and processes <script> blocks from Vue SFCs, making them
available to the bundler as JavaScript/TypeScript modules.
Architecture
.vue file → load() hook → VueExtractor → Extract scripts → JavaScript/TypeScript → Rolldown
Why the load hook?
We use the load hook (not transform) because:
- Vue SFCs aren't valid JavaScript/TypeScript that Rolldown can parse
- We must intercept files before Rolldown's parser runs
- The
loadhook is designed for custom file formats - We return extracted JavaScript with the appropriate
ModuleType
Handling Multiple Scripts
Vue SFCs can have up to 2 script blocks:
- One regular
<script>block (Options API) - One
<script setup>block (Composition API)
When both exist, we combine them with <script setup> running first,
as per Vue's execution semantics.
Example Usage
use FobVuePlugin;
use Arc;
# async