generateAsync对20个图片进行打包压缩时,该方法没有执行,且没有报错
same issue here on 3.5.0
I also had generateAsync die silently on me.
We're using Webpack 5.9.0 and had to downgrade JSZip to 3.2.0 to get it working.
I also had generateAsync die silently on me.
We're using Webpack 5.9.0 and had to downgrade JSZip to 3.2.0 to get it working.
you use 3.2.0 version fixed the problem?
same issue here on 3.5.0
这个库是对图片大小有限制吗
you use 3.2.0 version fixed the problem?
Yup using 3.2.0 fixed the issue for me
Had the same issue. async won't resolve using the 3.5.0 version from npm. Fixed with 3.2.0.
I've been looking into this. 3.5.0 does work, but you have to change your imports to use jszip/dist/jszip.js (or min.js). However, TypeScript will complain as the type definitions aren't mapped there.
I have a feeling it's because of https://github.com/Stuk/jszip/commit/617e3ce439c1a0c694c2cb0a04f4a7578d94291f causing Webpack 5 to get something wrong in module resolution.
Update: Found a fix, I'll send a PR.
I've been looking into exactly why Webpack is hanging silently. One thing I noticed is that in Webpack 5, since it doesn't include polyfills and globals by default, people have to use the ProvidePlugin for globals like Buffer. However, JSZip uses the existence of Buffer for NodeJS support.
https://github.com/Stuk/jszip/blob/25d401e104926fef8528d670ecfe53f14e77a297/lib/support.js#L7
This was likely already an issue before Webpack 5. The dist build removes Buffer using Browserify which is why it works. But in Webpack 5, it fails to resolve browser in the package.json and falls back to main (which is the fix #742 provides).
There's likely a switch somewhere that switches to a NodeJS stream that never emits events in a browser, causing a silent failure from this hanging promise.
Anyways, that's why it hangs without an error. Browsers should use the dist build (#742).
Unfortunately my time is very limited at the moment so haven't been able to confirm this fix. However, I've published #742 as version 3.6.0-0 and if someone confirm that this fixes the issue for them I'd really appreciate it.
@Stuk can confirm it works now, was hanging before for me as well. Thanks!
@MichaelFedora thanks for checking! Fix published in 3.6.0
Most helpful comment
same issue here on 3.5.0