pdfmake makes my bundle size huge

Created on 11 Nov 2017  路  9Comments  路  Source: bpampuch/pdfmake

I am using pdfmake in my angular 4 app and it really helps me in making nice pdf docs on the client side. But I am a little concerned when I look into the bundle-report after an aot build. It adds a considerable amount of weight to my chunk. Is there any way to reduce this, like importing only the needed parts/services/modules or so? Right now I am importing it as below

import { createPdf } from 'pdfmake/build/pdfmake';

screenshot from 2017-10-29 23 27 15

Most helpful comment

I cut my bundle size in half by changing my import from:

import * as pdfMake from 'pdfmake/build/pdfmake';

to

import * as pdfMake from 'pdfmake/build/pdfmake.min';

All 9 comments

New version 0.1.34 a little reduces size of pdfmake.js and pdfmake.min.js files because lodash dependency was removed. Currently minified version has 950 kB.
Generating pdf files is too complex, so pdfmake is big, it can not be changed.

@anoopbaabte have you managed to resolve bundle size issue and would you mind sharing working sample for Angular 4 component?

Same situation here. Bundle size is huge i.n Angular 6. Size of node_modules is 2.96 mb and 2.13 mb of it comes from pdfmake

Try code splitting, with webpack for instance, so at least this big pdf bundle will be only loaded when needed

Guys, I have the same issue any idea?

You can try https://www.npmjs.com/package/pdfmake-lite loading fonts and assets with https://www.npmjs.com/package/pdfmake-utils

It does not support IE, arabic fonts and woff2 fonts

I cut my bundle size in half by changing my import from:

import * as pdfMake from 'pdfmake/build/pdfmake';

to

import * as pdfMake from 'pdfmake/build/pdfmake.min';

I cut my bundle size in half by changing my import from:

import * as pdfMake from 'pdfmake/build/pdfmake';

to

import * as pdfMake from 'pdfmake/build/pdfmake.min';

This produce an error on production build

@anthonyballugjr thank you for this, I'm dynamically importing the module, the minified version is considerably smaller!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Masber picture Masber  路  3Comments

davidyeiser picture davidyeiser  路  3Comments

MathLavallee picture MathLavallee  路  3Comments

svenyonson picture svenyonson  路  3Comments

ValeSauer picture ValeSauer  路  3Comments