Here is the case. I am using Nrwl NX Monorepo. I have 2 libraries: lib-a
and lib-b
; both are publishable libraries created via NX.
Now I create a MyClass.ts
in lib-a
. Naturally under paths in workspace/tsconfig.json
> paths
NX creates an alias to this lib-a
("@workspace/lib-a": ["libs/lib-a/src/index.ts"]
).
So far so good. Now we can use this class anywhere within the workspace/monorepo by importing it via import { MyClass } from '@workspace/lib-a';
Unfortunately we can not build lib-b
which is importing MyClass
. When we try to do it we get the bellow error. So question is how can we build lib-b
?
PS: It seems strange that NX monorepo actually don't support such a common scenario linking 2 publishable libs.
"error TS6059: File "d:/workspace/libs/lib-a/src/index.ts" is not under 'rootDir' "d:\workspace\libs\lib-b\src" rootDir is expected to contain all source files"
tsconfig.base.json
file to change the alise to the lib? In my case that was the issue. if so that same alise name should be under the libs/<lib-name>/package.json -> name property. let me know the comment is not clear, I'll post a new answer. – Wirra