Lib mode format: es.min
See original GitHub issueClear and concise description of the problem
Currently when building in lib mode we do not minify the ES build because that would remove pure annotations and break treeshaking. However, this is assuming that the ES build is only used with bundlers. In the future, more users could be using ES builds over CDNs with native ES imports, so a minified ES build could be necessary for those cases.
Suggested solution
// vite config
build: {
lib: {
formats: ['es', 'es.min']
}
}
Alternative
lib: { minifyES: true }
Additional context
https://github.com/vuejs/petite-vue/pull/112
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that request the same feature to avoid creating a duplicate.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:14
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Build Options - Vite
Note the build.minify option does not minify whitespaces when using the 'es' format in lib mode, as it removes pure annotations and breaks...
Read more >Create a library using Vite lib mode - YouTube
Most of the tutorials out there are pretty much a basic HelloWorld, but did you know you can also create professional OSS libraries...
Read more >Custom date and time format strings | Microsoft Learn
Learn to use custom date and time format strings to convert DateTime or DateTimeOffset values into text representations, or to parse strings ...
Read more >Understand the different javascript modules formats
3 min read. When it comes to building your application, if you're like me you always ask yourself: which format should I use...
Read more >The Boost Format library - 1.54.0
A format object is constructed from a format-string, and is then given arguments through repeated calls to operator%. Each of those arguments ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t understand, is minifying just disabled entirely for
es
library output?I’ve tried for example this:
It doesn’t minify or mangle at all - I have no control of the terser options at all?
I can understand having sensible defaults, so you don’t accidentally break tree shaking - but blocking me from configuring terser entirely? And not even a warning - it just doesn’t work. Very confusing.
At this time,
minify: "esbuild"
gives a significantly smaller file, because it actually compresses and minifies - withminify: "terser"
it doesn’t minify at all. How is this setting useful?I was able to manually minify with
terser
after the fact, so it’s not that this isn’t possible.Would love to see this implemented!
Currently this is my workaround:
Add an extra
esm
format to lib entry (don’t mind the TS error):Then add this plugin to the build:
This will generate the ES amd ES minified variants.