The rise of Amazon.com has sparked an evolution in big-box retailers. Retailers' have shifted strategies to defend their turf. It's paying off for some; others less so.

Both Walmart and Costco have made bold but different moves that are succeeding in retail's modern competitive landscape. Let's look at the opportunities from an investing point of view while comparing these two stocks head-to-head.

Walmart is reinventing itself with digital strategies

As the world's largest private sector employer and biggest retailer, Walmart (WMT 0.57%) is an absolute titan. But being big isn't always better. 

Sales growth is challenging at Walmart's size. Trailing-12-month revenue was more than $500 billion, but it was up only 2%. Further, that growth has been in the low single digits for the last several years, with a 1% decline in 2016. The brick-and-mortar stores remain Walmart's major source of revenue, and they continue to show small positive sales growth, essentially treading water.

But Walmart is changing up its business mix in response to Amazon.com, Costco (COST -0.12%), and others. In Walmart's third-quarter fiscal 2020 earnings report, e-commerce showed a 41% increase year over year. The company's e-commerce approach is working.

Blurred photo of big box grocery area

Image source: Getty Images.

Leveraging its brick-and-mortar stores in conjunction with online shopping, Walmart has moved aggressively into the grocery business. In September, it expanded its "unlimited" grocery delivery service nationwide, charging $98 annually or $12.95 a month.

A positive response to the omnichannel grocery plan is fueling segment expansion. In fiscal 2020, management plans to build out to 3,100 grocery pickup locations and 1,600 grocery delivery locations.

One of Walmart's biggest challenges all year has been the U.S.-China trade war. Margins for anything sourced from China have become thinner and thinner. The current truce is a relief, but that could break down at any time.

Looking to the full year, Walmart now expects adjusted earnings per share to increase slightly compared with last year.

Costco's push into China is a game changer.

Costco is the leader in the membership warehouse business, offering members savings across virtually every category of consumer goods, from snow tires to baby food. 

Earnings have grown impressively -- by an average of 22% year over year over three quarters. Analysts see earnings rising 5% in fiscal 2020 and 8% in 2021.

The company's report for the quarter including October showed comparable-store sales growth of 5.1% -- in line with estimates.

Costco can offer great discounts because it essentially breaks even on actual sales. Virtually all of its earnings are based on membership fees, so increasing its customer base is the company's focus. The average store has 68,000 members.

The stock has rebounded strongly from a slump in 2016 largely due to optimism surrounding future warehouse clubs in China, a market that could drive huge growth. 

In August, the first Costco opened in Shanghai and was immediately swamped with enthusiastic customers. That store has already signed up more than 200,000 members. "Clearly, [the opening] surpassed all of our very high expectations," CFO Richard Galanti said.

More stores in China are planned, but management wants to move deliberately in capitalizing on demand. The next opening is planned for early 2021 in the Pudong area of Shanghai.

And the better buy is...

Walmart has worked hard to compete with Amazon, but the result so far has Walmart treading water in terms of sales and earnings growth.

Management has pivoted its strategy to build attractive omnichannel offerings, but it will take time to see rewards. The company projects losses of over $1 billion this year for the U.S. e-commerce division.

Costco doesn't provide financial guidance, but we can draw some educated conclusions. Analysts see earnings growth cooling, but also predict better earnings growth prospects than Walmart. On sales, Costco looks to have more going for it.

Further, Costco had a massive opening in China, where the future looks very promising. Selling memberships to a club that can meet or beat Walmart's prices gives Costco a great value proposition. 

Though both retailers expect a great holiday season and will likely perform well, Costco has the edge from an investing point of view and is the better buy.