Skip to content

Size-limit action shows "—" diff instead of percentage in Version Packages PR #362

@yamcodes

Description

@yamcodes

Problem

In the Version Packages PR (from changeset-release/main branch), the size-limit action is showing "—" for the diff column instead of calculating and displaying the percentage difference between the npm baseline and current branch sizes.

Reference

GitHub Actions run: https://github.com/yamcodes/arkenv/actions/runs/19243060481/job/55010220016

Observations from Logs

1. arkenv@0.7.4 baseline fetch fails

The size-limit check on the downloaded npm package fails because it exceeds the limit:

⚠️ size-limit failed for arkenv: [
  {
    "name": "dist/index.js",
    "passed": false,
    "size": 41534,
    "sizeLimit": 2000
  }
]

⚠️ No size-limit results for arkenv, skipping baseline

Issue: When size-limit fails (even if it returns valid JSON results), the code treats it as "no results" and skips adding it to the baseline map. However, the size data (41534 bytes) is still valid and should be used for comparison.

2. @arkenv/vite-plugin@0.0.15 baseline fetch fails

The size-limit check fails with many Node.js built-in module resolution errors:

✘ [ERROR] Could not resolve "node:path"
✘ [ERROR] Could not resolve "node:fs"
✘ [ERROR] Could not resolve "node:util"
... (many more Node.js built-in modules)

Issue: The bundler is trying to bundle Node.js built-in modules, which suggests the size-limit configuration might need platform: 'node' or proper externals configuration for Node.js packages.

3. Result

Both packages end up with no baseline sizes:

⚠️ No baseline sizes found from npm. This might be the first release.

This causes the diff calculation to show "—" instead of actual percentages:

| Package | Size | Limit | Diff | Status |
|---------|------|-------|------|--------|
| `@arkenv/vite-plugin` | 807 B | 2 kB | — | ✅ |
| `arkenv` | 708 B | 2 kB | — | ✅ |

Expected Behavior

  • When size-limit returns results (even if passed: false), the size data should still be used for baseline comparison
  • Node.js built-in modules should be properly handled (either marked as external or configured with platform: 'node')
  • The diff column should show percentage differences (e.g., -5.2%, +10.1%, 0.0%) instead of "—"

Potential Solutions

  1. Handle failed size-limit checks: Extract size data from failed checks and still use it for baseline comparison
  2. Fix Node.js built-in module resolution: Configure size-limit properly for Node.js packages (possibly using platform: 'node' or externals)
  3. Improve error handling: Better distinguish between "no results" (empty array) and "failed check" (results with passed: false)

Related Code

The issue likely involves:

  • .github/actions/size-limit/lib/size-limit.ts - handling of size-limit results
  • .github/actions/size-limit/lib/npm.ts - baseline fetching from npm
  • Size-limit configuration in packages/*/package.json files

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginfraInfrastructure related issue or pull request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions