ts-resolve.mjs
This file
Path
benchmarks/fetch/ts-resolve.mjs
26 lines 路 878 bytes 路 JavaScript
Last changed by
chore(benchmark): add app.fetch() overhead benchmark (#5117)Yusuke Wadabefore adoptionc285f9a
History of this fileTake it
123456789101112131415161718192021222324252627// Resolve extensionless TypeScript imports (e.g. `./request` -> `./request.ts`)// so that Node's built-in type stripping can run hono's src directly.// Import this once at the top of a bench file, then load hono via dynamic import().// No-op on Bun, which resolves extensionless imports natively.import * as mod from 'node:module'
if (typeof mod.registerHooks === 'function') { mod.registerHooks({ resolve(specifier, context, nextResolve) { try { return nextResolve(specifier, context) } catch (err) { if (specifier.startsWith('.') || specifier.startsWith('file:')) { for (const suffix of ['.ts', '/index.ts']) { try { return nextResolve(specifier + suffix, context) } catch { // try the next suffix } } } throw err } }, })}