Beijing allowed Tesla to become the first foreign automaker allowed to manufacture in China without a local partner, and the Shanghai government helped foot some of the factory-building costs.