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

Circular dependency warnings when importing helpers in sub-components #15

Closed
matthewrobb opened this issue Nov 29, 2019 · 3 comments
Closed

Comments

@matthewrobb
Copy link

If you try to import { url } from 'svelte-filerouter'; inside of any sub component of a routed component you get circular dependency warnings due to the way the generated route file works. This makes building components like difficult to do presently. I am filing this issue because honestly I am not sure what the best approach ought to be to avoid this in a clean way.

Sidenote: Awesome project so far!

@matthewrobb
Copy link
Author

Thought: what if const ROUTES_FILE = 'generatedRoutes.js' was instead something like const ROUTES_FILE = 'svelte-filerouter/generated-routes' and it was required to be explicitly imported and passed to the main lib?

@matthewrobb
Copy link
Author

Locally what I did was remove all direct imports to the generated routes file in this lib. In my App.svelte I import the generated routes file and pass the routes in with <Router {routes} />.

This seems to work well but there's even more optimization that can happen by moving routes into the store module. Then the generated module can import and set the store.

@jakobrosenberg
Copy link
Member

jakobrosenberg commented Nov 30, 2019

Thanks for the kind words.

I'm considering to add the url helper as a prop instead of having to import it. That would make it context aware and enable URLs that are relational to the current file, rather than the current URL.

For instance, currently if you have an admin module with navigational links like "./posts" and "./users". Navigating to users while you're in posts would direct you to /posts/messages.

My only concern is poluting the props. We already have route, routes and _routerOptions being passed to every page. I'll create a new issue on this.

EDIT:
Solved in v2.

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

2 participants