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

Conflict of pdfmake.js and lodash #29

Closed
MaokaiLin opened this issue Mar 3, 2016 · 6 comments
Closed

Conflict of pdfmake.js and lodash #29

MaokaiLin opened this issue Mar 3, 2016 · 6 comments

Comments

@MaokaiLin
Copy link

First, thanks for making this tool set available. It's very handy!

I am experiencing some trouble integrating the pdfmake lib with my codebase. The main cause is the conflict between the use of _ (underscore) in pdfmake.js and the use of _ in lodash.

My specific problem is that it gives me an error that zipWith function does not exist when I call _.zipWith function in my own code. Removing pdfmake.js file resolves that conflict, but the pdf export functionality is no longer available.

I didn't look closely into the pdfmake.js file, but my guess is that some use of _ in that file is leaked into the global namespace. It is a serious bug if this is the case.

Could you take a look at it? Thanks a lot for the help!

@MaokaiLin
Copy link
Author

actually took another look. pdfmake is using lodash 3.1.0, and zipWith is introduced in lodash 3.8.0.

note that lodash v3.1.0 is significantly behind the current version (4.5.1). but either way, the lodash library used in pdfmake should be strictly confined within the package. could you get this fixed?

@maertz
Copy link
Collaborator

maertz commented Mar 3, 2016

Thanks for pointing this out, we simply include the default built from pdfMake.
They have already few issues regarding the namespacing issue, one seems to be the one you are looking for which respects the loDash global var.

On the other hand it might be fixed if you manually include the resources into your document and add the "loDash" resource after pdfMake.js file, that might already fix your issue by resetting the overwritten loDash methods.

@MaokaiLin
Copy link
Author

Got it. I'll try it out later today and let you know if it works. Thanks for getting back so quickly.

@maertz
Copy link
Collaborator

maertz commented Jun 13, 2016

any news?

@maertz maertz closed this as completed Jul 27, 2016
@mg1075
Copy link

mg1075 commented Mar 13, 2017

@maertz - I was wondering about some odd lodash behaviors. Yes, amcharts/pdfmake in front of lodash dependency overrides my app's lodash version. Putting (my newer or at least expected version) lodash after amcharts/pdfmake did override the old lodash version inside pdfmake.

@yaviner
Copy link

yaviner commented May 5, 2017

Hi,

I encountered this issue recently as well! I ended up fixing it by removing pdfmake as a dependency (I wasn't using this feature), but it's worth noting that the latest versions of pdfmake have fixed this: bpampuch/pdfmake#443

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

4 participants