npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@vuebro/loader-sfc

v2.4.4

Published

A lightweight library that enables loading Vue 3 Single File Components (.vue files) directly in the browser at runtime without requiring a build step. Supports TypeScript and JSX transformations for dynamic component loading.

Readme

Vue SFC Loader

Vue3 Single File Component (SFC) loader. Load .vue files directly from your browser without any build step.

Features

  • 🚀 Load Vue 3 SFCs directly in the browser at runtime
  • ⚡ No build step required - perfect for dynamic component loading
  • 🛠️ Supports TypeScript and JSX
  • 📦 Lightweight and efficient
  • 🔧 Compatible with Vue's defineAsyncComponent

Installation

Install @vuebro/loader-sfc with npm:

npm install @vuebro/loader-sfc

Or with yarn:

yarn add @vuebro/loader-sfc

Or with pnpm:

pnpm add @vuebro/loader-sfc

Usage

Basic Usage

To load .vue files dynamically at runtime just use the loadModule function:

<script setup>
import { defineAsyncComponent } from "vue";
import loadModule from "@vuebro/loader-sfc";

const AdminPage = defineAsyncComponent(async () =>
  loadModule(await (await fetch("./components/AdminPageComponent.vue")).text()),
);
</script>

<template>
  <AdminPage />
</template>

Advanced Usage with Configuration

You can pass configuration options to customize the compilation process:

import { defineAsyncComponent } from "vue";
import loadModule from "@vuebro/loader-sfc";

const MyComponent = defineAsyncComponent(async () =>
  loadModule(await (await fetch("./components/MyComponent.vue")).text(), {
    scriptOptions: {
      templateOptions: {
        compilerOptions: {
          expressionPlugins: ["typescript"], // Additional Babel plugins
        },
      },
    },
    parseOptions: {
      // Options for the SFC parser
    },
    styleOptions: {
      // Options for style compilation
    },
  }),
);

API

loadModule(filename: string, options?: LoadModuleOptions)

Loads and compiles a Vue SFC file at runtime.

Parameters

  • filename (string): Path to the .vue file to load
  • options (LoadModuleOptions, optional): Configuration options for compilation

Options

  • scriptOptions: Options for script compilation
    • templateOptions: Options for template compilation
      • compilerOptions: Vue template compiler options
        • expressionPlugins: Additional Babel parser plugins (e.g., 'typescript', 'jsx')
  • parseOptions: Options for SFC parsing
  • styleOptions: Options for style compilation (e.g., scss, less)

Requirements

  • Vue 3.x
  • Modern browser that supports ES modules and dynamic imports

Performance Considerations

  • The first load of a component will be slower as it needs to fetch and compile the SFC
  • Subsequent loads of the same component will be faster due to browser caching
  • Styles are injected into the document once per component and cached by a hash of the filename
  • Consider using this loader for truly dynamic components, not for all components in your application

Building and Development

To build the project locally:

npm run build

To lint the code:

npm run lint

Examples

A simple example of using @vuebro/loader-sfc in a template Vue 3 + TypeScript + Vite application for dynamic loading and compilation of an SFC module during application runtime in the browser can be found in the repository: loader-sfc-example

License

This project is licensed under the AGPL-3.0-only License.