pdfmake-wrapper icon indicating copy to clipboard operation
pdfmake-wrapper copied to clipboard

angular commonjs dependencies warning

Open alexladeira opened this issue 2 years ago • 7 comments

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.

alexladeira avatar Jun 07 '22 02:06 alexladeira

Hi @alexladeira! What's the angular version you are using? can you give me more details about how you are using pdfmake-wrapper?

Lugriz avatar Jun 10 '22 20:06 Lugriz

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();

alexladeira avatar Jun 13 '22 19:06 alexladeira

Have you added the fonts to use?

PdfMakeWrapper.setFonts(pdfFonts)

You can check how to create your first PDF here.

Lugriz avatar Jun 19 '22 17:06 Lugriz

Yes, I added this line inside the constructor method (I'm using Typescript)

alexladeira avatar Jun 20 '22 03:06 alexladeira

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.

alexladeira avatar Jun 21 '22 18:06 alexladeira

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.

Leccho avatar Nov 29 '22 14:11 Leccho

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.

alexladeira avatar Dec 02 '22 03:12 alexladeira