873ec033fe
The plugin was importing from internal Headlamp paths like '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster' instead of using the official public API '@kinvolk/headlamp-plugin/lib'. This caused the plugin to fail loading in the browser with: "TypeError: undefined is not an object (evaluating 'Ot.KubeObject')" Changes: - Updated imports to use K8s.cluster and ApiProxy from main export - Added vite.config.js with custom globals (now obsolete with this fix) - Moved node-forge to dependencies for proper bundling The plugin now uses only the official documented Headlamp plugin API. Fixes: #[issue number if exists] Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
29 lines
940 B
JavaScript
29 lines
940 B
JavaScript
import { defineConfig, mergeConfig } from 'vite';
|
|
import baseConfig from '@kinvolk/headlamp-plugin/config/vite.config.mjs';
|
|
|
|
// Override the base config to add missing externals
|
|
export default mergeConfig(baseConfig, defineConfig({
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
globals: (request) => {
|
|
// Add the missing /lib/lib/k8s/* mappings
|
|
if (request === '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster') {
|
|
return 'pluginLib.libk8scluster';
|
|
}
|
|
if (request === '@kinvolk/headlamp-plugin/lib/lib/k8s/apiProxy') {
|
|
return 'pluginLib.libk8sapiProxy';
|
|
}
|
|
|
|
// Use base config's globals function for everything else
|
|
if (typeof baseConfig.build.rollupOptions.output.globals === 'function') {
|
|
return baseConfig.build.rollupOptions.output.globals(request);
|
|
}
|
|
|
|
return request;
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}));
|