File tree 5 files changed +21
-4
lines changed 5 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export default defineConfig({
30
30
siteTitle : 'tsx' ,
31
31
32
32
editLink : {
33
- pattern : 'https://github.com/privatenumber/tsx/edit/develop /docs/:path' ,
33
+ pattern : 'https://github.com/privatenumber/tsx/edit/master /docs/:path' ,
34
34
text : 'Edit this page on GitHub' ,
35
35
} ,
36
36
Original file line number Diff line number Diff line change 2
2
3
3
` tsx ` stands for _ TypeScript Execute_ , and it's a simple command to run TypeScript in Node.js.
4
4
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:
6
6
7
7
<div class =" tsx-before-after " >
8
8
@@ -12,11 +12,11 @@ node file.js
12
12
<span class =" hidden sm:block " >→</span >
13
13
<span class =" sm:hidden " >↓</span >
14
14
``` sh
15
- tsx file.js
15
+ tsx file.ts
16
16
```
17
17
</div >
18
18
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 ` !
20
20
21
21
## Features
22
22
Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ Load `tsx/cjs` at the top of your entry-file:
30
30
31
31
``` js
32
32
require (' tsx/cjs' )
33
+
34
+ // Now you can load TS files
35
+ require (' ./file.ts' )
33
36
```
34
37
35
38
### Registration & Unregistration
Original file line number Diff line number Diff line change @@ -32,6 +32,15 @@ NODE_OPTIONS='--loader tsx/esm' npx some-binary
32
32
33
33
## Programmatic API
34
34
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
+
35
44
### Registration & Unregistration
36
45
37
46
``` js
@@ -40,6 +49,8 @@ import { register } from 'tsx/esm/api'
40
49
// register tsx enhancement
41
50
const unregister = register ()
42
51
52
+ await import (' ./file.ts' )
53
+
43
54
// Unregister when needed
44
55
unregister ()
45
56
```
Original file line number Diff line number Diff line change @@ -34,4 +34,7 @@ NODE_OPTIONS='--import tsx' npx eslint
34
34
Load ` tsx ` at the top of your entry-file:
35
35
``` js
36
36
import ' tsx'
37
+
38
+ // Now you can load TS files
39
+ await import (' ./file.ts' )
37
40
```
You can’t perform that action at this time.
0 commit comments