I have two projects that share a types package dedicated to that project, and I import it from my github like this:
"myproject-types": "git+https://<my-key>:x-oauth-basic@github.com/myprojecttypes/myprojecttypes.git"
When I use this in Angular, it works perfectly fine but when I use this on my backend NestJS I get errors like this:
Error: Cannot find module 'myproject-types/src/enums/session-event.enum'
It's because the build script I run does not compile these typescript files, because the package only containing typescript files.
This is my tsconfig
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true
},
"include": [
"src/**/*.ts",
"node_modules/myproject-types"
]
}
I can't really understand why doesn't it compile the typescript while nestjs typescript files are compiled on build.
Is there a way to compile the package typescript so js files will be created upon npm install in node_modules?