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

set module.exports to "global.key" rather than just "key" to play nice w... #113

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

Conversation

burl
Copy link

@burl burl commented Jan 20, 2014

Using: module.exports = global.key fixed a problem I observed at runtime when using a bundle built with browserify.

@notlion
Copy link

notlion commented Jan 28, 2014

+1 module.exports = assignKey would allow for slightly more minification.

@blixt
Copy link

blixt commented Jan 29, 2014

Wouldn't it make sense to only assign global.key if module is undefined? In the other case, assign to the global. This way both CommonJS and non-CommonJS behaves as expected (module local vs. global scopes).

Something like this (replacing all global.key… lines):

assignKey.setScope = setScope;
assignKey.getScope = getScope;
assignKey.deleteScope = deleteScope;
assignKey.filter = filter;
assignKey.isPressed = isPressed;
assignKey.getPressedKeyCodes = getPressedKeyCodes;
assignKey.unbind = unbindKey;

if (typeof module === 'undefined') {
  assignKey.noConflict = noConflict;
  global.key = assignKey;
} else {
  module.exports = assignKey;
}

Note that the reason I define everything on assignKey is because the first line used to be global.key = assignKey basically resulting in the same as the above.

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.

3 participants