Bundle postcss in standalone SSR builds - #13673
Conversation
This reverts commit b4ab0ea.
🪼 branch checks and previews
Install Gradio from this PR pip install https://huggingface.co/buckets/gradio/pypi-previews/resolve/2399b03260a1971df98b119d854b67053c9f386f/gradio-6.20.0-py3-none-any.whlInstall Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@2399b03260a1971df98b119d854b67053c9f386f#subdirectory=client/python"Import Gradio JS Client from this PR via CDN import { Client } from "https://huggingface.co/buckets/gradio/npm-previews/resolve/2399b03260a1971df98b119d854b67053c9f386f/browser.js"; |
🦄 change detectedThis Pull Request includes changes to the following packages.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a regression in Gradio’s standalone SSR Node build (shipped in the Python wheel) where postcss is externalized in Vite 8 SSR output and therefore missing at runtime, causing SSR renders to fail. It also adds a build-time verification step that copies the built SSR output into an isolated temp directory and performs an SSR render to catch future accidentally-externalized runtime dependencies during the frontend build.
Changes:
- Bundle
postcssinto the SSR output viassr.noExternalin the Vite config. - Add
js/app/verify_build.jsto perform an isolated SSR render verification as part of the build pipeline. - Run the verification step during
@self/app’sbuildscript.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
js/app/vite.config.ts |
Adds postcss to SSR noExternal to ensure it’s bundled into the SSR output. |
js/app/verify_build.js |
New build-time isolated SSR render verification script. |
js/app/package.json |
Runs verify_build.js as part of the build script. |
.changeset/thin-donuts-make.md |
Adds a changeset entry for @self/app. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (result.status !== 0) { | ||
| throw new Error("Standalone SSR build verification failed"); | ||
| } |
| --- | ||
| "@self/app": minor | ||
| --- | ||
|
|
||
| feat:Bundle postcss in standalone SSR builds |
abidlabs
left a comment
There was a problem hiding this comment.
Great LGTM and confirmed https://huggingface.co/spaces/gradio-pr-deploys/pr-13673-all-demos is up now
#13673 landed the same `ssr.noExternal` change and its own js/app/verify_build.js, so take main's version of both and of the build script. What's left here is the Python side that PR didn't cover: surfacing Node's stderr instead of blaming the Node install, and serving without SSR on the user-facing port instead of stranding the app on an internal one. Also drop the hand-written changeset — per AGENTS.md #7 (merged in #13682) the bot generates it from the PR title.
Description
Vite 8 externalizes
postcssfrom the SSR output, but the Node build shipped in the wheel does not install it. This makes style sanitization fail at runtime and every SSR render return HTTP 500.This PR bundles
postcssthroughssr.noExternaland adds a build-time check that copies the generated server and production dependencies into an isolated temporary directory, then performs an SSR render. Future accidentally externalized runtime dependencies will therefore fail the frontend build.Closes: #13672
AI Disclosure
🎯 PRs Should Target Issues
Issue #13672 describes the regression and reproduction. No overlapping open issue or PR was found before opening this PR.
Testing and Formatting Your Code
pnpm --filter @self/app buildnode js/app/verify_build.jsnode --test js/app/proxy_routes.test.js(60 passed)curl http://127.0.0.1:7860/returns HTTP 200bash scripts/format_frontend.shformatted the patch; its repository-wide type-check step still reports existing errors in unrelated frontend filesMinimal demo (kept untracked):