MCPcopy Create free account
hub / github.com/vercel/vercel / readFile

Function readFile

packages/backends/src/cervel/node-file-trace.ts:43–69  ·  view source on GitHub ↗
(fsPath)

Source from the content-addressed store, hash-verified

41 return nftResolveDependency(id, parent, job, cjsResolve);
42 },
43 async readFile(fsPath) {
44 try {
45 let source: string | Buffer = await readFile(fsPath);
46
47 // NFT doesn't support TypeScript, so we need to transform the source code.
48 if (
49 (fsPath.endsWith('.ts') && !fsPath.endsWith('.d.ts')) ||
50 fsPath.endsWith('.tsx') ||
51 fsPath.endsWith('.mts') ||
52 fsPath.endsWith('.cts')
53 ) {
54 const transformResult = await transform(fsPath, source.toString());
55 source = transformResult.code;
56 }
57
58 return source;
59 } catch (error: unknown) {
60 if (
61 isNativeError(error) &&
62 'code' in error &&
63 (error.code === 'ENOENT' || error.code === 'EISDIR')
64 ) {
65 return null;
66 }
67 throw error;
68 }
69 },
70 });
71
72 const nftSpan = span.child('vc.builder.backends.nft');

Callers 13

rolldownFunction · 0.70
getPackageJsonFunction · 0.70
getBuildSummaryFunction · 0.70
loadFixtureMetadataFunction · 0.50
loadVercelJsonFunction · 0.50
unit.test.tsFile · 0.50
findEntrypointFunction · 0.50
getPackageJsonFunction · 0.50
handlerFunction · 0.50
runNftFunction · 0.50

Calls 2

transformFunction · 0.50
toStringMethod · 0.45

Tested by 2

loadFixtureMetadataFunction · 0.40
loadVercelJsonFunction · 0.40