J.M. Smucker and Mondelez are the food companies worst positioned to compete with Amazon when it comes to selling their packaged foods online, according to a research note from Bernstein.

Amazon has been disrupting retail ever since it only sold books. Now the e-commerce giant is poised to take market share from the giants of the consumer packaged goods industry as more Americans start shopping for food online. Bernstein estimates that e-commerce represents only about 1 percent of U.S. packaged food sales, but that the could grow to 5 or 6 percent in the coming years.

Ever since it acquired Whole Foods in 2017, Amazon has been promoting the grocery store's private label brand online, in addition to its private label lines. It has also changed its website to feature its brands more prominently as it experiments with what private label products are selling well.

"While we expect private label shelf space to normalize over time as Amazon separates winners from losers, we continue to believe that Amazon's private label could pose a meaningful threat to branded food manufacturers, especially as its 365 Everyday Value Brand is already highly credible with consumers," Bernstein analyst Alexia Howard wrote in the note.

McCormick took the top spot in Bernstein's rankings because of its strong online presence and the overall strength of the seasoning category. Seasoning is one of the most profitable food categories, according to the note, because salt and pepper are light weight — saving on shipping costs — but still priced relatively high per unit.

By its estimates, chocolate is another highly profitable category, helping Hershey take the second spot in the rankings. Bernstein also noted that the company has invested heavily in digital strategies.

Smucker's, which owns Folgers Coffee and distributes Dunkin' Donuts coffee, is the worst positioned because rivals are doing a better job of hawking their wares online, Bernstein said. Mondelez ranked second-worst, with Bernstein saying that the company under-indexes its cookie brands like Oreo and Chips Ahoy online.

Kellogg, General Mills, Kraft Heinz and Campbell Soup landed in the middle of Bernstein's rankings.

Many food companies have argued that shifting to selling online hasn't been affecting their margins, but Howard says that can't be true. To keep up with the shift to e-commerce, brands have to sell more of their products in bulk, list sponsored products and participate in Amazon programs like Prime Pantry.

Some companies are also teaming up with the e-commerce giant to launch exclusive brands available only on Amazon. Equal, the sweetener brand, announced a partnership with Amazon on Monday to develop an exclusive line of sugar substitutes.

WATCH: How Amazon's Whole Foods deal will change the US grocery business