Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PanelPlugin is not a constructor #20338

Closed
simPod opened this issue Nov 13, 2019 · 6 comments
Closed

PanelPlugin is not a constructor #20338

simPod opened this issue Nov 13, 2019 · 6 comments

Comments

@simPod
Copy link
Contributor

simPod commented Nov 13, 2019

I'm creating custom plugin. This is my module.tsx:

import { PanelPlugin } from '@grafana/ui';
import { Plugin } from './plugin';

export const plugin = new PanelPlugin(Plugin);

However, I'm getting

Error loading panel plugin: simpod-sankey-diagram-panel TypeError: grafana_ui__WEBPACK_IMPORTED_MODULE_0_.PanelPlugin is not a constructor

It worked with Grafana 6.3, now it's not. I checked the docs and it all seems to comply 🤔

Environment:

  • Grafana version: 6.4
  • OS Grafana is installed on: macos
  • "@grafana/toolkit": "^6.4.0-beta.2",
@ryantxu
Copy link
Member

ryantxu commented Nov 13, 2019

I am not sure what is happening -- in 6.5 (master/beta) you should be able to import from either grafana/ui or grafana/data

import { PanelPlugin } from '@grafana/ui';
  OR
import { PanelPlugin } from '@grafana/data';

is this a plugin that was built earlier, and is now not working? are you able to compile it against 6.4 or master?

@simPod
Copy link
Contributor Author

simPod commented Nov 13, 2019

Changing this helped, thanks

+ // @ts-ignore
+ import { PanelPlugin } from '@grafana/data';
- import { PanelPlugin } from '@grafana/ui';

But importing from @grafana/ui used to work properly 🤔 Also PanelPlugin export is not typed in @grafana/data

@ryantxu
Copy link
Member

ryantxu commented Nov 13, 2019

In 6.5+ it is moved to '@grafana/data' -- until 7.0, it will also be exported at runtime to panels under @grafana/ui. See this semi-hack https://github.com/grafana/grafana/blob/master/public/app/features/plugins/plugin_loader.ts#L42

@ryantxu
Copy link
Member

ryantxu commented Nov 13, 2019

I'll close this -- and think it works (with back compatibility) in 6.5+

reopen if there is something you think we can change moving forward (besides having a stable API!!!)

@WaleedNaveed
Copy link

@simPod how did you manage to run it with Grafana 6.3 ? I am working on Grafana 6.3.5 and facing issue with react plugin.

@simPod
Copy link
Contributor Author

simPod commented Feb 3, 2020

@WaleedNaveed sorry, I don't remember. I always use bleeding edge and Grafana 6.3 is old so I guess I have not tried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants