flexdinesh / browser-or-node

Check where your code is running. In the browser or in node.js environment.
MIT License
245 stars 20 forks source link

Would probably fail in bundle environment #1

Closed mubaidr closed 6 years ago

mubaidr commented 6 years ago

I think Bundlers (like webpack, parcel) define these properties/methods n their own, so i think this will fail in those environments.

const isNode = typeof module !== 'undefined' && typeof module.exports !== 'undefined';
swansontec commented 6 years ago

I can confirm that this fails with the Parcel bundler. I get isNode === true, even in the browser.

swansontec commented 6 years ago

Pull request: https://github.com/flexdinesh/browser-or-node/pull/2

flexdinesh commented 6 years ago

PR #2 should address this issue. Closing it as it's been merged.

cesarve77 commented 6 years ago

It still fail with babelify browserify IsNode===true

flexdinesh commented 6 years ago

@cesarve77 I haven't published a new version yet. I'll definitely publish a new version tomorrow.

flexdinesh commented 6 years ago

v1.1.0 is now published with these changes.