Skip to content
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

If app-routing isn't in same dir as app.module, guess errors on it's lazily loaded routes. #345

Open
aaronfrost opened this issue Mar 4, 2020 · 6 comments

Comments

@aaronfrost
Copy link

If my project looks like this:

- app.module.ts
- routing
    |- app-routing.module.ts

And in the app-routing I have routes that are lazily loaded, when I do the traverseForRoutes stuff... it errors on the lazily loaded modules in the app-routing. If I move the file back to the same dir as the app.module... the error goes away.

@mgechev
Copy link
Member

mgechev commented Mar 5, 2020

It'll be helpful if you can provide a tiny repro so I can play around with it over the weekend.

@aaronfrost
Copy link
Author

This is a good point. Let me see if I can get something together for you.

@suke
Copy link

suke commented Jan 23, 2021

Hi, I created a demo app that reproduces this problem.
It also includes a script to run guess-parser node ./scripts/routes.js.

@mgechev
Copy link
Member

mgechev commented Jan 23, 2021

Thank you @suke, I'll make some time for this issue in the next a couple of days.

@rhutchison
Copy link

I can confirm I'm also seeing an issue with path resolution. lmk if you need additional details, but it sounds like the same issue.

Error: The relative path "../../collections/collections-routing.module" to "C:\Websites\gym.com\apps\gym\src\app\app.module.ts" cannot be resolved to a module
    at Object.exports.getModulePathFromRoute (C:\Websites\gym.com\node_modules\guess-parser\dist\guess-parser\index.js:334:15)
    at Object.exports.getRoute (C:\Websites\gym.com\node_modules\guess-parser\dist\guess-parser\index.js:570:34)
    at C:\Websites\gym.com\node_modules\guess-parser\dist\guess-parser\index.js:558:28
    at Array.map (<anonymous>)
    at Object.exports.getRoute (C:\Websites\gym.com\node_modules\guess-parser\dist\guess-parser\index.js:554:14)
    at C:\Websites\gym.com\node_modules\guess-parser\dist\guess-parser\index.js:938:34
    at visitTopLevelRoutes (C:\Websites\gym.com\node_modules\guess-parser\dist\guess-parser\index.js:909:13)
    at visitNodes (C:\Websites\gym.com\node_modules\typescript\lib\typescript.js:27858:30)
    at Object.forEachChild (C:\Websites\gym.com\node_modules\typescript\lib\typescript.js:28032:24)
    at NodeObject.forEachChild (C:\Websites\gym.com\node_modules\typescript\lib\typescript.js:146142:23)

@AlexAegis
Copy link

I encountered the problem too, and explored it a little further, for example in the case of nested lazy modules. Please check the description of this issue: scullyio/scully#1347

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants