tsx 3.8.0 → 3.9.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/README.md +16 -5
- package/dist/cli.cjs +26 -26
- package/dist/cli.js +25 -25
- package/dist/loader.cjs +1 -1
- package/dist/loader.js +1 -1
- package/dist/package-09e0298a.cjs +1 -0
- package/dist/package-4f7aaad4.js +1 -0
- package/dist/{pkgroll_create-require-cf14dfa9.cjs → pkgroll_create-require-03df4aab.cjs} +0 -0
- package/dist/{pkgroll_create-require-08349338.js → pkgroll_create-require-2f711411.js} +0 -0
- package/dist/pkgroll_create-require-315607d1.cjs +1 -0
- package/dist/pkgroll_create-require-d260ac03.js +1 -0
- package/dist/repl.cjs +3 -3
- package/dist/repl.js +3 -3
- package/package.json +39 -70
- package/dist/package-403547c0.cjs +0 -1
- package/dist/package-46c43c2a.js +0 -1
package/README.md
CHANGED
|
@@ -161,16 +161,27 @@ It's recommended to run TypeScript separately as a command (`tsc --noEmit`) or v
|
|
|
161
161
|
|
|
162
162
|
### How is `tsx` different from [`ts-node`](https://github.com/TypeStrong/ts-node)?
|
|
163
163
|
|
|
164
|
-
They
|
|
164
|
+
They're both tools to run TypeScript files. But tsx does a lot more to improve the experience of using Node.js.
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
tsx _just works_. It's zero-config and doesn't require `tsconfig.json` to get started, making it easy for users that just want to run TypeScript code and not get caught up in the configuration.
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
It's a single binary with no peer-dependencies (e.g. TypeScript or esbuild), so there is no setup necessary, enabling usage that is elegant and frictionless for first-time users:
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
```
|
|
171
|
+
npx tsx ./script.ts
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
tsx is zero-config because it has smart detections built in. As a runtime, it detects what's imported to make many options in `tsconfig.json` redundant—which was designed for compiling matching files regardless of whether they're imported.
|
|
175
|
+
|
|
176
|
+
It seamlessly adapts between CommonJS and ESM package types by detecting how modules are loaded (`require()` or `import`) to determine how to compile them. It even adds support for `require()`ing ESM modules from CommonJS so you don't have to worry about your dependencies as the ecosystem migrates to ESM.
|
|
177
|
+
|
|
178
|
+
[Newer and unsupported syntax](https://esbuild.github.io/content-types/) & features like [importing `node:` prefixes](https://2ality.com/2021/12/node-protocol-imports.html) are downgraded by detecting the Node.js version. For large TypeScript codebases, it has [`tsconfig.json paths`](https://www.typescriptlang.org/tsconfig#paths) aliasing support out of the box.
|
|
179
|
+
|
|
180
|
+
At the core, tsx is powered by esbuild for [blazing fast TypeScript compilation](https://esbuild.github.io/faq/#:~:text=typescript%20benchmark), whereas `ts-node` (by default) uses the TypeScript compiler. Because esbuild doesn't type check, `tsx` is similar to `ts-node --esm --swc` (which uses the [SWC compiler](https://github.com/TypeStrong/ts-node#swc-1)).
|
|
171
181
|
|
|
172
|
-
|
|
182
|
+
As a bonus, tsx also comes with a watcher to speed up your development.
|
|
173
183
|
|
|
184
|
+
[Here's an exhaustive technical comparison](https://github.com/privatenumber/ts-runtime-comparison) between `tsx`, `ts-node`, and other runtimes.
|
|
174
185
|
|
|
175
186
|
### Can it use esbuild plugins?
|
|
176
187
|
|