You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I add a lazy.module.css for the lazy page, the build output:
> build
> npm run build:client && npm run build:server
> build:client
> vite build --outDir dist/client --ssrManifest
vite v4.3.9 building for production...
✓ 32 modules transformed.
dist/client/index.html 0.44 kB │ gzip: 0.30 kB
dist/client/ssr-manifest.json 1.59 kB │ gzip: 0.35 kB
dist/client/assets/lazy-754af4a9.css 0.03 kB │ gzip: 0.05 kB
dist/client/assets/index-2e05da30.css 0.28 kB │ gzip: 0.22 kB
dist/client/assets/lazy-17ab1330.js 0.63 kB │ gzip: 0.38 kB
dist/client/assets/index-50fa91a8.js 378.66 kB │ gzip: 118.34 kB
✓ built in 2.80s
> build:server
> vite build --ssr src/entry.server.tsx --outDir dist/server
vite v4.3.9 building SSR bundle for production...
✓ 4 modules transformed.
dist/server/assets/lazy-b6dcff78.js 1.05 kB
dist/server/entry.server.js 10.23 kB
✓ built in 285ms
When I visit the lazy page, there should be multiple files(index-xxx.js/index-xxx.css/lazy-xxxx.js/lazy-xxxx.css) for the path lazy, but the server-side rendering only returned 2 files((index-xxx.js/index-xxx.css). The complete set of files appeared only after hydration, leading to a flickering effect in the page styles.
the server side rendering html:
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8" /><metaname="viewport" content="width=device-width, initial-scale=1.0" /><title>React Router - Data Router SSR Example</title><scripttype="module" crossoriginsrc="/assets/index-50fa91a8.js"></script><linkrel="stylesheet" href="/assets/index-2e05da30.css" /></head><body><divid="app"><!-- ...... --></div></body></html>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I tried the react-router/examples/ssr-data-router and found an issue:
I add a
lazy.module.css
for the lazy page, the build output:When I visit the lazy page, there should be multiple files(index-xxx.js/index-xxx.css/lazy-xxxx.js/lazy-xxxx.css) for the path lazy, but the server-side rendering only returned 2 files((index-xxx.js/index-xxx.css). The complete set of files appeared only after hydration, leading to a flickering effect in the page styles.
the server side rendering html:
client side:
The manifest(dist/client/ssr-manifest.json) contains mappings of module IDs to their associated chunks and asset files.
To leverage the manifest, frameworks need to provide a way to collect the module IDs of the components that were used during a server render call.
Is there a vite plugin which supports context.modules for react SSR ?
Beta Was this translation helpful? Give feedback.
All reactions