After setting up a vue2 library using vue-cli, I have numerous components included in the index.ts file as shown below:
import MyComponent1 from './components/MyComponent1.vue';
import MyComponent2 from './components/MyComponent2.vue';
export {MyComponent1, MyComponent2}
export default{
install(Vue:any){
Vue.component('MyComponent1', MyComponent);
Vue.component('MyComponent2', MyComponent);
}
}
The index.ts
allows developers to incorporate the library by utilizing Vue.use(MyLib)
or importing specific components manually like so:
import {MyComponent1} from 'my-lib';
import {Vue, Component} from 'vue-property-decorator';
@Component({
components:{
MyComponent1
}
})
export default class Test extends Vue{}
Now, my question is whether registering all components in the install method and using Vue.use(MyLib)
has any impact on performance compared to having developers manually bind the required components?
In addition, when it comes to custom components, I face the same decision of either registering all components in main.ts
or importing the component only where it's necessary.
What approach would you recommend in this scenario?