Comments (11)
Hi @mrlundis,
First thank you for the compliment.
Yes I considered to add support for this, I think it's a very good feature. The philosophy of this library is to be as simple as possible for the user. We have to get Webpack stats, yes. But the biggest problem to solve is linking a component to a webpack chunk, and it's not easy.
I don't want to couple this library to Webpack. If you have an idea to do it without adding complexity it could be interesting. I am thinking about it but I didn't find a good solution yet.
from loadable-components.
I have just given another look, to clarify, server-side we do not have any idea of the corresponding Webpack chunk. The key to achieve it is to be able to know server-side the chunk id corresponding to the import. I don't know the best way to do it.
from loadable-components.
Maybe we can solve this by adding a companion webpack plugin? I don't think this package would need any significant changes, maybe just an option to output the preload tags given a manifest.
I know that Vue projects has prefetch tags working out-of-the-box. Their webpack setup is documented here:
https://github.com/vuejs/vue-ssr-docs/blob/master/en/build-config.md and their plugin source is available here: https://github.com/vuejs/vue/tree/dev/src/server/webpack-plugin
from loadable-components.
@mrlundis a Webpack plugin is not sufficient because we have to know it server-side, and server-side Webpack is not present. Do not hesitate to try it, if it is OK I will merge it!
from loadable-components.
What I meant was that a companion webpack plugin could be used to generate a manifest mapping the module ids to the correct bundles/chunks. That manifest could then be used by the server to generate the correct preload tags.
Will send a PR as soon as I get around to implementing this, will probably take some time though. Have a few other big tasks to tackle first.
from loadable-components.
Hey there. I have another problem, but related. So I did prerendering, and I have code splitting and I have <link rel="preload">
to speed up download. But the problem is that async component loading triggers redraw of pre-rendered content. Do you have solution for this?
P.S. Full code here https://github.com/stereobooster/an-almost-static-stack, I use react-loadable, not loadable-components, but I suppose it will be the same for any "loadable" solution.
from loadable-components.
@stereobooster no I am sorry loadable-components does not support preloading yet.
from loadable-components.
I poked a bit more. You are actually doing excellent work with getLoadableState
. This is not a solution for my case because I do snapshots, not a SSR, but anyway this is totally brilliant.
from loadable-components.
@stereobooster thank you! This is inspired from Apollo server-side rendering, I found the idea brillant and I copied it 🤗.
from loadable-components.
This feature requires a strong dependency with Webpack and increase the setup complexity. It is actually possible to prefetch in JavaScript. Until a simplification in the Webpack ecosystem I don't plan to support preload meta tags.
from loadable-components.
I think preloading not so important if:
- You are using manifest chunk and preload it
- You are using vendors (biggest) chunk and preload it
- Setup correct chunk size with https://webpack.js.org/plugins/min-chunk-size-plugin/
- And also limit their amount with https://webpack.js.org/plugins/limit-chunk-count-plugin/
from loadable-components.
Related Issues (20)
- problem with redial HOT 2
- How to change referencing external styles to preload mode
- Fallback running even when component has previously loaded HOT 1
- Webpack doesn't like @loadable/server 5.16.4 HOT 5
- Server is caching old request split chunks, and these are not being re-requested when a new request is made to the server.
- SassError: Undefined variable HOT 1
- Inline Chunk injection HOT 2
- Not working with latest @loadable/server & @loadable/babel-plugin `v5.16.0` version HOT 4
- How to lazyload a hook? HOT 3
- Fallback behaviour HOT 1
- Main.js is rendered on every page even if I splitted each page into chunks with @loadable/component
- error in ./node_modules/@loadable/component/dist/loadable.esm.mjs HOT 9
- Why ChunkExtractor is required? HOT 3
- Is website sync with repo?
- If I am using react18, do I still need loadable-components HOT 6
- Add esbuild support HOT 3
- react-native-web SSR support HOT 1
- Loading state is always true on first render HOT 3
- Add query parameter support HOT 3
- SSR is broken for component v5.16.2+ HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from loadable-components.