1997 GMC JImmy - replace engine?

Hi- Our engine developed a terminal problem at 142,000 miles. Over the past couple years, it’s gotten new tires, ball joints, fuel pump, brakes, and some other things – so we’d like to keep it going. And buying a newer car doesn’t work well with the family budget right now. Would it be advisable to have a rebuilt engine installed? Our mechanic doesn’t advise it but I trust him to do a very good job installing a new engine. Thanks.