headlamp
headlamp copied to clipboard
Headlamp as an npm package
Current situation
Currently it's not an package.
Impact
- reusing code from plugins is harder without a package
- being on npm website provides more visibility
- starting headlamp is harder for npm/npx users.
npx "@kinvolk/headlamp"
could be convenient (npx headlamp
perhaps more so).
Implementation options
Splitting out components into a separate library is fairly time consuming. Being able to import headlamp packages in plugins before this happens would be useful.
import X from '@kinvolk/headlamp/components/common';
import Y from '@kinvolk/headlamp/lib/k8s/cluster';
This doesn't stop components being split out at a later date. After separation of components into a shared library the import paths within headlamp could continue to exist where they are now.
Related to https://github.com/kinvolk/headlamp/issues/151
Hey @illume , please see my comments below:
- reusing code from plugins is harder without a package
That's right, and splitting out Headlamp's components into a library is a bit complex at the moment. Besides, even though the use of Headlamp as a lib would help make things a bit more clear in the development, Headlamp is not supposed to be a library in the sense that plugins will run within it, and therefore we should treat it as an external dependency on webpack at least. So IMO if there's a way for us to refer to the headlamp codebase through a regular import, but not having the whole code as a library in NPM, it'd be the way to go. Maybe there's some webpack magic to make this happen.
If my proposal cannot work without having at least files describing the API, then we can make that library.
- being on npm website provides more visibility
We have https://www.npmjs.com/package/@kinvolk/headlamp-plugin . I'd say it's nice to have things in NPM but it's not crucial for the success of the project.
- starting headlamp is harder for npm/npx users. npx "@kinvolk/headlamp" could be convenient (npx headlamp perhaps more so).
I don't think having a binary of Headlamp to run in npx is a big advantage and will bring some complexity about shipping the server for the right platform. We already have binaries for the 3 big platforms, so if we add a way to load the plugins, it should be fine for the plugin development without adding yet another maintenance burden.