pdfmake-wrapper
pdfmake-wrapper copied to clipboard
angular commonjs dependencies warning
Hi, I am using this library to generate PDF documents, and when I run my app this message appears on the console:
Warning: .../node_modules/pdfmake-wrapper/lib/pdfmake-wrapper.js depends on 'pdfmake/build/pdfmake'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
This link from the angular.io is just a way to disable the warning, it does not resolve it. Do you have any hint how to resolve it? Thanks in advice.
Hi @alexladeira! What's the angular version you are using? can you give me more details about how you are using pdfmake-wrapper?
Hi, I'm using angular 13 with pdfmake-wrapper 2.1.2. I am importing the dependencies in one of my ts files like this:
import { Canvas, Columns, Line, PdfMakeWrapper, Rect, Stack, Table, Txt } from 'pdfmake-wrapper'; import * as pdfFonts from 'pdfmake/build/vfs_fonts';
and starting as pdf = new PdfMakeWrapper();
Have you added the fonts to use?
PdfMakeWrapper.setFonts(pdfFonts)
You can check how to create your first PDF here.
Yes, I added this line inside the constructor method (I'm using Typescript)
Updating with more information, I create an repo on my account - https://github.com/alexladeira/angular-pdfmake-wrapper. It's not exactly my setup, because angular is on the last version, but when you run "npm run start" the same problem occurs. Thanks for your help.
This is because pdfmake uses commonjs dependencies. Angular prefers ECMAScript. The problem you may encounter, is that your application will be larger and slower. It's possible to ignore this warning, but not recommended. My recommendation would be to use the pdfmake-wrapper in your backend solution if this one is part of the nodejs ecosystem.
This is because pdfmake uses commonjs dependencies. Angular prefers ECMAScript. The problem you may encounter, is that your application will be larger and slower. It's possible to ignore this warning, but not recommended. My recommendation would be to use the pdfmake-wrapper in your backend solution if this one is part of the nodejs ecosystem.
Hello, your backend is in Java, so what you suggests can't be done in your case, as far as I know. Anyway, thanks for your tip.