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(export): a package lands in one directory, not two
yhh9897462e7cbd
diff --git a/desktop/electron/exportGame.ts b/desktop/electron/exportGame.tsindex 677ec47c2..782fe7a7e 100644--- a/desktop/electron/exportGame.ts+++ b/desktop/electron/exportGame.ts@@ -634,7 +634,17 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>});}- const absOut = path.isAbsolute(opts.outDir) ? opts.outDir : path.join(opts.root, opts.outDir);+ // path.resolve, not isAbsolute-or-join: on Windows `/Users/me/out` IS absolute+ // and yet names no DRIVE, so it survived that branch unchanged — and then each+ // consumer anchored it somewhere else. Node's fs took the current drive's root;+ // esbuild took its own working directory. The cook, the SDK tree and the html+ // landed in one place and `game.js` + `scripts.mjs` in another, and because+ // neither half FAILED the export reported ok with no errors: a package whose+ // index.html loads a script that is not in it. resolve() yields one+ // fully-qualified path for every consumer, anchors a relative one at the+ // project (which is what `dist-game` has always meant), and leaves a properly+ // drive-qualified absolute path alone.+ const absOut = path.resolve(opts.root, opts.outDir);// Desktop nests the web build under app/; the Electron shell sits beside it.const payloadDir = platform === 'desktop' ? path.join(absOut, 'app') : absOut;// The native app carries the runtime in its binary (engine core + SDK bundle),diff --git a/desktop/tests/export-game.test.ts b/desktop/tests/export-game.test.tsindex c5b2ed6de..01508b329 100644--- a/desktop/tests/export-game.test.ts+++ b/desktop/tests/export-game.test.ts@@ -341,3 +341,69 @@ describe('exportGame', () => {rmSync(path.join(root, '.esengine'), { recursive: true, force: true });}, 60_000);});++/**+ * On Windows a POSIX-style `/Users/me/out` IS absolute and yet names no DRIVE.+ * The old `isAbsolute ? outDir : join(root, outDir)` passed it through unchanged,+ * and every consumer then anchored it somewhere else — Node's fs at the current+ * drive's root, esbuild at its own working directory. The cooked assets, the SDK+ * tree and index.html went one way and `game.js` + `scripts.mjs` the other, and+ * since neither half threw, the export reported ok with no errors: a package+ * whose only script tag points at a file that is not in it.+ */+describe('where an export lands', () => {+ it('writes ONE package — the host and scripts beside the assets', async () => {+ const out = path.join(root, 'sibling-out');+ const res = await exportGame({+ root,+ entryScene: 'scenes/main.esscene',+ gameHostEntry: GAME_HOST,+ scriptsEntry: 'src/main.ts',+ sdkDistDir: path.join(root, '_sdk'),+ wasmDir: path.join(root, '_wasm'),+ outDir: out,+ title: 'One Package',+ });+ expect(res.ok).toBe(true);+ expect(res.errors).toEqual([]);+ // The three that index.html cannot boot without, in the directory it reports.+ for (const f of ['index.html', 'game.js', 'scripts.mjs']) {+ expect([f, existsSync(path.join(res.outDir, f))]).toEqual([f, true]);+ }+ }, 60_000);++ it('resolves a relative outDir against the PROJECT, not the process', async () => {+ const res = await exportGame({+ root,+ entryScene: 'scenes/main.esscene',+ gameHostEntry: GAME_HOST,+ sdkDistDir: path.join(root, '_sdk'),+ wasmDir: path.join(root, '_wasm'),+ outDir: 'rel-out',+ title: 'Relative',+ });+ expect(res.outDir).toBe(path.resolve(root, 'rel-out'));+ expect(existsSync(path.join(res.outDir, 'game.js'))).toBe(true);+ }, 60_000);++ it('gives a driveless absolute path a drive, so every consumer means one place', async () => {+ // The exact shape that split a package in two: absolute by isAbsolute(), and+ // naming no drive, so fs and esbuild each picked a different one.+ const res = await exportGame({+ root,+ entryScene: 'scenes/main.esscene',+ gameHostEntry: GAME_HOST,+ scriptsEntry: 'src/main.ts',+ sdkDistDir: path.join(root, '_sdk'),+ wasmDir: path.join(root, '_wasm'),+ outDir: '/estella-driveless-out',+ title: 'Driveless',+ });+ expect(res.ok).toBe(true);+ expect(res.outDir).toMatch(/^[A-Za-z]:/);+ for (const f of ['index.html', 'game.js', 'scripts.mjs']) {+ expect([f, existsSync(path.join(res.outDir, f))]).toEqual([f, true]);+ }+ rmSync(res.outDir, { recursive: true, force: true });+ }, 60_000);+});