Automatically use package.json
's dependencies for rollupOptions.external
when in lib
mode
#10582
Shinigami92
started this conversation in
Ideas
Replies: 1 comment
-
In that case, I think we need to phase out UMD support in library mode by default too. It's not supported when using multiple entries anyway #10315 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I switched some of my projects from using
tsc
to build withvite
so I can benefit from a nice CLI output and bundlingcjs
,es(m)
anddts
While doing that I found out that I need to configure
build > rollupOptions > external
to contain thepackage.json
'sdependencies
so they don't get bundled inside thedist
's content.IMO this should be the default behavior so we don't need to explicitly configure that.
Changing this would result in a breaking change, so if we want that nice-to-have, it must be published in a new major version.
I can think of that if
build > lib > entry
is set to a value andbuild > rollupOptions > external
isundefined
, then use dependencies array as default value forexternal
.We will still have the possibility to change the behavior in our configs by overriding that default behavior by just configure
external
on demand.Some things I found while searching through already existing issues / discussions in Vite Repo:
rollup-plugin-node-externals
, but I don't want to install a plugin, because the goal is to reduce the config for default behavior.Off-Topic extra thought: Might it be possible to extract
library-mode
completely out of Vite's Core and just provide a plugin? 👀vitest
already somehow changed and opt-in to Vite'sdefineConfig
to provide the option propertytest
. Maybe we can add via the same way support forbuild > lib
🤔Edit: started with an implementation
Beta Was this translation helpful? Give feedback.
All reactions