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

Async resource definition #77

Closed
theKashey opened this issue Mar 31, 2021 · 3 comments
Closed

Async resource definition #77

theKashey opened this issue Mar 31, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@theKashey
Copy link
Collaborator

Feature request

  • Allow route definition level code splitting.

Details

Right now the only way to code split resource logic is to implement getDataLoader for a resource, while resources are more or less static property on the route definition.

While getDataLoader seems to be the correct way of doing it - it allows some "already loaded resources" to act sooner - it creates some over complications if has to be compulsorily used, and in our case it is.

Proposal

  • extend resources field of Route to also accept a function resolving into a set of promises
  • or extend resource in resources to accept a LazyResource, and expose a helper function to convert import('my-resource') into such object.

What is solves

In feature request is not changing anything for the end customer, however makes life of a developer a little easier, decreasing the initial bundle size as well by making it easier to defer resources without any extra code written.

@albertogasparin
Copy link
Collaborator

albertogasparin commented Apr 14, 2021

This is an interesting idea. Needs some spiking as not entirely sure of the implications if we cannot immediately know the type and the getKey function. I'm especially thinking about hydration from SSR, where we pass the state directly to the router and expect useResource hooks to immediately render with data 🤔

@albertogasparin albertogasparin added the enhancement New feature or request label Apr 14, 2021
@theKashey
Copy link
Collaborator Author

The resource chunk existence before the application start sounds not like a big problem for code splitting, however in this case it will be loaded with the full dataLoader as well, bringing more code than required initially.
Quite far from the perfect.

Sounds like writting a little more code is still a better idea.

@albertogasparin
Copy link
Collaborator

I'll close this issue for now, if we have better ideas for the future happy to reopen :)

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

No branches or pull requests

2 participants