Skip to content

Conversation

@kdy1
Copy link
Member

@kdy1 kdy1 commented Jan 23, 2026

When resolving imports with baseUrl, hidden directories (dot-prefixed like .foo) were incorrectly losing their ./ prefix, turning ./.foo into .foo which is not a valid relative import.

The issue was that the code checked starts_with('.') to determine if a path was already relative, but this matched hidden directory names (which start with .) even though they need a ./ prefix to be valid relative paths.

The fix changes the check to look for actual relative path markers (./ or ../) instead of just ..

Fixes #9551

Generated with Claude Code

When resolving imports with `baseUrl`, hidden directories (dot-prefixed like `.foo`) were incorrectly losing their `./` prefix, turning `./.foo` into `.foo` which is not a valid relative import.

The issue was that the code checked `starts_with('.')` to determine if a path was already relative, but this matched hidden directory names (which start with `.`) even though they need a `./` prefix to be valid relative paths.

The fix changes the check to look for actual relative path markers (`./` or `../`) instead of just `.`.

Fixes #9551

Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
@kdy1 kdy1 added this to the Planned milestone Jan 23, 2026
@kdy1 kdy1 self-assigned this Jan 23, 2026
@changeset-bot
Copy link

changeset-bot bot commented Jan 23, 2026

⚠️ No Changeset found

Latest commit: 087a721

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.

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

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2026

Binary Sizes

File Size
swc.linux-x64-gnu.node 28M (28665160 bytes)

Commit: d43031b

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 23, 2026

Merging this PR will not alter performance

✅ 184 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing claude/issue-9551-20260123-0242 (087a721) with main (fade647)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@kdy1
Copy link
Member Author

kdy1 commented Jan 23, 2026

@claude Fix CI

@claude
Copy link
Contributor

claude bot commented Jan 23, 2026

Claude finished @kdy1's task in 2m 39s —— View job


Fixing CI

  • Check CI status and identify failures
  • Investigate the failing tests
  • Fix the issue
  • Push fixes

Root Cause:
The Windows CI was failing because diff_paths returns paths with backslashes on Windows (e.g., ..\url-alphabet\index.js). The fix was checking for Unix-style relative path prefixes (./ and ../) but not the Windows backslash variants (.\ and ..\).

Solution:
Added checks for Windows backslash path prefixes (.\ and ..\) in addition to the existing Unix-style checks in crates/swc_ecma_transforms_module/src/path.rs:350-353.

Commit: 087a721 - CI is now running.
| | View new CI run

…e imports

The previous fix checked for Unix-style relative path prefixes (./ and ../)
but on Windows, diff_paths returns paths with backslashes. This caused the
code to incorrectly add ./ prefix to paths like ..\url-alphabet\index.js,
resulting in ./..\url-alphabet\index.js instead of ..\url-alphabet\index.js.

Fixes CI failures on Windows.

Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

SWC transform with baseUrl mangles imports of hidden directories

3 participants