Vue 3 `<script setup>` Name & Attrs Extension
vite-plugin-vue-setup-extend-plus is a Vite plugin designed to enhance the Vue 3 `<script setup>` syntactic sugar within Single File Components (SFCs). It specifically introduces support for defining the `name` and `inheritAttrs` attributes directly on the `<script setup>` tag, a capability not natively available in Vue 3's initial `<script setup>` implementation. This allows for easier component introspection and finer control over attribute inheritance for components utilizing the composition API. The package is currently at version 0.1.0 and appears to have had a single release. It builds upon `vite-plugin-vue-setup-extend` but explicitly indicates that "iterative updates are made in unplugin-vue-setup-extend-plus during the later period," suggesting it has been superseded by its `unplugin` counterpart for ongoing development and maintenance. Its primary function is a targeted code transformation during the Vite build process to enable these additional attributes.
Common errors
-
Error: Cannot find module 'vite-plugin-vue-setup-extend-plus'
cause The package might not be correctly installed or is missing from `devDependencies`.fixRun `npm install vite-plugin-vue-setup-extend-plus -D` or `yarn add vite-plugin-vue-setup-extend-plus -D` to install it. -
TypeError: vueSetupExtend is not a function
cause Incorrect import statement; `vite-plugin-vue-setup-extend-plus` is a default export, but it might be imported as a named export.fixEnsure the import is `import vueSetupExtend from 'vite-plugin-vue-setup-extend-plus'` in your `vite.config.ts`.
Warnings
- deprecated This package is explicitly deprecated in its README, which states: "Iterative updates are made in unplugin-vue-setup-extend-plus during the later period." Users should migrate to `unplugin-vue-setup-extend-plus` for continued maintenance and new features.
- gotcha The package has only a single published version (0.1.0) and is no longer actively maintained. This means it will not receive bug fixes, security updates, or support for newer Vue/Vite versions.
Install
-
npm install vite-plugin-vue-setup-extend-plus -
yarn add vite-plugin-vue-setup-extend-plus -
pnpm add vite-plugin-vue-setup-extend-plus
Imports
- vueSetupExtend
const vueSetupExtend = require('vite-plugin-vue-setup-extend-plus')import vueSetupExtend from 'vite-plugin-vue-setup-extend-plus'
- defineConfig
import defineConfig from 'vite'
import { defineConfig } from 'vite' - vue
import { vue } from '@vitejs/plugin-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-plus'
export default defineConfig({
plugins: [
vue(),
vueSetupExtend()
],
})
// In your Vue SFC (e.g., src/App.vue):
// <template>
// <div>hello world {{ message }}</div>
// </template>
// <script lang="ts" setup name="App" inheritAttrs="false">
// const message = 'from App component'
// </script>