-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to minify es
format in library mode
#5167
Comments
es
format in library modees
format in library mode
ref 06d86e4 according to change its currently not possible to enable minify for es output which make sense as people potentially could enable something breaking tree shaking |
Yes, this recent change prevents |
Agree. For example: the vite v2.6.2 building for production... vite v2.5.10 building for production... |
You can use a CDN like jsDelivr, which allows auto-minification by adding That said, CDNs are an anti-pattern these days, due to HTTP cache partitioning. You end up downloading more data than if you bundled, because less byte compression can be done. Additionally, minifying your library is hostile to NPM users, since it can make debugging more difficult, and it prohibits the use of tools like patch-package. |
I suggest adding options to allow minimization when using esbuild to package, sometimes not just build libraries into npm, and sometimes debugging information is not needed. |
I think there are legitimate uses for cdn libraries, like if you want to create a package that is to be used outside of a node framework. Sure the caching might not work between websites but that's not the main feature of a CDN based javascript library, the main feature is that it is accessible via the web. What is the use case for library mode? Because this combined with not being able to inject css styles makes me think that there is a very specific use case in mode. If it's specifically creating pure javascript modules for npm and usage in the node ecosystem that's perfectly acceptable and maybe the answer is that it's specified in the vite documentation and people who need further functionality either create something else rollup or webpack based. Or maybe even library mode should be it's own vite like offshoot package that supports a breadth of use cases. Tsdx exists but it hasn't been updated in a year. |
Clear and concise description of the problem
In Vite v2.6.0, the
es
format is no longer minified in library mode.I understand that this is necessary for proper tree-shaking.
However, libraries that cannot benefit from tree-shaking (e.g. a single exported Vue component) are still limited to un-minified files.
Suggested solution
Add an explicit option to minify
es
format in library mode.Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: