Bundle library with externalized dependencies and Vite? #16123
florianmartens
started this conversation in
General
Replies: 1 comment 1 reply
-
Did you check this discussion? It shows a few ideas to put I don't know either why Vite doesn't do this default, but considering it's rather simple to just copy |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to publish a browser focused
type:module
(esm) library to npm. I'm using vite's library mode with the following config:Ideally, I don't even want to bundle into one big file (but that's a different topic -
preserveModules is
not the solution here).My understanding is that since my dependencies are clearly stated in
package.json
I do not need to bundle them. However, by default vite bundles everything and the resulting.mjs
file contains no import statements.While this is not a big deal, it seems inefficient. Consumers need to install all dependencies anyway - why have the code twice?
How can I change my config so that external dependencies are imported rather than bundled? This seems to be vite's default and I can't quite understand why that is.
Things I've tried
Use external rollout option as a function external: (id: string) => { return /^node_modules/.test(id)} as well as with values
["@uppy/core"]
Beta Was this translation helpful? Give feedback.
All reactions