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

plugins: Migrate plugins to vite #2001

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@
"../app/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
"prettier --config package.json --write"
],
"../plugins/headlamp-plugin/{bin,lib,template}/**/*.{ts,tsx}": [
"../plugins/headlamp-plugin/{bin,lib}/**/*.{ts,tsx}": [
"eslint -c package.json --fix"
],
"../plugins/headlamp-plugin/{bin,lib,template}/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
"../plugins/headlamp-plugin/{bin,lib}/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
"prettier --config package.json --write"
],
"../plugins/examples/**/*.{ts,tsx}": [
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export async function fetchAndExecutePlugins(
// Execute plugins inside a context (not in global/window)
(function (str: string) {
try {
const result = eval(str);
const result = eval(str + `\n//# sourceURL=main.js`);
return result;
} catch (e) {
// We just continue if there is an error.
Expand Down
6 changes: 3 additions & 3 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export default defineConfig({
cors: true,
},
plugins: [
nodePolyfills({
include: ['process', 'buffer', 'stream'],
}),
svgr({
svgrOptions: {
prettier: false,
Expand All @@ -34,9 +37,6 @@ export default defineConfig({
},
}),
react(),
nodePolyfills({
include: ['process', 'buffer', 'stream'],
}),
],
test: {
globals: true,
Expand Down
27 changes: 20 additions & 7 deletions plugins/examples/dynamic-clusters/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions plugins/examples/dynamic-clusters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,11 @@
},
"devDependencies": {
"@kinvolk/headlamp-plugin": "^0.9.2"
},
"dependencies": {
"js-yaml": "^4.1.0"
},
"overrides": {
"domain-browser": "npm:dry-uninstall"
}
}
2 changes: 1 addition & 1 deletion plugins/examples/dynamic-clusters/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function ClusterCreationButton() {
const isValidKubeconfig = (base64Kubeconfig: string): string | null => {
try {
// Decode the base64-encoded kubeconfig
const kubeconfig = Buffer.from(base64Kubeconfig, 'base64').toString('utf-8');
const kubeconfig = atob(base64Kubeconfig);

// Attempt to parse the kubeconfig as YAML
const kubeconfigObject: any = yaml.load(kubeconfig);
Expand Down
Loading
Loading