fob-plugin-vue 0.2.1

Rolldown bundler plugin for Vue - extract and process script blocks from Vue SFCs
Documentation

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 load hook 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 fob_plugin_vue::FobVuePlugin;
use std::sync::Arc;

# async fn example() -> Result<(), Box<dyn std::error::Error>> {
let plugin = Arc::new(FobVuePlugin::new());
// Add to your Rolldown bundler configuration
# Ok(())
# }