Registry / web-framework / piral-vue

piral-vue

JSON →
library1.10.3jsnpmunverified

Piral-vue is a plugin designed for integrating Vue 2 components within a Piral microfrontend application. It acts as a converter, allowing developers to seamlessly register and render existing or new Vue 2 components as pilets (microfrontends) or parts of pilets. The package is an integral part of the larger Piral ecosystem, which focuses on building scalable and maintainable web portals using a microfrontend architecture, facilitating the combination of different frontend frameworks. As of version 1.10.3, it continues to receive regular updates, typically with minor point releases addressing bug fixes, dependency updates, and improvements within the broader Piral framework, ensuring compatibility and stability within the Piral ecosystem. Its key differentiator is its explicit support for Vue 2, enabling the reuse of established Vue 2 codebases within a modern microfrontend shell. This provides a clear migration path or coexistence strategy for organizations with significant investments in Vue 2 applications, allowing them to incrementally modernize or integrate without forcing an immediate, large-scale upgrade to Vue 3. The plugin handles the necessary lifecycle management and integration points to make Vue 2 components behave as native Piral extensions or pages.

npm install piral-vue
INSTALL
IMPORT
SIG · PIRAL-VUE
P
piral-vue
web-frameworkjavascriptv1.10.3
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.

createVueApi
import { createVueApi } from 'piral-vue';
const createVueApi = require('piral-vue');
This function is used in your Piral instance's `createInstance` plugins array to enable Vue 2 support for pilets. Piral primarily uses ESM.
PiletVueApi
import type { PiletVueApi } from 'piral-vue';
import { PiletVueApi } from 'piral-vue';
This TypeScript interface extends the standard PiletApi with Vue 2-specific functions like `fromVue`. Use `import type` for type-only imports to avoid bundling type definitions.
VueComponent
import type { VueComponent } from 'piral-vue';
import { VueComponent } from 'vue';
Refers to the Piral-specific wrapper type for Vue components, ensuring correct integration into the microfrontend context. This is not the raw Vue component constructor directly from the `vue` package.

Demonstrates how a Pilet uses `piral-vue` to define and register a Vue 2 component as both a Piral extension and a full page. This quickstart assumes `piral-vue` has been configured in the main Piral instance.

import type { PiletApi } from 'piral'; import { defineComponent } from 'vue'; // Ensure vue@2 is a dependency in your pilet // Extend PiletApi with piral-vue specific functions provided by the Piral instance. // This assumes 'piral-vue' has been configured in the Piral instance's createInstance call. interface MyPiletApi extends PiletApi { fromVue(component: any): any; // The actual type is VueComponentConverter<VueComponent> } // Define a simple Vue 2 component const MyVueComponent = defineComponent({ name: 'MyVueComponent', props: { message: { type: String, default: 'Hello from Vue 2 Pilet!', }, }, template: ` <div style="padding: 10px; border: 1px solid #42b983; margin: 10px; border-radius: 5px;"> <h3>{{ message }}</h3> <p>This is a Vue 2 component served by a Pilet.</p> <button @click="increment">Count: {{ count }}</button> </div> `, data() { return { count: 0, }; }, methods: { increment() { this.count++; }, }, }); /** * The setup function for the Pilet. * It registers a Vue component as an extension and a page within the Piral application. */ export function setup(app: MyPiletApi) { // Register the Vue component as an extension. // It can be embedded anywhere in the Piral app using <Extension name="vue-pilet-card" />. app.registerExtension('vue-pilet-card', app.fromVue(MyVueComponent)); // Register the Vue component as a full page, accessible via a route. app.registerPage('/vue-pilet-page', app.fromVue(MyVueComponent)); console.log('Vue 2 Pilet: MyVueComponent registered as extension "vue-pilet-card" and page "/vue-pilet-page".'); }
Debug
Known issues
breakingThis `piral-vue` package is strictly designed for Vue 2.x applications. Attempting to use it with Vue 3.x or newer will result in runtime errors due to significant API changes between Vue major versions.
fix
For Vue 3 projects, use the dedicated `piral-vue3` package. Ensure your Pilet's `package.json` specifies `vue@^2.x` and that your Piral instance is consistently configured for Vue 2.
affects: >=1.0.0
gotchaVue components registered through `piral-vue` operate within isolated contexts. Relying on global Vue instances or directly modifying globally shared state (e.g., a single Vuex store) across multiple pilets can lead to unpredictable behavior, state collisions, or memory leaks.
fix
Utilize Piral's built-in event bus (`app.on(...)`, `app.emit(...)`) or Piral's global state management (`app.readState(...)`, `app.updateState(...)`) for communication and state sharing between pilets. Each Vue Pilet should manage its own local Vuex store if needed.
affects: >=1.0.0
gotchaWhile Vue components often use scoped CSS, integration into a microfrontend shell can still lead to styling conflicts. Global styles from the Piral shell or other pilets might unintentionally affect Vue 2 components, and vice-versa.
fix
Employ robust CSS methodologies like BEM within your Vue components, use CSS Modules, or leverage Piral's built-in CSS isolation features (if available). Regularly review generated CSS to prevent unintended style bleed, and consider using shadow DOM for stricter encapsulation.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'extend')
This error typically occurs when a Vue 3 component or API is mistakenly used within a Vue 2 context (or vice versa), or when Vue 2 is not properly loaded/available. The `extend` method is specific to Vue 2's component definition.
fix
Verify that `vue@^2.x` is correctly installed in your pilet's `package.json` and that your component definitions strictly adhere to the Vue 2 API. If you intend to use Vue 3, switch to `piral-vue3` instead of `piral-vue`.
Failed to mount component: template or render function not defined.
This common Vue 2 error indicates that the component object passed to `app.fromVue()` is missing either a `template` string or a `render` function, both of which are essential for Vue to render the component.
fix
Ensure your Vue 2 component definition includes either a `template` property (as a string) or a `render` function. Double-check for any syntax errors in your component's options object or if a build step (like a Vue loader) failed to process the component correctly.
Upgrade
Version history
1.10.3latest on npm
Audit
Dependencies
vuerequiredPeer dependency for Vue 2 component rendering. Must be Vue 2.x.
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
piral-vue — npm install piral-vue · libregistry