ITADN

tsx fails to resolve tsconfig paths aliases when module is loaded via worker_threads

#793Openzaaack 创建于 2026-05-16
bugpending triage
Z
zaaackcommented
### Acknowledgements - [x] I read the documentation and searched existing issues to avoid duplicates - [x] I understand this is a **bug tracker** and anything other than a proven bug will be closed - [x] I understand this is a free project and relies on community contributions - [x] I read and understood the [Contribution guide](https://github.com/privatenumber/tsx/blob/master/CONTRIBUTING.md) ### Minimal reproduction URL https://github.com/zaaack/tsx-tsconfig-paths-bug ### Problem & expected behavior (under 200 words) ## Bug Description When a TypeScript file uses tsconfig `paths` aliases (e.g., `@/*`) and is loaded via `worker_threads.Worker`, `tsx` throws `ERR_MODULE_NOT_FOUND` because the path aliases are not resolved. ## Reproduction ```ts // tsconfig.json: paths: { "@/*": ["./src/*"] } // src/utils/helper.ts: export const greet = (name: string) => ... // src/worker.ts: import { greet } from '@/utils/helper.js' // ❌ via worker_threads const worker = new Worker('src/worker.ts', { execArgv: ['--import', 'tsx'] }); // ✅ directly: tsx src/worker.ts ``` ## Expected `tsx` should resolve `paths` aliases regardless of whether the module runs directly or is loaded from a worker thread. ## Actual ``` Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@/utils' imported from .../src/worker.ts ``` ## Environment - tsx: 4.22.0 - Node: ^22 - pnpm: latest ### Bugs are expected to be fixed by those affected by it - [ ] I'm interested in working on this issue ### Compensating engineering work will speed up resolution and support the project - [ ] I'm willing to offer $10 for financial support
0 条评论