Skip to content
プロジェクト

概要

Xmas.JS is a lightweight, high-performance JavaScript/TypeScript runtime

言語・ランタイム

この数値の測り方

計測したスター増加

24時間
0
7日間
+2
15日間
+3
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

XMASJS LOGO

The logo does not represent any religious affiliation.

Xmas.JS

A complete JavaScript runtime in one small binary. No JIT(except WASM).

License: Apache-2.0 OR GPL-3.0 WinterTC Pure Rust


TL;DR: EVERYTHING INCLUDED with Binary size 11.3 MiB

One binary that runs TypeScript, serves HTTP, installs packages, and executes WebAssembly.

  • TypeScript and TSX run as they are. oxc strips the types in-process. There is no build step.
  • A real server. export default { fetch } and xmas serve. Trillium speaks HTTP/1.1, one realm per worker thread, with SSE and WebSocket upgrade.
  • WebAssembly. The standard JS API (Module, Instance, Memory, Table, Global, streaming compile), backed by WNJR. memory.buffer is the wasm memory itself, not a copy.
  • Sockets. WinterTC connect() for TCP, plus a UDPSocket.
  • Node-flavored modules. buffer, crypto, fs, path, stream, zlib, child_process, util, assert, os, process and more, listed below.
  • CommonJS. require, module.exports, __dirname, and .cjs files work next to ES modules.
  • A FAST package manager. xmas install, add, why, x. It also runs your package.json scripts quickly.

Measured on one machine (Apple silicon macOS, release build, fat LTO, one codegen unit, symbols stripped):

Runtime Cold Start Memory (Idle) Best Use Case
Node.js ~100-200ms ~30-50MB Web servers, long-running apps
Deno 🪦 ~150-300ms ~40-60MB Secure web apps, TypeScript projects
Bun ~50-100ms ~25-35MB Fast web development
Xmas.JS 🎄 ~10-20ms ~10-17MB System scripts, CLI tools, serverless

Hello

// app.ts
export default {
  fetch(request: Request) {
    return new Response('hello from ' + new URL(request.url).pathname + '\n');
  },
};
xmas serve app.ts --port 8000 --workers 4

WebAssembly

const { instance } = await WebAssembly.instantiate(bytes, { env: { log: (n: number) => console.log(n) } });
instance.exports.run();

Memory is zero-copy and memory.grow() detaches the old ArrayBuffer, as the spec says. What is missing is listed in runtime/docs/wasm.md.

Sockets

import { connect } from 'cloudflare:sockets';

TCP follows the WinterTC proposal. startTls() and secureTransport: 'on' throw a TypeError. They do not pretend. See runtime/docs/sockets.md.

CommonJS

const _ = require('lodash');
module.exports = { chunk: _.chunk };

require works by static scan: oxc finds every require("literal") before the file runs. require(variable) throws MODULE_NOT_FOUND and says why. See runtime/docs/modules.md.

Import from a URL

import * as rollup from 'https://unpkg.com/@rollup/browser/dist/es/rollup.browser.js';

we love web standard, sadly Deno passed away this year.

🪦 R.I.P. DENO

FFI (libc build)

xmas:ffi is bun:ffi's API over libffi: dlopen, JSCallback, ptr, toArrayBuffer, CString, read. It is in the libc build only (xmas-libc-* release assets, cargo build --features libc, xmas --version says (libc)); the default build leaves it, and libffi's C, out. See runtime/docs/ffi.md.


Install

There is no installer yet. Build it:

git clone https://github.com/LemonHX/Xmas.JS
cd Xmas.JS
cargo build --release      # needs a recent nightly Rust, no C compiler
./target/release/xmas --help

GitHub Actions

setup-xmas installs a released xmas on Linux, macOS and Windows runners, checks it against the release's SHA256SUMS, puts it on PATH, and caches both the binary and the package store (.xmas/store, keyed on xmas.lock):

- uses: actions/checkout@v7
- uses: 0xfe-project/setup-xmas@v1
  with:
    xmas-version: latest   # or rc, 0.10.0-rc.3, ^0.10; or xmas-version-file: .xmas-version
- run: xmas install --immutable
- run: xmas test

TypeScript types

xmas-types (in types/) declares every global and built-in module, node:* and xmas:*, as Xmas.JS implements them. Install it from the types branch and list it in compilerOptions.types; do not install @types/node next to it:

pnpm add -D xmas-types@github:LemonHX/Xmas.JS#types   # or: bun add -d ...; npm i -D --allow-git=root ...
{ "compilerOptions": { "lib": ["esnext"], "types": ["xmas-types"] } }

Commands

xmas [OPTIONS] [COMMAND]

  install  Install packages defined in package.json
  add      Add package to package.json
  remove   Remove package from package.json
  run      Run a script defined in package.json
  update   Prepare and save a newly planned lockfile
  upgrade  Update packages to the latest available version
  clean    Clean node_modules and cache
  exec     Execute a command (not a script)
  why      Find all uses of a given package
  create   Create new project from a starter kit
  x        Download and execute a package (like npx)
  serve    Serve a module as an HTTP app

Options:
  -v, --verbose
      --immutable                  Refuse to modify the lockfile
      --working-dir <WORKING_DIR>  Run in a custom working directory

xmas serve <ENTRY> takes --port (default 8000), --host (default 0.0.0.0) and --workers (default one per core).

There is no REPL and no xmas file.ts shortcut at the moment. Use serve, or xmas run for package scripts.


How it stays small

  • No JS JIT. The engine is quickjs-oxide, a Rust QuickJS working cooperated with pocketjs team.
  • Zero C at build time. TLS is rustls with a pure-Rust crypto provider. No OpenSSL, no libz, no system certificate store.
  • Tested for system libraries. A test fails the build if openssl, native-tls or libz-sys show up in the runtime's dependency tree.
  • smol, not tokio. The async runtime is smol everywhere, and tokio is not in the runtime's dependency tree today.

Status

Pre-1.0. The WASM engine, the HTTP server and the package manager are young. Pin your versions.

Console output matches Node: console.log('x') writes exactly x\n to stdout, with no [log] prefix (earlier versions printed [log] x, [warn] x and so on, all on stdout). log, info, debug and dir go to stdout; warn, error, trace and failed asserts go to stderr. So stdout can carry JSON lines, an LSP/MCP stdio protocol, or a pipe like xmas x.js | jq ..

Not done yet: import.meta.resolve, new WebAssembly.Table()/Global() constructors from JS, streaming zlib classes (createGzip and friends), and the benchmark comparison against other runtimes.


License

Dual-licensed under Apache-2.0 OR GPL-3.0. Choose Apache-2.0 for almost everything. GPL-3.0 applies if you want to offer Xmas.JS as a managed service.

Thanks

and txiki.js for the idea that a small runtime is worth having.

Made by ❤️ LemonHX 🍋 and the Xmas.JS 🎄 team.

関連プロジェクトを探す

読み込み中…