@skaldapp/loader-sfc
| Install | |
|---|---|
npm install @skaldapp/loader-sfc |
|
| Latest Version: | 2.4.80 |
| License: | AGPL-3.0-only |
| Last Updated: | Oct 21, 2026 |
| Links: | npm |
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 @skaldapp/loader-sfc with npm:
npm install @skaldapp/loader-sfc
Or with yarn:
yarn add @skaldapp/loader-sfc
Or with pnpm:
pnpm add @skaldapp/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 "@skaldapp/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 "@skaldapp/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 loadoptions(LoadModuleOptions, optional): Configuration options for compilation
Options
scriptOptions: Options for script compilationtemplateOptions: Options for template compilationcompilerOptions: Vue template compiler optionsexpressionPlugins: Additional Babel parser plugins (e.g., 'typescript', 'jsx')
parseOptions: Options for SFC parsingstyleOptions: 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 @skaldapp/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.
Related Packages
Version History
| Version | Released | License |
|---|---|---|
| 2.4.80 | AGPL-3.0-only | |
| 2.4.79 | AGPL-3.0-only | |
| 2.4.78 | AGPL-3.0-only | |
| 2.4.77 | AGPL-3.0-only | |
| 2.4.76 | AGPL-3.0-only | |
| 2.4.75 | AGPL-3.0-only | |
| 2.4.74 | AGPL-3.0-only | |
| 2.4.73 | AGPL-3.0-only | |
| 2.4.72 | AGPL-3.0-only | |
| 2.4.71 | AGPL-3.0-only | |
| 2.4.70 | AGPL-3.0-only | |
| 2.4.69 | AGPL-3.0-only | |
| 2.4.68 | AGPL-3.0-only | |
| 2.4.67 | AGPL-3.0-only | |
| 2.4.66 | AGPL-3.0-only | |
| 2.4.65 | AGPL-3.0-only | |
| 2.4.64 | AGPL-3.0-only | |
| 2.4.63 | AGPL-3.0-only | |
| 2.4.62 | AGPL-3.0-only | |
| 2.4.61 | AGPL-3.0-only | |
| 2.4.60 | AGPL-3.0-only | |
| 2.4.59 | AGPL-3.0-only | |
| 2.4.58 | AGPL-3.0-only | |
| 2.4.57 | AGPL-3.0-only | |
| 2.4.56 | AGPL-3.0-only | |
| 2.4.55 | AGPL-3.0-only | |
| 2.4.54 | AGPL-3.0-only | |
| 2.4.53 | AGPL-3.0-only | |
| 2.4.52 | AGPL-3.0-only | |
| 2.4.51 | AGPL-3.0-only |
Showing the latest 30 of 71. See every release on npm