andywer / andywer/threads.js

Support for custom paths in tsconfig.json

Open
#493 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.5k
Forks
173
PR merge metrics
No merged PRs in 30d

Description

# Problem

When configuring `tsconfig.json` with `paths`:

```
{
"compilerOptions": {
"baseUrl": "./",
"paths": [
"@fancyModules/*": ["./src/modules/fancyModule/*"]
]
}
}
```

the transpiler/loader used by `threads` wouldn't resolve these imports:

```
import { Thing } from "@fanceModules/things"
```

and thus lead to "module not found" errors.

Although this works perfectly when running the same code with `ts-node` / `tsx`.

# Workaround

Do not use custom `paths` imports in any module that are directly or indirectly imported by a worker. Instead use relative imports for workers.

# Related documentation

- https://www.typescriptlang.org/tsconfig/#paths
- https://www.typescriptlang.org/docs/handbook/modules/reference.html#paths

# Possible support for `threads`?

Is there any change to get support for `paths` into `threads`?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.