A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(export): a playable ships the shape it is uploaded in
esengine8228c0796512
diff --git a/pipeline/bin/estella.mjs b/pipeline/bin/estella.mjsindex 1abf82e2a..3bc3e30c6 100644--- a/pipeline/bin/estella.mjs+++ b/pipeline/bin/estella.mjs@@ -27,6 +27,7 @@ const USAGE = `usage: node pipeline/bin/estella.mjs export <projectDir> [options--output project android: emit a Gradle project instead of an apk--json <file> also write the result here, for a caller that reads it back--enforce-budget fail (exit 1) when the package is over a size limit+ --minify minify the bundled scripts, as a shipping build does--steam-sdk <dir> desktop: a Steamworks SDK whose redistributable ships in the app--steam-appid <id> desktop: also write the Steam depot scripts for this app id@@ -50,7 +51,7 @@ The panorama itself is not shipped — a light references the \`.esenv\`.`;/** Options take a value; these do not — without the distinction a trailing flag* swallows nothing, ends the loop, and a CI job silently gets no gate. */-const FLAGS = new Set(['enforce-budget']);+const FLAGS = new Set(['enforce-budget', 'minify']);function parseArgs(argv) {const [command, projectDir, ...rest] = argv;@@ -388,6 +389,7 @@ try {: undefined,iosSources: platform === 'ios' && templateDir ? iosTemplateSources(templateDir) : null,androidOutput: opts.output === 'project' ? 'project' : undefined,+ minify: opts.minify,sizeBudgetBytes,});const report = { ...result, outDir };diff --git a/pipeline/src/export/exportPlayable.ts b/pipeline/src/export/exportPlayable.tsindex 502d37958..b851df0b3 100644--- a/pipeline/src/export/exportPlayable.ts+++ b/pipeline/src/export/exportPlayable.ts@@ -179,6 +179,18 @@ export async function exportPlayable(opts: {* pin it — a playable must fit whatever container the SDK gives it — this only* reaches the ad-network profile, which may declare it to the platform. */orientation?: ScreenOrientation;+ /**+ * Defaults to ON here, unlike every other target.+ *+ * A playable exists to be uploaded to an ad network under a hard byte cap;+ * there is no dev build of one, and shipping it unminified spent 0.31MB of a+ * 2MB budget on whitespace. Verified as a no-op on what it draws: the same+ * platformer package minified and not is identical to the pixel (frame+ * distance 0.0000, against a 0.06 tolerance).+ *+ * An explicit `false` is still honoured — the editor's Development+ * configuration passes one.+ */minify?: boolean;/** The project's runtime settings, derived once by `runtimeConfigOf`; the page* carries the packaged slice of them as one global the host reads. */@@ -270,7 +282,7 @@ export async function exportPlayable(opts: {// esengine is INLINED (single-file, no import map) → resolve it from the SDK// dist; the project root has no esengine installed.alias: esengineAlias(opts.sdkDir),- minify: opts.minify ?? false,+ minify: opts.minify ?? true,write: false,outfile: 'game-bundle.js',logLevel: 'silent',diff --git a/pipeline/tests/export-playable.test.ts b/pipeline/tests/export-playable.test.tsindex 395b6a33e..ebd8f98fc 100644--- a/pipeline/tests/export-playable.test.ts+++ b/pipeline/tests/export-playable.test.ts@@ -70,6 +70,13 @@ describe('exportGame (playable)', () => {outDir: out,title: 'Playable Demo',platform: 'playable',+ // Structure is what this asserts, so it reads the unminified shape. The+ // stub SDK below exports `defineComponent(){}` — an empty function, and+ // esbuild is right to drop a call to one, which takes `SpawnMarker` with+ // it. The real SDK's writes a registry, so the same project keeps its+ // components minified (verified on platformer: identical to the pixel).+ // The default is asserted on its own, below.+ minify: false,});expect(res.ok).toBe(true);@@ -104,6 +111,34 @@ describe('exportGame (playable)', () => {expect(html).not.toContain('screen.orientation');}, 60_000);+ // A playable is uploaded to an ad network under a hard byte cap and there is no+ // dev build of one, so this target minifies unless told not to — the opposite+ // default from every other. Shipping it unminified spent 0.31MB of a 2MB budget+ // on whitespace, and the CLI had no flag to say otherwise, so every packaged+ // playable CI ever weighed was the unshipped shape.+ it('minifies by default, and still honours an explicit no', async () => {+ const run = async (minify: boolean | undefined, dir: string): Promise<number> => {+ const res = await exportGame({+ root,+ entryScene: 'scenes/main.esscene',+ gameHostEntry: 'unused-for-playable',+ playableHostEntry: PLAYABLE_HOST,+ scriptsEntry: 'src/main.ts',+ sdkDistDir: path.join(root, '_sdk'),+ wasmDir: path.join(root, '_wasm'),+ outDir: path.join(out, dir),+ platform: 'playable',+ minify,+ });+ expect(res.ok).toBe(true);+ return res.inlineParts?.find((p) => p.path === 'game-bundle.js')?.bytes ?? 0;+ };+ const [byDefault, askedFor, refused] = [await run(undefined, 'd'), await run(true, 'y'), await run(false, 'n')];+ expect(byDefault).toBeGreaterThan(0);+ expect(byDefault).toBe(askedFor); // the default IS the shipping shape+ expect(byDefault).toBeLessThan(refused); // and an explicit false still opts out+ }, 120_000);+// The ad network is a PROFILE, not a branch: what it contributes is head markup, a// CTA bridge, and the size it accepts. A project profile and a built-in one reach// the pipeline the same way, so this exercises the contract with a bespoke one.