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
muslnode 18–226 runs
build_error
glibcnode 18–226 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.fixEnsure `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.fixRely 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.fixBe 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.
fixAdd 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.
fixVerify 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.
Audit
Dependencies
No dependency data recorded yet.