__dirname value differs from tsc and tsx
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
When I call ```__dirname``` in tsc or tsx its value is the current directory. But in tsup the value is the entrypoint directory.
Example:
Suppose there is a project where the entry point is /home/project/src/server/index.ts:
```ts
import '../modules/example'
```
And the file /home/project/src/modules/example.ts:
```
console.log(__dirname)
```
When I build from tsc or run using tsx, the result is:
```
/home/project/dist/modules/
```
But when I build from tsup the result is:
```
/home/project/dist/server
```
Is there a way to get same result from tsc and tsx?
Contributor guide
Research direction
Reproduce the example with the entrypoint /home/project/src/server/index.ts and imported file /home/project/src/modules/example.ts, comparing tsup with tsc and tsx. Read how tsup handles __dirname during the build; done means determining whether the output can match the other tools and documenting or addressing the discrepancy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100