本文へスキップ
Skillpedia
一般的なプログラミング6.4k · #14199

melonjs-deployment

できること

このガイドは、新しいmelonJSのプロジェクトの設定、Web向けのビルド、モバイルまたはゲームプラットフォーム向けのパッケージ化を扱います。melonJSのゲームを公開したい開発者向けです。

使う場面

  • ✓開発者が、公式のテンプレートから新しいmelonJSのゲームプロジェクトを始めたいとき。
  • ✓開発者が、melonJSのゲームをiPhoneまたはAndroidのアプリとしてパッケージ化したいとき。
  • ✓開発者が、melonJSのゲームをゲームプラットフォームに公開したいとき。

スキルのリンク

https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-deployment/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-deployment/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“新しいmelonJSのゲームプロジェクトを作成し、Web向けのビルド方法を教えてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

このスキルは公式のプロジェクトのスターターを使い、古いブラウザ向けのトランスパイルを含め、ゲームのビルドとブラウザの対応状況の確認方法を説明します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)を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 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.

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 plugin
  • melonjs-getting-started — the Application bootstrap the template produces
よくある質問

スターターには何が含まれていますか?

Viteとデバッグのプラグインが組み込まれたTypeScriptのプロジェクトを設定します。

古いブラウザで空白のページになるのはなぜですか?

エンジンのバンドルは現代の規格を対象としており、古いブラウザでは読み込み自体に失敗することがあるからです。

既存のプロジェクトにmelonJSを追加できますか?

はい。npmでパッケージをインストールするようスキルは述べています。

詳細

作者による元の説明

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

人気

GitHubのスター
6.4k
ランキング
#14199
ライセンス
MIT
更新日
2026/11/2

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル