Skip to content

fix(bundle): preserve root output path#224

Open
Lexiie wants to merge 1 commit into
TestSprite:mainfrom
Lexiie:fix/bundle-root-out-path
Open

fix(bundle): preserve root output path#224
Lexiie wants to merge 1 commit into
TestSprite:mainfrom
Lexiie:fix/bundle-root-out-path

Conversation

@Lexiie

@Lexiie Lexiie commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Resubmission of #205 after the release-process hiccup closed it without merge.

resolveBundleDir('/') currently strips the trailing slash before checking whether the path is absolute. For the filesystem root path, that turns / into an empty string, so the helper resolves it against process.cwd() instead of preserving /.

This PR keeps the root path intact while preserving the existing behavior for ordinary trailing slashes like /tmp/bundle/.

Changes

  • Only strip a trailing slash when the raw path has more than one character.
  • Add regression coverage that resolveBundleDir('/') returns /.

Verification

  • rtk vitest run src/lib/bundle.test.ts -t "root|resolveBundleDir"
  • rtk npx eslint src/lib/bundle.ts src/lib/bundle.test.ts --fix-dry-run --format stylish
  • rtk npx eslint src/lib/bundle.ts src/lib/bundle.test.ts
  • rtk npm run typecheck

Summary by CodeRabbit

  • Bug Fixes
    • Preserved the filesystem root path when cleaning up output directories, so / is no longer reduced to an empty value.
    • Improved handling of paths with trailing slashes, keeping valid root paths intact while still normalizing other paths.
    • Added coverage for the root-path case to prevent regressions.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 99b6e9f0-2092-4890-b4cc-bb705bdec3ff

📥 Commits

Reviewing files that changed from the base of the PR and between 3305dfa and 40cf454.

📒 Files selected for processing (2)
  • src/lib/bundle.test.ts
  • src/lib/bundle.ts

Walkthrough

The resolveBundleDir function in src/lib/bundle.ts now only trims a trailing / when the resulting path would remain non-empty, preventing the root path / from being reduced to an empty string. A corresponding test case was added to verify this behavior.

Changes

resolveBundleDir root path fix

Layer / File(s) Summary
Preserve root path in trailing-slash trimming
src/lib/bundle.ts, src/lib/bundle.test.ts
resolveBundleDir now trims a trailing / only when the path length exceeds 1 character, preserving '/' as-is; a new test verifies resolveBundleDir('/') returns '/'.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Suggested reviewers: ruili-testsprite, zeshi-du

🚥 Pre-merge checks | ✅ 5
✅ 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 clearly summarizes the main change: preserving the root bundle output path instead of stripping it.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant