For years, one aspect of Tesla Inc.’s business has been growing outside the public eye, its revenue soaring even as the company’s electric car sales sputtered and stalled.