You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to use this tool in a monorepo, I'm getting 'module not found' errors for some of my cross-module imports that rely on the paths setting in tsconfig. This seems to be due to an issue with how the tsconfig file is being loaded when your tsconfig is in a subdirectory and extends other tsconfig files:
If I log parseResult, I see it has errors and is unable to find./tsconfig.json, since it's resolving configFile against the passed basePath path.resolve(path.dirname(configFile)), which is yielding a path of lib/mydomain/lib/mydomain/tsconfig.lib.json. The trivial fix is to pass path.resolve(configFile) as the 5th argument, instead of configFile. Making this change locally resolved the issue.
When trying to use this tool in a monorepo, I'm getting 'module not found' errors for some of my cross-module imports that rely on the paths setting in tsconfig. This seems to be due to an issue with how the tsconfig file is being loaded when your tsconfig is in a subdirectory and extends other tsconfig files:
i.e. tsconfig: 'lib/mydomain/tsconfig.lib.json':
In
loadTsConfigFile.ts
, you have:If I log parseResult, I see it has errors and is unable to find
./tsconfig.json
, since it's resolvingconfigFile
against the passed basePathpath.resolve(path.dirname(configFile))
, which is yielding a path oflib/mydomain/lib/mydomain/tsconfig.lib.json
. The trivial fix is to passpath.resolve(configFile)
as the 5th argument, instead ofconfigFile
. Making this change locally resolved the issue.See https://github.com/microsoft/TypeScript/blob/cf33fd0cde22905effce371bb02484a9f2009023/src/compiler/commandLineParser.ts#L2074 for the equivalent code in tsc, which does indeed resolve the path of configFile.
I couldn't find a workaround, since your code handles the tsconfig loading and there's no way to specify the config manually.
The text was updated successfully, but these errors were encountered: