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
fix(playable): a playable imports the module an asset needs and its entry does not carry - the whole entry installs what a scene can name and not esengine/image, which only a texture recipe asks for, so a playable shipped its recipes and drew none of them; the modules its cooked assets name are imported before the host, and one with no recipe carries no drawer
yhh5bbe47454d43
diff --git a/pipeline/src/export/exportPlayable.ts b/pipeline/src/export/exportPlayable.tsindex a816bffe2..dd7fa9d9d 100644--- a/pipeline/src/export/exportPlayable.ts+++ b/pipeline/src/export/exportPlayable.ts@@ -41,7 +41,7 @@ import { checkPlayable, type PlayableCheckReport } from './playableCheck';import { makeZip } from '../../../build-tools/utils/zip.js';import { planSideModules, spineRefusalMessage, sideModuleFiles } from '../bundle/sideModuleScan';import type { Physics3DBackend } from 'esengine';-import { forcedSideModules, moduleChoices } from '../bundle/engineInstalls';+import { forcedSideModules, moduleChoices, moduleForAsset } from '../bundle/engineInstalls';import type { ModuleChoice, ProjectFeatures, ProjectPackaging } from '../project/format';export interface ExportPlayableResult {@@ -311,7 +311,11 @@ export async function exportPlayable(opts: {// 4. Host + esengine + project scripts → ONE IIFE (esengine INLINED; no import map).progress({ phase: 'Bundling game' });const scriptsAbs = opts.scriptsEntry ? path.join(opts.root, opts.scriptsEntry) : null;+ // The whole entry installs every subsystem a scene can name, and not what only a file asks for: a texture recipe is drawn by+ // esengine/image, which nothing imports unless an asset is one. Without it a playable shipped its recipes and drew none of them.+ const assetModules = [...new Set(cook.includedPaths.map(moduleForAsset).filter((m): m is string => m !== null))].sort();const entrySrc =+ assetModules.map((m) => `import ${JSON.stringify(m)};\n`).join('') +(scriptsAbs && existsSync(scriptsAbs) ? `import ${JSON.stringify(scriptsAbs)};\n` : '') +`import ${JSON.stringify(runtimeHostEntry(opts.hostsDir, 'playableHost'))};\n`;let bundle = '';diff --git a/pipeline/tests/export-playable.test.ts b/pipeline/tests/export-playable.test.tsindex 3c3f3f0e6..f8eb6c356 100644--- a/pipeline/tests/export-playable.test.ts+++ b/pipeline/tests/export-playable.test.ts@@ -230,6 +230,30 @@ describe('exportGame (playable)', () => {expect(html).not.toContain('screen.orientation');}, 60_000);+ // A texture recipe is drawn by esengine/image, which the whole entry does not carry: it is imported for the asset that needs+ // it. A playable shipped six recipes and drew its ground and its walls with no texture, with nothing in the build saying so.+ it('imports the module an asset needs and the entry does not carry', async () => {+ const RECIPE = 'cccccccc-cccc-4ccc-8ccc-cccccccccccc';+ writeFileSync(path.join(root, 'assets', 'plate.esimage'), JSON.stringify({ size: 8, layers: [] }));+ writeFileSync(path.join(root, 'assets', 'plate.esimage.meta'), meta(RECIPE, 'imageSource'));+ writeFileSync(path.join(root, 'scenes', 'recipe.esscene'),+ JSON.stringify({ version: '1.0', name: 'Recipe', entities: [{ id: 0, components: [{ type: 'Sprite', data: { texture: `@uuid:${RECIPE}` } }] }] }));+ writeFileSync(path.join(root, 'scenes', 'recipe.esscene.meta'), meta('dddddddd-dddd-4ddd-8ddd-dddddddddddd', 'scene'));+ mkdirSync(path.join(root, '_sdk', 'image'), { recursive: true });+ writeFileSync(path.join(root, '_sdk', 'image', 'index.js'), `globalThis.__estellaRecipes = 'RECIPE_DRAWER_INSTALLED';\n`);+ const exportOf = (entryScene: string, outDir: string) => exportGame({+ root, entryScene, hostsDir: HOSTS, packagesDir: OFFICIAL_PACKAGES, scriptsEntry: 'src/main.ts',+ sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wasm'), outDir, title: 'Recipes', platform: 'playable', minify: false,+ });+ const withRecipe = path.join(root, 'dist-recipe');+ expect((await exportOf('scenes/recipe.esscene', withRecipe)).ok).toBe(true);+ expect(inlinedText(readFileSync(path.join(withRecipe, 'index.html'), 'utf8'), '__GAME_BUNDLE__')).toContain('RECIPE_DRAWER_INSTALLED');+ // And only then: a playable with no recipe does not pay for the drawer.+ const without = path.join(root, 'dist-no-recipe');+ expect((await exportOf('scenes/main.esscene', without)).ok).toBe(true);+ expect(inlinedText(readFileSync(path.join(without, 'index.html'), 'utf8'), '__GAME_BUNDLE__')).not.toContain('RECIPE_DRAWER_INSTALLED');+ }, 60_000);+// The editor never bundles the hosts from their sources: a packaged app ships// none, so it exports from the tree it prebuilt. Every other test here reads the// sources, where a host the prebuild never emitted is still right beside them.