Skip to content

bugfix: use explicit export block in SSR bridge to fix Rolldown/Vite+ builds#1098

Merged
justinvdm merged 1 commit intoredwoodjs:mainfrom
joefairburn:fix-ssr-bridge-exports
Mar 22, 2026
Merged

bugfix: use explicit export block in SSR bridge to fix Rolldown/Vite+ builds#1098
justinvdm merged 1 commit intoredwoodjs:mainfrom
joefairburn:fix-ssr-bridge-exports

Conversation

@joefairburn
Copy link
Copy Markdown
Contributor

Summary

Fixes #1097

  • The ssrBridgeWrapPlugin wraps the SSR bridge output in an IIFE during Rollup's renderChunk hook. After this, Vite's esbuild minification mangles the destructured binding names (renderHtmlStream: e, ssrLoadModule: t, etc.), so the actual ES module exports become single-letter variables
  • Rolldown's (used by Vite+) strict static analysis reports MISSING_EXPORT errors. Rollup seems to be more lenient, and doesn't throw errors for this.
  • Changed from export const { renderHtmlStream, ... } = (function() { ... })() to local destructuring + a separate export { ... } block, which minifiers always preserve

Test plan

  • Verified vp build fails without the fix (MISSING_EXPORT x3)
  • Verified vp build passes with the fix
  • Verified regular vite build still passes (hello-world playground)

The destructured `export const { renderHtmlStream: e, ... }` pattern
exports mangled single-letter bindings after minification. Rolldown
(Vite+) does strict static analysis and correctly rejects imports of the
original names. Switch to local destructuring + `export { ... }` block,
which minifiers always preserve.
@justinvdm
Copy link
Copy Markdown
Collaborator

Thank you so much @joefairburn! Both for testing rwsdk out with vite+, then fixing what you ran into 🙇

Change makes total sense 👍

@justinvdm justinvdm merged commit 409331d into redwoodjs:main Mar 22, 2026
11 of 14 checks passed
@justinvdm
Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vite+ builds fail due to ssr_bridge.js exports

2 participants