Publishing and Typing Vue Plugins
Package structure, TypeScript augmentation of ComponentCustomProperties, npm distribution.
Packaging a Plugin for npm
To share a Vue plugin you publish it as an npm package. The package must declare the right dependencies, ship a proper build, include TypeScript types, and be published correctly. This lesson covers each step.
peerDependencies for Vue
List Vue as a peerDependency, not a regular dependency. This ensures the host app provides Vue, avoiding two copies of Vue in one bundle (which breaks reactivity).
{
"name": "vue-toast-kit",
"peerDependencies": {
"vue": "^3.4.0"
},
"devDependencies": {
"vue": "^3.4.0"
}
}All lessons in this course
- Plugin Architecture and app.use()
- Global Properties and provide/inject in Plugins
- Notification and Toast Plugin Example
- Publishing and Typing Vue Plugins