Best practices for customizing a dependency (via forking) and deploying on Heroku

I've been working on a Node.js app and deploying on Heroku. All has been fine, but just today I found a need to add a feature to one of our dependencies. I've forked from the owner's repository and added the necessary feature (which could continue to develop as far as a pull request perhaps). It seems too small a change to create a new item in the npm catalog, so I simply require the customized dependency from the directory in which I keep all my repositories.

Example: ~/Repositories/dependency contains its own package.json and makes sense standing alone. I can add features and push to my fork on GitHub

~/Repositories/app/lib/file.js can require('../../dependency') and everything works

The trouble is that Heroku has no knowledge of my dependency fork and my way of requiring it won't work in the deployment.

  • Is there a way to get Heroku to keep multiple repositories, one with the app and one with the dependency?
  • Is there a feature of npm that could solve this for me?
  • Is it really OK to add to the npm catalog for something so trivial?

I would like to keep all repositories at the same level in the filesystem and not nest this dependency fork within the app's repository.

If I understand your question, you want to include an arbitrary repository as a dependency? Well, NPM can do that!

NPM supports dependencies directly from git or publicly hosted tarballs. Just includes something like the following in your package.json:

"dependencies": {
    "some-package" : "git://github.com/user/some-package.git#commit-ish"
}

NPM also supports GitHub URLs directly:

"dependencies" {
    "some-package" : "user/some-package"
}