heic-to
heic-to copied to clipboard
Optimize package size – Reduce heic-to bundle size
Description: The heic-to package is quite large, currently around 9.4MB (gzipped: 888.2KB). This significantly increases build sizes, especially for frontend projects.
Request:
- Consider optimizing dependencies and reducing the bundle size.
- Provide a lightweight version for environments where size is a concern.
Why it matters:
- Large package size impacts performance in frontend applications.
- Many alternative HEIC-to-JPEG converters exist with smaller footprints.
Would love to know if there are any plans for optimization. Thanks for your work! 🚀
Hi @dzmitry-karelin , thanks for concern about the performance.
I think most people is using it with a JS builder which can will simply minify it to about 2MB.
The core lib(libheif.js(It's about 2MB)) heic-to relies on is compiled from libheif. I did some research on this topic, and it seems we don't have much thing to do about this to make it less than 2MB.
And I also have a heic-to.min.js release with this package. For circumstance like with CDN script, we can direct use the minified version with something like https://cdn.jsdelivr.net/npm/[email protected]/dist/heic-to.min.js
Maybe I should set heic-to.min.js as the default main point? I see some libs like dayjs is using min version, but some lib are not. I'm not sure what's the best practice for this. Any suggestions?
We are now using webpack alias to heic-to.min.js as a workaround. So I guess It would be just a little better to have heic-to.min.js as the default main point. Thanks for your job a lot!
We are facing also this issue in our Angular application. We replaced heic2any by heic-to and now we see a much increased bundle size.
Bundle size with heic2any:
Warning: bundle initial exceeded maximum budget. Budget 2.00 MB was not met by 1.13 MB with a total of 3.13 MB.
Bundle size with heic-to:
Warning: bundle initial exceeded maximum budget. Budget 2.00 MB was not met by 9.22 MB with a total of 11.22 MB.
Error: bundle initial exceeded maximum budget. Budget 5.00 MB was not met by 6.22 MB with a total of 11.22 MB.
This is an increase about 8,09 MB.
As a workaround we lazy load heic-to, so the lib is loading when the first HEIC image should be converted.
type HeicToType = typeof import('heic-to');
private getHeicToLib(): Promise<HeicToType> {
if (!this.heicToLib) {
this.heicToLib = import('heic-to');
}
return this.heicToLib;
}
await convertHeicToJpeg(file, this.getHeicToLib());
@dzmitry-karelin @BuZZ-dEE Sorry for the late response. I just bumped a new version 1.1.11 to minify the exports from 8MB to 2MB.
Please have a test.
@hoppergee it is smaller now. 🙂
@hoppergee I think this issue could be closed.