I see this question, but it is slightly different and has no answers
I have a couple of git submodules. They are large existing projects, and I thought I could just reuse pieces directly like:
myproject/
src/
submod1/src
submod2/src
with tsconfig.json like
<snip...>
"rootDir": "src/",
"outDir": "./dist",
"paths": {
"@submod1/*": [ "submod1/src/*" ],
"@submod1/*": [ "submod2/src/*" ],
"@app/*": [ "src/*" ]
},
And in my code things like
import { SomeVar } from '@submod1/constants';
But vscode (and tsc presumably) are reporting
File '<path>/submod1/src/index.ts' is not under 'rootDir' '<path>/src'. 'rootDir' is expected to contain all source files.
I'm just trying to do something simple and pragmatic. Is there a way to achieve this? I guess I could do something with symlinks, but that seems like a big mistake. I could put the submodules under src/ but that also seems wrong.
Looks like there's no 'clear' solution to this. You can either
myproject in your tsconfig.json's rootDir which might be error prone if you're going to have more modules and wouldn't like to reuse anything besides submod1 and submod2or
rootDirs property to selectively include all the needed submodules{
"compilerOptions": {
"rootDirs": ["src", "submod1/src", "submod2/src"]
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With