stewartlord / identicon.js

GitHub-style identicons as PNGs or SVGs in JS
BSD 2-Clause "Simplified" License
1.32k stars 129 forks source link

TypeError: PNGlib is not a constructor #12

Closed bvs90 closed 8 years ago

bvs90 commented 8 years ago

After the most recent update (for NPM fixes) the above error now occurs. We are not using a module loading system. It seems the PNGLib is not present on window before the main library tries to use it.

stewartlord commented 8 years ago

Oh no! Very sorry. I will take a look ASAP

stewartlord commented 8 years ago

Hi @bvs90, I'm having trouble reproducing this. Can you include repro steps?

mitar commented 8 years ago

@bvs90: Do you have by some accident globally available module symbol?

bvs90 commented 8 years ago

@stewartlord @mitar Apologies for the late reply. We are using the library in an Angular project. We are injecting the the library through a factory that just returns $window.identicon and then calling new Identicon() when we need it.

bvs90 commented 8 years ago

We've pegged our bower.json to an earlier commit so we're able to get around the issue but I'd be curious to know if anyone else was having an issue with using the library in Angular.

mitar commented 8 years ago

Yes, but is there a window.module symbol defined in your app? From somewhere else? Because if it is, our detection could misdetect it and then not export it to window, which is what you expect.

Can you just go in your app and run window.module in the browser console and see if it returns anything?

justerhan commented 8 years ago

In my case, including pnglib.js prior to identicon.js fixes the issue.

stewartlord commented 8 years ago

Closing this issue as it seems to be working.