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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gmitch215/bytebox

v1.0.0

Published

Run Java on Cloudflare Workers

Readme

bytebox

The Cloudflare Workers loader for Java compiled to WebAssembly

bun add @gmitch215/bytebox

This is the JavaScript half of bytebox. The Gradle plugin generates a Worker that imports it, so a project built with ./gradlew buildWorker needs nothing from this page. Reach for it directly to assemble a Worker by hand.

Why It Exists

TeaVM's own loader cannot run on Workers. It compiles a feature-detection module from bytes, which the runtime refuses outside module evaluation; it takes the Node branch whenever process is defined, which nodejs_compat makes true; and it resolves npm imports through a dynamic import() of a string read from a wasm custom section, which no bundler can follow.

Loading A Module

import { load } from '@gmitch215/bytebox';
import * as runtime from './app.wasm-runtime.js';
import bytes from './app.wasmbin';

const instance = await load({ runtime, bytes });

load must be called during module evaluation. Workers allows WebAssembly compilation at startup and forbids it inside a request, so a module compiled lazily on the first request throws.

Handling Requests

One instance serves every request in the isolate, and a Java fiber that suspends yields to the event loop, so a second request can arrive while the first is parked. The gate serialises entry:

import { createGate, load } from '@gmitch215/bytebox';

const instance = await load({ runtime, bytes });
const gate = createGate(instance);

export default {
	async fetch(request, env, ctx) {
		return gate.fetch(request, env, ctx);
	}
};

Timers

Compiled Java schedules its fibers on a queue the host owns. Workers freeze the clock between I/O, so a Thread.sleep measured against Date.now() would never come due; the scheduler advances a clock of its own to cover one and gives the compiled program the same clock to read.

Each trigger drains under a fiber budget rather than a wall-clock timeout, because no CPU meter is readable from inside a request. FIBER_BUDGET carries the defaults.

Exports

| Import | Provides | | ------------------------------ | ------------------------------------------------------------ | | @gmitch215/bytebox | load, createGate, createScheduler, the error types | | @gmitch215/bytebox/loader | load, requiredModules | | @gmitch215/bytebox/gate | createGate | | @gmitch215/bytebox/scheduler | createScheduler, FIBER_BUDGET | | @gmitch215/bytebox/errors | LoadError, EntryPointError, ImportError, BudgetError | | @gmitch215/bytebox/bundler | an esbuild plugin that stubs the node:* imports out | | @gmitch215/bytebox/bindgen | generates Java bindings from a package's TypeScript types |

esbuild and typescript are optional peers, needed only by @gmitch215/bytebox/bundler and @gmitch215/bytebox/bindgen. A Worker at runtime needs neither.

@gmitch215/bytebox/bindgen also installs a command. The two are the same tool: bytebox-bindgen parses arguments and calls writeBindings, which is the function @gmitch215/bytebox/bindgen exports. The Gradle plugin runs the command; a TypeScript caller imports the function.

bunx bytebox-bindgen --out src/generated nanoid @noble/hashes

License

MIT