npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@king-3/play-tsx

v2.0.0

Published

Enhanced TypeScript playground powered by tsx - Run .ts files with smart defaults, watch mode, and zero configuration

Readme

play-tsx

Enhanced TypeScript playground powered by tsx - Run .ts files with smart defaults, watch mode, and zero configuration

npm version npm downloads bundle size License: MIT

English | 中文

✨ Features

  • 🚀 Zero Config - Works out of the box with sensible defaults
  • 👀 Watch Mode - Automatically reload on file changes
  • 📁 Smart File Management - Organize files in a playground directory
  • 🔧 TypeScript Config - Custom tsconfig.json support
  • 📋 File Listing - View all available playground files
  • 🐛 Debug Mode - Detailed execution information
  • 🌍 Environment Variables - Configure via ENV vars
  • 🔄 Auto Install - Automatically install tsx if missing

📦 Installation

# npm
npm install -D @king-3/play-tsx

# pnpm
pnpm add -D @king-3/play-tsx

# yarn
yarn add -D @king-3/play-tsx

🚀 Quick Start

# Run default file (playground/index.ts)
pnpm play

# Run specific file
play play -f other            # Run playground/other.ts

# Enable watch mode
pnpm play --watch test        # Run playground/test.ts and watch
pnpm play -w -f other         # Run playground/other.ts and watch

# List available files
pnpm play --list
pnpm play -l

📖 Usage

Basic Commands

# Run file
play [options] [file]

# Show help
play --help
play -h

# Show version
play --version
play -v

Options

| Option | Alias | Description | Default | | ------------------- | ----- | --------------------- | ----------- | | --file <path> | -f | File to run | index | | --watch | -w | Enable watch mode | false | | --list | -l | List available files | false | | --tsconfig <path> | -t | Path to tsconfig.json | Auto-detect | | --debug | -d | Enable debug output | false | | --version | -v | Show version number | - | | --help | -h | Show help information | - |

Examples

# Basic usage
play                          # Run playground/index.ts
play -f other                 # Run playground/other.ts

# Watch mode
play --watch -f file          # Enable watch mode
play -w -f other              # Watch + specify file

# Custom tsconfig
play --tsconfig ./tsconfig.dev.json -f file
play -t ./tsconfig.dev.json -w -f file

# Debug mode
play --debug -f file          # Show debug information
play -d -w -f other           # Debug + watch + file

# List files
play --list                   # List all available .ts files
play -l                       # Short form

⚙️ Configuration

Programmatic Usage

import { play } from 'play-tsx'

play({
  name: 'play-tsx',
  version: '1.0.0',
  description: 'Enhanced TypeScript playground',
  rootDir: './playground', // Root directory for files
  tsconfig: './tsconfig.json', // Default tsconfig path
  autoInstall: true, // Auto-install tsx if missing
  flags: {
    // Custom flags
    myFlag: {
      type: Boolean,
      alias: 'm',
      default: false,
      description: 'My custom flag'
    }
  }
})

Environment Variables

# Set root directory
PLAY_TSX_ROOT_DIR=./src pnpm play

# Set tsconfig path
PLAY_TSX_TSCONFIG=./tsconfig.dev.json pnpm play

# Enable auto-install
PLAY_TSX_AUTO_INSTALL=true pnpm play

Package.json Scripts

{
  "scripts": {
    "play": "play",
    "play:watch": "play --watch",
    "play:debug": "play --debug"
  }
}

📁 Project Structure

your-project/
├── playground/           # Default playground directory
│   ├── index.ts         # Default entry file
│   ├── test.ts
│   └── examples/
│       └── demo.ts
├── tsconfig.json        # TypeScript configuration
└── package.json

🔧 Priority Order

The tool resolves configuration in the following priority:

  1. Command line arguments (highest)
  2. Environment variables
  3. PlayOptions configuration
  4. Auto-detection (lowest)

Tsconfig Resolution

  1. --tsconfig command line argument
  2. PLAY_TSX_TSCONFIG environment variable
  3. PlayOptions.tsconfig configuration
  4. tsconfig.json in project root
  5. tsx default configuration

📄 License

MIT License © 2025 king3

🤝 Contributing

Contributions, issues and feature requests are welcome!

🙏 Credits

Built on top of the amazing tsx by @privatenumber