adamhalasz / uniqid

Unique ID Generator
https://adamhalasz.com
617 stars 49 forks source link

Being defensive (for bundlers) when checking module.parent.uniqid_debug #9

Closed joeldenning closed 7 years ago

joeldenning commented 8 years ago

Neither webpack nor jspm support module.parent, which causes problems when bundling uniqid. In the case of jspm, even when uniqid is just a build tool (that's helping bundle other things but is not even being bundled itself), it will throw errors since jspm/systemjs build tools run inside of a controlled non-cjs environment. See https://github.com/webpack/webpack/issues/1569, https://github.com/jspm/jspm-cli/issues/2134, and https://github.com/systemjs/systemjs/issues/1470.

This change simply is to be defensive so that uniqid doesn't die when it is running in the browser or an environment that doesn't have full cjs support (like webpack and jspm)