fix(plugin-rsc): skip build-only generateBundle in bundledDev#1296
Open
mellyeliu wants to merge 2 commits into
Open
fix(plugin-rsc): skip build-only generateBundle in bundledDev#1296mellyeliu wants to merge 2 commits into
mellyeliu wants to merge 2 commits into
Conversation
In bundledDev mode the client environment runs a Rollup build while mode === 'dev', so the assets-manifest generateBundle hook fires even though no RSC build output exists. It then reads manager.bundles['rsc'] (populated only by a production build) and crashes with 'TypeError: Cannot convert undefined or null to object'. The dev manifest is already served by the load hook, so the build-only asset copying and buildAssetsManifest construction are unnecessary in dev. Return early when mode === 'dev'.
Reuses examples/basic with 'pnpm dev --experimental-bundle' and asserts the dev server starts, renders, and hydrates without the generateBundle crash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
experimental.bundledDev: truecrashes the dev server on startup:The
assets-manifestmanifest is served two ways: theloadhook builds it in dev, andgenerateBundlebuilds it in production frommanager.bundles['rsc']. In normal dev,generateBundlenever runs. In bundledDev the client environment runs a Rollup build whilemode === 'dev', sogenerateBundlefires, but there's no RSC build, somanager.bundles['rsc']isundefinedandObject.values(rscBundle)throws.The fix is to return early from
generateBundlein dev, since theloadhook already provides the manifest there.(Production builds and are unaffected)
Testing
plugin-rscunit suite passes (448/448).use client/use server+ hydration) withbundledDev: true: crashed before, works after, dev server starts and serves a correct RSC response.e2e/bundled-dev.test.ts(runsexamples/starterwith--experimental-bundle). I couldn't run the Playwright suite locally, so CI should confirm it