I am using browserify to bundle front-end code. It's been great so far, but I've been having difficulty mixing npm and non npm packages. For example, using the npm version of jQuery with non CJS versions of jQuery plugins.
My current solution is to use the browser
key in package.json
to point to jQuery's dist, and then use browserify-shim
to add it as a dependency of the plugins.
Is there a cleaner way to do this than what I currently have?
Edit: I'm currently trying to use npm and package.json
to manage all my dependencies, so I don't want to use bower on this project. Call me crazy : )
Package.json
{
"dependencies": {
"jquery": "~2.1.0",
"browserify": "latest",
"browserify-shim": "^3.5.0",
"jquery-waypoints": "git@github.com:imakewebthings/jquery-waypoints.git",
"jquery-validation": "git://github.com/jzaefferer/jquery-validation"
},
"browser": {
"jquery": "./node_modules/jquery/dist/jquery.js",
"jquery-waypoints": "./node_modules/jquery-waypoints/waypoints.js",
"jquery-validate": "./node_modules/jquery-validation/build/release.js"
},
"browserify-shim": {
"jquery": "$",
"jquery-waypoints": {
"depends": [
"jquery"
]
},
"jquery-validate": {
"depends": [
"jquery"
]
}
},
"browserify": {
"transform": [
"browserify-shim"
]
}
}