andywer / andywer/threads.js

Support for custom paths in tsconfig.json

未关闭
#493 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
3.5k
派生
173
PR 合并指标
30 天内没有已合并 PR

描述

# 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`?

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。