What a difference one year -- and some major government policies -- can make. In 2017, shares of SunPower (NASDAQ:SPWR)Canadian Solar Inc. (NASDAQ:CSIQ)JinkoSolar Holding Co., Ltd. (NYSE:JKS), and First Solar, Inc. (NASDAQ:FSLR) investors enjoyed solid gains of 28%, 38%, 58% and 110% respectively. 

But alas, 2018 hasn't worked out quite so well for these four solar panel manufacturers, which -- along with other panel-making peers -- have struggled following U.S. and Chinese government actions that have seriously impacted the industry. While a handful of other companies have seen their prospects improve this year, panel makers have struggled mightily. 

Dusty solar panel with clean me please written in the dirt.

Image source: Getty Images.

Let's take a closer look at what's happening. As much as solar panel makers have struggled this year, their long-term prospects could be better than you think. 

More tariffs, fewer incentives taking a big bite out of solar demand

That's more or less been the story of solar in 2018. And that's precisely why the worst-performing solar stocks this year have been solar panel and panel component manufacturers:

SPWR Chart

SPWR price change. Data source: YCharts.

I've added the performance of the S&P 500 and the MAC Global Solar Index to the chart above, for context. In short, the market itself has had a relatively decent year. Though it's not on the same pace as recent years, U.S. stocks are on track to generate a solid positive return for investors. The solar industry, however, isn't having a good year, largely because of the impact of U.S. trade actions and more recently China's reduction in domestic solar incentives

Starting in early 2018, the Trump administration enacted tariffs on imported solar cells and modules, starting at a 30% rate this year, and falling by 5 percentage points each year for the next four years. Since the bulk of global solar cells and modules are manufactured outside of the U.S., this immediately raised prices for solar installs, and by a substantial amount. 

And while this was taking a big bite out of the U.S. solar industry -- some estimates were for more than 10,000 domestic solar installers and service personnel to lose their jobs this year -- there have also been signs that manufacturers are adapting, with JinkoSolar even saying it would build a U.S. manufacturing plant

But fast-forward from the U.S. tariffs in January to the June announcement by China, and the industry got a double-whammy that even First Solar, whose proprietary thin-film panels were exempt from the tariffs on silicon cells and modules, felt the impact

The rest of 2018 looks to be pretty ugly

Tremors from China's decision to slash domestic solar incentives are going to be felt throughout the industry, and on a global basis. As one of the biggest solar markets in the world, this move created a massive oversupply of panel capacity essentially overnight, something that's going to push panel prices down as manufacturers fight to move product.

That could help counteract U.S. tariffs, which would be great for U.S. customers looking to buy solar, and the installers like Vivint Solar (NYSE:VSLR) and Sunrun Inc (NASDAQ:RUN) (which have both been excellent performers this year, despite worries they would struggle with weak demand in a post-tariff world). 

RUN Chart

RUN  and VSLR price change. Data source: YCharts.

But it's likely to add even more pressure to panel makers, driving prices and margins even lower for the foreseeable future. 

Thinking -- and investing -- long-term 

The solar industry is likely to remain exposed to the risk of shifting government policies in the years ahead. After all, energy supply is something that every country's leaders feel an obligation to secure for their citizens, and reduced air pollution and lower carbon emissions are established goals for nearly every developed -- and many developing -- economies. 

The good news for investors is that the industry is also relatively mature, and in many markets, solar can generate electricity at a similar or even lower price than any other source. There's also an argument that, at this stage, the industry should be forced to compete without government incentives to "prop" up a for-profit industry, particularly now that it has become so well-established. Yet it's inevitable that governments will continue to play a role -- both to the positive and the detriment -- of the solar industry for many more years to come. 

And if you're looking for solid investments to make in solar that should perform well in the future, my top picks are two of the stocks that have been stinkers in 2018: First Solar and SunPower.

Both companies have strong track records of innovation and leadership in the industry, and command significant market share. First Solar has an incredibly strong balance sheet with over $3 billion in cash and investments versus $456 million in debt, and generated $1.1 billion in operating cash flow over the past year. SunPower doesn't have as strong a balance sheet, but has paid down over $700 million in debt the past two years, and has a strong backing partner in the energy giant Total, which owns a majority stake. 

It hasn't been a great year to own these two solar giants, but I'd expect investors who bought shares today and held for five years or more to come out well ahead. 

Jason Hall owns shares of First Solar and SunPower. The Motley Fool recommends First Solar. The Motley Fool has a disclosure policy.