mirror of
https://github.com/hanzoai/swc.git
synced 2026-10-30 19:42:53 +00:00
**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.