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
Support baseUrl in tsconfig #7935
Comments
I needed this feature so i did a workaround using tsconfig-paths-webpack-plugin My next.config.js ended up like this EDIT: I just made a template repository using it https://github.com/PabloSzx/Next-TypeScript-Paths |
Duplicate of #7779 |
@PabloSzx Thanks a lot for that comment, I have been looking for solutions for this for a long while now. |
@PabloSzx does this actually work for you? I tried adding as next.config.js
and
inside the tsconfig, but root imports still don't seem to be working (may be due to me mixing js and tsx files). |
@sakulstra i just made a Next 9 template repository which uses TypeScript and tsconfig-paths-webpack-plugin https://github.com/PabloSzx/Next-TypeScript-Paths |
@PabloSzx you need to use |
config.resolve.plugins is an array, should be this:
:D |
@zhengrenzhe @PabloSzx Out of curiosity, do you have the |
It doesn't matter in the final build, and the path equivalents are made in compilation time. Although, there is an experimental official support for this feature |
You'll probably want to use the experimental support from #11293 indeed. It'll be on stable very soon. |
For me, restarting the Next.js dev server worked haha |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
When using the
baseUrl
property intsconfig.json
, Next 9 fails to build with the following error:Module not found: Can't resolve ...
This is resolved by updating the import path to be absolute.
When running
tsc
on the same directory, the relative import works.Expected behavior
The
baseUrl
intsconfig.json
is used when runningnext build
To Reproduce
Update tsconfig to use
baseUrl
compiler option:Assuming a directory structure of:
Import file using relative path:
package.json
The text was updated successfully, but these errors were encountered: