https://answers.yahoo.com/question/index?qid=20080401174600A...
I'd wager a guess that you'd be looking at well north of $30k for putting in a brand new engine in a Tesla-bracket BMW of semi-recent vintage.
I think right now it’s 13k? So maybe a tad more than a BMW engine but falling fast.
I buy and sell cars as a side gig, and there are plenty of models which people like me would not touch with a barge pole because of issues like this - many of them German - and you'll find many for sale as spares or repairs, and find that secondhand engine supply is low (as many have blown up), and therefore expensive. Look at a diesel vauxhall insignia, for instance. Hand grenade engine, no chance of getting one secondhand (and even if it did, its got the pin pulled).
And batteries which are thermally managed (ie anything but an old leaf) will have a better lifetime than a typical ICE engine -tesla easily achieve 300k miles with less than 10% range loss.