Grocery store openings declined 29 percent last year as expansion plans cooled and some supermarkets prepared to file for bankruptcy in the year Amazon acquired Whole Foods, according to a new report from Jones Lang LaSalle.

But investments in grocery-anchored shopping centers in 2017 climbed 5.3 percent from 2016, JLL found, making it one of the only retail sectors to see deal growth in a year of low transaction volume.

"Traditionally, retail has such a reputation right now of everybody being afraid of disruption by e-commerce," James Cook, JLL's director of retail research in the Americas, told CNBC. "Grocery is considered to have a moat around it to defend against e-commerce, and because of that, these [assets] are seen by retail property investors as a safe investment."

To be sure, these investors aren't interested in all grocery-anchored centers, Cook cautioned. Just this month, for example, Williamsville, New York-based Tops Friendly Markets filed for bankruptcy, and reports surfaced that Winn-Dixie owner Bi-Lo was preparing to do so, too. There's a glut of shopping centers built around weak tenants that risk going dark, just like many malls anchored by weak department stores.

"In many U.S. markets you might have six or more grocery chains," Cook said. "In most cases, investors are only interested in the top one or two. Those are the most defensible."

The short list for those top grocery contenders include Whole Foods, Trader Joe's, Florida-based Publix, Wegmans and some of Kroger's brands. And for the most part today, these chains are opening few new stores. Instead, they are investing in their existing locations to fulfill online orders and ease the delivery of groceries to homes.

The strongest U.S. markets for grocery stores, where the most businesses continue to expand, include California, Virginia and North Carolina, according to JLL. Texas, although it's still a top market for grocers, added fewer stores in 2017 than in 2016. The growth in that state has stemmed from a spurt of new residential development. Where there are homes, people need more grocery stores.

Source: Jones Lang LaSalle

"Retailers die but retail does not," Cook said about the ongoing evolution in the grocery space. "There's just churn as retailers are either disrupted by new business models, or they go out of fashion."

Germany-based Lidl was one new player in the U.S. grocery market that everyone had their eyes on in 2017, when it began opening stores across the Southeast. Shortly thereafter, Lidl halted several of its construction projects, local news outlets have reported, as the company admitted it might have started expanding too quickly. Lidl opened nearly 50 stores across the U.S. last year.

In turn, Lidl offered other supermarket chains a warning sign: Many markets weren't ready for another grocer in town. The German company also had to fix a few snags internally. It's still working out its private-label items, its layout of U.S. stores and its marketing strategy for American consumers.

The most successful grocers today have well-known private labels, fresh food at affordable prices and digital platforms that allow for shopping online, Cook said.

"We've got two types of classes in grocery right now: One is about offering the best goods at the lowest prices — it's a price play that's targeted at the families in America shopping on a budget, so someone like Aldi is a part of that," he said. "Another avenue of success is offering a great shopping experience to shoppers who aren't as price sensitive — those leaders are Whole foods and Wegmans."