thinkpixellab / PxLoader

PxLoader is a simple JavasScript library for creating preloaders and resource downloaders for HTML5 apps.
http://thinkpixellab.com/pxloader
1.11k stars 173 forks source link

CommonJS support #43

Closed positlabs closed 8 years ago

positlabs commented 8 years ago

The way exports are defined in PxLoader are incompatible with CommonJS. The PxLoader script becomes un-scoped from the window, so exporting to this is useless.

CommonJS support can be added with this line: if(module && module.exports) module.exports = PxLoader;

andheiberg commented 8 years ago

Glorious man! Thanks!

andheiberg commented 8 years ago

45

leup commented 8 years ago

As pointed out by @AureliePrd there is an error where "module is not defined". (https://github.com/thinkpixellab/PxLoader/commit/613791ed96479acfed2e2835753c1376a1dbd142#commitcomment-14711450)

I think it should use the following syntax

if (typeof module !== 'undefined' && module.exports)

daviestar commented 8 years ago

Can you please release a tagged version including CommonJS support. Thanks.