As software developers, everything we build will be obsolete, discarded or dead in 5-10 years. We are craftsmen of the ephemeral.
If ephemeral codebases bother you, work on projects that will last longer. Things I expect will outlive us: Chrome, PostgreSQL, SQLite, LLVM, Linux/Windows/MacOS, Unity, Nodejs, Nginx.
I have a few small contributions in chromium and nodejs. There's something really delightful about looking at a strangers' laptop and knowing some of my code is in their machine.
It is precisely due to my varied experience that I can point this out: the vast majority of startups and tech is dust in the wind.