Skip to content

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.

feat(assets): content-addressing on by default for web/desktop exports

yhhab29dc518fb9
diff --git a/desktop/electron/exportGame.ts b/desktop/electron/exportGame.ts
index 3657fe452..336f80769 100644
--- a/desktop/electron/exportGame.ts
+++ b/desktop/electron/exportGame.ts
@@ -204,9 +204,11 @@ export async function exportGame(opts: {
sdkDistDir: string;
wasmDir: string;
outDir: string;
- /** Emit content-addressed asset filenames (<hash><ext>) for dedup + immutable caching. */
+ /** Content-addressed asset filenames (<hash><ext>) — dedup + immutable/CDN caching.
+ * Default ON (the modern-bundler standard); set false to keep logical paths. */
contentAddressed?: boolean;
- /** Encode raster textures to GPU-compressed KTX2 at cook time. */
+ /** Encode raster textures to GPU-compressed KTX2 at cook time. Default off
+ * (lossy + encode-time cost — opt in per project). */
compressTextures?: boolean;
title?: string;
platform?: ExportPlatform;
@@ -282,7 +284,7 @@ export async function exportGame(opts: {
// 1. Cook reachable assets + manifest (the entry scene file is staged too).
progress({ phase: 'Cooking assets' });
- const cook = await cookAssets(opts.root, { entryScenes: [opts.entryScene], outDir: payloadDir, contentAddressed: opts.contentAddressed, compressTextures: opts.compressTextures });
+ const cook = await cookAssets(opts.root, { entryScenes: [opts.entryScene], outDir: payloadDir, contentAddressed: opts.contentAddressed ?? true, compressTextures: opts.compressTextures });
warnings.push(...cook.warnings);
progress({ phase: 'Cooking assets', detail: `${cook.included.length} reachable` });
diff --git a/desktop/tests/export-desktop.test.ts b/desktop/tests/export-desktop.test.ts
index 2c59e19e6..1e68c7615 100644
--- a/desktop/tests/export-desktop.test.ts
+++ b/desktop/tests/export-desktop.test.ts
@@ -71,7 +71,11 @@ describe('exportGame (desktop)', () => {
}
expect(existsSync(path.join(app, 'wasm', 'esengine.js'))).toBe(true);
expect(existsSync(path.join(app, 'sdk', 'index.js'))).toBe(true);
- expect(existsSync(path.join(app, 'assets', 'hero.png'))).toBe(true);
+ // Content-addressed by default: the texture ships as assets/<hash>.png.
+ const m = JSON.parse(readFileSync(path.join(app, 'assets.manifest.json'), 'utf8'));
+ const tex = m.entries.find((e: { type: string }) => e.type === 'texture');
+ expect(tex.path).toMatch(/^assets\/[0-9a-f]{16}\.png$/);
+ expect(existsSync(path.join(app, tex.path))).toBe(true);
// Electron shell beside it.
const main = readFileSync(path.join(out, 'main.cjs'), 'utf8');
diff --git a/desktop/tests/export-game.test.ts b/desktop/tests/export-game.test.ts
index ab4ab55c8..8a75ba349 100644
--- a/desktop/tests/export-game.test.ts
+++ b/desktop/tests/export-game.test.ts
@@ -79,7 +79,11 @@ describe('exportGame', () => {
expect(has('game.config.json')).toBe(true);
expect(has('assets.manifest.json')).toBe(true);
expect(has('scenes/main.esscene')).toBe(true);
- expect(has('assets/hero.png')).toBe(true);
+ // Content-addressing is on by default now: the texture ships as assets/<hash>.png.
+ const m = JSON.parse(readFileSync(path.join(out, 'assets.manifest.json'), 'utf8'));
+ const tex = m.entries.find((e: { type: string }) => e.type === 'texture');
+ expect(tex.path).toMatch(/^assets\/[0-9a-f]{16}\.png$/);
+ expect(has(tex.path)).toBe(true);
expect(has('wasm/esengine.js')).toBe(true);
// The host + project bundle are esengine-EXTERNAL (small; resolved by the