Skip to content

Commit 9f04dae

Browse files
committed
docs: clarify programmatic api usage
1 parent 7c85303 commit 9f04dae

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

docs/.vitepress/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default defineConfig({
3030
siteTitle: 'tsx',
3131

3232
editLink: {
33-
pattern: 'https://github.com/privatenumber/tsx/edit/develop/docs/:path',
33+
pattern: 'https://github.com/privatenumber/tsx/edit/master/docs/:path',
3434
text: 'Edit this page on GitHub',
3535
},
3636

docs/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
`tsx` stands for _TypeScript Execute_, and it's a simple command to run TypeScript in Node.js.
44

5-
Because `tsx` is basically an alias to `node`, you can use it the same way:
5+
`tsx` is basically an alias to `node`, so you can use it the same way:
66

77
<div class="tsx-before-after">
88

@@ -12,11 +12,11 @@ node file.js
1212
<span class="hidden sm:block">→</span>
1313
<span class="sm:hidden">↓</span>
1414
```sh
15-
tsx file.js
15+
tsx file.ts
1616
```
1717
</div>
1818

19-
<sub>Since it's Node.js underneath, all command-line flags are supported. Use `tsx` as you would use `node`!</sub>
19+
All Node.js command-line flags are supported—use `tsx` the same way you would use `node`!
2020

2121
## Features
2222

docs/node/cjs.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Load `tsx/cjs` at the top of your entry-file:
3030

3131
```js
3232
require('tsx/cjs')
33+
34+
// Now you can load TS files
35+
require('./file.ts')
3336
```
3437

3538
### Registration & Unregistration

docs/node/esm.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ NODE_OPTIONS='--loader tsx/esm' npx some-binary
3232

3333
## Programmatic API
3434

35+
Load `tsx/esm` at the top of your entry-file:
36+
37+
```js
38+
import 'tsx/esm'
39+
40+
// Now you can load TS files
41+
await import('./file.ts')
42+
```
43+
3544
### Registration & Unregistration
3645

3746
```js
@@ -40,6 +49,8 @@ import { register } from 'tsx/esm/api'
4049
// register tsx enhancement
4150
const unregister = register()
4251

52+
await import('./file.ts')
53+
4354
// Unregister when needed
4455
unregister()
4556
```

docs/node/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,7 @@ NODE_OPTIONS='--import tsx' npx eslint
3434
Load `tsx` at the top of your entry-file:
3535
```js
3636
import 'tsx'
37+
38+
// Now you can load TS files
39+
await import('./file.ts')
3740
```

0 commit comments

Comments
 (0)