ng2-pdf-viewer icon indicating copy to clipboard operation
ng2-pdf-viewer copied to clipboard

Angular 10 issue -> optimization bailouts

Open Seharad opened this issue 5 years ago • 69 comments

WARNING in /../node_modules/ng2-pdf-viewer/ivy_ngcc/fesm2015/ng2-pdf-viewer.js depends on pdfjs-dist/build/pdf. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Seharad avatar Jun 25 '20 19:06 Seharad

same here

JohnnyTMD avatar Jul 03 '20 11:07 JohnnyTMD

same here, but put in angular.json like they said in official guide

[https://angular.io/guide/build#configuring-commonjs-dependencies]

"options": {
						"allowedCommonJsDependencies": [",
							"moment-business",
							"ng2-pdf-viewer",
							"pdfjs-dist/build/pdf",
							"pdfjs-dist/web/pdf_viewer"
						],

PedroS5499 avatar Jul 08 '20 09:07 PedroS5499

this is just for ignoring the warnings. But the goal should be to get rid of the warnings in general.

seopei avatar Jul 08 '20 10:07 seopei

Ignoring errors is not the way to go.

Seharad avatar Jul 13 '20 17:07 Seharad

same here, any news?

bekstn avatar Aug 03 '20 13:08 bekstn

pdfjs is not written with es modules, but they made a es module wrapper available that could be used in the meantime: https://www.npmjs.com/package/@bundled-es-modules/pdfjs-dist

for more info: https://github.com/mozilla/pdf.js/issues/10317

saithis avatar Aug 06 '20 15:08 saithis

@saithis thanks for pointing the right issue @bundled-es-modules/pdfjs-dist seems to be outdated

VadimDez avatar Aug 07 '20 21:08 VadimDez

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 06 '20 21:10 stale[bot]

Can we re-open this one?

mrmokwa avatar Nov 11 '20 18:11 mrmokwa

@mrmokwa yes indeed

PedroS5499 avatar Nov 12 '20 20:11 PedroS5499

any news?

PedroS5499 avatar Nov 18 '20 21:11 PedroS5499

I hate this Warning :'(

mememelm avatar Nov 21 '20 09:11 mememelm

Any updates?

raichshlv avatar Nov 29 '20 13:11 raichshlv

Any updates on this?

edusoccer1121 avatar Dec 15 '20 18:12 edusoccer1121

This warning is really annoying any pending fixes for this yet?

oussemazouaghi avatar Dec 25 '20 10:12 oussemazouaghi

I m able to fix the issue by adding commonJsdependency property in the angular.json

angular.json

Inside Build command there is an option "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "allowedCommonJsDependencies": ["ng2-pdf-viewer"], }

imvikaskohli avatar Dec 29 '20 10:12 imvikaskohli

I m able to fix the issue by adding commonJsdependency property in the angular.json

angular.json

Inside Build command there is an option "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "allowedCommonJsDependencies": ["ng2-pdf-viewer"], }

this is not a fix, this is an ignore.

Seharad avatar Dec 29 '20 10:12 Seharad

@VadimDez When I tried to build you library from source, I ran into the same problem. Even worse: the require() statements work in the ng2-pdf-viewer demo project, but they failed to work after copying the dist folder to my test project.

Can we get rid of the require() statements? Angular's stopped supporting require.js. It'd be nice to use an import statement instead. Or we could load pdf.js and viewer.js directly. That'd allow for loading these big files lazily.

stephanrauh avatar Dec 29 '20 17:12 stephanrauh

any updates?

nikhil-kapoor-quo avatar Jan 24 '21 13:01 nikhil-kapoor-quo

all require()s have been removed

VadimDez avatar Feb 18 '21 08:02 VadimDez

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 19 '21 09:04 stale[bot]

@VadimDez If i understand this correctly, unless an ECMAScript module bundle version of ng2-pdf-viewer is released, we have to add ng2-pdf-viewer to allowedCommonJsDependencies to ignore this warning? 🤔

Do you think an ECMAScript module bundle version of ng2-pdf-viewer will be available in the future? 🔭

turbolego avatar Apr 21 '21 09:04 turbolego

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 20 '21 10:06 stale[bot]

Bump to remove stale.

MikeMatusz avatar Jun 21 '21 13:06 MikeMatusz

Has anyone actually found a solution to this? Even if its temporary workaround?

SKhalidQ avatar Jul 12 '21 00:07 SKhalidQ

https://github.com/mozilla/pdf.js/issues/10317

Still open :( Hope they will provide it.

nischi avatar Aug 04 '21 06:08 nischi

Not to sound like a broken record, but has there been any progress on this issue?

hal2814 avatar Aug 13 '21 19:08 hal2814

first create an ngcc.config.js file on the root => https://githubmemory.com/repo/VadimDez/ng2-pdf-viewer/issues/754

and then allowedCommonJsDependencies

"allowedCommonJsDependencies": [ "ng2-pdf-viewer", "pdfjs-dist" ]

it work for my project

korvised avatar Sep 16 '21 02:09 korvised

Any progress? It seems like this type of module causes my initial bundle to have extra 500 Kb, while I'm using it only in lazy loaded modules so I'm expecting it not to be present in an initial bundle

gultyayev avatar Sep 22 '21 14:09 gultyayev

Also hoping for any updates on this.

\node_modules\ng2-pdf-viewer_ivy_ngcc_\fesm2015\ng2-pdf-viewer.js depends on 'pdfjs-dist/es5/build/pdf'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

psarno avatar Sep 28 '21 11:09 psarno