tsx 3.5.0 → 3.7.0

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 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,8 +9,10 @@
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
 
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>
14
16
 
15
17
  ## About
16
18
  `tsx` is a CLI command (alternative to `node`) for seamlessly running TypeScript & ESM, in both `commonjs` & `module` package types.
@@ -65,6 +67,9 @@ tsx ...
65
67
 
66
68
  ## Usage
67
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
+
68
73
  ### Run TypeScript / ESM / CJS module
69
74
 
70
75
  Pass in a file to run:
@@ -73,8 +78,17 @@ Pass in a file to run:
73
78
  tsx ./file.ts
74
79
  ```
75
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
+
76
90
  ### Watch mode
77
- Run file and automatically re-run on changes:
91
+ Run file and automatically rerun on changes:
78
92
 
79
93
  ```sh
80
94
  tsx watch ./file.ts
@@ -83,7 +97,9 @@ tsx watch ./file.ts
83
97
  All imported files are watched except from the following directories:
84
98
  `node_modules`, `bower_components`, `vendor`, `dist`, and `.*` (hidden directories).
85
99
 
86
- Press <kbd>Return</kbd> to manually re-run.
100
+ #### Tips
101
+ - Press <kbd>Return</kbd> to manually rerun
102
+ - Pass in `--clear-screen=false` to disable clearing the screen on rerun
87
103
 
88
104
  ### REPL
89
105
  Start a TypeScript REPL by running with no arguments:
@@ -130,6 +146,12 @@ NODE_OPTIONS='--loader tsx' node ./file.ts
130
146
 
131
147
  ## FAQ
132
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
+
133
155
  ### Does it do type-checking?
134
156
 
135
157
  No, [esbuild does not support type checking](https://esbuild.github.io/faq/#:~:text=TypeScript%20type%20checking%20(just%20run%20tsc%20separately)).
@@ -148,3 +170,12 @@ Because esbuild doesn't do type checking, `tsx` is more equivalent to `ts-node -
148
170
  [Here's an exhaustive comparison](https://github.com/privatenumber/ts-runtime-comparison) between `tsx` vs `ts-node` (and other runtimes).
149
171
 
150
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.