Skip to content

Defer React loading until fetch dedupe construction - #100401

Merged
kassens merged 3 commits into
canaryfrom
kassens/lazy-fetch-react
Oct 22, 2026
Merged

kassens merged 3 commits into
canaryfrom
kassens/lazy-fetch-react

Conversation

@kassens

@kassens kassens commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Avoid initializing React when the router server and fetch helpers are imported. Load React when constructing the fetch deduplication helper, and share the fetch-patched symbol through a standalone module so the router server can access it without loading the fetch patcher.

Removed the lazy module evaluation unit test following review feedback.

Verification

  • Previously validated fetch deduplication and fetch patching unit tests, plus test/e2e/app-dir/app-fetch-deduping/app-fetch-deduping.test.ts in development with Turbopack and production with webpack.
  • Rebased onto canary (3f51f6e612); confirmed the implementation patches are unchanged. Tests were not rerun for the test deletion.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: dc706e3

@kassens
kassens marked this pull request as ready for review October 19, 2026 16:36
@kassens
kassens requested review from eps1lon and gnoff and removed request for eps1lon October 19, 2026 16:39
Comment thread test/unit/lazy-fetch-react/lazy-fetch-react.test.ts Outdated
@kassens
kassens force-pushed the kassens/lazy-fetch-react branch from b1edfba to dc706e3 Compare October 20, 2026 15:59
@kassens

kassens commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Updated and confirmed in a local build that a pure API route no longer loads react.

@kassens
kassens enabled auto-merge (squash) October 20, 2026 16:03
@kassens
kassens merged commit 417f8c0 into canary Oct 22, 2026
120 checks passed
@kassens
kassens deleted the kassens/lazy-fetch-react branch October 22, 2026 14:27
mischnic pushed a commit that referenced this pull request Oct 23, 2026
)

Backports #100467 and #100401 to `releases/lts/active`.

#100401 defers React loading in `dedupe-fetch.ts`; it builds on #100467,
which separates render validation from dynamic tracking and moves the
fetch-patch marker into a standalone module so server bootstrap imports
cannot reach React. Backported together since the goal of #100401 is
only achieved with the #100467 groundwork.

---------

Co-authored-by: Jan Kassens <kassens@vercel.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants