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

Use noConflict by default for CommonJS #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HenrikJoreteg
Copy link

Hey, Thomas!

When requiring a module with CommonJS style I generally assume it's not going to create any globals for me. Since I'll be assigning the required module to your own variable when requiring it anyway:

var key = require('keymaster');

I simply tweaked it to call noConflict if you're requiring it.

if(typeof module !== 'undefined') {
  module.exports = key;
  noConflict();
}

It's a silly little thing, but figured I'd propose this change if you want it. That's the pattern I've seen in other projects that do both, like backbone, etc: https://github.com/documentcloud/backbone/blob/master/backbone.js#L30

If you're requiring this as a module you probably don't want the global. Since you'll be assigning the required module to your own variable.
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 this pull request may close these issues.

1 participant