bpampuch / pdfmake

Client/server side PDF printing in pure JavaScript
http://pdfmake.org
Other
11.4k stars 2.02k forks source link

pdfmake error in Vite + React #2718

Open yeshua-aguilar opened 1 month ago

yeshua-aguilar commented 1 month ago

there is a bug with the pdfmake and vfs_fonts dependency. And it is that at the time of compiling in Vite to pass it to production, there is an error that detects that it does not export an object pdfMake. Since Vite copies it into ES modules, it does not detect it.

The problems with pdfmake and vfs_fonts, it is likely that the error is related to the fact that I am using libraries that are written as CommonJS modules, while Vite expects ES modules.

Vite has built-in support for CommonJS modules, but there may be problems with certain libraries that use CommonJS-specific features that are not compatible with ES modules.

This error means that Vite is trying to import vfs_fonts as an ES module, but vfs_fonts is a CommonJS module and does not have a default export.

Translated with DeepL.com (free version)