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
refactor(export): the entry asks for the runtime where the layout put it
esengine9a5e67dc6cda
diff --git a/pipeline/src/export/exportMiniGame.ts b/pipeline/src/export/exportMiniGame.tsindex d7580d293..d0fd9fd4f 100644--- a/pipeline/src/export/exportMiniGame.ts+++ b/pipeline/src/export/exportMiniGame.ts@@ -90,6 +90,10 @@ function stripUuidRefs(v: unknown): unknown {interface RuntimeLayout {/** Package-relative path the boot config hands the loader. */readonly enginePath: string;+ /** Package-relative directory the runtime artifacts land in, as the generated+ * entry requires them (`./wasm/`) — one author for where they are and where+ * they are asked for. */+ readonly runtimeDir: string;/** Engine artifacts to stage, as the name in `wasmDir` → the name in the package. */readonly files: ReadonlyArray<{ readonly src: string; readonly staged: string; readonly brotli?: true }>;}@@ -109,6 +113,7 @@ function planRuntimeLayout(const engineStaged = brotli ? `${engineBinary}.br` : engineBinary;return {enginePath: `wasm/${engineStaged}`,+ runtimeDir: 'wasm',files: [{ src: engineGlueFile, staged: engineGlueFile },...(brotli@@ -489,7 +494,8 @@ export async function exportMiniGame(profile: MiniGameExportProfile, opts: {);}}- await writeFile(path.join(absOut, 'game.js'), profile.emitEntry({ sideModules, engineGlueFile }));+ await writeFile(path.join(absOut, 'game.js'),+ profile.emitEntry({ sideModules, engineGlueFile, runtimeDir: runtimeLayout.runtimeDir }));const configFiles = profile.emitConfigFiles({title,appid: opts.appid ?? '',diff --git a/pipeline/src/export/miniGameExportProfile.ts b/pipeline/src/export/miniGameExportProfile.tsindex 032c9eca9..8b05b4777 100644--- a/pipeline/src/export/miniGameExportProfile.ts+++ b/pipeline/src/export/miniGameExportProfile.ts@@ -58,6 +58,9 @@ export interface MiniGameEntryContext {sideModules: ReadonlyArray<{ id: string; file: string }>;/** The engine glue filename staged into wasm/ (esengine.wxgame.js | esengine.js). */engineGlueFile: string;+ /** Package-relative directory those artifacts landed in, decided by the+ * export's runtime layout. The entry asks for them WHERE THEY ARE. */+ runtimeDir: string;}/**@@ -68,12 +71,12 @@ export interface MiniGameEntryContext {*/export function defaultMiniGameEntry(ctx: MiniGameEntryContext): string {const requires = ctx.sideModules- .map((m) => ` ${JSON.stringify(m.id)}: asFactory(require('./wasm/${m.file}.js')),`)+ .map((m) => ` ${JSON.stringify(m.id)}: asFactory(require('./${ctx.runtimeDir}/${m.file}.js')),`).join('\n');return `'use strict';// Generated by Estella exportGame (MiniGame entry).const asFactory = (m) => (typeof m === 'function' ? m : (m && m.default) || m);-const engineFactory = asFactory(require('./wasm/${ctx.engineGlueFile}'));+const engineFactory = asFactory(require('./${ctx.runtimeDir}/${ctx.engineGlueFile}'));const sideModuleFactories = {${requires}};diff --git a/pipeline/tests/platform-catalog.test.ts b/pipeline/tests/platform-catalog.test.tsindex 6dce1bac1..1e8d88120 100644--- a/pipeline/tests/platform-catalog.test.ts+++ b/pipeline/tests/platform-catalog.test.ts@@ -240,7 +240,7 @@ describe('loadProjectPlatform — the profile handed to exportMiniGame', () => {expect(typeof p.emitEntry).toBe('function');// The default entry is the same CommonJS shape WeChat ships.- const entry = p.emitEntry({ sideModules: [{ id: 'physics', file: 'physics' }], engineGlueFile: 'esengine.js' });+ const entry = p.emitEntry({ sideModules: [{ id: 'physics', file: 'physics' }], engineGlueFile: 'esengine.js', runtimeDir: 'wasm' });expect(entry).toContain("require('./wasm/esengine.js')");expect(entry).toContain(`"physics": asFactory(require('./wasm/physics.js'))`);expect(entry).toContain("require('./game-bundle.js')");diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 9f7225d4a..285274503 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -28,6 +28,9 @@ export const NOTES_FLOOR = 'v0.65.0';* the reader recognises anyway.*/export const NOTED = {+ 'refactor(export): the entry asks for the runtime where the layout put it':+ { internal: 'One author for a path inside the package; what it answers is unchanged.' },+'fix(assets): a load that failed is warned, not only recorded':{ note: 'An asset that fails to load says so.' },