@@ -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