Skip to content

SSR: Phase 0.4 request-safe collection#89

Merged
dbanksdesign merged 2 commits into
mainfrom
fix/ssr-collection-p0-4
Jun 12, 2026
Merged

SSR: Phase 0.4 request-safe collection#89
dbanksdesign merged 2 commits into
mainfrom
fix/ssr-collection-p0-4

Conversation

@dbanksdesign

Copy link
Copy Markdown
Collaborator

Summary

  • Refactor sheet state into a pluggable store (sheet-context.ts) so SSR collection can run in isolated scopes
  • On Node, typestyles/server and typestyles/build enable AsyncLocalStorage isolation (sheet-node.ts) — concurrent collectStyles / collectStylesFromModules calls no longer share ssrBuffer or dedupe state
  • Add async render support: collectStyles(async () => …) returns Promise<{ html, css }> (sync callers unchanged)
  • Browser bundle unchanged — sheet-node is only imported from server/build entries; node:async_hooks marked external in tsup

Test plan

  • pnpm --filter typestyles test (includes concurrent async isolation test)
  • Full monorepo pnpm test
  • pnpm --filter typestyles build
  • Verify @typestyles/next collectStylesFromComponent still works in an App Router app

Made with Cursor

dbanksdesign and others added 2 commits June 11, 2026 21:36
Isolate per-request sheet state for collectStyles and collectStylesFromModules on Node, and add async render function support to collectStyles.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@dbanksdesign dbanksdesign merged commit b29a531 into main Jun 12, 2026
6 checks passed
@dbanksdesign dbanksdesign deleted the fix/ssr-collection-p0-4 branch June 12, 2026 04:43
@github-actions github-actions Bot mentioned this pull request Jun 12, 2026
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