The S&P 500 is in the red so far in 2022, with the index down 11.3% this year. But investors shouldn't forget that the stock market has been an ideal place to grow one's wealth in the long run. This is evident from the 198% growth in the S&P 500 over the past decade. That's why now looks like a good time for savvy investors to take advantage of the stock market's weak performance in 2022 to add some solid companies to their portfolios for the long run.

Tesla (TSLA -2.76%) and Micron Technology (MU 0.10%) are two such technology stocks that could soar impressively over the next decade thanks to secular growth opportunities. Let's look at the reasons why these companies are worth buying now and holding on to for the next 10 years.

1. Tesla

Electric vehicle (EV) maker Tesla has been a big winner on the stock market over the past decade, with shares rising by a whopping 14,620%. The Elon Musk-led company looks capable of sustaining its impressive run over the next decade as well thanks to the efforts it is undertaking to make the most of the global EV opportunity.

Tesla is laser-focused on expanding its manufacturing capacity. The company recently shipped its 3 millionth vehicle, with the Shanghai plant alone making more than 1 million EVs. Tesla's first EV went into regular production in 2008, so the company has taken its own sweet time to hit the milestone of 3 million cars.

However, it now looks well-positioned to grow its sales at a nice clip. Last month Tesla reported that it has produced 1.1 million cars in the trailing 12 months. It is now capable of producing 2 million cars a year, which is double its capacity in the second quarter of 2021.

The company has set an ambitious target of selling 20 million EVs a year by 2030, indicating that it will continue to aggressively expand its manufacturing footprint to make the most of the growing adoption of EVs. For instance, Tesla's Berlin factory is expected to hit a peak production capacity of 500,000 vehicles annually, compared to the current capacity of 250,000.

Tesla delivered 936,000 EVs last year, so it still has a long way to go to achieve the target it has set for itself by the end of the decade. However, the company plans to clock an annual delivery growth rate of 50% over the long run, and the rapid expansion of its manufacturing capacity indicates that it is moving in the right direction.

With the market for battery-powered electric vehicles expected to hit annual revenue of $212 billion by 2030 from $53 billion last year, Tesla seems to be pulling the right strings to boost sales. Not surprisingly, analysts expect 45% annual earnings-per-share growth from the company.

That's why investors looking to buy a growth stock for the long haul should consider going long Tesla right now, even though it is on the expensive side. Tesla stock trades at nearly 110 times trailing earnings, but the forward earnings multiple of 77 points toward bottom-line growth. While the valuation is rich, Tesla stock's pullback means that it is trading at a relatively attractive multiple.

The stock was trading at 343 times earnings last year. In 2020, Tesla had a price-to-earnings ratio of 1,341. Given the company's projected earnings growth, now looks like a good time to buy this EV play before it becomes more expensive.

2. Micron Technology

Micron Technology stock is down 33% in 2022 so far, but the memory specialist has been a solid investment over the years. Shares of the chipmaker have soared close to 860% in the past decade despite the memory boom and bust cycles that have impacted its financial performance along the way.

Micron's near-term prospects are gloomy. Weak demand and lower prices of memory chips used in computers, smartphones, and data centers mean that the chipmaker's top and bottom lines are on track to contract significantly. Analysts expect the company's top line to contract 19% in fiscal 2023 (which begins next month) to $25 billion, while earnings are expected to drop 40% to $4.96 per share.

However, investors should focus on the bigger picture, as the demand for memory chips should ideally explode in the long run thanks to the data boom. From data centers to 5G smartphones to connected vehicles to the Internet of Things (IoT), there are multiple reasons why the cloud storage market is expected to grow at an annual pace of 24% through the end of the decade.

Micron itself estimates that global data creation is going to more than double in the next four years. As a result, the demand for the DRAM (dynamic random access memory) and NAND flash chips that Micron sells should increase in the long run. The chipmaker forecasts an addressable revenue opportunity worth $330 billion in 2030, compared to $161 billion last year.

At the same time, memory manufacturers have been reducing their outlays on equipment spending. Micron points out that industry players were spending 57% of their earnings before interest, taxes, depreciation, and amortization (EBITDA) on capital equipment in 2011. That figure came down to 30% in 2021. And as memory prices are now on the decline, chipmakers have decided to further rein in their outlay.

SK Hynix, for instance, is expected to reduce its 2023 capital expenditure by 25% to $12.2 billion. The lower capital outlay along with secular growth in demand should support memory prices in the long run. As such, Micron should be able to overcome the near-term weakness and regain its mojo in the future once the demand-supply dynamics improve, and that could help the stock deliver impressive upside over the next decade as it has in the past one.