| 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'); |