grafana / grafana/plugin-tools

Bug: Lazily loading dependencies does not function properly in App with nested plugins

Open
#2,172 2 comments 0 reactions 0 assignees View on GitHub
no stalebot
Dominant language
TypeScript
Stars
89
Forks
57
Avg merge
3d 17h
Merged PRs (30d)
37

Description

### Which package(s) does this bug affect?

- [x] Create Plugin
- [ ] Sign Plugin
- [ ] Plugin E2E
- [ ] Plugin Meta Extractor
- [ ] Plugin ESLint Rules

### Package versions

```shell
create-plugin@5.26.9
```

### What happened?

We scaffolded an app plugin that has a panel plugin located within a panel folder in the plugin (nesting two different plugins). When the panel tries to lazily load dependencies it try to fetch them from the following path:

`GET /public/plugins/grafana-medtech-panel`

But with the current build config the vendor dependencies are placed in the `dist` folder of the root app plugin. So if I change the path to:

`GET /public/plugins/grafana-medtech-app`

I can fetch the dependency successfully. I guess in this edge case we should try to fetch all lazily loaded plugins from the root plugin path instead of the path of the nested plugin.

### What you expected to happen

It should load all dependencies successfully. I'm not sure what the right call is here.

I guess we have two options:

1. Make sure that for nested plugins we try to fetch all dependencies from the root plugin path.
2. When building a plugin with nested plugins in it: emit the dependencies in the nested plugin's path.

### How to reproduce it (as minimally and precisely as possible)

1. Clone this repo and use the linked commit: https://github.com/hugohaggmark/grafana-medtech-app/tree/e275a66120bd56a56896af55db14c2be1b44cbac
2. npm i && mage -v
3. npm run dev
4. docker compose up
5. Go into the provisioned dashboard and check the network tab.

### Environment

```shell
n/a
```

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.