Skip to content

Bundle postcss in standalone SSR builds - #13673

Merged
dawoodkhan82 merged 3 commits into
mainfrom
codex/fix-ssr-postcss
Jul 29, 2026
Merged

Bundle postcss in standalone SSR builds#13673
dawoodkhan82 merged 3 commits into
mainfrom
codex/fix-ssr-postcss

Conversation

@dawoodkhan82

@dawoodkhan82 dawoodkhan82 commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Description

Vite 8 externalizes postcss from 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 postcss through ssr.noExternal and 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

  • I used AI to investigate the regression, implement the fix and standalone build check, and draft this PR. I self-reviewed every changed line.
  • I did not use AI

🎯 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 build
  • node js/app/verify_build.js
  • node --test js/app/proxy_routes.test.js (60 passed)
  • Local Gradio SSR demo: Node listens on port 7860 and curl http://127.0.0.1:7860/ returns HTTP 200
  • bash scripts/format_frontend.sh formatted the patch; its repository-wide type-check step still reports existing errors in unrelated frontend files

Minimal demo (kept untracked):

import gradio as gr

with gr.Blocks() as demo:
    gr.HTML('<div style="color: red">SSR standalone build works</div>')

if __name__ == "__main__":
    demo.launch(ssr_mode=True, server_port=7860, debug=True)

@gradio-pr-bot

gradio-pr-bot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://huggingface.co/buckets/gradio/pypi-previews/resolve/2399b03260a1971df98b119d854b67053c9f386f/gradio-6.20.0-py3-none-any.whl

Install 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";

@gradio-pr-bot

Copy link
Copy Markdown
Collaborator

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@self/app minor

  • Bundle postcss in standalone SSR builds

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@dawoodkhan82
dawoodkhan82 requested a review from Copilot July 29, 2026 01:43
@dawoodkhan82
dawoodkhan82 marked this pull request as ready for review July 29, 2026 01:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 postcss into the SSR output via ssr.noExternal in the Vite config.
  • Add js/app/verify_build.js to perform an isolated SSR render verification as part of the build pipeline.
  • Run the verification step during @self/app’s build script.

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.

Comment thread js/app/verify_build.js
Comment on lines +74 to +76
if (result.status !== 0) {
throw new Error("Standalone SSR build verification failed");
}
Comment on lines +1 to +5
---
"@self/app": minor
---

feat:Bundle postcss in standalone SSR builds

@abidlabs abidlabs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dawoodkhan82
dawoodkhan82 merged commit f412c6d into main Jul 29, 2026
31 of 32 checks passed
@dawoodkhan82
dawoodkhan82 deleted the codex/fix-ssr-postcss branch July 29, 2026 02:04
abidlabs added a commit that referenced this pull request Jul 29, 2026
#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSR wheel renders fail when postcss is not bundled

4 participants