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

@jitsi/cf-ts-bundler-worker

v1.0.2

Published

A fast, lightweight Cloudflare Worker that runs esbuild on the edge to compile TypeScript to JavaScript with CDN imports support

Readme

cf-ts-bundler-worker

A fast, lightweight Cloudflare Worker that runs esbuild on the edge to compile TypeScript to JavaScript with CDN imports support.

License TypeScript Cloudflare Workers

Features

  • ⚡ Dynamic TypeScript compilation with esbuild-wasm running on the edge
  • 🌐 Automatic CDN imports resolution
  • 📡 REST API with OpenAPI documentation
  • 📁 File upload support
  • ☁️ Low-latency compilation powered by Cloudflare's global network

Installation

This package provides a pre-built, production-ready Cloudflare Worker bundle. No build step required!

npm install @jitsi/cf-ts-bundler-worker

The package includes:

  • Minified Worker code (~265 KB)
  • esbuild-wasm module (~12 MB)
  • Source maps for debugging

Quick Start

Option 1: Deploy using Wrangler (Recommended)

# Install the package
npm install @jitsi/cf-ts-bundler-worker

# Deploy to Cloudflare (no build needed!)
npx wrangler deploy node_modules/@jitsi/cf-ts-bundler-worker/worker-dist/index.js \
  --name my-ts-bundler \
  --compatibility-flag nodejs_compat

Option 2: Deploy from Source

Clone and customize the Worker:

git clone https://github.com/jitsi/cloudflare-ts-bundler-worker.git
cd cloudflare-ts-bundler-worker
npm install
npm run deploy

Configuration

Environment Variables

The worker uses the following environment variables:

| Variable | Description | Required | Default | |----------|-------------|----------|---------| | AUTH_ENABLED | Enable/disable JWT authentication. Set to 'true' to enable. | No | false (disabled) | | JWT_ISSUER | Expected issuer claim in JWT tokens | Only when AUTH_ENABLED=true | - | | PUBLIC_KEY | RSA public key in PEM format (SPKI) for JWT signature verification | Only when AUTH_ENABLED=true | - |

Note: The PUBLIC_KEY is a public key and is not sensitive data. Only the corresponding private key (used to sign tokens) needs to be kept secret.

Security Consideration: By default, authentication is disabled for easier development and testing. For production deployments, it's recommended to set AUTH_ENABLED=true to protect your endpoints.

Local Development

  1. Copy the example environment file:

    cp .dev.vars.example .dev.vars
  2. Edit .dev.vars with your actual values:

    JWT_ISSUER=https://your-auth-server.com
    PUBLIC_KEY=-----BEGIN PUBLIC KEY-----
    Your actual RSA public key here
    -----END PUBLIC KEY-----
  3. Start the dev server (it will automatically load .dev.vars):

    npm run dev

Production Deployment

Set environment variables using Wrangler CLI:

# Enable authentication (recommended for production)
wrangler secret put AUTH_ENABLED
# When prompted, enter: true

# Set JWT configuration (required when AUTH_ENABLED=true)
wrangler secret put JWT_ISSUER
wrangler secret put PUBLIC_KEY

# Or set as regular environment variables
wrangler deploy --var AUTH_ENABLED:true --var JWT_ISSUER:https://your-auth-server.com

Alternatively, use the Cloudflare dashboard to set environment variables in your worker settings.

For development/testing environments without authentication:

# Omit AUTH_ENABLED or set it to false
wrangler deploy
# Authentication will be disabled by default

API Reference

Base URL: https://your-worker.your-subdomain.workers.dev

Interactive Documentation:

  • Swagger UI: /_cfw/cf-ts-bundler-worker/docs
  • OpenAPI JSON: /_cfw/cf-ts-bundler-worker/openapi.json

Usage Examples

Basic Compilation (cURL)

curl -X POST https://your-worker.your-subdomain.workers.dev/_cfw/cf-ts-bundler-worker/compile \
  -H "Content-Type: application/json" \
  -d '{"code": "const message: string = \"Hello!\"; console.log(message);"}'

Response:

{
  "success": true,
  "compiledCode": "var o=\"Hello!\";console.log(o);\n"
}

File Upload Compilation (cURL)

curl -X POST https://your-worker.your-subdomain.workers.dev/_cfw/cf-ts-bundler-worker/compile-file \
  -F "[email protected]"

Note: Currently supports single file uploads only. Multi-file project bundling is planned for future releases.

Response: Returns the compiled JavaScript file for download.

Example TypeScript File (example.ts)

import { Hono } from 'hono';
import { z } from 'zod';
import { zValidator } from '@hono/zod-validator';

const userSchema = z.object({
  name: z.literal("John"),
  age: z.number().min(18),
  email: z.email().optional(),
});

type User = z.infer<typeof userSchema> & {
  id: string;
};

const app = new Hono();

app.get('/', (c) => c.json({ message: 'Hello World!' }));

app.post('/users', zValidator('json', userSchema), (c) => {
  const userData = c.req.valid('json');
  
  const user: User = {
    id: `user-${crypto.randomUUID().slice(0, 8)}`,
    ...userData,
  };
  
  return c.json({ message: 'User created!', user }, 201);
});

export default app;

Development

# Local development
npm run dev

# Run tests
npm test

# Deploy
npm run deploy

TODO / Roadmap

  • [ ] 📦 Multiple files support - Bundle entire TypeScript projects with multiple files and dependencies
  • [ ] 📊 Compilation performance metrics and caching
  • [ ] 🔧 Custom esbuild configuration options
  • [ ] 🔐 JWKS or ASAP-style (Key by Hash Method) support to improve JWT authentication with key rotation

License

Apache License 2.0 - see LICENSE file for details.