Skip to content

Why should we bundle dependencies when using lib mode? #18744

Answered by hi-ogawa
ianzone asked this question in Q&A
Discussion options

You must be logged in to vote

That might not be intuitive, but that's somewhat known convention and it's required to set rollupOptions.external manually. See the doc saying https://vite.dev/guide/build.html#library-mode

Make sure to also externalize any dependencies that you do not want to bundle into your library, e.g. vue or react:

In rollup, people commonly reuse package.json's dependencies as external such as

...Object.keys(pkg.dependencies),
...Object.keys(pkg.peerDependencies),

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ianzone
Comment options

Answer selected by ianzone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants