1.0.1 • Published 10 years ago
jquery-browserify-integration v1.0.1
jquery-browserify-integration
In your app you are:
- trying to use jQuery.
- trying to use browserify.
- trying to use jQuery plugins.
All at the same time?!?! IS IT EVEN POSSIBLE?
Well sure.
how do i do it?
See the main.js
file. If you want to fiddle with how this all works (perhaps try adding your plugins, widgets, and gidgets!), clone the repo and run npm run demo
. This will boot a beefy server in order to browserify the demo code and let you load it in the browser directly. Rad!
gotchas!
If you use a jQuery plugin that is designed to work with npm, and you find that require('jquery')
statements are returning different instances of jQuery, you need to understand how browserify bundles your code. To use the same jQuery singleton across your module and your dependent modules:
- use
package.json
versioning in yourdependencies
forjquery
. Your root jQuery package must be compatible with all of your plugins' package.json jQuery requirements. - browserify doesn't concern itself with versions, but npm does. That is, use
npm dedupe
as needed.npm dedupe
will remove each of your modules'jquery
if the module can instead use your root project'sjquery
. In this regard, you don't bundle multiple different versions of jQuery!- not sure what jquery instances your modules are using?
browserify --deps yourFile.js > depsCheck
. You can parsedepsCheck
, find your module, look at itsdeps
object, and observe the exact jQuery file it will be using!
- not sure what jquery instances your modules are using?
don't forget
contributing
send dem PRs on over.