Registry / web-framework / vue-runtime-helpers

vue-runtime-helpers

JSON →
library1.1.2jsnpmunverified

vue-runtime-helpers is a utility package that provides internal runtime helpers crucial for the compilation and rendering of Vue Single File Components (SFCs). These helpers are primarily consumed by Vue build tools such as `vue-loader` for Webpack, `@vitejs/plugin-vue` for Vite, and older tools like `rollup-plugin-vue`. Its core functionalities include `normalizeComponent`, which standardizes component options for the Vue runtime, and `createInjector`, used for injecting component-scoped styles. While the package itself, currently at version 1.1.2, has not seen active development since its last release seven years ago, its underlying concepts and the problems it solves (like component normalization and style injection) remain integral to the Vue ecosystem's build pipeline. It is not intended for direct consumption by most application developers but rather serves as low-level plumbing, with its essential logic now absorbed or re-implemented within actively maintained Vue tooling. It does not follow an independent release cadence.

npm install vue-runtime-helpers
INSTALL
IMPORT
SIG · VUE-RUNTIME-HELPER
V
vue-runtime-helpers
web-frameworkjavascriptv1.1.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

normalizeComponent
import { normalizeComponent } from 'vue-runtime-helpers';
const normalizeComponent = require('vue-runtime-helpers').normalizeComponent;
Primarily for tooling; not typically imported by application code. ESM-first, but older tooling might use CJS require.
createInjector
import { createInjector } from 'vue-runtime-helpers';
const createInjector = require('vue-runtime-helpers').createInjector;
Primarily for tooling; used to handle style injection. ESM-first.

This quickstart illustrates the conceptual roles of `normalizeComponent` and `createInjector` within the Vue build pipeline, showcasing how they process raw component options and styles from SFCs. It emphasizes that these are internal tooling functions, not for direct application use.

/* This example is conceptual and demonstrates the *purpose* of vue-runtime-helpers. In a real Vue project, these helpers are used internally by build tools (e.g., Vite, Vue CLI) to process Single File Components (SFCs) and are NOT typically imported or called directly by application developers. These functions normalize component options and inject styles behind the scenes. */ // Imagine these are internal exports from vue-runtime-helpers // In a real build environment, they would be imported by a plugin like @vitejs/plugin-vue import { normalizeComponent, createInjector } from 'vue-runtime-helpers'; // Correct import path for tooling // A raw component definition, as it might be parsed from a .vue file's <script> block. // This is an oversimplification; actual SFC compilation is more complex. const rawComponentOptions = { name: 'HelloWorld', props: { msg: String, }, data() { return { count: 0 }; }, methods: { increment() { this.count++; }, }, template: '<div><h1>{{ msg }}</h1><button @click="increment">Count: {{ count }}</button></div>', // Styles extracted from the <style> block of an SFC styles: ['h1 { color: #42b983; } button { background-color: #eee; border: 1px solid #ccc; padding: 5px 10px; cursor: pointer; }'] }; // 1. Conceptual usage of normalizeComponent: // This function takes raw component options and normalizes them into a format // that the Vue runtime expects. It handles various transformations and optimizations. // The parameters are simplified here; actual usage in tooling is more involved. const normalizedComponent = normalizeComponent( rawComponentOptions, () => { /* Render function would be compiled here */ }, [], // scopeId for scoped CSS false, // isSsr null, // shadowMode null, // createInjector (often passed recursively or handled externally) null, // i18n true, // isProd null // globals ); console.log('--- Conceptual normalizeComponent Output ---'); console.log('Normalized component exports (simplified):', normalizedComponent.exports); console.log('Component name:', normalizedComponent.exports.name); console.log('Component props:', normalizedComponent.exports.props); // 2. Conceptual usage of createInjector (for injecting styles): // This function typically returns an object with methods to add or remove styles. // Build tools use this to apply component-specific styles to the DOM or Shadow DOM. const styleInjector = createInjector({}); // Configuration might be passed here console.log('\n--- Conceptual createInjector Output ---'); const stylesToInject = rawComponentOptions.styles; if (stylesToInject && stylesToInject.length > 0) { console.log('Styles prepared for injection:', stylesToInject); // In a real scenario, styleInjector would manage the <style> tags. // For instance, it might append them to the document head or a shadow root, // ensuring they are correctly scoped if needed. console.log('// Style injector would apply these styles to the document or shadow DOM.'); } // To reiterate, typical Vue application development does not involve these helpers directly. // You would write a .vue file, and your build setup (Vite, Vue CLI) would use these internal // utilities to turn your SFC into runnable JavaScript and CSS. // Example of how an end-user writes a component: /* <template> <div> <h1>{{ msg }}</h1> <button @click="increment">Count: {{ count }}</button> </div> </template> <script setup lang="ts"> import { ref } from 'vue'; defineProps<{ msg: string }>(); const count = ref(0); const increment = () => { count.value++; }; </script> <style scoped> h1 { color: #42b983; } button { background-color: #eee; border: 1px solid #ccc; padding: 5px 10px; cursor: pointer; } </style> */
Debug
Known issues
breakingWhen upgrading `rollup-plugin-vue` to version `5.1.2` or later, direct internal imports of `vue-runtime-helpers` were introduced, potentially causing build failures if `rollup-plugin-commonjs` was not correctly configured.
fix
Ensure `rollup-plugin-commonjs` is installed and listed in your `rollup.config.js` plugins array *before* `rollup-plugin-vue`. This ensures CommonJS modules (which `vue-runtime-helpers` might be treated as, or which it depended on in older contexts) are correctly processed.
affects: rollup-plugin-vue >= 5.1.2
gotchaThis package (`vue-runtime-helpers`) is an internal dependency of Vue's build tooling (e.g., `vue-loader`, `@vitejs/plugin-vue`). Its APIs are not part of Vue's public contract and are not intended for direct use by application developers. Directly importing or using these helpers can lead to unpredictable behavior and is not supported.
fix
Rely on official Vue build tools (Vite, Vue CLI) to handle the compilation and runtime injection of SFCs. Custom usage of this package is reserved for advanced tooling authors only.
affects: >=1.0.0
deprecatedThe `vue-runtime-helpers` package itself has been effectively unmaintained since its last release over seven years ago. While its underlying functionality is critical, its direct development as a standalone package has ceased. Functionality is now integrated or re-implemented within actively maintained build tools.
fix
Be aware that new features, bug fixes, or security patches will come from updates to your consuming Vue build tools (e.g., `@vitejs/plugin-vue`, `vue-loader`), not from this package directly. It remains stable as a plumbing piece but lacks independent evolution.
affects: >=1.0.0
Errors
Common errors & fixes
Uncaught TypeError: Failed to resolve module specifier "vue-runtime-helpers"
This error typically occurs in Rollup builds where `rollup-plugin-vue` (from v5.1.2 onwards) attempts to import `vue-runtime-helpers` as an ES module, but the CommonJS plugin required for proper resolution is either missing or incorrectly ordered.
fix
Add or ensure `rollup-plugin-commonjs` is present in your `rollup.config.js` and placed *before* `rollup-plugin-vue`. Example: `plugins: [commonjs(), vue()]`.
Webpack compilation failed: Module not found: Error: Can't resolve 'vue-runtime-helpers' in ...
Similar to Rollup issues, this indicates that Webpack or its associated loaders (`vue-loader`) cannot locate the `vue-runtime-helpers` module, often due to an incorrect configuration or incompatible versions of Vue-related packages.
fix
Verify that all Vue-related dependencies (e.g., `vue`, `vue-loader`, `@vue/compiler-sfc`) are compatible and up-to-date. Ensure your Webpack configuration correctly handles module resolution for Node.js packages. If using `vue-loader`, ensure it's correctly configured in your Webpack rules.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
vue-runtime-helpers — npm install vue-runtime-helpers · libregistry