Problem creating new React panel

Received “Error loading panel plugin my-new-panel: TypeError: grafana_data__WEBPACK_IMPORTED_MODULE_0_.PanelPlugin is not a constructor”.

I created a new panel using npx @grafana/toolkit plugin:create. I have not modified it in any way, just loaded it into my grafana dev enviroment, which points to my company’s fork of Grafana. This eem to point to grafana 6.4.0-pre. The import statement on PanelPlugin already pointed to data. I tried changing it to ui, since this is an older fork. That also did not work.

Thoughts?

It looks to me like SystemJS is not getting called with the correct path from custom.ini, even though the panel is picked up well enough that I can select it as a visualization (what I see in Chrome debug is “plugins/mycompany-custom-panel/module”).

It seems to me like there are not any people on the Grafana team answering these types of questions. If you want people to use your framework, you are going to have to either get the product to a level where it works without extensive assistance, or help people through these types of issues. I say that as someone who has answered more questions than I have seen you guys answering.

Just as a further note, I tried setting app_mode to “development” in custom.ini, and bra run failed to start the server.

Since there is so little help here for people encountering these issues, I am going to try to document what I’m finding in case it helps the next person. It looks like that path is correct, even though you don’t see anything there when you go look at the directory structure. This is apparently what is meant when they say they “mount” the dist directory in your plugin folder.

From the “Page” tab in “Sources” in Chrome Dev tools
image

I still have not figured out the error, but at least I’m starting to get a clearer picture of what’s not wrong.

1 Like

I edited the example plugin to check to see if the Grafana supporting libraries are loaded

This traces out
image

So that seems to me to say that the plugin is loaded in such a way that it doesn’t have access to the grafana code that was previously loaded. Little help here?

In the interest of eliminating the external path, I tried moving my plugin to the default location and commenting out the custom plugin path. Same result.

This works from the current version of Grafana. Not sure whether the problem is the fork is old or the changes our team in another country made.