Push HMR updates before the SSR rebuild in dev
Client-only edits are sent to the browser right after the hydration build, without re-running server functions; SSR rebuilds afterwards and props are re-fetched only when a .server.ts output changed or after fullRebuild. Page requests wait for an in-flight SSR rebuild. The SSR build no longer runs Tailwind, the PostCSS processor is reused across rebuilds, and the watcher debounce drops from 200ms to 50ms. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+14
-2
@@ -2,7 +2,7 @@ import * as esbuild from "esbuild";
|
||||
import grabAllPages from "../../utils/grab-all-pages";
|
||||
import grabDirNames from "../../utils/grab-dir-names";
|
||||
import isDevelopment from "../../utils/is-development";
|
||||
import tailwindEsbuildPlugin from "../server/web-pages/tailwind-esbuild-plugin";
|
||||
import { cssStubEsbuildPlugin } from "../server/web-pages/tailwind-esbuild-plugin";
|
||||
import grabPageReactComponentString from "../server/web-pages/grab-page-react-component-string";
|
||||
import grabRootFilePath from "../server/web-pages/grab-root-file-path";
|
||||
import ssrVirtualFilesPlugin from "./plugins/ssr-virtual-files-plugin";
|
||||
@@ -87,6 +87,16 @@ export default async function enqueueSSRRebuild(params) {
|
||||
rebuild_in_flight = run;
|
||||
return run;
|
||||
}
|
||||
/**
|
||||
* Resolves once the in-flight SSR rebuild (if any) has finished. Lets page
|
||||
* requests avoid rendering stale SSR modules against a newer client bundle.
|
||||
*/
|
||||
export async function awaitSSRRebuild() {
|
||||
try {
|
||||
await rebuild_in_flight;
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
async function doSSRRebuild(params) {
|
||||
const force = Boolean(params?.force);
|
||||
const dev = isDevelopment();
|
||||
@@ -137,7 +147,9 @@ async function doSSRRebuild(params) {
|
||||
entryNames: "[dir]/[hash]",
|
||||
metafile: true,
|
||||
plugins: [
|
||||
tailwindEsbuildPlugin,
|
||||
// SSR CSS output is never served (HTML links the
|
||||
// hydration build's CSS), so skip Tailwind here.
|
||||
cssStubEsbuildPlugin,
|
||||
ssrVirtualFilesPlugin({
|
||||
getEntryToPage: () => current_entry_map,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user