What makes heroku work with rails is rails' use of gemfiles/bundler, so that you don't have to upload every gem that your rails app uses. I don't know how it works with node, but from heroku's getting started articles, it looks like leiningen (a clojure build tool) is what that allows them to offer clojure support.
I don't know the scala ecosystem at all. Does scala have a similar tool that allows you to specify what java/scala libraries you want without actually having to upload said libraries?