I have two projects in one dir with the following file structure:
I want to use code from recommender
project in the data_generation
project. So I have added the following lines in the tsconfig files of the projects
recommender/tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"rootDir": "src",
"outDir": "bin",
"lib": [
"ESNext",
"DOM"
],
"esModuleInterop": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"strict": true,
"noUncheckedIndexedAccess": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"noPropertyAccessFromIndexSignature": true,
"disableSizeLimit": true,
"exactOptionalPropertyTypes": true,
"noEmitOnError": true,
"moduleResolution": "Bundler",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"composite": true
},
"include": [
"src/**/*.ts"
],
"references": []
}
data_generation/tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"rootDir": "src",
"outDir": "bin",
"lib": [
"ESNext",
"DOM",
],
"esModuleInterop": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"strict": true,
"noUncheckedIndexedAccess": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"noPropertyAccessFromIndexSignature": true,
"disableSizeLimit": true,
"exactOptionalPropertyTypes": true,
"noEmitOnError": true,
"moduleResolution": "Bundler",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
},
"include": [
"src/**/*.ts"
],
"references": [
{
"path": "../recommender",
}
]
}
Now, for example if want to use types I created on the recommender
project, it works just fine:
data_generation/src/data/teams.ts
import { Team } from "../../../recommender/src/models/team.js";
export const teams: Team[] = [
{ name: `Team A` },
{ name: `Team B` },
{ name: `Team C` },
{ name: `Team D` },
{ name: `Team E` },
{ name: `Team F` },
{ name: `Team G` },
];
printing all the exported code above works:
Now here comes the problem. When I try to import code and not just types, somehow it doesn’t run.
Trying to import class UUID
which is in recommend/src/functionality/uuid.ts
:
data_generation/src/functionality/event_generator_engine.ts
:
import { UUID } from "../../../recommender/src/functionality/uuid.js";
If I then build the recommender
project with tsc -b
and then build the data_generation
project with tsc -b
I get the following error when I call anything from the file above: