-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: publish typeahead and bloodhound on npm #743
Comments
The best way to ensure I do this is to modify the publish task in Gruntfile.js, otherwise I'm very likely to forget 😄 |
Published to npm, see https://www.npmjs.org/package/typeahead.js |
Looks good, although we I/You forgot to add the main file path to package.json, which means it's not possibel to simply Perhaps it's also worth opening a discussion whether bloodhound and typeahead should really be in the same package/repo. Since by now they are completely separated, which means they could be used on their own, perhaps it would make sense to break them into 2 different projects/packages/repos. This would then, in the longer run, allow doing something like |
I'd like to do this, but I'd need to work out the logistics. Maybe I'll aim to do this for the v1.0.0 release. |
I wasn't able to get the npm module to work with browserify. Narrowed it down to module.exports missing in the compiled typeahead.js and bloodhound.js files. Is this right? Did you get it working @ragulka? I might submit a PR if you can confirm. More info in this SO question: http://stackoverflow.com/questions/25343771/including-typeahead-js-bloodhound-with-browserify-gives-empty-object |
@tuckerconnelly I was having similar issues. Here is another link from someone else who resolved it. #872 |
This should be improved once v0.11 lands as both bloodhound and the jquery plugin will be wrapped in https://github.com/umdjs/umd. |
@jharding Is there a timeline for this? |
+1 |
@jharding Sorry to insist, but with more than 150 open issues, and 37 pending pull requests, this repo is starting to look abandoned. Are there plans to revive it? |
+1 |
For anyone visiting this after the fact: the package on npmjs.com is literally called typeahead.js, not typeahead. This probably should have been obvious to me, but when I searched for simply typeahead on npmjs I got a different module. Not sure why both results don't come up... Likewise, adding a dep on typeahead v0.11.1 in your package.json will fail, it needs to be "typeahead.js":"0.11.1". |
@santanubasu makes a very good point. I literally spent a whole day trying to figure out why the Typeahead I was using wasn't emitting the expected events, and then I discovered that Typeahead is a 1-year old version on NPM, while Typeahead**.js** is the correct, up-to-date version. |
Ah, as it turns out, it still doesn't work. The factory() in the NPM version doesn't return anything, so require('typeahead.js') returns undefined. I haven't figured out what it's supposed to return to work. |
FWIW, I did require("typeahead.jquery.js") and that worked. However, I didn't assign the result (undefined I assume) to any variable. Instead, I just used it via jquery, for example: this.$el.typeahead(...) |
Thanks, @santanubasu. That's what I ended up doing, although personally I didn't like doing it that way. There should be a proper export so I can do Typeahead(inputElement, options) or something like that. Also I think I still had to make a change to the Typeahead JS file to get it working properly (maybe added a "return typeahead" or something at one point. I also had to require('jquery') in my own code or else it wouldn't work. |
Including this library via npm is really annoying. I can include the library, but the module itself uses a |
If you are only using browserify, you might be able to get around your issue using browserify-resolutions (https://github.com/Updater/browserify-resolutions). I had the identical issue you reported with the bootstrap datetimepicker library, and this, um... resolved it. Note that this doesn't address a situation where you have jquery as a global via some other means, and you also require() it from inside a browserify bundle. That still seems to break in the way you reported, if anyone has a solution to that, would love to hear it. |
@aft-luke YES! I'm dealing with this exact problem. Did you figure out a way around it? I've spent all day trying to come up with a solution. |
Yes - you can use a combination of browserify-shim and the package.json |
I'm in the same boat with the browserify people. For a while my app was using the latest jquery version (2.1.3), so typeahead resolved its jquery dependency using the same version. Then when 2.1.4 came out, doing a recompile would make typeahead have its own nested version of jquery separate from the one I was setting globally. The solution was to update my app's version of jquery to 2.1.4 to make typeahead use the same version -- not optimal, but a huge relief once I understood what was happening. |
@nikvdp has packaged typeahead.js-browserify: https://www.npmjs.com/package/typeahead.js-browserify It claims to solve these issues...trying it now! |
@mikeymckay Let me know if you get it working. Whenever I try to use this version, it brings in it's own version of jQuery. I still haven't solved this problem in a way that I like. I'm successfully telling Browserify to include the Bower Typeahead.js version with a Browserify shim, but I can't do it in a separated way. By that, I mean, I can get Typeahead to use the global jQuery only if it is built into my app bundle. But I like to have my app.js separate from my vendor.js. For whatever reason, when I put typeahead.js into my vendor.js, Browserify simply won't use my global shim. It is maddening. So I have the Typeahead code being bundled with my app.js right now... not ideal, but at least it works. |
Has anyone else had any luck with this? |
My solution was to leave typeahead and use awesomeplete: On Thu, Feb 11, 2016 at 7:03 AM, Chase Gilliam notifications@github.com
|
@Ch4s3 I am using substack/browserify and found it easy enough to do the following in my package.json both before and after @jharding published typeahead.js to npm. {
"browser": {
"bloodhound": "./node_modules/typeahead.js/dist/bloodhound.js",
"typeahead.js": "./node_modules/typeahead.js/dist/typeahead.jquery.js"
},
"dependencies": {
"typeahead.js": "0.11.1"
// or just go directly to github and bypass the npm registry
"typeahead.js": "github:twitter/typeahead.js#0.11.1"
}
} |
This repo appears to be abandoned. Maintained fork: https://github.com/corejavascript/typeahead.js Also watch out for the npm typeahead library which is completely different from this. |
In the era of browserify and commonJS it makes sense to publish also front-end-only packages on npm.
The text was updated successfully, but these errors were encountered: