This isn’t such a problem with high end brands. I have a specialized ebike and am fairly sure I’ll get 5-10 years out of it. Only concern is the motor.
What I do hope is that otherwise good bikes and their parts don't become un-salvagable because someone can't find a wiring diagram or something like that. I hope that like with conventional bikes, a cottage industry arises that shares information and recycles out-of-fashion bikes into usable vehicles for the rest of us. What do they do with old bikes in India or Africa? That's what I want to see. I don't feel bad if that 5-10 years is followed by a decent life in someone else's hands.