Too Many Dependencies


I'm using meteor to get something done and I needed to implement "likes" as in something you can click to "like" something and then that thing can display a number of likes.

There's a package that helps with this in meteor. It's called "socialize likeable" and it seems fine. The code is not too big. I skimmed the code to see what it was doing. Before that I had thought about different ways to implement such a feature and from reading that code helped inform my own ideas about the what was probably the right way to do things. It was doing it that way so I go to install it

It installs 9 more dependencies

aldeed:collection2               added, version 2.3.3
aldeed:simple-schema             added, version 1.3.3
matb33:collection-hooks          added, version 0.7.15
meteorhacks:meteorx              added, version 1.0.2
meteorhacks:unblock              added, version 1.1.0
socialize:base-model             added, version 0.2.3
socialize:linkable-model         added, version 0.2.1
socialize:server-time            added, version 0.1.2
tmeasday:publish-with-relations  added, version 0.2.0

So I thought to myself "really? Isn't that a lot of code for something simple". So I set out to do it myself thinking if it turned out to be more involved I could still use it anyway. It took about 5 minutes and was 20 lines of code and seems to work.

Assuming you have a collection of "Posts" and each post has a "likes" number field then all I added was this

PostLikes = new Mongo.Collection("postlikes");

// on client

// on server
Meteor.publish("postlikes", function () {
  return ArtLikes.find({});

  likePost: function(postId) {
     var userId = Meteor.userId();
     if (!userId) {
       throw new Meteor.Error("can not like something if not logged in");
     var like = PostLikes.findOne({postId: postId, userId: userId});
     if (like) {
     } else {
       PostLikes.insert({postId: postId, userId: userId});
     Post.update({_id: postId}, {$inc: {likes: like ? -1 : 1}});

That's the entire thing.

If I wanted to know a particular user's likes it would just be

    userLikes: function() {
      return PostLikes.find({userId: Meteor.userId()});

I don't want to criticize that original package. For one it's doing a little magic in that it add methods to your collection so you can do "" and "Posts.unlike()" and a few other things so that's fancy. It also magically adds the "likes" number field to your Posts.

But at the same time, 9 packages!??!? Maybe they are all tiny and maybe it's really about adding together a bunch of small very useful things. I'm just scared to take so much code for something seemingly kind of simple. It's also possible I'm doing something stupid or inefficient that I'd be much better off taking the packages for but it's just as possible those packages have issues as well.

How do I decide if I should take those 9 packages for this one small feature?

Meteor's downsides