Skip to content
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

Closed
ragulka opened this issue Mar 6, 2014 · 27 comments
Closed

Request: publish typeahead and bloodhound on npm #743

ragulka opened this issue Mar 6, 2014 · 27 comments
Milestone

Comments

@ragulka
Copy link
Contributor

ragulka commented Mar 6, 2014

In the era of browserify and commonJS it makes sense to publish also front-end-only packages on npm.

  • npm stores the tagged versions on it's own servers
  • when managing dependencies, i'd rather manage them all in npm (most of the dependencies I use are already on npm)
  • it's nice to have the option, isn't it?
@jharding
Copy link
Contributor

jharding commented Mar 7, 2014

The best way to ensure I do this is to modify the publish task in Gruntfile.js, otherwise I'm very likely to forget 😄

@jharding jharding added this to the v0.10.2 milestone Mar 7, 2014
@jharding
Copy link
Contributor

jharding commented Mar 7, 2014

Published to npm, see https://www.npmjs.org/package/typeahead.js

@jharding jharding closed this as completed Mar 7, 2014
@ragulka
Copy link
Contributor Author

ragulka commented Mar 10, 2014

Looks good, although we I/You forgot to add the main file path to package.json, which means it's not possibel to simply require('typeahead.js') in node. I have created a PR to fix this here: #760

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 require('bloodhound') as well. (Think browserify).

@jharding
Copy link
Contributor

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.

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.

@tuckerconnelly
Copy link

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

@rtom-io
Copy link

rtom-io commented Aug 20, 2014

@tuckerconnelly I was having similar issues. Here is another link from someone else who resolved it. #872

@jharding
Copy link
Contributor

This should be improved once v0.11 lands as both bloodhound and the jquery plugin will be wrapped in https://github.com/umdjs/umd.

@unindented
Copy link

@jharding Is there a timeline for this?

@clayzermk1
Copy link

This should be improved once v0.11 lands as both bloodhound and the jquery plugin will be wrapped in https://github.com/umdjs/umd.

+1

@unindented
Copy link

@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?

@jstejada
Copy link

+1

@santanubasu
Copy link

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".

@kylegoetz
Copy link

@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.

@kylegoetz
Copy link

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.

@santanubasu
Copy link

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(...)

@kylegoetz
Copy link

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.

@ghost
Copy link

ghost commented Sep 17, 2015

Including this library via npm is really annoying. I can include the library, but the module itself uses a require('jquery')... meaning it will pull its own instance of jquery, attach to $.fn.typeahead, and export nothing. So if I have somewhere else in my code var $ = require ('jquery'); $(...).typeahead() that particular $ isn't going to have fn.typeahead. Anyone have a solution to this?

@santanubasu
Copy link

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.

@BrianGenisio
Copy link

@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.

@ghost
Copy link

ghost commented Oct 8, 2015

Yes - you can use a combination of browserify-shim and the package.json browser: {} with a global key to load jquery from a file (or a cdn), point browesrify to that global jquery: 'global:jQuery', then all successive requires will actually be reaching into the singular jquery, which browserify pulled off of window.jQuery. More details here

@nguyen-brian
Copy link

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.

@mikeymckay
Copy link

@nikvdp has packaged typeahead.js-browserify: https://www.npmjs.com/package/typeahead.js-browserify

It claims to solve these issues...trying it now!

@BrianGenisio
Copy link

@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.

@Ch4s3
Copy link

Ch4s3 commented Feb 11, 2016

Has anyone else had any luck with this?

@mikeymckay
Copy link

My solution was to leave typeahead and use awesomeplete:
https://www.npmjs.com/package/awesomplete

On Thu, Feb 11, 2016 at 7:03 AM, Chase Gilliam notifications@github.com
wrote:

Has anyone else had any luck with this?


Reply to this email directly or view it on GitHub
#743 (comment)
.

@clayzermk1
Copy link

@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"
  }
}

@Helgesmeby
Copy link

Helgesmeby commented Sep 17, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests