Comparing version 3.12.7 to 3.13.0
{ | ||
"name": "tsx", | ||
"version": "3.12.7", | ||
"version": "3.13.0", | ||
"description": "TypeScript Execute (tsx): Node.js enhanced with esbuild to run TypeScript & ESM files", | ||
@@ -26,17 +26,20 @@ "keywords": [ | ||
"./package.json": "./package.json", | ||
".": "./dist/loader.js", | ||
"./cli": "./dist/cli.js", | ||
".": "./dist/loader.mjs", | ||
"./cjs": "./dist/cjs/index.cjs", | ||
"./esm": "./dist/esm/index.mjs", | ||
"./cli": "./dist/cli.mjs", | ||
"./source-map": "./dist/source-map.cjs", | ||
"./suppress-warnings": "./dist/suppress-warnings.cjs", | ||
"./preflight": "./dist/preflight.cjs", | ||
"./repl": "./dist/repl.js" | ||
"./repl": "./dist/repl.mjs" | ||
}, | ||
"bin": "./dist/cli.js", | ||
"bin": "./dist/cli.mjs", | ||
"dependencies": { | ||
"@esbuild-kit/cjs-loader": "^2.4.2", | ||
"@esbuild-kit/core-utils": "^3.0.0", | ||
"@esbuild-kit/esm-loader": "^2.5.5" | ||
"esbuild": "~0.18.20", | ||
"get-tsconfig": "^4.7.2", | ||
"source-map-support": "^0.5.21" | ||
}, | ||
"optionalDependencies": { | ||
"fsevents": "~2.3.2" | ||
"fsevents": "~2.3.3" | ||
} | ||
} |
105
README.md
# 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> | ||
> _TypeScript Execute (`tsx`)_: Node.js enhanced with [esbuild](https://esbuild.github.io/) to run TypeScript & ESM files | ||
> _TypeScript Execute (`tsx`)_: Node.js enhanced to run TypeScript & ESM files | ||
@@ -13,6 +13,20 @@ ### Features | ||
- Resolves `tsconfig.json` [`paths`](https://www.typescriptlang.org/tsconfig#paths) | ||
- Tested on Linux & Windows with Node.js v12~18 | ||
- Tested on Linux & Windows with Node.js v12~20 | ||
<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> | ||
> **💡 Protip: Looking to bundle your TypeScript project?** | ||
> | ||
> If you're looking for a dead simple way to bundle your TypeScript projects, take a look at [`pkgroll`](https://github.com/privatenumber/pkgroll). It's an esbuild-enhanced Rollup that's auto configured based on your `package.json`! | ||
<br> | ||
<p align="center"> | ||
<a href="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum"> | ||
<picture> | ||
<source width="830" media="(prefers-color-scheme: dark)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum&image=dark"> | ||
<source width="830" media="(prefers-color-scheme: light)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum&image"> | ||
<img width="830" src="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum&image" alt="Premium sponsor banner"> | ||
</picture> | ||
</a> | ||
</p> | ||
## About | ||
@@ -31,2 +45,7 @@ `tsx` is a CLI command (alternative to `node`) for seamlessly running TypeScript & ESM, in both `commonjs` & `module` package types. | ||
### Mission | ||
tsx strives to: | ||
1. Enhance Node.js with TypeScript compatibility | ||
2. Improve ESM <-> CJS interoperability | ||
3. Support the latest major version of Node.js v12 and up _(likely to change in the future)_ | ||
@@ -139,19 +158,30 @@ ## Install | ||
To use `tsx` as a Node.js loader, simply pass it in to the [`--loader`](https://nodejs.org/api/esm.html#loaders) flag. | ||
To use `tsx` as a Node.js loader, pass it in to the [`--loader`](https://nodejs.org/api/esm.html#loaders) flag. This will add TypeScript & ESM support for both ESM and CommonJS contexts. | ||
> Note: The loader is limited to adding support for loading TypeScript/ESM files. CLI features such as _watch mode_ or suppressing "experimental feature" warnings will not be available. | ||
```sh | ||
# As a CLI flag | ||
node --loader tsx ./file.ts | ||
``` | ||
# As an environment variable | ||
Or as an environment variable: | ||
```sh | ||
NODE_OPTIONS='--loader tsx' node ./file.ts | ||
``` | ||
> Tip: In rare circumstances, you might be limited to using the [`-r, --require`](https://nodejs.org/api/cli.html#-r---require-module) flag. | ||
> | ||
> You can use [`@esbuild-kit/cjs-loader`](https://github.com/esbuild-kit/cjs-loader), but transformations will only be applied to `require()` (not `import`). | ||
> **Note:** The loader is limited to adding support for loading TypeScript/ESM files. CLI features such as _watch mode_ or suppressing "experimental feature" warnings will not be available. | ||
#### ESM only loader | ||
If you only need to add TypeScript support in a Module context, you can use the ESM loader: | ||
```sh | ||
node --loader tsx/esm ./file.ts | ||
``` | ||
#### CommonJS only loader | ||
If you only need to add TypeScript & ESM support in a CommonJS context, you can use the CJS loader: | ||
```sh | ||
node --require tsx/cjs ./file.ts | ||
``` | ||
### Hashbang | ||
@@ -181,10 +211,17 @@ | ||
## Dependencies | ||
<br> | ||
#### [@esbuild-kit/esm-loader](https://github.com/esbuild-kit/esm-loader) | ||
Node.js Loader to transform TypeScript to ESM. | ||
<p align="center"> | ||
<a href="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold"> | ||
<picture> | ||
<source width="830" media="(prefers-color-scheme: dark)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold&image=dark"> | ||
<source width="830" media="(prefers-color-scheme: light)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold&image"> | ||
<img width="830" src="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold&image" alt="Premium sponsor banner"> | ||
</picture> | ||
</a> | ||
</p> | ||
#### [@esbuild-kit/cjs-loader](https://github.com/esbuild-kit/cjs-loader) | ||
Node.js `require()` hook to transform TypeScript & ESM to CommonJS. | ||
## Support | ||
If there's a problem you're encountering or something you need help with, don't hesitate to take advantage of my [_Priority Support_ service](https://github.com/sponsors/privatenumber) where you can ask me questions in an exclusive forum. I'm well equppied to assist you with this project and would be happy to help you out! 🙂 | ||
@@ -249,1 +286,37 @@ ## FAQ | ||
For details, refer to esbuild's [JavaScript caveats](https://esbuild.github.io/content-types/#javascript-caveats) and [TypeScript caveats](https://esbuild.github.io/content-types/#typescript-caveats) documentation. | ||
### Does Yarn PnP work? | ||
In CommonJS mode, yes. But in Module/ESM mode, [Node.js version v19.6.0 and up](https://github.com/nodejs/node/blob/v19.6.0/doc/changelogs/CHANGELOG_V19.md#esm-leverage-loaders-when-resolving-subsequent-loaders) is required. | ||
### There's an outdated dependency in tsx—can you update? | ||
Dependencies are typically declared with SemVer ranges to allow updates. You can use the [`npm update <package name>`](https://docs.npmjs.com/cli/v8/commands/npm-update) command to automatically update them to the latest version within the defined range. | ||
If the dependencies are out of the specified range, it indicates a potential breaking change that requires manual review. You're welcome to submit a pull request to initiate the upgrade. | ||
## Sponsors | ||
<p align="center"> | ||
<a href="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1"> | ||
<picture> | ||
<source width="410" media="(prefers-color-scheme: dark)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1&image=dark"> | ||
<source width="410" media="(prefers-color-scheme: light)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1&image"> | ||
<img width="410" src="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1&image" alt="Premium sponsor banner"> | ||
</picture> | ||
</a> | ||
<a href="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2"> | ||
<picture> | ||
<source width="410" media="(prefers-color-scheme: dark)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2&image=dark"> | ||
<source width="410" media="(prefers-color-scheme: light)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2&image"> | ||
<img width="410" src="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2&image" alt="Premium sponsor banner"> | ||
</picture> | ||
</a> | ||
</p> | ||
<p align="center"> | ||
<a href="https://github.com/sponsors/privatenumber"> | ||
<img src="https://cdn.jsdelivr.net/gh/privatenumber/sponsors/sponsorkit/sponsors.svg"> | ||
</a> | ||
</p> | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
386855
31
1562
318
11
70
5
+ Addedesbuild@~0.18.20
+ Addedget-tsconfig@^4.7.2
+ Addedsource-map-support@^0.5.21
+ Addedget-tsconfig@4.8.1(transitive)
- Removed@esbuild-kit/cjs-loader@^2.4.2
- Removed@esbuild-kit/core-utils@^3.0.0
- Removed@esbuild-kit/esm-loader@^2.5.5
- Removed@esbuild-kit/cjs-loader@2.4.4(transitive)
- Removed@esbuild-kit/core-utils@3.3.2(transitive)
- Removed@esbuild-kit/esm-loader@2.6.5(transitive)
- Removedget-tsconfig@4.8.0(transitive)