wuruoyun / vue-component-lib-starter

A bare-bones example of creating your own Vue component library.
313 stars 59 forks source link

Question regarding to component registration #5

Closed nachodd closed 2 years ago

nachodd commented 4 years ago

This question isn't an issue referred to this particular repo. I mean, it's more a general question. Feel free to close this issue if you thinks it's inappropriate. Suppose you have 2 components: CompA and CompB. These components can be used separately. However, internally, CompA uses CompB. Something like:

<template>
  <div> <comp-b /> </div>
</template>
<script>
import CompB from "../CompB/CompB"

export default {
  components: { CompB }
}
</script>

This means that when you ship the library, CompA has the code of CompB internally and also the CompB component code is shipped separately. Am I right with this suppositions? In case it's ok, how do you manage to ship the code of component B only once? I mean, like registering all the components globally, so when in CompA uses CompB, it is already registered (and this would also implies smaller bundle size).

Thanks in advance! And BTW, great project!

wuruoyun commented 2 years ago

Importing CompB into CompA does not lead to duplication of CompB. The bundler will ensure only one copy of CompB is in the build artifact.