Build error when using `kibanaReact` and `kibanaUtils` in kibana 3rd party plugin

Hello,

I'm trying to use kibanaReact and kibanaUtils in my kibana plugin.
These 2 plugins added as requiredBundles in the kibana.json,

...
"requiredBundles": ["kibanaUtils", "kibanaReact"]
...

But error keep happens when run yarn build

Bundle for [testPlugin] lists [kibanaUtils, kibanaReact] as a required bundle, but does not use it. Please remove it.

Could you help me about this?
Thank you very much~

Are you actually using these? So, is there code in your plugin actually importing something from these plugins?

Yes, I'm using toMountPoint from import { toMountPoint } from '../../../../src/plugins/kibana_react/public'; and using Storage from import { Storage } from '../../../../src/plugins/kibana_utils/public';.

For example,

import { Storage } from '../../../../src/plugins/kibana_utils/public';

const local = new Storage(window.sessionStorage);
console.log(local);

Are the files where you use it part of the main entrypoint? What I mean is there a series of imports connecting these files to the main public/index.ts file of your plugin?

Nope, I'm using it in public/application.tsx

Please check this repo:

I also checked some example in x-pack, for example, monitoring:


It doesn't load import anything in public/index.ts.

Loading it in application.ts should be fine. I wrote

What I mean is there a series of imports connecting these files to the main public/index.ts file of your plugin?

In your plugin index.ts imports plugin.ts which imports application.ts - that's what I was talking about. Is there a series of imports connecting your usage of kibana utils to index.ts. As that's the case, the problem has to be somewhere else, I'm looking into the issue.

Thanks, that's helpful. I reached out to the team managing the build process to confirm, but it looks like for 3rd party plugins you simply can't use the requiredBundles setting - simply omit it and the build should work.

This is a special setting for sharing bundles for the built-in plugins and it's not relevant for custom plugins.

If there's more info I will update this thread.

Thanks for your kindly helping, that's solve me a lot time.
:grinning:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.