docs/dev-api/entry-point.md
Import tsx at the top of your entry-file:
import 'tsx'
// Now you can load TS files
await import('./file.ts')
Note, because of the order of static import evaluation in ESM, the enhancement only works on dynamic imports after registration.
::: danger Enhancing Node.js by loading tsx from within your source code at run-time can be unexpected for collaborators who aren’t aware of it.
When possible, it's recommended to use a more visible method, such as passing it as a CLI flag. :::
Require tsx/cjs at the top of your entry-file:
require('tsx/cjs')
// Now you can load TS files
require('./file.ts')
Import tsx/esm at the top of your entry-file:
import 'tsx/esm'
// Now you can load TS files
await import('./file.ts')