Skip to content
Latchkey

How to Profile a Slow Build in GitHub Actions

Most bundlers can emit a timing or dependency profile; capturing it in CI shows which modules and plugins dominate the build.

Enable a profiling flag (esbuild --metafile, webpack --profile --json, or vite build --profile), write the report, and upload it so you can open it in an analyzer.

Steps

  • Run the build with the bundler profiling flag enabled.
  • Write the profile to a file (metafile or stats JSON).
  • Upload it as an artifact to inspect locally.

Workflow

.github/workflows/ci.yml
jobs:
  build-profile:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 20 }
      - run: npm ci
      - run: npx esbuild src/index.js --bundle --metafile=meta.json --outfile=out.js
      - uses: actions/upload-artifact@v4
        with:
          name: build-profile
          path: meta.json

Gotchas

  • Open an esbuild metafile in the official bundle analyzer to see per-module byte and import costs.
  • Profiling adds overhead, so read durations as relative, not absolute, build time.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →