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

module.exports['browser'] <-- typo? #71

Closed
ibc opened this issue Dec 26, 2014 · 8 comments
Closed

module.exports['browser'] <-- typo? #71

ibc opened this issue Dec 26, 2014 · 8 comments

Comments

@ibc
Copy link

ibc commented Dec 26, 2014

!function (name, definition) {
  if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition()
  else if (typeof define == 'function' && define.amd) define(definition)
  else this[name] = definition()
}('bowser', function () {

May be it should be module.exports['bowser']?

@ibc
Copy link
Author

ibc commented Dec 26, 2014

Why module.exports[ANYTHING]? Currently when I use this library in a Node project that is finally bundled using "browserify", I need to do this to use its API:

var bowser = require('bowser');

if (bowser.browser.chrome) { ... }

Instead, if I load the library in the old way (<script src='js/bowser.js'></script>) then I should use:

if (bowser.chrome) { ... }

I'll send a PR to fix it.

@ibc ibc mentioned this issue Dec 26, 2014
@ibc
Copy link
Author

ibc commented Feb 3, 2015

OK, thanks.

@ded
Copy link
Collaborator

ded commented Feb 3, 2015

there's no right or wrong answer to this. we'd have to bump it to a major version, which is fine...

@ibc
Copy link
Author

ibc commented Feb 3, 2015

OK, note that it would be more consistent (same behavior and API for both browser and Node).
Thanks.

@vvo
Copy link

vvo commented Mar 6, 2015

10 minutes wasted because of this. What do we do?

@ibc
Copy link
Author

ibc commented Mar 6, 2015

var bowser = require('bowser') should export the bowser module, instead of an Object with a field called browser or bowser, so its API would be consistent regardless the library is used as a standalone <script> tag or as a AMD/CommonJS module.

vvo added a commit to vvo/bowser that referenced this issue Mar 6, 2015
@vvo
Copy link

vvo commented Mar 6, 2015

fixed this @ded

@ded
Copy link
Collaborator

ded commented Jul 26, 2015

hey all — this has been fixed in the 1.0.0 version. Thus require('bowser') will work the same as it does in Node.js 👍

@ded ded closed this as completed Jul 26, 2015
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

Successfully merging a pull request may close this issue.

3 participants