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

Plugin development: imports are confusing #3011

Open
mgalesloot opened this issue Mar 23, 2025 · 0 comments
Open

Plugin development: imports are confusing #3011

mgalesloot opened this issue Mar 23, 2025 · 0 comments
Labels
bug Something isn't working headlamp-plugin Related to the headlamp-plugin NPM package.

Comments

@mgalesloot
Copy link

mgalesloot commented Mar 23, 2025

Describe the bug

Plugin development: imports are confusing

Third party imports

  • Use the tsconfig.json as generated by @kinvolk/headlamp-plugin upgrade
  • In tsconfig compilerOptions set "strict" to true.
  • Run npm run tsc
  • Result: errors on import of third party lib such as MUI.
  • Now set compilerOptions.paths to {} and run tsc again
  • Result: no errors MUI imports.

I think it is the wildcard path "*" which is causing this issue. I have put this path to [''] in tsconfig as a workaround.

getAllowedNamespaces

In plugin development (e.g. Kubescape plugin) we use the method getAllowedNamespaces.
Visual Code suggests the import address for this method is '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster';
On running the app this gives an error: getAllowedNamespace is undefined.

After changing the import to '@kinvolk/headlamp-plugin/lib/k8s/cluster' (one lib, not two) the app works fine. Changing k8s to uppercase does not help.

Adding the following line to compilerOptions in the plugin tsconfig.json fixes the issue.

"@kinvolk/headlamp-plugin/lib/k8s/*": [
        "node_modules/@kinvolk/headlamp-plugin/lib/lib/k8s/*/index.d.ts",
        "node_modules/@kinvolk/headlamp-plugin/lib/lib/k8s/*.d.ts"
      ]

Environment

  • latest headlamp from main
  • headlamp in cluster v0.28

Are you able to fix this issue?

No

@mgalesloot mgalesloot added the bug Something isn't working label Mar 23, 2025
@dosubot dosubot bot added the headlamp-plugin Related to the headlamp-plugin NPM package. label Mar 23, 2025
@mgalesloot mgalesloot changed the title Plugin development: getAllowedNamespaces() import error Plugin development: import getAllowedNamespaces() is confusing Mar 23, 2025
@mgalesloot mgalesloot changed the title Plugin development: import getAllowedNamespaces() is confusing Plugin development: imports are confusing Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working headlamp-plugin Related to the headlamp-plugin NPM package.
Projects
Development

No branches or pull requests

1 participant