Tesla on Monday touted record second quarter production numbers for the Model 3 alongside continued strong output of the more expensive Model S and Model X. For the final week of June, Tesla says it produced 5,031 Model 3 and 1,913 Model S and Model X vehicles.

That's in line with the goal the company set for itself at the start of the year to produce 5,000 Model 3 vehicles per week by the end of June. Tesla's stock is up about three percent in the wake of the announcement.

For the second calendar quarter, Tesla says it produced a total of 28,578 Model 3 cars—almost triple the 9,766 it produced in the first quarter and vastly more than it produced last year. Meanwhile, production of Model S and X vehicles were flat at 24,761, slightly higher than last quarter but below the 28,320 vehicles Tesla manufactured in the fourth quarter of 2017.

Tesla averaged almost 2,200 Model 3 cars per week during the second quarter. The company says it was producing 5,000 cars per week by the end of the quarter, and it expects to reach 6,000 cars per week by late August. This suggests there's room for Tesla to more than double Model 3 output next quarter.

Perhaps of greatest importance to Wall Street, Tesla says that it will enjoy positive cash flow and positive net income in the third quarter of 2018. That would be the first quarterly profit in two years and one of only a handful of quarters the company has achieved a profit in its entire history.

It would also be consistent with Tesla's historical pattern. With each of Tesla's two previous vehicles—the Model S and the Model X—Tesla lost money for several back-to-back quarters as it ramped up its production efforts. Once the cars were being produced in volume, Tesla briefly enjoyed profits—until the company began production on the next model and the cycle of losses started over again.

The Model 3 is intended to be a much higher-volume product than the Model S or Model X. That meant much bigger losses over the last two years, but it also potentially means much larger cash flow and profits in the coming months.

In an internal email announcing layoffs last month, Elon Musk wrote that Tesla needs to become "sustainably profitable" in order to achieve its goal of accelerating the transition to clean energy technologies. If all goes well, the scale of Model 3 production could make that possible, producing consistent profits that Musk can then plow into forthcoming projects like the Semi, the Model Y, and the new version of Tesla's high-end Roadster sports car—thereby avoiding the huge cash flow swings of the last few years.

But Musk might also follow the same pattern as the last few product cycles: as soon as he has demonstrated that the Model 3 can produce profits for a couple of quarters, he may start spending even more heavily in order to lay the foundation for even further growth. After all, Musk's compensation is tied to achieving big gains in Tesla's profits and market valuation over the next decade. Hitting the most ambitious targets will require the company to grow rapidly for years to come.