fix: Separate entry point for rwsd/client during SSR #494
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.
Problem
Currently, if
rwsdk/client
is imported in a"use client"
component, this will cause us to evaluate code paths that were intended to only run in the browser in the cloudflare worker runtime environment too.This plays out in unexpected ways. For example,
globalThis.__webpack_require__
(used for loading client components on both client side and SSR in worker) gets overridden to use the module loader meant for the browser.Solution
workerd
import condition from vite config: this way, resolutions inclient
environment now (correctly) do not followworkerd
import conditions, butssr
andworker
environments still dorwsdk/client
export conditions to point to a different entry point in theworkerd
case, so that SSR can get its own entry point for this specifier that avoids code paths we only want to run client side