matfish2 / vue-stripe

Vue.js 2 Stripe checkout component
https://www.npmjs.com/package/vue-stripe
MIT License
58 stars 18 forks source link

Initialization requires including all of Vue #4

Closed gstjohn closed 7 years ago

gstjohn commented 7 years ago

In working with this projects, I found that it requires all of Vue for the event bus and to register the component. That's obviously not very ideal since it often means having the main Vue in a project as well as Vue for vue-stripe. This makes the file larger and ultimately introduces bloat.

My recommendation would be to get rid of the Bus (https://github.com/matfish2/vue-stripe/issues/1#issuecomment-270204702) and to not implement the actual injections of the Vue component (Vue.component('stripe-checkout', StripeCheckout)). This is the method many other open source Vue components are being built.

Additionally, it would likely be rare that vue-stripe needs to be a global component so using Vue.use() seems like an over-step. Instead, using the component would look like this:

import VueStripe from 'vue-stripe';

new Vue({
    component: [VueStripe],
    ...
});

If it needs to be global it can be done this way, but it doesn't have to be. More flexibility, smaller package size, no more need for Vue dependency.

I'll be happy to do this if you will merge a PR.

Thanks!

matfish2 commented 7 years ago