Skip to main content

Crate fob_plugin_vue

Crate fob_plugin_vue 

Source
Expand description

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;

let plugin = Arc::new(FobVuePlugin::new());
// Add to your Rolldown bundler configuration

Structs§

FobVuePlugin
Rolldown plugin that extracts JavaScript/TypeScript from Vue SFCs