如何在使用 Turborepo 引导的 monorepo 中配置模块别名?

Log*_*phy 13 javascript node.js reactjs next.js turborepo

我正在尝试将多个存储库迁移到 monorepo 架构,目前正在开发使用Turborepo引导的 POC 。

我看到的问题是 ts 模块别名配置不正确。我目前有一个 ui 包,我正在尝试从中导出一个按钮组件index.tsx(注意,VS code 没有抱怨,它认为它可以解析该模块):

VS代码2

但是,当我尝试构建我的应用程序时,我发现该模块实际上并未解析:

找不到模块:无法解析“@/components/Button”

我在这里不知所措,有谁知道如何使用 Turbo repo 正确配置模块别名?以下是 tsconfig.json:

{
  "extends": "tsconfig/react-library.json",
  "include": ["."],
  "exclude": ["dist", "build", "node_modules"],
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/components/*": ["./components/*"]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

may*_*513 0

看看这个线程。您必须进行一些尝试和错误才能做到这一点。但这个答案将使我们朝着正确的方向前进。