Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra test case for a weird situation with symlinks and potential impliedNodeFormat clash #3

Open
wants to merge 1 commit into
base: bug/57553
Choose a base branch
from
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
125 changes: 125 additions & 0 deletions src/testRunner/unittests/tsserver/symLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,129 @@ new C();`,
});
});
});

it("when monorepo module gets loaded from other symlinked monorepo module and from a regular node module", () => {
const projectRootPath = "/users/username/cal.com";

const libPkg = `${projectRootPath}/packages/lib`;
const getAllUserBookingsFile: File = {
path: `${libPkg}/bookings/getAllUserBookings.ts`,
content: `export const getAllUserBookings = async () => {};`,
};
const libPkgJson: File = {
path: `${libPkg}/package.json`,
content: jsonToReadableText({
name: "@calcom/lib",
version: "0.0.0", // version field for this package is important for the test
}),
};
const libTsconfig: File = {
path: `${libPkg}/tsconfig.json`,
content: jsonToReadableText({
compilerOptions: {
moduleResolution: "node",
},
}),
};
const typesPkg = `${projectRootPath}/packages/types`;
const paymentServiceFile: File = {
path: `${typesPkg}/PaymentService.d.ts`,
content: ``,
};
const videoApiAdapterFile: File = {
path: `${typesPkg}/VideoApiAdapter.d.ts`,
content: `import {} from "@calcom/lib/bookings/getAllUserBookings";`,
};
const typesPkgJson: File = {
path: `${typesPkg}/package.json`,
content: jsonToReadableText({ name: "@calcom/types" }),
};
const typesTsconfig: File = {
path: `${typesPkg}/tsconfig.json`,
content: jsonToReadableText({
compilerOptions: {
moduleResolution: "node",
},
}),
};
const uiPkg = `${projectRootPath}/packages/ui`;
const uiIndexFile: File = {
path: `${uiPkg}/index.tsx`,
content: `import type {} from "@calcom/platform-libraries";`,
};
const uiPkgJson: File = {
path: `${uiPkg}/package.json`,
content: jsonToReadableText({ name: "@calcom/ui" }),
};
const uiTsconfig: File = {
path: `${uiPkg}/tsconfig.json`,
content: jsonToReadableText({
compilerOptions: {
moduleResolution: "node",
},
include: [
"../types/*.d.ts", // this includes files from another project
"**/*.tsx",
],
}),
};

const libSymLink: SymLink = {
path: `${projectRootPath}/node_modules/@calcom/lib`,
symLink: "../../packages/lib",
};

const typesSymLink: SymLink = {
path: `${projectRootPath}/node_modules/@calcom/types`,
symLink: "../../packages/types",
};

const uiSymLink: SymLink = {
path: `${projectRootPath}/node_modules/@calcom/ui`,
symLink: "../../packages/ui",
};

const platformLibrariesNodeModule = `${projectRootPath}/node_modules/@calcom/platform-libraries`;

// this non-symlinked node module reaches into a sibling symlinked node module
const platformLibrariesIndexDts: File = {
path: `${platformLibrariesNodeModule}/dist/index.d.ts`,
content: `export { getAllUserBookings } from '../../lib/bookings/getAllUserBookings';`,
};

const platformLibrariesPkgJson: File = {
path: `${platformLibrariesNodeModule}/package.json`,
content: jsonToReadableText({ name: "@calcom/platform-libraries", types: "./dist/index.d.ts" }),
};

const files = [
// monorepo files
getAllUserBookingsFile,
libPkgJson,
libTsconfig,
paymentServiceFile,
videoApiAdapterFile,
typesPkgJson,
typesTsconfig,
uiIndexFile,
uiPkgJson,
uiTsconfig,

// regular monorepo node_modules symlinks
libSymLink,
typesSymLink,
uiSymLink,

// regular node_modules
platformLibrariesIndexDts,
platformLibrariesPkgJson,
];
const host = TestServerHost.createServerHost(files);
const session = new TestSession(host);
openFilesForSession([uiIndexFile], session);
openFilesForSession([videoApiAdapterFile], session);
closeFilesForSession([uiIndexFile], session);
openFilesForSession([paymentServiceFile], session);
baselineTsserverLogs("symLinks", "when monorepo module gets loaded from other symlinked monorepo module and from a regular node module", session);
});
});
Loading