Closed tiberiuzuld closed 9 months ago
Doesn't it work with import autoTable from 'jspdf-autotable'
? it works fine with me.
It works when I use Ng serve but as soon as I make the production build it is no longer working. I saw some relevant comments on this issue that the other PR was also mentioned:
https://github.com/angular/angular-cli/issues/26888
From my debugging the esbuild just imports the cjs file and not the mjs one, and when it makes the final bundle, at runtime I just get an error with not a function for autotable.
I didn't use dynamic import and didn't test import from jspdf-autotable/es, but I saw in the issue above those are not working.
I tested it myself, it works fine with static imports, what problem are you having with static import in production?
Added a "module" field now in the new v4 branch, but kept the other things as is. Although it is non standard and should not be needed it seems that most other libraries are doing this. Also tried creating a new angular project with v4 branch which worked great.
Hello,
I made changes to package.json to make it compatible with Angular 17 and the new esbuild/vite bundler that the angular-cli is using. I tried multiple configurations, but this last one is what also jsPDF is using and is working well with ESM modules.
https://github.com/parallax/jsPDF/blob/master/package.json