前端开发

plugin-bundle-size

grafana/skills

Optimise Grafana app plugin bundle size using React.lazy, Suspense, and webpack code splitting. Use when the user asks to reduce plugin bundle size, optimise module.js, add code splitting, improve initial plugin load performance, split plugin chunks, lazy load plugin pages, or help implement lazy loading in a Grafana app plugin. Triggers on phrases like "optimise plugin bundle size", "module.js is too large", "plugin is slow to load", "code split the plugin", "reduce initial JS payload", or "help me with Suspense in my plugin".

  • 4270 次安装
  • 296 星标
  • 收录于

安装命令

npx skills add https://github.com/grafana/skills --skill plugin-bundle-size

SKILL.md

Grafana plugin bundle size optimisation

module.js is the render-blocking entry point for every Grafana app plugin. The smaller it is, the less impact the plugin has on Grafana's overall startup time. A well-split plugin should have a module.js under ~200 KB that contains nothing but lazy-loaded wrappers — all feature code loads on demand.

Target: ~15–25 JS chunks total. Fewer means too little splitting; far more (50+) means over-engineering.

Risk levels

Not all splitting opportunities carry the same risk. Apply them in this order:

Level What Risk Impact
Safe module.tsx lazy wrappers (Priority 1) Very low — no behaviour change Highest — module.js drops 90%+
Safe Route-level lazy() (Priority 2) Low — each route is self-contained High — one chunk per route
Safe Extension lazy() (Priority 3) Low — extensions are isolated Medium — independent chunk per extension
Moderate Component registries / tab panels (Priority 4) Medium — verify Suspense placement Medium — splits heavy pages further
Do not touch Vendor libraries (@grafana/scenes, @reduxjs/toolkit) N/A N/A — webpack splits these automatically
Do not touch Shared utility components (Markdown, Spinner) used across many files High churn, many callsites Low — already in shared vendor chunks