An open API service indexing awesome lists of open source software.

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

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);
```