From 40cf4548211060028d0f7a377d9452fae32dc26c Mon Sep 17 00:00:00 2001 From: Lexiie <28455136+Lexiie@users.noreply.github.com> Date: Tue, 7 Jul 2026 05:52:38 +0800 Subject: [PATCH] fix(bundle): preserve root output path --- src/lib/bundle.test.ts | 4 ++++ src/lib/bundle.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/bundle.test.ts b/src/lib/bundle.test.ts index aec451a..438092b 100644 --- a/src/lib/bundle.test.ts +++ b/src/lib/bundle.test.ts @@ -601,6 +601,10 @@ describe('resolveBundleDir', () => { const out = resolveBundleDir('/tmp/x/'); expect(out).toBe('/tmp/x'); }); + + it('preserves the filesystem root path', () => { + expect(resolveBundleDir('/')).toBe('/'); + }); }); describe('streamUrlToFile retry', () => { diff --git a/src/lib/bundle.ts b/src/lib/bundle.ts index a3c0808..8d4eba0 100644 --- a/src/lib/bundle.ts +++ b/src/lib/bundle.ts @@ -325,7 +325,7 @@ export function resolveBundleDir(rawPath: string): string { }, }); } - const trimmed = rawPath.endsWith('/') ? rawPath.slice(0, -1) : rawPath; + const trimmed = rawPath.endsWith('/') && rawPath.length > 1 ? rawPath.slice(0, -1) : rawPath; return isAbsolute(trimmed) ? trimmed : resolve(process.cwd(), trimmed); }