Skip to main content

Build

Melonjs Deployment

melonJS

Use this skill when packaging, shipping or scaffolding a melonJS game — starting a project with create-melonjs, building for the web, browser support and transpiling, and bundle size. For running inside a game portal, a native app, a mini-game runtime or with no DOM, use melonjs-platforms. Triggers on: create-melonjs, scaffold, new project, build, deploy, publish, browser support, transpile, ES2022, bundle size, tree-shaking.

  • New
  • v1.0.2
  • No reviews yet

Capabilities

  • Scaffolding

    The project name is required — without it the command prints its usage…

  • Adding melonJS to an existing project

    The package is a tree-shakeable ES module with TypeScript declarations…

  • Browser support and transpiling

    The published bundle targets ES2022 and uses private class members

  • Size

    The whole engine is roughly 320 kB minified and gzipped (about 1 MB…

Getting started

Full instructions

Example command

Scaffolding

npm create melonjs@latest my-game

Instructions: SKILL.mdv1.0.2

Starting and shipping a project

Scaffolding

Start from the template rather than assembling a build by hand:

bash
npm create melonjs@latest my-game

The project name is required — without it the command prints its usage and
exits — and it names a new directory: an existing one is refused. It downloads
the melonJS TypeScript boilerplate (Vite, TypeScript and the debug plugin
already wired in), which saves you the top-level-await and asset-path issues
that a hand-rolled config usually hits first. Then npm install and
npm run dev in that directory.

Adding melonJS to an existing project

bash
npm install melonjs
js
import { Application, Sprite, loader } from "melonjs";

The package is a tree-shakeable ES module with TypeScript declarations included
and no runtime dependencies.

A CDN build exists for quick experiments, but not for production:

html
<script type="module">
    import { Application } from "https://cdn.jsdelivr.net/npm/melonjs@20/+esm";
</script>

Browser support and transpiling

The published bundle targets ES2022 and uses private class members. A browser
that predates that cannot parse the file at all — it fails at load, not when
a feature is used, so the symptom is a blank page with a syntax error.

To support older browsers, transpile melonJS together with your own code.
The usual trap is that build setups skip node_modules by default, leaving
melonJS untouched however low you set your target:

js
// vite.config.js — esbuild downlevels dependencies too
export default { build: { target: "es2020" } };
js
// webpack: the default `exclude: /node_modules/` would skip melonjs
{ test: /\.js$/, exclude: /node_modules\/(?!melonjs)/, use: "babel-loader" }

Two caveats worth knowing:

  • Transpiling handles syntax only. Built-in methods need separate polyfills;
    a bundler's target setting will never add them.
  • Downlevelled private class members become WeakMap lookups, and melonJS uses
    them in the renderer's hot paths. This is a real trade, not a free switch.

Platforms: portals, native apps, mini-games, no DOM

Running inside a game portal (YouTube Playables, Facebook Instant Games), a
native app wrapper (Capacitor, Cordova), a mini-game runtime (WeChat Mini
Games), or with no DOM at all (nx.js on the Nintendo Switch, a Web Worker) is
covered by melonjs-platforms: each platform's setup, and the shared way of
handing pausing, saving and sound to the platform.

Size

The whole engine is roughly 320 kB minified and gzipped (about 1 MB minified). Tree-shaking helps less than
you might expect — the engine's subsystems reach each other, so a game importing
a handful of symbols still pulls most of it. Budget for the full figure.

Practical wins are in assets, not the engine: pack sprites into atlases, prefer
one tileset over several, and use stream: true for long music tracks so they
are not decoded into memory.

Symptom → cause

symptom cause
blank page, syntax error in the console browser older than the ES2022 target
transpiling changes nothing build config excludes node_modules
a built-in method is missing after transpiling transpiling is syntax-only; polyfills are separate
bundle much larger than expected tree-shaking recovers little — subsystems are interconnected
  • melonjs-platforms — portals, native apps, mini-games and runtimes with no DOM
  • melonjs — the companion packages, including the Capacitor plugin
  • melonjs-plugins — registering the Capacitor plugin, and its helpers
  • melonjs-getting-started — the Application bootstrap the template produces

Explore more skills

Browse all
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

More from melonJS

View source →
melonjs-testingUse this skill to check that a melonJS game actually works before saying it does: running it in a headless browser, reading the console the engine writes, finding out which renderer the run got, driving the keyboard and the pointer,…0 installsmelonjs-ui-and-textUse this skill for HUDs, buttons, menus, options screens, dialogue panels, progress bars and on-screen text in melonJS. Covers UIBaseElement/UISpriteElement/UITextButton, UICheckbox, UISlider, ProgressBar, UIPanel (skins, layout,…0 installsmelonjs-inputUse this skill for keyboard, pointer, mouse, touch and gamepad input in melonJS. Covers the bindKey action indirection, registerPointerEvent on regions, the isKinematic requirement that silently blocks pointer events, which of several…0 installsmelonjs-performanceUse this skill when a melonJS game drops frames, allocates heavily, or needs to scale to many objects. Covers object pooling, draw-call batching, atlases, baking with CanvasRenderTarget, instancing, culling and alwaysUpdate, the debug…0 installsmelonjs-mathUse this skill for vector and matrix maths in melonJS — Vector2d, Vector3d, their observable variants, Matrix2d, Matrix3d, and the math utility functions. Covers which methods mutate and which allocate, the vector pool and when clone() is…0 installsmelonjs-renderablesUse this skill when subclassing Renderable, writing a custom draw() method, handling pointer or click events on game objects, applying post effects and shaders, or controlling draw order. Covers the pos-relative draw contract, isKinematic…0 installs

Frequently asked questions about melonjs-deployment

What does the melonjs-deployment skill do?

Use this skill when packaging, shipping or scaffolding a melonJS game — starting a project with create-melonjs, building for the web, browser support and transpiling, and bundle size. For running inside a game portal, a native app, a mini-game runtime or with no DOM, use melonjs-platforms. Triggers on: create-melonjs, scaffold, new project, build, deploy, publish, browser support, transpile, ES2022, bundle size, tree-shaking. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the melonjs-deployment skill?

Run `npx @skills-hub-ai/cli install melonjs-deployment` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/melonjs-deployment/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does melonjs-deployment work with?

melonjs-deployment runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the melonjs-deployment skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use melonjs-deployment after installing it?

In Claude Code, type `/melonjs-deployment` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the melonjs-deployment skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.

Badge for your README

Show that this skill is on Skills Hub. The badge links back to this page and shows the live install count.

Install on Skills Hub badge preview
Markdown
[![Install on Skills Hub](https://skills-hub.ai/api/badges/skill/melonjs-deployment)](https://skills-hub.ai/skills/melonjs-deployment)
HTML
<a href="https://skills-hub.ai/skills/melonjs-deployment"><img src="https://skills-hub.ai/api/badges/skill/melonjs-deployment" alt="Install on Skills Hub"></a>

More options in the badge docs.