Open alSergey opened 6 months ago
Hello, thanks for the cool library. I'm using nuxt and have encountered an issue where when using the library I'm getting incorrect relative paths returned from tsconfig.
{ "extends": "./.nuxt/tsconfig.json" }
{ "compilerOptions": { "paths": { "~": [ ".." ], "assets": [ "../assets" ], "#app": [ "../node_modules/nuxt/dist/app" ], "#imports": [ "./imports" ], } }, }
{ "paths": { "~": [ "." ], "assets": [ "assets" ], "#app": [ "node_modules/nuxt/dist/app" ], "#imports": [ ".nuxt/imports" ], } }
{ "paths": { "~": [ ".." ], "assets": [ "../assets" ], "#app": [ "../node_modules/nuxt/dist/app" ], "#imports": [ "./imports" ], } }
When searching for paths in tsconfig.json, consider the path to the tsconfig file in which the paths were found and the baseUrl field.
const filesBasePath = path.join(configRelativeDir, baseUrl || '.') // configRelativeDir = '.nuxt' const relativePaths = Object.entries(paths).reduce((obj, [key, values]) => ({ ...obj, [key]: values?.map((item) => path.join(filesBasePath, item)), }), {})
Hello, thanks for the cool library. I'm using nuxt and have encountered an issue where when using the library I'm getting incorrect relative paths returned from tsconfig.
Example
FIle System
tsconfig.json
.nuxt/tsconfig.json
Expected
Result
Suggestion
When searching for paths in tsconfig.json, consider the path to the tsconfig file in which the paths were found and the baseUrl field.
Example code