Pdf.js: Drop webpack peerDependency from pdfjs-dist project

Created on 17 May 2018  路  7Comments  路  Source: mozilla/pdf.js

What is the expected behavior?
The pdfjs-dist project should not include webpack as a peerDependency for it can really work without it when loading the scripts from build directory.

What went wrong?
I am using PDFJS in a component to visualize a PDF using Angular 6. No including webpack in my project (I do not need it at all), make a peerDependency warning popup every time I run any npm command or every time anyone install my component.

1-other

Most helpful comment

Hi, @timvandermeij. Thanks for your reply!

webpack is a build tool and, as such, it usually only makes sense as a "devDependency" - or is otherwise restricted to the build pipeline of the library. Including it as a "peerDependency" means that users need to either install it locally (even though they may not need it/don't care for it) or ignore the warning that pops out every time on npm install.

I am not familiar with worker-loader, so take my comments with a pinch of salt. But if it is like any other webpack loader, they are typically only required as a build configuration step and nothing else. Also, it makes little sense in a context where the library is meant to be used outside the web (like Node).

Is pdf.js acting as a webpack plugin of sorts in some cases? If it _is_, it _might_ make sense to include both the loader and webpack as a dependency. But, even then, I'd argue that that kind of support should be extracted to its own repo/module.

I took the liberty of forking the repo and taking everything webpack related out. It's still working absolutely fine for me in my Node application.

All 7 comments

Exactly. Having webpack as a "peerDependency" in a distributable package such as this is plain wrong and should be removed.

The peer dependency was added in #9249 because of worker-loader. Could you elaborate a bit on why it's wrong to have it in our repository? I'm fine with removing it if it's sure to not break things.

Hi, @timvandermeij. Thanks for your reply!

webpack is a build tool and, as such, it usually only makes sense as a "devDependency" - or is otherwise restricted to the build pipeline of the library. Including it as a "peerDependency" means that users need to either install it locally (even though they may not need it/don't care for it) or ignore the warning that pops out every time on npm install.

I am not familiar with worker-loader, so take my comments with a pinch of salt. But if it is like any other webpack loader, they are typically only required as a build configuration step and nothing else. Also, it makes little sense in a context where the library is meant to be used outside the web (like Node).

Is pdf.js acting as a webpack plugin of sorts in some cases? If it _is_, it _might_ make sense to include both the loader and webpack as a dependency. But, even then, I'd argue that that kind of support should be extracted to its own repo/module.

I took the liberty of forking the repo and taking everything webpack related out. It's still working absolutely fine for me in my Node application.

Is there any plan to remove webpack as a dependency. @nfantone did you plan on submitting a PR?

@mishawakerman I never really received an "official" response to this issue - and I still don't know why webpack is listed as a dependency. My (limited) intuition tells me this is part of a bigger issue where pdf.js is coupled to some part of its implementation that indirectly depends on webpack and needs to be refactored in some way.

This question is also asked on IRC and we got this answer: https://mozilla.logbot.info/pdfjs/20180606#c14862530-c14862541. In short, I'm not really familiar with Webpack bundling itself, but if it's really only for the example I guess we can remove it. Please check if that is the case before submitting a PR though.

Closing since doing this isn't really a good option given that #9248 will return if we do that. Instead, what we should do is #9580 which is discussed in IRC at https://mozilla.logbot.info/pdfjs/20180606#c14862530-c14862634.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smit-modi picture smit-modi  路  3Comments

azetutu picture azetutu  路  4Comments

xingxiaoyiyio picture xingxiaoyiyio  路  3Comments

aaronshaf picture aaronshaf  路  3Comments

sujit-baniya picture sujit-baniya  路  3Comments