@@ -278,4 +278,129 @@ new C();`,
278
278
} ) ;
279
279
} ) ;
280
280
} ) ;
281
+
282
+ it ( "when monorepo module gets loaded from other symlinked monorepo module and from a regular node module" , ( ) => {
283
+ const projectRootPath = "/users/username/cal.com" ;
284
+
285
+ const libPkg = `${ projectRootPath } /packages/lib` ;
286
+ const getAllUserBookingsFile : File = {
287
+ path : `${ libPkg } /bookings/getAllUserBookings.ts` ,
288
+ content : `export const getAllUserBookings = async () => {};` ,
289
+ } ;
290
+ const libPkgJson : File = {
291
+ path : `${ libPkg } /package.json` ,
292
+ content : jsonToReadableText ( {
293
+ name : "@calcom/lib" ,
294
+ version : "0.0.0" , // version field for this package is important for the test
295
+ } ) ,
296
+ } ;
297
+ const libTsconfig : File = {
298
+ path : `${ libPkg } /tsconfig.json` ,
299
+ content : jsonToReadableText ( {
300
+ compilerOptions : {
301
+ moduleResolution : "node" ,
302
+ } ,
303
+ } ) ,
304
+ } ;
305
+ const typesPkg = `${ projectRootPath } /packages/types` ;
306
+ const paymentServiceFile : File = {
307
+ path : `${ typesPkg } /PaymentService.d.ts` ,
308
+ content : `` ,
309
+ } ;
310
+ const videoApiAdapterFile : File = {
311
+ path : `${ typesPkg } /VideoApiAdapter.d.ts` ,
312
+ content : `import {} from "@calcom/lib/bookings/getAllUserBookings";` ,
313
+ } ;
314
+ const typesPkgJson : File = {
315
+ path : `${ typesPkg } /package.json` ,
316
+ content : jsonToReadableText ( { name : "@calcom/types" } ) ,
317
+ } ;
318
+ const typesTsconfig : File = {
319
+ path : `${ typesPkg } /tsconfig.json` ,
320
+ content : jsonToReadableText ( {
321
+ compilerOptions : {
322
+ moduleResolution : "node" ,
323
+ } ,
324
+ } ) ,
325
+ } ;
326
+ const uiPkg = `${ projectRootPath } /packages/ui` ;
327
+ const uiIndexFile : File = {
328
+ path : `${ uiPkg } /index.tsx` ,
329
+ content : `import type {} from "@calcom/platform-libraries";` ,
330
+ } ;
331
+ const uiPkgJson : File = {
332
+ path : `${ uiPkg } /package.json` ,
333
+ content : jsonToReadableText ( { name : "@calcom/ui" } ) ,
334
+ } ;
335
+ const uiTsconfig : File = {
336
+ path : `${ uiPkg } /tsconfig.json` ,
337
+ content : jsonToReadableText ( {
338
+ compilerOptions : {
339
+ moduleResolution : "node" ,
340
+ } ,
341
+ include : [
342
+ "../types/*.d.ts" , // this includes files from another project
343
+ "**/*.tsx" ,
344
+ ] ,
345
+ } ) ,
346
+ } ;
347
+
348
+ const libSymLink : SymLink = {
349
+ path : `${ projectRootPath } /node_modules/@calcom/lib` ,
350
+ symLink : "../../packages/lib" ,
351
+ } ;
352
+
353
+ const typesSymLink : SymLink = {
354
+ path : `${ projectRootPath } /node_modules/@calcom/types` ,
355
+ symLink : "../../packages/types" ,
356
+ } ;
357
+
358
+ const uiSymLink : SymLink = {
359
+ path : `${ projectRootPath } /node_modules/@calcom/ui` ,
360
+ symLink : "../../packages/ui" ,
361
+ } ;
362
+
363
+ const platformLibrariesNodeModule = `${ projectRootPath } /node_modules/@calcom/platform-libraries` ;
364
+
365
+ // this non-symlinked node module reaches into a sibling symlinked node module
366
+ const platformLibrariesIndexDts : File = {
367
+ path : `${ platformLibrariesNodeModule } /dist/index.d.ts` ,
368
+ content : `export { getAllUserBookings } from '../../lib/bookings/getAllUserBookings';` ,
369
+ } ;
370
+
371
+ const platformLibrariesPkgJson : File = {
372
+ path : `${ platformLibrariesNodeModule } /package.json` ,
373
+ content : jsonToReadableText ( { name : "@calcom/platform-libraries" , types : "./dist/index.d.ts" } ) ,
374
+ } ;
375
+
376
+ const files = [
377
+ // monorepo files
378
+ getAllUserBookingsFile ,
379
+ libPkgJson ,
380
+ libTsconfig ,
381
+ paymentServiceFile ,
382
+ videoApiAdapterFile ,
383
+ typesPkgJson ,
384
+ typesTsconfig ,
385
+ uiIndexFile ,
386
+ uiPkgJson ,
387
+ uiTsconfig ,
388
+
389
+ // regular monorepo node_modules symlinks
390
+ libSymLink ,
391
+ typesSymLink ,
392
+ uiSymLink ,
393
+
394
+ // regular node_modules
395
+ platformLibrariesIndexDts ,
396
+ platformLibrariesPkgJson ,
397
+ ] ;
398
+ const host = TestServerHost . createServerHost ( files ) ;
399
+ const session = new TestSession ( host ) ;
400
+ openFilesForSession ( [ uiIndexFile ] , session ) ;
401
+ openFilesForSession ( [ videoApiAdapterFile ] , session ) ;
402
+ closeFilesForSession ( [ uiIndexFile ] , session ) ;
403
+ openFilesForSession ( [ paymentServiceFile ] , session ) ;
404
+ baselineTsserverLogs ( "symLinks" , "when monorepo module gets loaded from other symlinked monorepo module and from a regular node module" , session ) ;
405
+ } ) ;
281
406
} ) ;
0 commit comments