Giter Site home page Giter Site logo

Comments (3)

galvez avatar galvez commented on May 1, 2024 1

We're able to do this because Webpack is smart enough to know what a shared chunk is, and what isn't.

This is exactly how Vite behaves as well.

would I be able to disable hydration and remove the JS bundles all together?

Yes, I'm actually almost done with an example demonstrating just that!

from fastify-vite.

galvez avatar galvez commented on May 1, 2024

How we can use the ssr-manifest to find the bundles used in the current render path (i.e. how do we know the moduleIds, especially when rendering React?)

Indeed, that is a question I have myself now — and is currently unanswered. With Vue, running renderToString() (the SSR function) with a context object will get you ctx.modules, which you can then use to do the mapping, but I haven't found a working alternative for React yet — or maybe haven't looked hard enough.

How Vite or Fastify-Vite is inserting the bundle in the first place.

The bundle comes from the /mount.js include in index.html.

Vite automatically transforms that, both in development and production modes.

As for code-splitting, it's already possible. The vue-hydration example has lazy-loaded routes. For React, lazy-loading of routes now requires you to use SSR in streaming mode otherwise it just doesn't work (having React.lazy(), that is). I'm working on a new set of examples that demonstrate all of this in place for React.

Let's keep this issue open to track this.

from fastify-vite.

dac09 avatar dac09 commented on May 1, 2024

Thanks for the reply @galvez - and great to get the conversation started.

which you can then use to do the mapping, but I haven't found a working alternative for React yet — or maybe haven't looked hard enough

yeah me neither - its a complete mystery to me still. However - I wonder if we do codesplit across routes using import - I wonder ssr-manifest will have the required bundles per route. What we do in Redwood is we create a "base" app bundle (included with all pages) - then dynamically load the bundles per route. We're able to do this because Webpack is smart enough to know what a shared chunk is, and what isn't. I suspect the solution here will need to be something similar.

The bundle comes from the /mount.js include in index.html.

Yup - but I wonder if we have more control over this? For example - when I go to /mystaticpage, and this page is completely prerendered (i.e. no need for js) - would I be able to disable hydration and remove the JS bundles all together?

from fastify-vite.

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.