Skip to content

fix(expo): use require.resolve in config plugin to locate ClerkViewFactory.swift#8111

Open
chriscanin wants to merge 2 commits intomainfrom
chris/fix-config-plugin-swift-path
Open

fix(expo): use require.resolve in config plugin to locate ClerkViewFactory.swift#8111
chriscanin wants to merge 2 commits intomainfrom
chris/fix-config-plugin-swift-path

Conversation

@chriscanin
Copy link
Member

@chriscanin chriscanin commented Mar 18, 2026

Summary

  • Replaces hardcoded possiblePaths array in withClerkIOS config plugin with require.resolve('@clerk/expo/package.json') to locate ClerkViewFactory.swift
  • Node's module resolution handles arbitrary monorepo nesting depths, fixing failures in pnpm workspaces where the app is nested 2+ levels deep (e.g. apps/mobile/)

Reported in

Closes #8049

Test plan

  • Run expo prebuild in a pnpm workspace with app nested 2+ levels deep and verify no ⚠️ ClerkViewFactory.swift not found warning
  • Run expo prebuild in a standard npm/yarn project and verify it still works

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed file resolution issues in the Expo config plugin for pnpm workspaces nested two or more levels deep, ensuring proper configuration setup in complex workspace structures.

@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2026

🦋 Changeset detected

Latest commit: 780acce

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

This PR includes changesets to release 1 package
Name Type
@clerk/expo 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

@github-actions github-actions bot added the expo label Mar 18, 2026
@vercel
Copy link

vercel bot commented Mar 18, 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 Mar 20, 2026 4:17pm

Request Review

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 18, 2026

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8111

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8111

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 780acce

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 403a5aab-686f-478e-accb-b756852f365f

📥 Commits

Reviewing files that changed from the base of the PR and between 4686538 and a434677.

📒 Files selected for processing (2)
  • .changeset/fix-config-plugin-swift-path.md
  • packages/expo/app.plugin.js

📝 Walkthrough

Walkthrough

This pull request adds a patch-level fix to the Expo config plugin that changes how ClerkViewFactory.swift is located during iOS AppDelegate injection. The previous multi-location search approach is replaced with a require.resolve-based method that derives the package root from @clerk/expo/package.json and resolves ClerkViewFactory.swift from that location. This addresses compatibility issues in pnpm workspaces nested two or more levels deep. If the file cannot be resolved or doesn't exist, the sourceFile remains null and processing is skipped. A changeset entry documenting the fix is also included.

Possibly related issues

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately describes the main change: using require.resolve in the Expo config plugin to locate ClerkViewFactory.swift, which directly matches the PR's core objective of fixing module resolution in nested monorepos.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Tip

CodeRabbit can approve the review once all CodeRabbit's comments are resolved.

Enable the reviews.request_changes_workflow setting to automatically approve the review once all CodeRabbit's comments are resolved.

Copy link
Member

@brkalow brkalow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can we test this?

@chriscanin
Copy link
Member Author

!snapshot

@chriscanin
Copy link
Member Author

@brkalow

  1. Install the current published version of @clerk/expo in a pnpm workspace or Turborepo where the app is nested 2+ levels deep (e.g. apps/mobile/):
my-monorepo/
├── pnpm-workspace.yaml
├── packages/
│   └── shared/
└── apps/
    └── mobile/       <-- Expo app here (2 levels deep)
        ├── app.json  <-- has "plugins": ["@clerk/expo"]
        └── package.json
  1. Run npx expo prebuild --clean --platform ios from the apps/mobile/ directory.

  2. You will observe the warning: ⚠️ ClerkViewFactory.swift not found, skipping injection

  3. The file is missing from the iOS project — grep -r "ClerkViewFactory" ios/ returns nothing.

Steps to verify the fix (after the fix)

  1. Install the version from this PR.

  2. Run npx expo prebuild --clean --platform ios from the same nested apps/mobile/ directory.

  3. The warning should not appear. Instead you should see: ✅ Copied ClerkViewFactory.swift to app target

  4. Confirm the file exists: grep -r "ClerkViewFactory" ios/ should return results.

Why it broke

The config plugin used a hardcoded list of relative paths to find ClerkViewFactory.swift (e.g. ../../node_modules/@clerk/expo/ios/). In pnpm workspaces nested 2+ levels deep, none of those paths resolve. The fix uses require.resolve('@clerk/expo/package.json') which lets Node's module resolution handle arbitrary nesting depths.

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.

withClerkIOS: ClerkViewFactory.swift not found in pnpm workspaces nested 2+ levels deep

2 participants