-
Notifications
You must be signed in to change notification settings - Fork 202
Handle path mappings in Nx monorepos #300
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
Conversation
@chrisguttandin would you have a look since you have the most context. |
if (loadChildren.startsWith('.')) { | ||
return join(dirname(parentPath), childModule); | ||
return join(dirname(parentPath), childModuleFile); | ||
} | ||
const parentSegments = dirname(parentPath).split(sep); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping to get rid of this but resolveModuleName
seems to get confused when the route is relative to the app root, which in Angular is possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is because TypeScript does not even attempt to look up a file if it does not start with a dot. I guess it does try to look up the first part of those paths as a node module instead. So if we define loadChildren: 'app/qux/qux.module'
TypeScript will probably look for a node module named 'app' and if it exists it would attempt to find the 'qux/qux.module' file in it.
Anyway I wondered if we could help TypeScript by prepending a './' to tell it that we want it to look for a file and not a node module. I did a quick test but it doesn't work right now. I think it's because the test fixture is inconsistent when it comes to the the old loadChildren
syntax. The path defined here would have to be prepended with '../' since the path starts with the parent folder. But here the path would have to be prepended with './' since it starts with a folder inside the current directory. Did Angular resolve both of them correctly or is that a bug in the test fixture?
Unfortunately the update broke the integration tests of angular-prerender. https://github.com/chrisguttandin/angular-prerender/runs/393678803 I'm on the run now but I will try to have a look later today. |
Looking at the failure, seems like the route did not get rendered:
|
Sorry, the error was unrelated to this update. It was a side effect of the update of @wessberg/ts-evaluator. It used to have typescript as a dependency but that got removed. I had to define typescript as an explicit dependency of angular-prerender to get it working with npx again. |
No description provided.