My answers to all the questions that might be in your head:
1, Has it been done before?
It’s not an alien concept, people have been doing it ever since it existed due to various reasons.
2, What convinced me?
The reason that convinced me to do is changing the legacy dependencies. When you develop some real life project you often need to change how things work in legacy codebase.
3, Could I have done it the other way?
YES, the other way would involve using a fork of the legacy dependency and pushing the changes to that and using it in the app instead of original.
4, Will I change the way I did it?
MAYBE YES, the constraints for different project varies I felt this part do not deserve that much time currently instead I can focus on some other important part.
5, Any particular downside of committing node_modules?
The downside is that you’ll have a hard time scaling your app horizontally this way also it may happen that some dependencies change in the mean time.Well in my case it is less likely that I’ll need to scale it horizontally in next 6–10 months.
6, Should you do it?
If you don’t have much time, or you won’t need to scale the system in near future then go for it if not consider all the parameters and try some other ways to do it.