Skip to content
This repository has been archived by the owner on Mar 21, 2018. It is now read-only.

Add compatibility with commonjs and browserify #5

Merged
merged 1 commit into from
Apr 24, 2014

Conversation

wbinnssmith
Copy link
Contributor

Adds a commonjs export and package.json so this can be packaged with commonjs bundlers. Had to move this in the wrapper call to window since this is the current module in cjs environments.

If eventie#3 gets merged I can move the package json dependency to desandro/eventie

} else {
// browser global
window.docReady = defineDocReady( window.eventie );
}

})( this );
})( window );
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious -- why not use the global this value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In node and browserify, the top-level this is the current module, i.e. module.exports and is {} until anything is exported. So in this case it looks for document on the current module. Obviously this won't work in node since it uses window but most other commonjs bundlers implement things this way (I think). Here's a thread with a bunch of node/browserify folks clearing it up.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! thanks for clearing that up 😀

desandro added a commit that referenced this pull request Apr 24, 2014
Add compatibility with commonjs and browserify
@desandro desandro merged commit 7b441b2 into desandro:master Apr 24, 2014
@desandro
Copy link
Owner

Thank you again (so much!) for the PR. I made a tweak to the package.json for desandro/eventie. We should be good with this one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants