The market sell-off in 2022 has been brutal, but the longer you invest, the more you recognize that market corrections are opportunities. If you have more than 10 years until retirement, buying shares of strong companies while their stock prices are down has historically been a smart way to build wealth.

Investing $1,000 might not sound like a lot, but with compounding interest, it can snowball quickly by holding shares of a growing business. If you invest just $500 a month at the historical average annual return of the stock market of 10%, you would have $1.1 million after 30 years.

What follows are two companies that have bright futures. While they may not immediately go up in value, adding $500 to each this month could be a stepping stone toward great returns down the road.

Small businesses are leaning on Shopify to solve problems 

Shopify (SHOP -2.19%) started out more than a decade ago to help small merchants set up online storefronts to compete in an increasingly digital economy. It has grown tremendously. If you add up all the merchants that use the platform, Shopify would be the second-largest online retailer in the U.S. Its gross merchandise volume totaled $175 billion in 2021, up 47% over 2020. 

The company's goal is to be the central operating system for all businesses that use the platform. It offers management tools, including Shopify Capital, Shipping, and Payments, through a subscription plan. It also offers over 8,000 third-party apps through the Shopify app store.  

The stock has fallen 81% from its highs due to slowing e-commerce growth as more shoppers returned to in-store browsing over the last year. Just as the spike in growth during 2020 was not normal, investors shouldn't assume that Shopify's current slower rate of growth is the new norm, either. As they say, the truth is somewhere in between.

That said, Shopify posted a 16% year-over-year revenue increase in the second quarter. While that pales in comparison to the growth experienced last year, it's still solid in the context of the supply chain problems and inflation that small merchants are wrestling with right now. Looking at the long-term trend, Shopify's recent growth represents a three-year compound annual growth rate of 53%.

Merchants are turning to Shopify to solve problems, and one of those needs right now is shipping items. To accomplish this, Shopify put the finishing touches on the Shopify Fulfillment Network with the recent acquisition of Deliverr. This leading expert knows which fulfillment center to direct merchandise to after it arrives at the port.

With all the solutions it's bringing merchants, Shopify's management believes they are building a business that can last 100 years, if not longer. The e-commerce market is expected to grow to $7 trillion by 2025, according to eMarketer, providing Shopify a lot of runway to deliver growth and returns to shareholders. 

Dollar General is winning customers with unbeatable value

Dollar General (DG -0.18%) has proven its value to the consumer in this environment. People are seeking the store's $1 or less products amid the inflationary headwinds driving up prices for everyday goods. In the second quarter, Dollar General reported a 4.6% increase in same-store sales, driven by a slight increase in traffic. 

The company is delivering savings to shoppers while showing it can hold the line on costs and produce a respectable profit, which many companies are struggling to do this year. Dollar General reported a 10.8% increase in earnings per share over the year-ago quarter. 

Solid business performance pushed the stock up 4% year to date, which significantly outperforms the rest of the market. Investors no doubt like the efforts by Dollar General to keep prices down as inventory costs rise, including investments in its own private transportation fleet, improvements to distribution, and the rollout of self-checkout across 11,000 stores this year. These improvements should yield reduced costs and more time for employees to serve customers.

Management expects to report full-year earnings growth of approximately 12% to 14%. Even excluding the benefit of an extra week in the year, compared to 2021, earnings per share should still increase by at least 8%. Those numbers make the stock an excellent defensive holding for the near term while positioning investors for compounding gains over the long term.