Vite Plugin for Vue Script Setup Extension
This package, `vite-plugin-vue-setup-extend`, enhances the `<script setup>` syntactic sugar in Vue Single File Components (SFCs). Its primary function is to allow developers to define additional attributes directly on the `<script setup>` tag, such as `name` and `inheritAttrs`, which are typically unavailable in the standard `<script setup>` syntax. This capability is particularly useful for debugging with Vue DevTools, enabling recursive components, or explicitly setting component names for clearer component hierarchies. The current stable version is 0.4.0, but it was last published over four years ago (January 2022). Due to its lack of recent updates, it is considered abandoned and may not be compatible with newer versions of Vue or Vite, which have undergone significant changes since its last release. Users should proceed with caution and be prepared for potential compatibility issues with modern tooling.
Common errors
-
Error [ERR_REQUIRE_ESM]: require() of ES Module ...vite-plugin-vue-setup-extend.js from ...vite.config.js not supported
cause Attempting to import the plugin using CommonJS `require()` syntax in a Vite configuration file that expects ESM.fixChange `const vueSetupExtend = require('vite-plugin-vue-setup-extend')` to `import vueSetupExtend from 'vite-plugin-vue-setup-extend'`. -
Internal server error: At least one <template> or <script> is required in a single file component.
cause This generic Vue/Vite error can sometimes occur if a plugin, especially an outdated one, interferes with SFC parsing or hot module replacement (HMR).fixVerify the plugin's compatibility with your current Vite and Vue versions. If using an older plugin like `vite-plugin-vue-setup-extend`, consider if it's causing conflicts and disabling it or searching for a maintained alternative. Clear your Node modules and `node_modules/.vite` cache.
Warnings
- breaking This package has not been updated in over four years (last publish January 2022). Significant breaking changes have occurred in Vite and `@vitejs/plugin-vue` since then, making this plugin potentially incompatible with newer project setups.
- gotcha Vite plugin ordering is crucial. Ensure `vite-plugin-vue-setup-extend` is placed *after* `@vitejs/plugin-vue` in your `plugins` array to ensure it correctly processes Vue SFCs.
- gotcha Vite configurations are typically ESM-only. Using CommonJS `require()` syntax in `vite.config.js` or `vite.config.ts` will lead to errors, especially for ESM-only packages.
Install
-
npm install vite-plugin-vue-setup-extend -
yarn add vite-plugin-vue-setup-extend -
pnpm add vite-plugin-vue-setup-extend
Imports
- vueSetupExtend
const vueSetupExtend = require('vite-plugin-vue-setup-extend')import vueSetupExtend from 'vite-plugin-vue-setup-extend'
- defineConfig
import { defineConfig } from 'vite' - vue
import vue from '@vitejs/plugin-vue'
Quickstart
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueSetupExtend from 'vite-plugin-vue-setup-extend';
export default defineConfig({
plugins: [
vue(),
vueSetupExtend()
],
// Other Vite configurations...
});