Skip to content

fix: Separate entry point for rwsd/client during SSR #494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2025

Conversation

justinvdm
Copy link
Collaborator

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

  • Remove the global workerd import condition from vite config: this way, resolutions in client environment now (correctly) do not follow workerd import conditions, but ssr and worker environments still do
  • Change our rwsdk/client export conditions to point to a different entry point in the workerd case, so that SSR can get its own entry point for this specifier that avoids code paths we only want to run client side

@justinvdm justinvdm merged commit 08b147d into main Jun 5, 2025
5 checks passed
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.

1 participant