https://github.com/devjiwonchoi/repro-swc-base-url-paths
https://github.com/devjiwonchoi/repro-swc-base-url-paths
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/devjiwonchoi/repro-swc-base-url-paths
- Owner: devjiwonchoi
- Created: 2024-02-24T14:36:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-04T01:43:41.000Z (over 2 years ago)
- Last Synced: 2024-10-11T12:08:40.026Z (over 1 year ago)
- Language: TypeScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SWC `baseUrl` Repro
**SWC Transform is not resolving the `baseUrl` properly.**
## To Reproduce
Run the following command:
```sh
pnpm i
pnpm tsx .
```
SWC `transform` requires the `baseUrl` to be absolute path.
The common case is to use `resolve` to get the absolute path resolving the `cwd` and `baseUrl`.
For the following examples, I'm using `process.cwd()` as resolved `baseUrl`.
## Current Behavior
If pass `process.cwd()` as `baseUrl` to `swc` transform, it resolves the path as the parent folder.
Also, it does not resolve the path for the `baseUrl` folder.
```js
import { foo } from "./repro-swc-base-url-paths/src/foo"; // parent folder
import { bar } from "src/bar"; // not resolved
console.log(foo, bar);
```
## Expected Behavior
It should resolve the path for the `baseUrl` folder and should not resolve the path for the parent folder.
```js
import { foo } from "./src/foo"; // based on current dir
import { foo } from "./src/bar"; // resolved
console.log(foo, bar);
```