Skip to content

297 add size limit for small libraries with GitHub actions#298

Merged
yamcodes merged 17 commits into
mainfrom
297-add-size-limit-for-small-libraries-with-github-actions
Nov 9, 2025
Merged

297 add size limit for small libraries with GitHub actions#298
yamcodes merged 17 commits into
mainfrom
297-add-size-limit-for-small-libraries-with-github-actions

Conversation

@yamcodes

@yamcodes yamcodes commented Nov 8, 2025

Copy link
Copy Markdown
Owner

Closes #297

Summary by CodeRabbit

  • New Features

    • Automated bundle size checks run on PRs and post/update a "Bundle Size Report" as a PR comment
    • CI adds a dedicated size task that runs after build for affected packages
  • Chores

    • Added size-limit tooling, package-level size policy and a local size script (2 kB target for arkenv)
    • CI workflow and Dependabot configured for the new size-check action
    • Lint override and .gitignore updated for action scripts and size artifacts

- Added `@size-limit/esbuild-why`, `@size-limit/preset-small-lib`, and `size-limit` to `devDependencies` in `package.json`.
- Configured size limits for the project in `package.json`.
- Updated `pnpm-lock.yaml` to include new versions for size-limit related packages and other dependencies.

This update enhances the project's build process by integrating size-limit for monitoring bundle sizes.
- Constrained the inner container of the video section to a maximum width of 1024px to prevent stretching.
- Removed extra horizontal padding on small screens for a more consistent appearance.
- Updated component tests to align with the revised layout.

This change enhances the visual consistency of the video demo across different screen sizes.
- Adjusted the video section layout by constraining the inner container to a maximum width of 1024px and removing unnecessary horizontal padding on smaller screens.
- Updated component tests to reflect the changes in layout and ensure consistency across different screen sizes.

This enhancement improves the visual presentation of the video section.
@yamcodes yamcodes linked an issue Nov 8, 2025 that may be closed by this pull request
6 tasks
@changeset-bot

changeset-bot Bot commented Nov 8, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6a9ea78

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Nov 8, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
arkenv Ready Ready Preview Comment Nov 9, 2025 4:46pm

@coderabbitai

coderabbitai Bot commented Nov 8, 2025

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report


> arkenv-monorepo@ size /home/runner/work/arkenv/arkenv
> turbo run size --filter './packages/*'

• Packages in scope: @arkenv/vite-plugin, arkenv
• Running size in 2 packages
• Remote caching enabled
::group::arkenv:build
cache hit, replaying logs f62e55d6df9a1ffc

> arkenv@0.7.3 build /home/runner/work/arkenv/arkenv/packages/arkenv
> tsdown

�[34mℹ�[39m tsdown �[2mv0.15.12�[22m powered by rolldown �[2mv1.0.0-beta.45�[22m
�[34mℹ�[39m Using tsdown config: �[4m/home/runner/work/arkenv/arkenv/packages/arkenv/tsdown.config.ts�[24m
�[34mℹ�[39m entry: �[34msrc/index.ts�[39m
�[34mℹ�[39m tsconfig: �[34mtsconfig.json�[39m
�[34mℹ�[39m Build start
�[34mℹ�[39m �[33m[CJS]�[39m �[2mdist/�[22m�[1mindex.cjs�[22m  �[2m6.16 kB�[22m �[2m│ gzip: 2.43 kB�[22m
�[34mℹ�[39m �[33m[CJS]�[39m 1 files, total: 6.16 kB
�[34mℹ�[39m �[34m[ESM]�[39m �[2mdist/�[22m�[1mindex.js�[22m    �[2m4.98 kB�[22m �[2m│ gzip: 2.00 kB�[22m
�[34mℹ�[39m �[34m[ESM]�[39m �[2mdist/�[22m�[32m�[1mindex.d.ts�[22m�[39m  �[2m7.05 kB�[22m �[2m│ gzip: 1.27 kB�[22m
�[34mℹ�[39m �[34m[ESM]�[39m 2 files, total: 12.03 kB
�[34mℹ�[39m �[33m[CJS]�[39m �[2mdist/�[22m�[32m�[1mindex.d.cts�[22m�[39m  �[2m7.05 kB�[22m �[2m│ gzip: 1.27 kB�[22m
�[34mℹ�[39m �[33m[CJS]�[39m 1 files, total: 7.05 kB
�[32m✔�[39m Build complete in �[32m2119ms�[39m
::endgroup::
::group::@arkenv/vite-plugin:build
cache hit, replaying logs af6cad21d7d647c8

> @arkenv/vite-plugin@0.0.14 build /home/runner/work/arkenv/arkenv/packages/vite-plugin
> tsdown

�[34mℹ�[39m tsdown �[2mv0.15.12�[22m powered by rolldown �[2mv1.0.0-beta.45�[22m
�[34mℹ�[39m Using tsdown config: �[4m/home/runner/work/arkenv/arkenv/packages/vite-plugin/tsdown.config.ts�[24m
�[34mℹ�[39m entry: �[34msrc/index.ts�[39m
�[34mℹ�[39m tsconfig: �[34mtsconfig.json�[39m
�[34mℹ�[39m Build start
�[34mℹ�[39m �[33m[CJS]�[39m �[2mdist/�[22m�[1mindex.cjs�[22m  �[2m1.65 kB�[22m �[2m│ gzip: 0.85 kB�[22m
�[34mℹ�[39m �[33m[CJS]�[39m 1 files, total: 1.65 kB
�[34mℹ�[39m �[34m[ESM]�[39m �[2mdist/�[22m�[1mindex.js�[22m    �[2m0.61 kB�[22m �[2m│ gzip: 0.41 kB�[22m
�[34mℹ�[39m �[34m[ESM]�[39m �[2mdist/�[22m�[32m�[1mindex.d.ts�[22m�[39m  �[2m0.40 kB�[22m �[2m│ gzip: 0.27 kB�[22m
�[34mℹ�[39m �[34m[ESM]�[39m 2 files, total: 1.02 kB
�[34mℹ�[39m �[33m[CJS]�[39m �[2mdist/�[22m�[32m�[1mindex.d.cts�[22m�[39m  �[2m0.38 kB�[22m �[2m│ gzip: 0.26 kB�[22m
�[34mℹ�[39m �[33m[CJS]�[39m 1 files, total: 0.38 kB
�[32m✔�[39m Build complete in �[32m1870ms�[39m
::endgroup::
::group::arkenv:size
cache bypass, force executing d7187653b1481db2

> arkenv@0.7.3 size /home/runner/work/arkenv/arkenv/packages/arkenv
> size-limit

�[33m-�[39m Adding to empty esbuild project
�[32m✔�[39m Adding to empty esbuild project
  
  Size limit: �[32m�[1m2 kB�[22m�[39m
  Size:       �[32m�[1m711 B�[22m�[39m �[90mwith all dependencies, minified and brotlied�[39m
  
::endgroup::

 Tasks:    3 successful, 3 total
Cached:    2 cached, 3 total
  Time:    762ms 


Attention:
Turborepo now collects completely anonymous telemetry regarding usage.
This information is used to shape the Turborepo roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://turborepo.com/docs/telemetry


All size limits passed!

@github-actions github-actions Bot added arkenv Changes to the `arkenv` npm package. github actions Pull requests that update GitHub Actions code labels Nov 8, 2025
@pkg-pr-new

pkg-pr-new Bot commented Nov 8, 2025

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/arkenv@298
npm i https://pkg.pr.new/@arkenv/vite-plugin@298

commit: 6a9ea78

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb70ae8 and 46f983c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • .github/actions/size-limit/action.yml (1 hunks)
  • .github/actions/size-limit/package.json (1 hunks)
  • .github/actions/size-limit/run-size-check.ts (1 hunks)
  • .github/actions/size-limit/tsconfig.json (1 hunks)
  • .github/workflows/size-limit.yml (1 hunks)
  • biome.jsonc (1 hunks)
  • packages/arkenv/.gitignore (1 hunks)
  • packages/arkenv/package.json (2 hunks)
  • turbo.json (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/arkenv/package.json (1)
examples/with-bun-react/build.ts (1)
  • output (153-157)
.github/actions/size-limit/action.yml (1)
examples/with-bun-react/build.ts (1)
  • output (153-157)
🪛 GitHub Actions: autofix.ci
.github/actions/size-limit/run-size-check.ts

[error] 90-90: lint/style/noNonNullAssertion: Forbidden non-null assertion. (pkgName.split("/")[1]!)


[error] 135-135: lint/style/noNonNullAssertion: Forbidden non-null assertion. (colonMatch[1]!)


[warning] 105-105: lint/complexity/useOptionalChain: FIXABLE - Change to an optional chain (fileMatch?.[1]).


[warning] 110-110: lint/complexity/useOptionalChain: FIXABLE - Change to an optional chain (limitMatch?.[1]).


[warning] 115-115: lint/complexity/useOptionalChain: FIXABLE - Change to an optional chain (sizeMatch?.[1]).


[warning] 144-144: lint/complexity/useOptionalChain: FIXABLE - Change to an optional chain (hashMatch?.[1]).


[warning] 95-95: lint/suspicious/noControlCharactersInRegex: Unexpected control character in a regular expression.


[warning] 97-97: lint/suspicious/noControlCharactersInRegex: Unexpected control character in a regular expression.


[warning] 97-97: lint/suspicious/noControlCharactersInRegex: Unexpected control character in a regular expression.

🔇 Additional comments (9)
packages/arkenv/.gitignore (1)

1-2: Appropriate ignores for size-limit tooling.

The entries properly suppress generated artifacts from size-limit and esbuild analysis.

biome.jsonc (1)

108-117: Appropriate linter override for GitHub Action scripts.

Console output in GitHub Action scripts is legitimate and necessary. The override correctly mirrors the pattern used for bin scripts.

.github/actions/size-limit/tsconfig.json (1)

1-29: TypeScript config is appropriately configured for action scripts.

The strict settings are suitable for infrastructure code, and allowing unused locals/parameters provides flexibility for conditional logic in action scripts.

.github/actions/size-limit/package.json (1)

1-15: Action package metadata is well-structured.

The private package correctly isolates the action's dependencies. Using @types/bun version "latest" for dev-only tooling is acceptable, as it's not shipped to users.

turbo.json (1)

65-69: Size task correctly configured for always-running checks.

Disabling cache and depending on build is the right approach—size checks must always execute to catch regressions, and the bundles must be built first.

.github/actions/size-limit/action.yml (2)

34-75: PR comment logic is well-designed.

The comment script correctly handles finding and updating existing bot comments, with appropriate pass/fail messaging. Using actions/github-script@v7 is the standard approach for GitHub API operations in workflows.


20-33: Review comment is factually incorrect and should be disregarded.

The run-size-check.ts script exists at .github/actions/size-limit/run-size-check.ts and is properly implemented. The script:

  • Correctly reads all environment inputs (TURBO_TOKEN, TURBO_TEAM, FILTER)
  • Properly writes outputs to GITHUB_OUTPUT as result (markdown table) and has_errors (boolean)
  • Includes robust error handling (try-catch, exit code checking)
  • Correctly integrates with pnpm, Turbo, and size-limit via output parsing
  • Exits with code 1 on failure and 0 on success

No changes are required. The file was included in the PR.

Likely an incorrect or invalid review comment.

.github/workflows/size-limit.yml (1)

1-49: Workflow structure is sound with proper conditionals and caching.

The use of path filtering and conditional job execution is efficient. However, verify whether .github/actions/size-limit/run-size-check.ts invokes Turbo again—if so, the build step at line 42 may be redundant.

Confirm that line 42 (pnpm turbo run build --filter='./packages/*') doesn't duplicate build invocations if the run-size-check.ts script also runs Turbo tasks.

packages/arkenv/package.json (1)

56-62: CJS monitoring gap confirmed; limit values require verification against PR description.

The build produces both ESM and CJS formats (tsdown.config.ts: format: ["esm", "cjs"]), and both are exported in package.json, but size-limit only monitors dist/index.js (ESM). The CJS entry should be added.

However, the stated limits (3.0 kB for ESM, 3.4 kB for CJS) could not be verified in the codebase documentation. These must be confirmed against the actual PR description or requirements before updating.

Required action:

  1. Verify the target bundle size limits from the PR objectives
  2. Add monitoring for dist/index.cjs with the appropriate CJS limit
  3. Update the ESM limit if the PR objectives differ from the current 2 kB setting

Comment thread .github/actions/size-limit/run-size-check.ts
Comment thread .github/actions/size-limit/run-size-check.ts Outdated
- Added "packageManager": "bun@1.2.2" to package.json for better dependency management.
- Refactored regex checks in run-size-check.ts to use optional chaining for improved safety and readability.
… action

- Introduced arkregex as a dependency in package.json and bun.lock for enhanced regex functionality.
- Updated regex definitions in run-size-check.ts to utilize arkregex for improved performance and clarity.
- Updated the regex matching logic in run-size-check.ts to ensure proper handling of package names.
- Improved code readability by removing unnecessary non-null assertions.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46f983c and 8e495b4.

⛔ Files ignored due to path filters (1)
  • .github/actions/size-limit/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • .github/actions/size-limit/package.json (1 hunks)
  • .github/actions/size-limit/run-size-check.ts (1 hunks)
  • .github/actions/size-limit/tsconfig.json (1 hunks)
  • .github/dependabot.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/actions/size-limit/package.json
🧰 Additional context used
🪛 GitHub Actions: size-limit
.github/actions/size-limit/run-size-check.ts

[error] 1-1: Cannot find package 'arkregex' from '/home/runner/work/arkenv/arkenv/.github/actions/size-limit/run-size-check.ts'.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test-e2e (a11y)

Comment thread .github/actions/size-limit/run-size-check.ts
…ll dependencies

- Changed Bun version to 1.2.22 for consistency.
- Added step to install dependencies using Bun in the size-limit action workflow.
- Added 'bash' as the shell for the dependency installation step in the size-limit action workflow.
…tput handling

- Updated the size-limit action to utilize environment variables for accessing the size check results and error status.
- Removed the build step from the size-limit workflow to streamline the process.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
.github/actions/size-limit/action.yml (2)

61-63: Bot detection logic is correct but can be more explicit.

GitHub Actions comments have comment.user.type set to 'Bot', so the current filter is reliable. However, the existing code already mitigates specificity concerns through the dual check with comment.body.includes('Bundle Size Report').

For better clarity and explicitness, consider the suggested refactor:

  const botComment = comments.find(comment => 
-   comment.user.type === 'Bot' && comment.body.includes('Bundle Size Report')
+   comment.user.login === 'github-actions[bot]' && comment.body.includes('Bundle Size Report')
  );

This makes the intent more explicit and directly targets the GitHub Actions bot identity.


23-23: Update Bun version to the latest stable release.

Bun v1.2.22 was released Sept 14, 2025, but the latest release is v1.2.23 (Sept 28, 2025). Update the pinned version to 1.2.23 to use the most recent stable release. If pinning to a specific patch version is intentional for stability reasons, document the rationale; otherwise, consider using a minor version constraint (1.2.x) for better maintainability.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e495b4 and 7b1abd4.

📒 Files selected for processing (2)
  • .github/actions/size-limit/action.yml (1 hunks)
  • .github/actions/size-limit/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/actions/size-limit/package.json

Comment thread .github/actions/size-limit/action.yml
Comment thread .github/actions/size-limit/action.yml Outdated
- Wrapped the comment posting logic in a try-catch block to handle potential errors gracefully.
- Improved error logging to provide more context in case of failures when posting comments on PRs.
- Added a new "size" script to package.json for running size checks.
- Modified the size-check action to use the updated command for consistency in execution.
@coderabbitai

coderabbitai Bot commented Nov 9, 2025

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@yamcodes has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 38 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between fb70ae8 and 6a9ea78.

⛔ Files ignored due to path filters (2)
  • .github/actions/size-limit/bun.lock is excluded by !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • .github/actions/size-limit/action.yml (1 hunks)
  • .github/actions/size-limit/package.json (1 hunks)
  • .github/actions/size-limit/run-size-check.ts (1 hunks)
  • .github/actions/size-limit/tsconfig.json (1 hunks)
  • .github/dependabot.yml (1 hunks)
  • .github/workflows/size-limit.yml (1 hunks)
  • biome.jsonc (1 hunks)
  • package.json (1 hunks)
  • packages/arkenv/.gitignore (1 hunks)
  • packages/arkenv/package.json (2 hunks)
  • turbo.json (1 hunks)
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 297-add-size-limit-for-small-libraries-with-github-actions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yamcodes
yamcodes merged commit 79668cb into main Nov 9, 2025
19 checks passed
@yamcodes
yamcodes deleted the 297-add-size-limit-for-small-libraries-with-github-actions branch November 9, 2025 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arkenv Changes to the `arkenv` npm package. github actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add size-limit for small libraries with GitHub Actions

1 participant