Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

angular commonjs dependencies warning #80

Open
alexladeira opened this issue Jun 7, 2022 · 7 comments
Open

angular commonjs dependencies warning #80

alexladeira opened this issue Jun 7, 2022 · 7 comments

Comments

@alexladeira
Copy link

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.

@Lugriz
Copy link
Owner

Lugriz commented Jun 10, 2022

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

@alexladeira
Copy link
Author

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

@Lugriz
Copy link
Owner

Lugriz commented Jun 19, 2022

Have you added the fonts to use?

PdfMakeWrapper.setFonts(pdfFonts)

You can check how to create your first PDF here.

@alexladeira
Copy link
Author

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

@alexladeira
Copy link
Author

alexladeira commented Jun 21, 2022

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.

@Leccho
Copy link

Leccho commented Nov 29, 2022

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.

@alexladeira
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants