Skip to content

fix(react): gate remote Clerk UI loader behind __BUILD_DISABLE_RHC__#8773

Open
jacekradko wants to merge 1 commit into
mainfrom
jacek/chrome-ext-ui-rhc-gate
Open

fix(react): gate remote Clerk UI loader behind __BUILD_DISABLE_RHC__#8773
jacekradko wants to merge 1 commit into
mainfrom
jacek/chrome-ext-ui-rhc-gate

Conversation

@jacekradko
Copy link
Copy Markdown
Member

@jacekradko jacekradko commented Jun 8, 2026

@clerk/chrome-extension was getting rejected from the Chrome Web Store under MV3 because the bundle ships a remote script loader for @clerk/ui's ui.browser.js. The extension already bundles the UI via @clerk/ui/no-rhc so the loader never runs, but getClerkUIEntryChunk wasn't gating it behind __BUILD_DISABLE_RHC__ the way getClerkJsEntryChunk already does for clerk-js. Gating it lets the loader (and the createElement('script') it uses) tree-shake out of the extension build.

The search-for-rhc.mjs postbuild check should have caught this since it already greps for /npm/@clerk/ui, but its directory mode was missing -r, so grep never looked inside dist and always came back clean. That's fixed here too, which is why it goes in the same PR as the gate rather than on its own. I rebuilt react and the extension to confirm the RHC strings are gone and the check passes, then pointed the fixed checker at a planted URL to make sure it still fails when there's something to find.

Closes #8770

getClerkUIEntryChunk did not gate loadClerkUIScript behind
__BUILD_DISABLE_RHC__, so no-remote-code builds (e.g. @clerk/chrome-extension)
shipped the @clerk/ui ui.browser.js CDN loader as unreachable code. The Chrome
Web Store rejects this under Manifest V3 even though it never runs. Gate it like
getClerkJsEntryChunk so it dead-code-eliminates out of the bundle.

Also fix scripts/search-for-rhc.mjs directory mode, which was missing -r and so
never descended into dist, silently passing. This made the chrome-extension
postbuild and ui check:no-rhc guards no-ops.

Closes #8770
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 8, 2026

🦋 Changeset detected

Latest commit: c8ff729

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

This PR includes changesets to release 6 packages
Name Type
@clerk/chrome-extension Patch
@clerk/react Patch
@clerk/expo Patch
@clerk/nextjs Patch
@clerk/react-router Patch
@clerk/tanstack-react-start 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

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jun 8, 2026 1:36am

Request Review

@github-actions github-actions Bot added the react label Jun 8, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR gates the Clerk UI remote script loader behind the __BUILD_DISABLE_RHC__ build flag in the React package, preventing its bundling in no-remote-code builds. It documents the resulting Chrome extension cleanup and enhances the RHC search utility for recursive directory traversal.

Changes

Remote Code Gate for Clerk UI

Layer / File(s) Summary
Build-time gate for Clerk UI remote loader
packages/react/src/isomorphicClerk.ts, .changeset/react-gate-ui-loader-norhc.md
getClerkUIEntryChunk wraps the UI CDN loader in a !__BUILD_DISABLE_RHC__ guard, returning undefined when the flag is enabled to prevent bundling of the remote script loader; standard builds remain unaffected.
Chrome extension cleanup documentation and RHC search improvement
.changeset/chrome-extension-strip-ui-rhc-loader.md, scripts/search-for-rhc.mjs
The Chrome extension changeset documents the removal of the remote UI loader from the bundle. The asyncSearchRHC utility now performs recursive grep on directories to detect RHC violations in nested files.

🎯 2 (Simple) | ⏱️ ~10 minutes


A gate to block the script so tight,
No remote code will bundle in flight!
Chrome's manifest won't fuss and fight,
Extensions pass inspection just right. 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and accurately summarizes the main objective: gating the remote Clerk UI loader behind BUILD_DISABLE_RHC flag in the React package.
Linked Issues check ✅ Passed All changes directly address issue #8770: gating loadClerkUIScript behind BUILD_DISABLE_RHC to eliminate the remote UI loader from no-RHC builds, fixing the Chrome Web Store Manifest V3 rejection.
Out of Scope Changes check ✅ Passed All changes are in scope: the primary fix to isomorphicClerk.ts gates the UI loader; the changeset files document the patch; the search-for-rhc.mjs fix supports proper verification of the RHC guard in directories.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 8, 2026

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8773

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8773

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8773

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8773

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8773

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8773

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8773

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8773

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8773

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8773

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8773

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8773

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8773

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8773

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8773

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8773

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8773

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8773

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8773

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8773

commit: c8ff729

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 8, 2026

Break Check: no API changes detected across the tracked packages.

Last ran on c8ff729. Pushes that change no tracked declarations (no API surface change vs. base) are skipped and don't update this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@clerk/chrome-extension bundles remote UI script loader, rejected by Chrome Web Store under Manifest V3

1 participant