plugin-bundle-size

Convert Grafana plugin eager imports into lazy-loaded chunks with CI reporting.

213|18|Updated Mar 17, 2026
One-click install
npx skills add https://github.com/grafana/skills --skill plugin-bundle-size
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: plugin-bundle-size
Source: https://github.com/grafana/skills/tree/main/skills/grafana-plugins/plugin-bundle-size
Command: npx skills add https://github.com/grafana/skills --skill plugin-bundle-size

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Grafana app plugins often ship a large, render-blocking module.js that slows Grafana startup and increases perceived latency for users. This Skill provides a step-by-step approach to identify eager imports, convert the entry point to a lazy-loaded root, and apply route- and extension-level code splitting so feature code loads on demand.

Core Features & Use Cases

  • Entry-point refactor: Rename module.ts to module.tsx and ensure the entry imports only lightweight wrappers while feature code is loaded with React.lazy and Suspense.
  • Route and extension splitting: Convert route components and plugin extensions to lazy-loaded chunks to reduce the initial payload and defer heavy code until needed.
  • CI and measurement: Add bundle-size CI reporting to capture PR diffs, measure module.js and chunk counts, and verify targets (module.js < ~200 KB; 15–25 chunks).
  • Troubleshooting and safety: Guidance on extracting singletons (e.g., Faro), grouping chunks with webpack magic comments, and common fixes for Suspense boundaries and chunk loading issues.

Quick Start

Diagnose and reduce your plugin's module.js by converting the entry to module.tsx, wrapping routes and extensions with React.lazy and Suspense, and running a production build to verify module.js and chunk counts.

Frequently Asked Questions about plugin-bundle-size

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce my Grafana plugin bundle size and startup time?

Reduce Grafana plugin bundle size by converting eager entry imports into lazy-loaded chunks and applying route-level code splitting. This defers heavy feature code so the plugin loads on demand instead of blocking startup.

What's the best way to split a large Grafana module.js into smaller chunks?

Split a large Grafana module.js by renaming module.ts to module.tsx and wrapping route components and plugin extensions with React.lazy and Suspense. This breaks the render-blocking entry point into smaller, on-demand chunks.

How does React.lazy code splitting work for Grafana app plugins?

React.lazy code splitting for Grafana plugins works by ensuring the entry point imports only lightweight wrappers while feature code is loaded dynamically. Target a production module.js under 200 KB and 15–25 JS chunks.

Can I track Grafana plugin bundle size diffs in CI workflows?

You can track Grafana plugin bundle size in CI by integrating bundle-size reporting to capture PR diffs, measure module.js size and chunk counts, and verify targets like module.js under 200 KB.

Does code splitting work with Grafana datasource plugins and monorepos?

Code splitting applies to both Grafana app and datasource plugins, including monorepos and subdirectory plugin layouts. It handles these layouts by extracting initializers to preserve singletons like Faro across lazy boundaries.

Why does my Grafana plugin throw chunk loading errors after adding Suspense?

Chunk loading errors in Grafana plugins after adding Suspense often stem from missing boundaries or ungrouped chunks. Fix them by ensuring proper Suspense boundaries and using webpack magic comments to group chunks logically.