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

Make the FS router support lazy loading #3264

Open
Legioth opened this issue Feb 20, 2025 · 0 comments
Open

Make the FS router support lazy loading #3264

Legioth opened this issue Feb 20, 2025 · 0 comments
Labels
enhancement New feature or request hilla Issues related to Hilla

Comments

@Legioth
Copy link
Member

Legioth commented Feb 20, 2025

Describe your motivation

In a big application, views should be split up into separate JS bundles so that the main bundle doesn't keep growing as more views are added.

Describe the solution you'd like

Add a lazy: boolean field to ViewConfig. The default value is false for a view mapped to / or /login and true for all other views. (Yes, this is yet another property where the default is true but that's fine-ish since lazy is much more descriptive than any other name that I've considered).

For a view that is lazy (either explicitly configured or based on the default), we generate file-routes.ts to do const ViewName = lazy(() => import("../views/view-name.js")) instead of the current import * as ViewName from "../views/view-name.js".

Describe alternatives you've considered

We might also want to make it possible to group multiple related views into a single import instead of creating a separate import for each view. We can add that later by changing the type of lazy to boolean | string and changing the logic for generating file-routes.ts so that all views using the same lazy string value are imported from the same URL (by generating a separate helper file that imports and re-exports all desired views).

Additional context

No response

@Legioth Legioth added enhancement New feature or request hilla Issues related to Hilla labels Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hilla Issues related to Hilla
Projects
None yet
Development

No branches or pull requests

1 participant