Does not work with Project References that have a rootDir in their tsconfig
In my main project tsconfig.json there is:
"compilerOptions": {
...
"outDir": "../dist/api",
"baseUrl": ".",
"paths": {
"models": ["../models/src/index.ts"]
}
},
"include": ["./src"],
"references": [
{
"path": "../models"
}
]
being models a Project Reference, there's a tsconfig.json file in its directory:
{
"compilerOptions": {
"composite": true,
"outDir": "../dist/models",
"rootDir": "./src"
},
"include": ["./src"]
}
This means the output of tsc will be put directly in ../dist/models skipping the src subdirectory.
When tsc-aliases runs, it is trying to locate the file dist/models/src/index.js, deems it invalid and doesn't replace the import.
But it should have been looking in dist/models/index.js instead.
@miguel-leon can you provide us the console output when running with --debug?
It contained a lot of unnecessary information, because it wasn't a new empty project.
I took the path it is trying to locate ...dist/models/src/index.js from that output, that's how I know.
Also there wasn't any signs of the models/tsconfig.json being loaded to check up on the rootDir.
I already moved on, so I don't have it anymore. I was letting you guys know in case you were interested.
This issue could probably be solved by changing
"models": ["../models/src/index.ts"]
to
"models": ["../models/src/index.ts", "../models/index.js"]
I think an update to rootDir's parsing is needed to fully resolve this issue here. Make it possible to parse the directory after the build.
This issue could probably be solved by changing
"models": ["../models/src/index.ts"]to"models": ["../models/src/index.ts", "../models/index.js"]
This doesn't work.