tsx 3.5.1 → 3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +33 -3
- package/dist/cli.cjs +25 -25
- package/dist/cli.js +26 -26
- package/dist/loader.cjs +1 -1
- package/dist/loader.js +1 -1
- package/dist/package-1447d2cf.js +1 -0
- package/dist/package-e2cef8ee.cjs +1 -0
- package/dist/{pkgroll_create-require-890b6873.js → pkgroll_create-require-aa02bf11.js} +0 -0
- package/dist/{pkgroll_create-require-6cd0a902.cjs → pkgroll_create-require-b5f2d578.cjs} +0 -0
- package/dist/repl.cjs +3 -3
- package/dist/repl.js +3 -3
- package/package.json +12 -22
- package/dist/package-0f4ac2cf.js +0 -1
- package/dist/package-853fb12a.cjs +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Hiroki Osame <hiroki.osame@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# tsx
|
|
1
|
+
# tsx <a href="https://npm.im/tsx"><img src="https://badgen.net/npm/v/tsx"></a> <a href="https://npm.im/tsx"><img src="https://badgen.net/npm/dm/tsx"></a> <a href="https://packagephobia.now.sh/result?p=tsx"><img src="https://packagephobia.now.sh/badge?p=tsx"></a>
|
|
2
2
|
|
|
3
3
|
> _TypeScript Execute (`tsx`)_: Node.js enhanced with [esbuild](https://esbuild.github.io/) to run TypeScript & ESM files
|
|
4
4
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
- Supports `node:` import prefixes
|
|
10
10
|
- Hides experimental feature warnings
|
|
11
11
|
- TypeScript REPL
|
|
12
|
+
- Resolves `tsconfig.json` [`paths`](https://www.typescriptlang.org/tsconfig#paths)
|
|
12
13
|
- Tested on Linux & Windows with Node.js v12~18
|
|
13
14
|
|
|
14
15
|
<sub>Support this project by ⭐️ starring and sharing it. [Follow me](https://github.com/privatenumber) to see what other cool projects I'm working on! ❤️</sub>
|
|
@@ -66,6 +67,9 @@ tsx ...
|
|
|
66
67
|
|
|
67
68
|
## Usage
|
|
68
69
|
|
|
70
|
+
`tsx` is designed to be a drop-in replacement for `node`, so you can use it just the way you would use Node.js. All command-line arguments (with the exception of a few) are propagated to Node.js.
|
|
71
|
+
|
|
72
|
+
|
|
69
73
|
### Run TypeScript / ESM / CJS module
|
|
70
74
|
|
|
71
75
|
Pass in a file to run:
|
|
@@ -74,8 +78,17 @@ Pass in a file to run:
|
|
|
74
78
|
tsx ./file.ts
|
|
75
79
|
```
|
|
76
80
|
|
|
81
|
+
#### Custom `tsconfig.json` path
|
|
82
|
+
By default, `tsconfig.json` will be detected from the current working directory.
|
|
83
|
+
|
|
84
|
+
To set a custom path, use the `--tsconfig` flag:
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
tsx --tsconfig ./path/to/tsconfig.custom.json ./file.ts
|
|
88
|
+
```
|
|
89
|
+
|
|
77
90
|
### Watch mode
|
|
78
|
-
Run file and automatically
|
|
91
|
+
Run file and automatically rerun on changes:
|
|
79
92
|
|
|
80
93
|
```sh
|
|
81
94
|
tsx watch ./file.ts
|
|
@@ -84,7 +97,9 @@ tsx watch ./file.ts
|
|
|
84
97
|
All imported files are watched except from the following directories:
|
|
85
98
|
`node_modules`, `bower_components`, `vendor`, `dist`, and `.*` (hidden directories).
|
|
86
99
|
|
|
87
|
-
|
|
100
|
+
#### Tips
|
|
101
|
+
- Press <kbd>Return</kbd> to manually rerun
|
|
102
|
+
- Pass in `--clear-screen=false` to disable clearing the screen on rerun
|
|
88
103
|
|
|
89
104
|
### REPL
|
|
90
105
|
Start a TypeScript REPL by running with no arguments:
|
|
@@ -131,6 +146,12 @@ NODE_OPTIONS='--loader tsx' node ./file.ts
|
|
|
131
146
|
|
|
132
147
|
## FAQ
|
|
133
148
|
|
|
149
|
+
### Why is it named `tsx`?
|
|
150
|
+
|
|
151
|
+
`tsx` stands for "TypeScript execute", similar to [`npx`](https://docs.npmjs.com/cli/v8/commands/npx) ("Node.js package execute").
|
|
152
|
+
|
|
153
|
+
It has an unfortunate overlap with React's [TSX/JSX](https://www.typescriptlang.org/docs/handbook/jsx.html), which stands for "JavaScript XML". However, we believe the naming is appropriate for what it does.
|
|
154
|
+
|
|
134
155
|
### Does it do type-checking?
|
|
135
156
|
|
|
136
157
|
No, [esbuild does not support type checking](https://esbuild.github.io/faq/#:~:text=TypeScript%20type%20checking%20(just%20run%20tsc%20separately)).
|
|
@@ -149,3 +170,12 @@ Because esbuild doesn't do type checking, `tsx` is more equivalent to `ts-node -
|
|
|
149
170
|
[Here's an exhaustive comparison](https://github.com/privatenumber/ts-runtime-comparison) between `tsx` vs `ts-node` (and other runtimes).
|
|
150
171
|
|
|
151
172
|
If you migrated from `ts-node`, please share your performance gains [here](https://github.com/esbuild-kit/tsx/discussions/10)!
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
### Can it use esbuild plugins?
|
|
176
|
+
|
|
177
|
+
No. tsx uses esbuild's [Transform API](https://esbuild.github.io/api/#transform-api), which doesn't support plugins.
|
|
178
|
+
|
|
179
|
+
### Does it have a configuration file?
|
|
180
|
+
|
|
181
|
+
No. tsx's integration with Node.js is designed to be seamless so there is no configuration.
|