我有具有以下文件结构的 monorepo(纱线工作区):
├── client (workspace @client)
│ ├── package.json
│ └── tsconfig.json (extended tsconfig)
├── server (workspace @server)
│ ├── getData.ts
│ ├── package.json
│ └── tsconfig.json (extended tsconfig)
├── shared
│ └── sanitizeData.ts
├── package.json (monorepo root)
└── tsconfig.json (base tsconfig)
我想使用shared/sanitizeData.ts
in 中的函数server/getData.ts
我尝试paths
从 Typescript 使用,根据文档它看起来很简单,但我做错了:
error TS2307: Cannot find module '@shared/sanitizeData'.
server/tsconfig.json
:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"rootDir": "../",
"outDir": "build",
"paths": {
"@shared/*": ["shared/*"]
}
}
}
server/getData.js
:
import { sanitizeData } from "@shared/sanitizeData";
请问你能帮帮我吗?