code splitting of routers?
See original GitHub issueI have recently focused on developing the Svelte project using Parcel… By the way, I wonder if the code splitting of parcel can be applied to the routes index map of spa router.
import Home from './routes/Home.svelte'
import Book from './routes/Book.svelte'
import NotFound from './routes/NotFound.svelte'
const routes = {
'/': Home,
// Might be like this?
'/author/:first/:last?': async () => await import('./routes/Author.svelte'),
'/book/*': Book,
'*': NotFound
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Code Splitting with React, React.lazy, and React Router - ui.dev
In this post you'll learn how to increase the performance of your React application by adding code splitting with React.lazy and React ...
Read more >Routing and Code Splitting in React - Better Programming
In this piece, I'll demonstrate how to use React Router and at the same time take into account performance optimization using route-based code...
Read more >React Router 6.4 Code-Splitting - Infoxicator.com
The Component and Loader can be code-split into separate files. The Component's javascript bundle and the data fetching start at the same time, ......
Read more >Code Splitting with React and React Router - Medium
Code splitting has gained popularity recently for its ability to allow you to split your app into separate bundles your users can progressively...
Read more >Code-Splitting - React
Here's an example of how to setup route-based code splitting into your app using libraries like React Router with React.lazy . import React,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for that. I like your solution, and I think it looks very elegant. I’m happy to include a note in the Advanced Usage readme. Let’s continue in #36
Hi @hmmhmmhm I have not tried this, but it should work.
However, what you need to keep in mind is that the async function would be executed when the route object is defined. So, yes, you’d get code splitting – but all routes would be loaded at the same time, on page load.
If you want true async loading, then a possible way is to add to the router a route whose sole job is to load the Author route asynchronously.
If you want to modify this router to support async route loading, you’re welcome to submit a PR 😃