Skip to content

fix(styled): defer default document access for server rendering - #2258

Open
YashAnand69 wants to merge 1 commit into
RocketChat:mainfrom
YashAnand69:fix/styled-server-import
Open

YashAnand69 wants to merge 1 commit into
RocketChat:mainfrom
YashAnand69:fix/styled-server-import

Conversation

@YashAnand69

Copy link
Copy Markdown

Proposed changes (including videos or screenshots)

Allow @rocket.chat/styled to be imported in Node so its existing server-rendering path can emit styles and markup.

The default OwnerDocument context currently evaluates window.document at import time. Resolve that default through a getter instead; browser access and explicitly provided documents retain the same Document type.

Issue(s)

Closes #2257

Further comments

  • Before the fix, the Node regression suite fails at import with window is not defined.
  • After the fix: full styled suite passes (2 suites, 5 tests), covering server markup/CSS, filtered props/class names, browser defaults, and a separate document provider.
  • Package lint, formatting, TypeScript and diff checks pass. Patch changeset included.
  • This fixes the styled package entry point; it does not claim that every Fuselage component supports SSR. Reading the default browser document itself still requires a browser. No styling rule or visual change.

AI assistance: implemented and tested with OpenAI Codex.

@changeset-bot

changeset-bot Bot commented Sep 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5696868

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@rocket.chat/styled Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
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.

styled: importing the package during server rendering throws window is not defined

1 participant