Struggling with setting up path mapping between two different typescript projects within a yarn workspace configuration.
There are 2 separate projects in the yarn workspace, resulting in the following folder structure:
packages
├── common
│ ├── node_modules
│ ├── package.json
│ ├── src
│ │ └── logger.ts
│ └── tsconfig.json
├── main
│ ├── node_modules
│ ├── package.json
│ ├── src
│ │ ├── app
│ │ │ └── settings.ts
│ │ └── main.ts
│ └── tsconfig.json
tsconfig.base.json
node_modules
In the tsconfig file for /main project, I have set the following:
"baseUrl": ".",
"paths": {
"Common/*": ["../common/src/*"]
},
"references": [
{ "path": "../common","prepend": true }
]
Trying to import a default export from the module in main/src/main.ts using this syntax:
import Log from 'Common/logger'
However, encountering the error:
TS2307: Cannot find module
This issue is unusual as it has not been encountered before with typescript, prompting thoughts that it may be related to the path being mapped and used as a project reference simultaneously.
Expecting the setup to function normally, enabling the import of ../common/src/logger
as Common/logger
.