-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue: not resolving paths on tsconfig for next.js projects #818
Comments
Hi @toni-monteagudo thank you for reporting this - and for the research you put into it - I really appreciate that! It turns out the I've checked (by removing the check) - and tsconfig-paths still does this in its latest version (and using the latest version of TypeScript), which one could argue to be a bug as it's not consistent anymore with how recent versions of TypeScript operate:
It seems the tsconfig-paths-webpack-plugin authors tend to agree with this: tsconfig-paths-webpack-plugin#99. fixing thisDocumenting this behavior is certainly an option - but just adding the (unrecommended) baseUrl option to a tsconfig to make tsconfig-paths/ dependency-cruiser work doesn't feel entirely right. Configuring TypeScript projects is hard enough as it is. In stead it'd be ideal if the tsconfig-paths(-webpack-plugin) wouldn't need it anymore either. If I can find the energy for it I'll see if I can take a stab at raising a PR over there. Alternatively (and probably quicker), I can implement a workaround in dependency-cruiser:
|
Hi @toni-monteagudo the update on tsconfig-paths-webpack-plugin didn't seem too hard to do so I've made a pull request on the project: tsconfig-paths-webpack-plugin #105. Updates on dependency-cruiser will follow (both in parallel to the time it takes to land the above PR & another one after). |
hi again @toni-monteagudo dependency-cruiser@13.0.5 (just released) contains the fix for this issue, which works independent of the the patch to the tsconfig-paths-webpack-plugin. |
Hi @sverweij ! Woah! This is awesome! Thanks for this quick update 😄 . I would update my project right now! It's a pleasure to work with people who maintain their projects so well. Thank you very much! |
Works like a charm! :) |
Expected Behavior
Current Behavior
By default, next.js generates a tsconfig.json like this, without baseURL:
When using TypeScript in a project without the baseUrl property in the tsconfig.json file, there is a problem with resolving file paths when running the analysis with dependency-cruiser. The file paths are not resolved correctly, leading to inaccurate dependency analysis.
This is the method: https://github.com/sverweij/dependency-cruiser/blob/main/src/main/resolve-options/normalize.mjs#L66C10-L66C33
Possible Solution
One possible solution to address this issue is to update the documentation of dependency-cruiser to provide clearer instructions on how to handle the absence of the baseUrl property in the tsconfig.json file. This would help users understand the impact of not setting the baseUrl and provide guidance on how to resolve file path issues when using TypeScript without baseUrl.
Steps to Reproduce (for bugs)
Your Environment
The text was updated successfully, but these errors were encountered: