I have monorepo (yarn workpaces) with following file structure:
├── 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)
And I want to use function from shared/sanitizeData.ts
in server/getData.ts
I tried to use paths
from Typescript, it looks pretty straightforward according to docs, but I'm doing something wrong:
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";
Could you help me please?