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

[BUG] adding a "required bundle" throws an error during build even if its used #6018

Closed
derek-ho opened this issue Mar 4, 2024 · 4 comments · Fixed by #6030
Closed

[BUG] adding a "required bundle" throws an error during build even if its used #6018

derek-ho opened this issue Mar 4, 2024 · 4 comments · Fixed by #6030
Assignees
Labels
bug Something isn't working multiple datasource multiple datasource project v2.13.0

Comments

@derek-ho
Copy link
Contributor

derek-ho commented Mar 4, 2024

Describe the bug

Adding "dataSourceManagement" as a required bundle throws an error during building.

 ERROR in /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/OpenSearch-Dashboards/plugins/security-dashboards-plugin/opensearch_dashboards.json
         │          Bundle for [securityDashboards] lists [dataSourceManagement] as a required bundle, but does not use it. 

Even if I use it. Found a similar issue reported here: https://discuss.elastic.co/t/build-error-when-using-kibanareact-and-kibanautils-in-kibana-3rd-party-plugin/261748/3

To Reproduce
Steps to reproduce the behavior:

  1. Add "dataSourceManagement" as a required bundle
  2. Use it
  3. run yarn build
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

OpenSearch Version
Please list the version of OpenSearch being used.

Dashboards Version
Please list the version of OpenSearch Dashboards being used.

Plugins

Please list all plugins currently enabled.

Screenshots

If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Browser and version [e.g. 22]

Additional context

Add any other context about the problem here.

@derek-ho derek-ho added bug Something isn't working untriaged labels Mar 4, 2024
@derek-ho derek-ho changed the title [BUG] [BUG] adding a "required bundle" throws an error during build even if its used Mar 4, 2024
@derek-ho
Copy link
Contributor Author

derek-ho commented Mar 4, 2024

If I remove it from the "requiredBundles" it throws a different error:

ERROR webpack compile errors
   │ERROR [securityDashboards] build
       │ERROR Optimizations failure.
       │         171 modules
       │          
       │          ERROR in ./public/apps/account/cluster-selector.tsx
       │          Module not found: Error: import [../../../../../src/plugins/data_source_management/public] references a public export of the [dataSourceManagement] bundle, but that bundle is not in the "requiredPlugins" or "requiredBundles" list in the plugin manifest [/home/runner/work/security-dashboards-plugin/security-dashboards-plugin/OpenSearch-Dashboards/plugins/security-dashboards-plugin/opensearch_dashboards.json]
       │           @ ./public/apps/account/cluster-selector.tsx 18:0-91 29:58-73
       │           @ ./public/plugin.ts
       │           @ ./public/index.ts
       │           @ /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/OpenSearch-Dashboards/packages/osd-optimizer/target/worker/entry_point_creator.js

@BionIT
Copy link
Collaborator

BionIT commented Mar 4, 2024

Hi @derek-ho, can you share how it is added to the opensearch_dashboards.json file?

@derek-ho
Copy link
Contributor Author

derek-ho commented Mar 4, 2024

Adding it like this:

...
  "optionalPlugins": [
    "managementOverview",
    "dataSource"
  ],
  "requiredBundles": ["dataSourceManagement"],
....

@BionIT
Copy link
Collaborator

BionIT commented Mar 5, 2024

Thanks @derek-ho ! After some investigation, we found requiredBundle is only for built-in osd plugins to share modules, and for external plugins, we need to consume with optionalPlugins: ["dataSourceManagement"] - yarn build is successful after making this change, but node scripts/build_opensearch_dashboards_platform_plugins.js failed due to OSD complains about the plugin imports a bundle which is not from requiredBundle nor required plugin. To move forward, we can expose the react component as function by the data source plugin similar to https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/data/public/plugin.ts#L249, thanks to @ashwin-pc for the suggestion! It works locally, and will create a PR to export the component this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working multiple datasource multiple datasource project v2.13.0
Projects
None yet
2 participants