Vite Plugin for Vue Facing Decorator HMR Fix

1.0.1 · active · verified Sun Apr 19

This Vite plugin addresses a known incompatibility between `vue-facing-decorator` and Vite's Hot Module Replacement (HMR) system when the `toNative()` method is omitted from Vue components. The `vue-facing-decorator` library typically requires calling `toNative()` on decorated components for HMR to function correctly, but this practice can severely degrade developer experience by breaking IDE features like auto-completion in environments such as WebStorm. This plugin, currently at version 1.0.1 (as of its initial release in 2024), transparently injects the necessary `toNative()` logic during the Vite build process, allowing developers to omit it from their source code, thereby preserving IDE functionality while maintaining HMR support. It offers a targeted solution for a specific development workflow challenge.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to integrate the plugin into your Vite configuration file to enable HMR for `vue-facing-decorator` components.

// vite.config.js or vite.config.ts
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueFacingDecoratorHmr from 'vite-plugin-vue-facing-decorator-hmr';

export default defineConfig({
  plugins: [
    vue(),
    vueFacingDecoratorHmr()
  ]
});

view raw JSON →