Skip to content

Commit 4146b84

Browse files
authored
fix(expo): use require.resolve in config plugin to locate ClerkViewFactory.swift (#8111)
1 parent 20237ea commit 4146b84

File tree

2 files changed

+12
-34
lines changed

2 files changed

+12
-34
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clerk/expo": patch
3+
---
4+
5+
fix(expo): use `require.resolve` in config plugin to find `ClerkViewFactory.swift`, resolving failures in pnpm workspaces nested 2+ levels deep

packages/expo/app.plugin.js

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -258,41 +258,14 @@ const withClerkIOS = config => {
258258
const projectName = config.modRequest.projectName;
259259
const iosProjectPath = path.join(platformProjectRoot, projectName);
260260

261-
// Find the ClerkViewFactory.swift source file
262-
// Check multiple possible locations in order of preference
261+
// Find the ClerkViewFactory.swift source file using Node's module resolution,
262+
// which handles arbitrary nesting depths in pnpm/yarn/npm workspaces.
263263
let sourceFile;
264-
const possiblePaths = [
265-
// Standard node_modules (npm, yarn)
266-
path.join(config.modRequest.projectRoot, 'node_modules', '@clerk', 'expo', 'ios', 'ClerkViewFactory.swift'),
267-
// pnpm hoisted node_modules
268-
path.join(
269-
config.modRequest.projectRoot,
270-
'..',
271-
'node_modules',
272-
'@clerk',
273-
'expo',
274-
'ios',
275-
'ClerkViewFactory.swift',
276-
),
277-
// Monorepo workspace (pnpm workspace)
278-
path.join(
279-
config.modRequest.projectRoot,
280-
'..',
281-
'javascript',
282-
'packages',
283-
'expo',
284-
'ios',
285-
'ClerkViewFactory.swift',
286-
),
287-
// Alternative monorepo structure
288-
path.join(config.modRequest.projectRoot, '..', 'packages', 'expo', 'ios', 'ClerkViewFactory.swift'),
289-
];
290-
291-
for (const possiblePath of possiblePaths) {
292-
if (fs.existsSync(possiblePath)) {
293-
sourceFile = possiblePath;
294-
break;
295-
}
264+
try {
265+
const packageRoot = path.dirname(require.resolve('@clerk/expo/package.json'));
266+
sourceFile = path.join(packageRoot, 'ios', 'ClerkViewFactory.swift');
267+
} catch {
268+
sourceFile = null;
296269
}
297270

298271
if (sourceFile && fs.existsSync(sourceFile)) {

0 commit comments

Comments
 (0)