Skip to content

Migrate mkjs to Bun-first ES6/TypeScript entrypoints and modernize multiplayer server#1

Draft
Qainguin wants to merge 1 commit intomasterfrom
codex/migrate-project-to-es6-and-typescript
Draft

Migrate mkjs to Bun-first ES6/TypeScript entrypoints and modernize multiplayer server#1
Qainguin wants to merge 1 commit intomasterfrom
codex/migrate-project-to-es6-and-typescript

Conversation

@Qainguin
Copy link
Copy Markdown
Owner

@Qainguin Qainguin commented Mar 4, 2026

Motivation

  • Modernize the legacy ES5 inline runtime so the app can be developed and served with a modern toolchain (Bun) and ES module loading semantics.
  • Convert server runtime to TypeScript ES modules for better type-safety and to run the dedicated multiplayer server with Bun.
  • Preserve the original runtime ordering and behavior so existing legacy engine scripts continue to work without a large rewrite.

Description

  • Replaced the large inline script boot in index.html with a single ES module entry code/bootstrap.ts that dynamically injects the legacy script files in the original order and ported the bootstrap/game-loop to TypeScript.
  • Added Bun + TypeScript project scaffolding: package.json, tsconfig.json, and bun.lock with convenient scripts (dev, serve, server, typecheck).
  • Migrated the dedicated server into TypeScript ES modules in server/server.ts and server/modules/mkjsInstance.ts, added Bun run scripts (server/run.sh, server/run.bat), and kept small deprecation shims (server/server.js, server/modules/mkjsInstance.js) to avoid breaking existing workflows.
  • Small runtime/type fixes made during migration (for example using ArrayBufferLike for packet buffers) and preserved the existing binary relay behavior for multiplayer packets.

Testing

  • Ran bun install to populate dependencies and bun run typecheck (TypeScript) which passed after a small type adjustment to server/modules/mkjsInstance.ts.
  • Started the server with bun run server --help which boots and reports the listening address, indicating the WebSocket server starts correctly.
  • Executed an in-process simulation via bun -e that created a MkjsInstance with two mock clients and sent a binary kart packet, which verified the server-side binary relay path (succeeded).
  • Launched the Bun HTML dev server via bun index.html which served the new index.html entrypoint successfully (dev server started), but an automated Playwright attempt to capture a screenshot failed due to a Chromium crash in the execution environment (not a project failure).

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant