I'm trying to use Bloodhound and Typeahead in my Browserify project. I'm using browserify-shim.
package.json
{
...
"browserify": {
"transform": ["browserify-shim"]
},
"browserify-shim": "./shim.js",
}
shim.js
module.exports = {
...
'typeahead.js/dist/bloodhound': {
exports: 'Bloodhound',
depends: {jquery: 'jQuery'}
}
};
test.js
...
var Bloodhound = require('typeahead.js/dist/bloodhound');
module.exports = function() {
console.log(Bloodhound);
}
Which outputs an empty object ({}).
I've followed everything in this relevant question, using vanilla Browserify from the command line, but still no dice.
I was able to get it working by adding
module.exports = Bloodhound;
to the bloodhound.js file, but this is far from ideal. Shouldn't browserify-shim be adding the exports? I didn't see a module.exports for Bloodhound in the generated bundle.js.