Skip to content

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