0

I am developing multiple websites in angular with similar content and have therefore decided to extract common components and functionality into a separate angular 13 library.

I have previously successfully used the JSZip library in one of these websites, but have then decided to move this implementation into the library.

Even though the code did not change, it stopped working.

If I try to call the method that uses JSZip from the library it now throws the following TypeError

ERROR TypeError: (jszip__WEBPACK_IMPORTED_MODULE_1___namespace_cache || jszip__WEBPACK_IMPORTED_MODULE_1___namespace_cache) is not a constructor

When I try to create a new JSZip instance like this

const zip = new JSZip();

Based on this question the problem might be in how I import the library. I do it like this

import * as JSZip from 'jszip';

And according to this question that is how it should be done.

Both the library and the website projects build correctly but throw this error at runtime, so I don't think it is a problem with dependencies.

Has someone encountered a similar problem before? What should I try to solve this?

Minop
  • 386
  • 4
  • 13
  • I have same problem, did you find the solution? – Lupe Jul 25 '22 at 10:49
  • @Lupe sadly not yet. Temporarily I have decided not to zip the files but that proved to be both anoying and bad, since the browser refused to let me download ~30 files at once and let just the first ~10 trough. I am currently looking into this again, but I am most likely going to look for alternatives to jszip – Minop Jul 25 '22 at 15:29
  • @Lupe I have thrown jszip out and replaced it with client-zip advertised by its author here https://stackoverflow.com/a/63738976/15893674. This works without any issues. It is not a complete substitue of jszip however, depending on what you want to use it for. – Minop Jul 25 '22 at 15:47

0 Answers0