Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-config-plugin-swift-path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/expo": patch
---

fix(expo): use `require.resolve` in config plugin to find `ClerkViewFactory.swift`, resolving failures in pnpm workspaces nested 2+ levels deep
41 changes: 7 additions & 34 deletions packages/expo/app.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,41 +258,14 @@ const withClerkIOS = config => {
const projectName = config.modRequest.projectName;
const iosProjectPath = path.join(platformProjectRoot, projectName);

// Find the ClerkViewFactory.swift source file
// Check multiple possible locations in order of preference
// Find the ClerkViewFactory.swift source file using Node's module resolution,
// which handles arbitrary nesting depths in pnpm/yarn/npm workspaces.
let sourceFile;
const possiblePaths = [
// Standard node_modules (npm, yarn)
path.join(config.modRequest.projectRoot, 'node_modules', '@clerk', 'expo', 'ios', 'ClerkViewFactory.swift'),
// pnpm hoisted node_modules
path.join(
config.modRequest.projectRoot,
'..',
'node_modules',
'@clerk',
'expo',
'ios',
'ClerkViewFactory.swift',
),
// Monorepo workspace (pnpm workspace)
path.join(
config.modRequest.projectRoot,
'..',
'javascript',
'packages',
'expo',
'ios',
'ClerkViewFactory.swift',
),
// Alternative monorepo structure
path.join(config.modRequest.projectRoot, '..', 'packages', 'expo', 'ios', 'ClerkViewFactory.swift'),
];

for (const possiblePath of possiblePaths) {
if (fs.existsSync(possiblePath)) {
sourceFile = possiblePath;
break;
}
try {
const packageRoot = path.dirname(require.resolve('@clerk/expo/package.json'));
sourceFile = path.join(packageRoot, 'ios', 'ClerkViewFactory.swift');
} catch {
sourceFile = null;
}

if (sourceFile && fs.existsSync(sourceFile)) {
Expand Down
Loading