Open night1008 opened 9 years ago
Thanks for your replying!!! So that is what it is. Learn from you.
The problem is that the factory method for typeahead jquery plugin does not return anything, hence:
module.exports = factory(require("jquery"));
Will always be undefined.
Moreover, there are two CommonJS module defined in one single file. I don't think it can ever work.
Solution is to require Typeahead and Bloodhound separately. To fix the bundle file, the umd task should probably be run after concatenation.
var typeahead = require('typeahead.js/dist/typeahead.jquery');
var Bloodhound = require('typeahead.js/dist/bloodhound');
@ChrisWren I tried your suggestion above but I'm getting this error: Uncaught TypeError: $searchBox.typeahead is not a function
@ChrisWren Thank you, your suggestion fixed my problem!
@saemchou nice! Glad to hear it.
Im using rollup.js and @ChrisWren's solution works for me, thank very much!
To add some further information, it seems that Typehead is totally broken for CommonJS usage.
module.exports
is set twice, and the second type it is set (in the 'typeahead.js' module loader shim) it is set toundefined
.Here are the changes I made to![changes to built js](http://take.ms/yvYjL)
typeahead.bundle.js
:Here's the console output when I![result](http://take.ms/yZBQP)
require()
this file in my browserify bundle.My browserify sourcecode: