Skip to content

Improve package change detection by traversing parent directories and remove explicit webpack disabling#507

Merged
yamcodes merged 1 commit intomainfrom
502-fix-size-limit-frequent-failures
Dec 8, 2025
Merged

Improve package change detection by traversing parent directories and remove explicit webpack disabling#507
yamcodes merged 1 commit intomainfrom
502-fix-size-limit-frequent-failures

Conversation

@yamcodes
Copy link
Owner

@yamcodes yamcodes commented Dec 8, 2025

Closes #502 (Hopefully)

Summary by CodeRabbit

  • Chores
    • Enhanced package change detection in CI workflow for improved reliability
    • Optimized build tool configuration in CI setup with better defaults

✏️ Tip: You can customize this high-level summary in your review settings.

…tories and remove explicit webpack disabling.
@changeset-bot
Copy link

changeset-bot bot commented Dec 8, 2025

⚠️ No Changeset found

Latest commit: 79ff26f

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
Copy link

vercel bot commented Dec 8, 2025

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

Project Deployment Preview Comments Updated (UTC)
arkenv Ready Ready Preview Comment Dec 8, 2025 1:03pm

@yamcodes yamcodes changed the title Improve package change detection by traversing parent directtories and remove explicit webpack disabling Improve package change detection by traversing parent directories and remove explicit webpack disabling Dec 8, 2025
@github-actions github-actions bot added the github actions Pull requests that update GitHub Actions code label Dec 8, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

Walkthrough

This PR refactors the size-limit GitHub Action to improve package discovery by implementing hierarchical directory traversal to find package.json files, with regex fallback for unlocated packages, and simplifies bundler configuration by removing explicit webpack disabling to use esbuild as default.

Changes

Cohort / File(s) Summary
Package discovery refactoring
<br>.github/actions/size-limit/src/package/changes.ts
Replaced exact path matching with hierarchical directory traversal to locate package.json files by iterating from the deepest directory upward. Added regex-based fallback for package name extraction when no package.json is found. Enhanced error handling for invalid or missing package.json files.
Bundler configuration simplification
.github/actions/size-limit/src/size-limit/package.ts
Removed explicit webpack: false assignment from size-limit config, allowing esbuild to be used as the default bundler. Retained existing handling of Node.js built-ins as external dependencies.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Hierarchical search logic: Verify the directory traversal correctly walks from deepest to shallowest level and properly stops on first valid package.json found
  • Regex fallback pattern: Confirm the regex correctly extracts both scoped and unscoped package names
  • Webpack config removal: Validate that esbuild is indeed the correct default and that this change doesn't break existing CI behavior

Possibly related PRs

Poem

🐰 Hoppy changes, friends, I say!
No more size checks go astray,
Hierarchies climbed, deep to high,
esbuild's now the bundler's sigh—
CI pipelines leap and bound,
Success at last! Hip-hip, around! 🎉

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the two main changes: improving package change detection via directory traversal and removing explicit webpack disabling.
Linked Issues check ✅ Passed The PR changes improve package detection robustness through hierarchical search and regex fallback, directly addressing issue #502's parsing failures and intermittent size-limit check failures.
Out of Scope Changes check ✅ Passed All changes align with issue #502 objectives: improving package change detection reliability and removing webpack configuration. No unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 502-fix-size-limit-frequent-failures

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52508a3 and 79ff26f.

📒 Files selected for processing (2)
  • .github/actions/size-limit/src/package/changes.ts (1 hunks)
  • .github/actions/size-limit/src/size-limit/package.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (12)
📓 Common learnings
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to packages/*/package.json : Packages in packages/ directory must be published to npm and require changesets for versioning, proper exports, and type definitions
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to package.json : Configure only built dependencies (native modules) in `pnpm.onlyBuiltDependencies`, including: biomejs/biome, sentry/cli, swc/core, tailwindcss/oxide, vercel/speed-insights, esbuild, and sharp

Applied to files:

  • .github/actions/size-limit/src/size-limit/package.ts
📚 Learning: 2025-11-29T08:57:24.056Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: examples/with-bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-29T08:57:24.056Z
Learning: Applies to examples/with-bun-react/**/*.{html,ts,tsx,css} : Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`

Applied to files:

  • .github/actions/size-limit/src/size-limit/package.ts
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.{ts,tsx,js,jsx,html,css} : Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild` for bundling

Applied to files:

  • .github/actions/size-limit/src/size-limit/package.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Prefer tree-shakeable exports for better bundling

Applied to files:

  • .github/actions/size-limit/src/size-limit/package.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use TypeScript 5.1+ features when appropriate

Applied to files:

  • .github/actions/size-limit/src/size-limit/package.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.{html,ts,tsx,css} : Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild` for bundling

Applied to files:

  • .github/actions/size-limit/src/size-limit/package.ts
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to packages/*/package.json : Packages in packages/ directory must be published to npm and require changesets for versioning, proper exports, and type definitions

Applied to files:

  • .github/actions/size-limit/src/package/changes.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Always run `pnpm changeset` for version bumps in published packages - never skip changesets

Applied to files:

  • .github/actions/size-limit/src/package/changes.ts
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Only packages in packages/ directory are published to npm; publishing is handled by changesets using pnpm release

Applied to files:

  • .github/actions/size-limit/src/package/changes.ts
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to tooling/*/package.json : Tooling in tooling/ directory contains development and testing tools that are not published to npm and excluded from changesets

Applied to files:

  • .github/actions/size-limit/src/package/changes.ts
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Organize workspace packages into appropriate directories: `packages/` for published npm packages, `apps/` for applications, `tooling/` for development tools (not published), and `examples/` for example projects

Applied to files:

  • .github/actions/size-limit/src/package/changes.ts
🧬 Code graph analysis (1)
.github/actions/size-limit/src/package/changes.ts (5)
.github/actions/size-limit/src/results.ts (2)
  • result (86-87)
  • results (71-93)
.github/actions/size-limit/src/utils/parser.ts (2)
  • currentPackage (42-69)
  • pkgName (71-82)
.github/actions/size-limit/src/package/names.ts (1)
  • filter (36-99)
packages/bun-plugin/src/index.ts (1)
  • cwd (182-236)
.github/actions/size-limit/src/output.ts (1)
  • Promise (40-51)
⏰ 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). (2)
  • GitHub Check: test-e2e (e2e)
  • GitHub Check: test-e2e (a11y)
🔇 Additional comments (3)
.github/actions/size-limit/src/package/changes.ts (2)

65-98: LGTM! Hierarchical package.json discovery is well-implemented.

The deep-to-shallow directory traversal correctly handles:

  • Nested package structures (e.g., packages/arkenv/src/index.ts → finds packages/arkenv/package.json)
  • Scoped packages (e.g., packages/@scope/package/src/index.ts → finds packages/@scope/package/package.json)
  • Invalid or missing package.json files via error handling

The slice logic parts.slice(1, i) correctly extracts directory segments between "packages" and the current level, and the loop bounds prevent checking outside the packages directory.


100-110: LGTM! Fallback regex extraction is robust.

The regex pattern correctly handles both scoped (@scope/package) and unscoped (package) package names, and the trailing slash requirement prevents false matches on files directly in the packages/ directory.

This fallback mechanism provides good resilience when package.json files are deleted or unreadable during change detection.

.github/actions/size-limit/src/size-limit/package.ts (1)

97-109: No action needed — esbuild is confirmed as the default bundler for @size-limit/preset-small-lib@11.2.0. The preset depends on @size-limit/esbuild and uses esbuild by default, making the removal of webpack: false safe and correct. The code's handling of Node.js built-in modules through the ignore configuration is appropriate for esbuild.


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 10f7f4a into main Dec 8, 2025
15 checks passed
@yamcodes yamcodes deleted the 502-fix-size-limit-frequent-failures branch December 8, 2025 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix size-limit frequent failures

1 participant