melonjs-deployment
Fungsinya
Panduan ini mencakup penyiapan proyek melonJS baru, pembangunan untuk web, dan pengemasan untuk platform seluler atau game. Panduan ini untuk pengembang yang ingin menerbitkan game melonJS.
Kapan dipakai
- βSaat seorang pengembang ingin memulai proyek game melonJS baru dari templat resmi.
- βSaat seorang pengembang ingin mengemas game melonJS sebagai aplikasi iPhone atau Android.
- βSaat seorang pengembang ingin menerbitkan game melonJS ke platform game.
Link skill
https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-deployment/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βSiapkan proyek game melonJS baru untuk saya dan tunjukkan cara membangunnya untuk web.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Skill memakai starter proyek resmi, lalu menjelaskan cara membangun game dan memeriksa dukungan browser, termasuk transpiling untuk browser yang lebih lama.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Starting and shipping a project
Scaffolding
Start from the template rather than assembling a build by hand:
npm create melonjs@latest my-game
The project name is required β without it the command prints its usage and exits. 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.
Adding melonJS to an existing project
npm install melonjs
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:
<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:
// vite.config.js β esbuild downlevels dependencies too
export default { build: { target: "es2020" } };
// 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
targetsetting will never add them. - Downlevelled private class members become
WeakMaplookups, and melonJS uses them in the renderer's hot paths. This is a real trade, not a free switch.
Native apps
Capacitor is the current recommendation for iOS and Android β see
@melonjs/capacitor-plugin. Cordova also works and is documented, but is the
older route.
The thing that breaks first in both is asset loading: the app is served from
file://, where fetch() cannot read local files. melonJS's loader falls back
to XHR for that scheme, so engine-loaded assets work β but any fetch() in
your game code will fail there.
Mini-game platforms
WeChat Mini Games and Facebook Instant Games are both documented in the
wiki. Note that device.platform.isWeixin detects WeChat's in-app browser,
which is a normal WebView. WeChat Mini Games are a different runtime with no
DOM, and need platform-specific adaptation rather than just detection β the one
hook the engine offers is that the renderer adopts a globalThis.canvas when
the runtime's adapter provides one, instead of creating its own.
Size
The whole engine is roughly 250 KB minzipped. 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 |
| assets 404 in a packaged native app | fetch() in game code β file:// needs XHR |
| 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 |
Related skills
melonjsβ the companion packages, including the Capacitor pluginmelonjs-getting-startedβ the Application bootstrap the template produces
Pertanyaan umum
Apa yang disertakan starter?
Starter menyiapkan proyek TypeScript dengan Vite dan plugin debug yang sudah terpasang.
Mengapa game saya menampilkan halaman kosong di browser lama?
Bundel mesin menargetkan standar modern, sehingga browser lama bisa gagal memuatnya sama sekali.
Bisakah saya menambahkan melonJS ke proyek yang sudah ada?
Ya. Skill menyatakan pasang paketnya dengan npm.
Detail
Deskripsi asli dari pembuat
Use this skill when packaging, shipping or scaffolding a melonJS game β starting a project with create-melonjs, building for the web, wrapping as a native app with Capacitor or Cordova, publishing to WeChat Mini Games or Facebook Instant Games, browser support and transpiling. Triggers on: create-melonjs, scaffold, new project, build, deploy, publish, Capacitor, Cordova, native app, iOS, Android, WeChat, Instant Games, browser support, transpile, ES2022, bundle size, tree-shaking.
repo: melonjs/melonJS
Popularitas
- Bintang GitHub
- 6.4k
- Peringkat
- #14199
- Lisensi
- MIT
- Diperbarui
- 2/11/2026
Komentar
- β¦
Skill lain dari repositori ini
melonjs-20-migration
6.4kMembantu agent Anda menulis kode game melonJS versi 20 dan menghindari metode yang usang dari versi lama, seperti startup async yang wajib.
melonjs-3d-assets
6.4kMembantu agent Anda memuat model 3D seperti berkas glTF, GLB, dan OBJ ke dalam game browser melonJS, dengan opsi skala dan pencahayaan.
melonjs-3d
6.4kMembantu agent Anda membangun adegan 3D atau 2.5D dalam game browser melonJS, mencakup kamera, mesh, lampu, dan kedalaman, dengan aturan sumbu mesin.
melonjs-audio
6.4kMembantu agent Anda menambahkan efek suara dan musik ke game melonJS, termasuk pengaturan audio, musik latar, kontrol volume, dan suara spasial.
Skill serupa
diffs
394kMemungkinkan agent Anda menghasilkan diff perubahan yang nyata dan dapat dibagikan sebagai tautan viewer atau file gambar, bukan ringkasan yang ditulis manual.
coding-agent
394kMembantu agent Anda menyerahkan pekerjaan pemrograman besar ke Codex, Claude Code, atau OpenCode di latar belakang, lalu memeriksa kemajuannya.
gh-issues
394kMembantu agent Anda menemukan issue GitHub, memilih yang dikerjakan, dan membuka pull request perbaikan, termasuk tindak lanjut komentar tinjauan.