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
It is related to this issue: #1437. Though AFAIU the problem is not caused by the file extension. Thus I decided to open a new issue. Hope that's fine.
Describe the solution you'd like
A solution could be to use tsc-alias as a post-compilation step, instead of using tsconfig-paths in pre-compilation.
A possible benefit: Rewriting the paths with tsconfig-paths in pre-compilation involves some custom code which you could probably lose with tsc-alias.
I haven't fully tested it, but when I change the build script to "nest build && tsc-alias -p tsconfig.build.json", the import is correct in the compiled dist/app.module.js after running npm run build. See here: https://stackblitz.com/edit/nestjs-typescript-starter-rcmvukfp
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
tsconfig-paths is used by the nest-cli to rewrite paths according to path aliases specified in tsconfig.json.
tsconfig-paths does not work with ES Modules as reported here e.g.:
Thus
nest start
throws an ERR_MODULE_NOT_FOUND when compiling to ES Modules and using path aliases. Here is a minimal example: https://stackblitz.com/edit/nestjs-typescript-starter-m27m4jmoIt is related to this issue: #1437. Though AFAIU the problem is not caused by the file extension. Thus I decided to open a new issue. Hope that's fine.
Describe the solution you'd like
A solution could be to use tsc-alias as a post-compilation step, instead of using tsconfig-paths in pre-compilation.
A possible benefit: Rewriting the paths with tsconfig-paths in pre-compilation involves some custom code which you could probably lose with tsc-alias.
I haven't fully tested it, but when I change the build script to
"nest build && tsc-alias -p tsconfig.build.json"
, the import is correct in the compileddist/app.module.js
after runningnpm run build
. See here: https://stackblitz.com/edit/nestjs-typescript-starter-rcmvukfpTeachability, documentation, adoption, migration strategy
No response
What is the motivation / use case for changing the behavior?
We would like to use path aliases in a project and this hinders it at the moment.
The text was updated successfully, but these errors were encountered: