Git Product home page Git Product logo

Comments (11)

gregberge avatar gregberge commented on August 10, 2024

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.

gregberge avatar gregberge commented on August 10, 2024

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.

jonatansberg avatar jonatansberg commented on August 10, 2024

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.

gregberge avatar gregberge commented on August 10, 2024

@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.

jonatansberg avatar jonatansberg commented on August 10, 2024

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.

stereobooster avatar stereobooster commented on August 10, 2024

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.

gregberge avatar gregberge commented on August 10, 2024

@stereobooster no I am sorry loadable-components does not support preloading yet.

from loadable-components.

stereobooster avatar stereobooster commented on August 10, 2024

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.

gregberge avatar gregberge commented on August 10, 2024

@stereobooster thank you! This is inspired from Apollo server-side rendering, I found the idea brillant and I copied it 🤗.

from loadable-components.

gregberge avatar gregberge commented on August 10, 2024

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.

max-mykhailenko avatar max-mykhailenko commented on August 10, 2024

I think preloading not so important if:

  1. You are using manifest chunk and preload it
  2. You are using vendors (biggest) chunk and preload it
  3. Setup correct chunk size with https://webpack.js.org/plugins/min-chunk-size-plugin/
  4. And also limit their amount with https://webpack.js.org/plugins/limit-chunk-count-plugin/

from loadable-components.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.