Files
Dex DevlonandGitHub d2e58b14b9 fix(es/module): Preserve explicit index.js import path when baseUrl is set (#11597)
**Related issue:**

- Closes #11586

When `baseUrl` is configured in `.swcrc`, `import './plugins/index.js'`
was being incorrectly rewritten to `import './plugins'`, causing
`ERR_UNSUPPORTED_DIR_IMPORT` at runtime.

**Root cause:** The resolver resolves `./plugins/index.js` →
`./plugins/index.ts` (the source file). In `to_specifier()`, the path
has a `.ts` extension (non-js) and a stem of `index`, so it hit a branch
that assumed the import was a bare directory import (`./plugins`) and
called `target_path.pop()`. It didn't account for the case where the
user explicitly wrote `index.js`.

**Fix:** When `orig_filename` has a file stem of `index` with an
extension (e.g. `index.js`), preserve the original filename via
`set_file_name` instead of popping the path. This matches how non-index
files like `a.js` are already handled.
2026-02-28 21:56:28 -08:00
..