I’m trying to use Twitter Typeahead in a Rails 7 project with Webpacker. I had it working when I included it via CDN, but for various build reasons I would like to stop using the CDN. I have installed it into the project with yarn add typeahead.js
. I can import typeahead to webpacker with import 'typeahead.js';
but I still get Uncaught ReferenceError: Bloodhound is not defined
in my chrome console. I can see the Bloodhound file on yarnpkg https://yarnpkg.com/package/typeahead.js?files
but I can’t get my app to reference it. import Bloodhound from 'typeahead.js';
and import Bloodhound from 'typeahead.js/dist/bloodhound';
do not work.
I have little experience with JS or webpacker. Any help would be appreciated!