Search code examples
reactjspolymerweb-componentlit-elementlit-html

bundle size: Is it possible to set lit-element as a peer dependency?


I noticed there is much code added to the bundled js for a simple lit-element based web component, and react components set react as a peer dependency so only one react runtime is bundled, since web components are framework-agnostic, if i used lit-element in my project and i'm using another external WC built with lit-element, will lit-element be bundled twice?


Solution

  • It depends on your bundler, but in most cases the bundler will detect that all those WCs have the same dependency and bundle it only once.

    (Of course, that only happens if you import the other documents in source format, using npm, as it's the good practice, and not in bundled/dist format)