Comments (3)
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.
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.
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)
- Files in /public folder are not served in production mode HOT 4
- Error on Windows: TypeError: Cannot read properties of null (reading 'replace')
- Websocket can not connect when using https fastify
- If vites config contains `defineConfig` with callback, then SSR is broken HOT 3
- How to configure multi-page entry
- Issues running with fastify-compress HOT 4
- Serve static assets from ssr builds in production mode HOT 2
- TypeError [ERR_INVALID_ARG_TYPE]: The "paths[0]" argument must be of type string
- Trace: The CJS build of Vite's Node API is deprecated
- Conflicting websockets between vite and `@fastify/websocket` causing infinite redirects HOT 1
- [react][windows] React Starter Template does not start on Windows HOT 4
- How to use Vue plugins like instance.use(...) HOT 4
- NPM install fails with 'edgesout' error HOT 3
- [SPA] allowing passing additional context to the render function HOT 3
- mts file extension is not supported for vite.config HOT 3
- @fastify/vue Smart Import doesn't resolve path in windows HOT 5
- How to config fastify-vite in a Electron Vite project HOT 1
- SPA Documentation / Examples HOT 5
- Move `fastify` and `vite` to peer dependencies
- Missing `fastify-plugin` dependency
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 fastify-vite.