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.

fix(export): a web package ships the chunks its entries reach

esengine6edd6c873aa0
diff --git a/pipeline/src/export/exportGame.ts b/pipeline/src/export/exportGame.ts
index d423f2fee..18b79446f 100644
--- a/pipeline/src/export/exportGame.ts
+++ b/pipeline/src/export/exportGame.ts
@@ -23,7 +23,7 @@ import type { BuildOptions, Plugin } from 'esbuild';
import { loadEsbuild } from '../bundle/esbuildRuntime';
import { runtimeHostEntry } from '../bundle/runtimeHosts';
import { writeFile, readFile, mkdir, cp, readdir, rm } from 'node:fs/promises';
-import { existsSync } from 'node:fs';
+import { existsSync, readFileSync, statSync } from 'node:fs';
import path from 'node:path';
import { cookAssets, loadAssetGroups, type CookManifest, type Inclusion } from '../assets/cookAssets';
import { cookWorlds, streamedScenes } from '../world/cookWorld';
@@ -141,43 +141,58 @@ export async function discoverProjectScenes(root: string, entryScene: string, sc
}
/**
- * Top-level bundles in sdk/dist a BROWSER page can load, derived from the map
- * that names them — `dist` holds every target's output side by side.
+ * Entry bundles in sdk/dist a BROWSER page can load, derived from the map that
+ * names them — `dist` holds every target's output side by side.
*
* Derived, not enumerated: a listed set went stale the first time an entry was
* added, and a web package shipped a WeChat SDK.
*/
-const BROWSER_TOP_LEVEL = new Set(
- Object.values(IMPORT_MAP.imports)
- .map((t) => t.replace(/^\.\/sdk\//, ''))
- .filter((t) => !t.includes('/')),
-);
+const BROWSER_ENTRIES = Object.values(IMPORT_MAP.imports).map((t) => t.replace(/^\.\/sdk\//, ''));
+
+/** The build's own record of which chunks each entry reaches (sdk/rolldown.config.js). */
+const CHUNK_MANIFEST = 'chunks.json';
+
+/**
+ * The files a browser package needs out of sdk/dist: the entries the import map
+ * names, plus the chunks the SDK build says those entries reach. Eleven entries
+ * share one chunk graph, and a `dist` can still hold an earlier build's output —
+ * a directory copy ships both (412KB of dead chunks the day this was written).
+ */
+function browserPayload(sdkDist: string): Set<string> {
+ const manifest = path.join(sdkDist, CHUNK_MANIFEST);
+ if (!existsSync(manifest)) {
+ // Loud, because the quiet alternative is shipping every target's runtime.
+ throw new Error(`${manifest} not found — rebuild the SDK (pnpm --filter ./sdk build).`);
+ }
+ const reach = JSON.parse(readFileSync(manifest, 'utf8')) as Record<string, readonly string[]>;
+ const want = new Set<string>();
+ for (const entry of BROWSER_ENTRIES) {
+ want.add(entry);
+ for (const chunk of reach[entry] ?? []) want.add(chunk);
+ }
+ return want;
+}
/**
* Whether a file under sdk/dist belongs in a browser package built with
- * `sourceMaps` on or off — the same answer the export's own bundles get, since
- * the maps a package carries are one decision and not one per producer.
- *
- * Directories always pass — the per-file test decides what lands inside them,
- * and refusing a directory would drop the shared chunks the entry imports.
- * Type declarations go too: nothing at runtime reads a `.d.ts`, and they are a
- * megabyte of a package whose whole point is what the player downloads.
- *
- * Deliberately a name test rather than a walk of the import graph: the graph
- * would be exact but silent when it is wrong, and a bundle this drops that
- * something did want is a 404 the moment the page loads, not a subtle bug.
+ * `sourceMaps` on or off — the maps a package carries are one decision and not
+ * one per producer. Declarations never ship: nothing at runtime reads a `.d.ts`.
*/
export function shipsToBrowser(sourceMaps: boolean, sdkDist?: string): (src: string) => boolean {
+ const want = sdkDist ? browserPayload(sdkDist) : undefined;
+ const root = sdkDist ? path.resolve(sdkDist) : undefined;
return (src: string) => {
const base = path.basename(src);
if (base.endsWith('.d.ts')) return false;
if (!sourceMaps && base.endsWith('.map')) return false;
- // Only the top level: a subpath's `index.js` lives in its own directory, and
- // `shared/` is chunks rather than entries.
- if (sdkDist && /\.js(\.map)?$/.test(base) && path.dirname(src) === path.resolve(sdkDist)) {
- return BROWSER_TOP_LEVEL.has(base.replace(/\.map$/, ''));
- }
- return true;
+ if (!want || !root) return true;
+ const rel = path.relative(root, src).split(path.sep).join('/');
+ if (rel === '') return true;
+ // A directory passes when something wanted is inside it; `cp` prunes the
+ // whole tree otherwise.
+ if (statSync(src, { throwIfNoEntry: false })?.isDirectory()) return [...want].some((f) => f.startsWith(`${rel}/`));
+ if (rel === CHUNK_MANIFEST) return false;
+ return want.has(rel.replace(/\.map$/, ''));
};
}
diff --git a/pipeline/tests/export-aot.test.ts b/pipeline/tests/export-aot.test.ts
index df7f29e11..4ad1f673d 100644
--- a/pipeline/tests/export-aot.test.ts
+++ b/pipeline/tests/export-aot.test.ts
@@ -17,6 +17,7 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { exportGame } from '../src/export/exportGame';
import { emccPath } from '../../build-tools/utils/emscripten.js';
+import { writeFakeSdkDist } from './fixtures/fakeSdkDist';
const HERE = path.dirname(fileURLToPath(import.meta.url));
const HOSTS = path.join(HERE, '..', 'src', 'runtime');
@@ -64,8 +65,7 @@ function setup(files: Record<string, string>): { root: string; out: string } {
mkdirSync(path.dirname(at), { recursive: true });
writeFileSync(at, body);
}
- mkdirSync(path.join(root, '_sdk'), { recursive: true });
- writeFileSync(path.join(root, '_sdk', 'index.js'), 'export const x = 1;\n');
+ writeFakeSdkDist(path.join(root, '_sdk'));
mkdirSync(path.join(root, '_wasm'), { recursive: true });
writeFileSync(path.join(root, '_wasm', 'esengine.js'), 'export default () => {};');
writeFileSync(path.join(root, '_wasm', 'esengine.wasm'), 'ENGINE');
diff --git a/pipeline/tests/export-compiled-systems.test.ts b/pipeline/tests/export-compiled-systems.test.ts
index 5e39d0165..2d320967d 100644
--- a/pipeline/tests/export-compiled-systems.test.ts
+++ b/pipeline/tests/export-compiled-systems.test.ts
@@ -20,6 +20,7 @@ import { fileURLToPath } from 'node:url';
import type { PackagedGameConfig } from 'esengine';
import { exportGame } from '../src/export/exportGame';
import { resolveEmcc } from '../src/bundle/emccPath';
+import { writeFakeSdkDist } from './fixtures/fakeSdkDist';
const HERE = path.dirname(fileURLToPath(import.meta.url));
const HOSTS = path.join(HERE, '..', 'src', 'runtime');
@@ -75,8 +76,7 @@ function project(source: string | null): { root: string; out: string } {
mkdirSync(path.join(root, 'src'), { recursive: true });
writeFileSync(path.join(root, 'src', 'main.ts'), source ?? 'export {};\n');
- mkdirSync(path.join(root, '_sdk'), { recursive: true });
- writeFileSync(path.join(root, '_sdk', 'index.js'), 'export const x = 1;');
+ writeFakeSdkDist(path.join(root, '_sdk'));
mkdirSync(path.join(root, '_wasm'), { recursive: true });
writeFileSync(path.join(root, '_wasm', 'esengine.js'), 'export default () => {};');
writeFileSync(path.join(root, '_wasm', 'esengine.wasm'), 'ENGINE');
diff --git a/pipeline/tests/export-desktop.test.ts b/pipeline/tests/export-desktop.test.ts
index f244d0170..30175b12b 100644
--- a/pipeline/tests/export-desktop.test.ts
+++ b/pipeline/tests/export-desktop.test.ts
@@ -14,6 +14,7 @@ import { tmpdir } from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { exportGame } from '../src/export/exportGame';
+import { writeFakeSdkDist } from './fixtures/fakeSdkDist';
const HERE = path.dirname(fileURLToPath(import.meta.url));
const HOSTS = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime');
@@ -37,8 +38,7 @@ beforeAll(async () => {
writeFileSync(path.join(root, 'scenes', 'main.esscene.meta'), meta(SCN, 'scene'));
mkdirSync(path.join(root, 'src'), { recursive: true });
writeFileSync(path.join(root, 'src', 'main.ts'), `import { defineComponent } from 'esengine';\ndefineComponent('SpawnMarker', { rate: 1 });\n`);
- mkdirSync(path.join(root, '_sdk'), { recursive: true });
- writeFileSync(path.join(root, '_sdk', 'index.js'), 'export const x = 1;');
+ writeFakeSdkDist(path.join(root, '_sdk'));
mkdirSync(path.join(root, '_wasm'), { recursive: true });
writeFileSync(path.join(root, '_wasm', 'esengine.js'), 'export default () => {};');
writeFileSync(path.join(root, '_wasm', 'esengine.wasm'), 'wasmbytes');
diff --git a/pipeline/tests/export-native.test.ts b/pipeline/tests/export-native.test.ts
index 9fa7a213d..41f706aa8 100644
--- a/pipeline/tests/export-native.test.ts
+++ b/pipeline/tests/export-native.test.ts
@@ -13,6 +13,7 @@ import { tmpdir } from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { exportGame } from '../src/export/exportGame';
+import { writeFakeSdkDist } from './fixtures/fakeSdkDist';
const HERE = path.dirname(fileURLToPath(import.meta.url));
const HOSTS = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime');
@@ -37,8 +38,7 @@ beforeAll(async () => {
writeFileSync(path.join(root, 'scenes', 'main.esscene.meta'), meta(SCN, 'scene'));
mkdirSync(path.join(root, 'src'), { recursive: true });
writeFileSync(path.join(root, 'src', 'main.ts'), `import { defineComponent } from 'esengine';\ndefineComponent('SpawnMarker', { rate: 1 });\n`);
- mkdirSync(path.join(root, '_sdk'), { recursive: true });
- writeFileSync(path.join(root, '_sdk', 'index.js'), 'export const x = 1;');
+ writeFakeSdkDist(path.join(root, '_sdk'));
mkdirSync(path.join(root, '_wasm'), { recursive: true });
writeFileSync(path.join(root, '_wasm', 'esengine.js'), 'export default () => {};');
diff --git a/pipeline/tests/export-progress.test.ts b/pipeline/tests/export-progress.test.ts
index 95f14802c..e42e59aa9 100644
--- a/pipeline/tests/export-progress.test.ts
+++ b/pipeline/tests/export-progress.test.ts
@@ -11,6 +11,7 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { exportGame } from '../src/export/exportGame';
import type { ExportProgress } from '../src/export/exportProgress';
+import { writeFakeSdkDist } from './fixtures/fakeSdkDist';
const HERE = path.dirname(fileURLToPath(import.meta.url));
const HOSTS = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime');
@@ -31,8 +32,7 @@ beforeAll(() => {
writeFileSync(path.join(root, 'scenes', 'main.esscene.meta'), meta(SCN, 'scene'));
mkdirSync(path.join(root, 'src'), { recursive: true });
writeFileSync(path.join(root, 'src', 'main.ts'), `import { defineComponent } from 'esengine';\ndefineComponent('M', { n: 1 });\n`);
- mkdirSync(path.join(root, '_sdk'), { recursive: true });
- writeFileSync(path.join(root, '_sdk', 'index.js'), 'export const x = 1;');
+ writeFakeSdkDist(path.join(root, '_sdk'));
mkdirSync(path.join(root, '_wasm'), { recursive: true });
writeFileSync(path.join(root, '_wasm', 'esengine.js'), 'export default () => {};');
writeFileSync(path.join(root, '_wasm', 'esengine.wasm'), 'wasmbytes');
diff --git a/pipeline/tests/export-side-modules.test.ts b/pipeline/tests/export-side-modules.test.ts
index ccb8ea2d0..5bb8521d6 100644
--- a/pipeline/tests/export-side-modules.test.ts
+++ b/pipeline/tests/export-side-modules.test.ts
@@ -11,6 +11,7 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { exportGame } from '../src/export/exportGame';
import { runtimeConfigOf } from '../src/project/runtimeConfig';
+import { writeFakeSdkDist } from './fixtures/fakeSdkDist';
const HERE = path.dirname(fileURLToPath(import.meta.url));
const HOSTS = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime');
@@ -33,8 +34,7 @@ function setup(scene: unknown, extra?: (root: string) => void): Fixture {
writeFileSync(path.join(root, 'scenes', 'main.esscene'), JSON.stringify(scene));
writeFileSync(path.join(root, 'scenes', 'main.esscene.meta'), meta(SCN, 'scene'));
- mkdirSync(path.join(root, '_sdk'), { recursive: true });
- writeFileSync(path.join(root, '_sdk', 'index.js'), 'export const x = 1;');
+ writeFakeSdkDist(path.join(root, '_sdk'));
mkdirSync(path.join(root, '_wasm'), { recursive: true });
writeFileSync(path.join(root, '_wasm', 'esengine.js'), 'export default () => {};');
diff --git a/pipeline/tests/export-source-maps.test.ts b/pipeline/tests/export-source-maps.test.ts
index eca077196..9218d6ddb 100644
--- a/pipeline/tests/export-source-maps.test.ts
+++ b/pipeline/tests/export-source-maps.test.ts
@@ -10,6 +10,7 @@ import { tmpdir } from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { exportGame } from '../src/export/exportGame';
+import { writeFakeSdkDist } from './fixtures/fakeSdkDist';
const HERE = path.dirname(fileURLToPath(import.meta.url));
const HOSTS = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime');
@@ -24,13 +25,14 @@ function setup(): { root: string; out: string } {
JSON.stringify({ version: '1.0', name: 'Main', entities: [{ id: 0, components: [] }] }));
writeFileSync(path.join(root, 'scenes', 'main.esscene.meta'), meta(SCN, 'scene'));
- mkdirSync(path.join(root, '_sdk', 'shared'), { recursive: true });
// Exactly how the SDK build writes them: the script names its map on the last
// line, and the map sits beside it.
- writeFileSync(path.join(root, '_sdk', 'index.js'), 'export const x = 1;\n//# sourceMappingURL=index.js.map\n');
- writeFileSync(path.join(root, '_sdk', 'index.js.map'), '{"version":3}');
- writeFileSync(path.join(root, '_sdk', 'shared', 'resource.js'), 'export const r = 1;\n//# sourceMappingURL=resource.js.map');
- writeFileSync(path.join(root, '_sdk', 'shared', 'resource.js.map'), '{"version":3}');
+ writeFakeSdkDist(path.join(root, '_sdk'), {
+ 'index.js': 'export const x = 1;\n//# sourceMappingURL=index.js.map\n',
+ 'index.js.map': '{"version":3}',
+ 'shared/resource.js': 'export const r = 1;\n//# sourceMappingURL=resource.js.map',
+ 'shared/resource.js.map': '{"version":3}',
+ });
mkdirSync(path.join(root, '_wasm'), { recursive: true });
writeFileSync(path.join(root, '_wasm', 'esengine.js'), 'export default () => {};');
diff --git a/pipeline/tests/fixtures/fakeSdkDist.ts b/pipeline/tests/fixtures/fakeSdkDist.ts
new file mode 100644
index 000000000..43b928226
--- /dev/null
+++ b/pipeline/tests/fixtures/fakeSdkDist.ts
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file A stand-in for `sdk/dist` that an export can be pointed at.
+ *
+ * The export reads the chunk manifest the SDK build writes and refuses a dist
+ * without one, so a fixture is now a shape rather than a file or two — and nine
+ * tests had each written their own.
+ */
+import { mkdirSync, writeFileSync } from 'node:fs';
+import path from 'node:path';
+
+const TRIVIAL = { 'index.js': 'export const x = 1;\n' };
+
+/**
+ * Write a minimal dist at `dir`: `files` maps a dist-relative path to its
+ * source. Anything under `shared/` is a chunk every entry reaches; everything
+ * else is an entry. Returns `dir`, so it reads as the argument it becomes.
+ */
+export function writeFakeSdkDist(dir: string, files: Readonly<Record<string, string>> = TRIVIAL): string {
+ mkdirSync(dir, { recursive: true });
+ for (const [rel, source] of Object.entries(files)) {
+ const file = path.join(dir, rel);
+ mkdirSync(path.dirname(file), { recursive: true });
+ writeFileSync(file, source);
+ }
+ const names = Object.keys(files).filter((f) => f.endsWith('.js'));
+ const chunks = names.filter((f) => f.startsWith('shared/'));
+ const manifest = Object.fromEntries(names.filter((f) => !chunks.includes(f)).map((f) => [f, chunks]));
+ writeFileSync(path.join(dir, 'chunks.json'), JSON.stringify(manifest, null, 2));
+ return dir;
+}
diff --git a/pipeline/tests/ships-to-browser.test.ts b/pipeline/tests/ships-to-browser.test.ts
index 61f57b7d2..3052cfc37 100644
--- a/pipeline/tests/ships-to-browser.test.ts
+++ b/pipeline/tests/ships-to-browser.test.ts
@@ -3,51 +3,80 @@
/**
* @file A web package carries the entry the page names and no other host's.
*
- * `sdk/dist` holds every target's build side by side, so the staging step is the
- * only thing standing between a browser package and the Node, WeChat, mini-game
- * and native SDKs. The set it keeps is derived from the import map, because an
- * enumerated one went stale the first time an entry was added.
+ * `sdk/dist` holds every target's build side by side, and its eleven entries
+ * share one code-split graph, so `shared/` is their union. The staging step is
+ * the only thing standing between a browser package and the Node, WeChat,
+ * mini-game and native SDKs — entries by the import map, chunks by the manifest
+ * the bundler writes.
*/
-import { describe, it, expect } from 'vitest';
+import { describe, it, expect, beforeAll, afterAll } from 'vitest';
+import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
import path from 'node:path';
import { shipsToBrowser } from '../src/export/exportGame';
import { IMPORT_MAP } from '../src/bundle/importMap';
-const DIST = path.resolve('/tmp/does-not-need-to-exist/dist');
+/** The shape of a real dist, small enough to read: entries, chunks, a manifest. */
+const ENTRIES = Object.values(IMPORT_MAP.imports).map((t) => t.replace('./sdk/', ''));
+const OTHER_HOSTS = [
+ 'index.node.js', 'index.wechat.js', 'index.wechat.cjs.js', 'index.wechat.lean.js',
+ 'index.minigame.js', 'index.native.js', 'index.native.bundled.js', 'index.bundled.js',
+];
+const WEB_CHUNK = 'shared/webAppFactory.js';
+const MINIGAME_CHUNK = 'shared/wechatRuntime.js';
+
+let DIST: string;
const at = (rel: string) => path.join(DIST, rel);
+beforeAll(() => {
+ DIST = mkdtempSync(path.join(tmpdir(), 'ships-'));
+ const write = (rel: string) => {
+ mkdirSync(path.dirname(at(rel)), { recursive: true });
+ writeFileSync(at(rel), '');
+ };
+ for (const f of [...ENTRIES, ...OTHER_HOSTS, WEB_CHUNK, MINIGAME_CHUNK]) write(f);
+ for (const f of ['index.d.ts', 'index.js.map', 'index.wechat.js.map']) write(f);
+ const manifest: Record<string, string[]> = { 'index.wechat.js': [MINIGAME_CHUNK] };
+ for (const e of ENTRIES) manifest[e] = [WEB_CHUNK];
+ writeFileSync(at('chunks.json'), JSON.stringify(manifest));
+});
+
+afterAll(() => rmSync(DIST, { recursive: true, force: true }));
+
describe('what a web export stages from sdk/dist', () => {
+ it('keeps exactly the entries the import map names', () => {
+ const keeps = shipsToBrowser(false, DIST);
+ for (const f of ENTRIES) expect(keeps(at(f)), f).toBe(true);
+ });
+
+ it.each(OTHER_HOSTS)('drops %s — a browser page can never load it', (f) => {
+ expect(shipsToBrowser(false, DIST)(at(f))).toBe(false);
+ });
+
+ it('keeps a chunk a web entry reaches and drops one only a mini-game entry does', () => {
+ const keeps = shipsToBrowser(false, DIST);
+ expect(keeps(at(WEB_CHUNK))).toBe(true);
+ expect(keeps(at(MINIGAME_CHUNK))).toBe(false);
+ });
+
+ it('keeps a directory something wanted lives in, so the copy is not pruned', () => {
+ const keeps = shipsToBrowser(false, DIST);
+ expect(keeps(at('shared'))).toBe(true);
+ expect(keeps(at('spine'))).toBe(true);
+ });
+
+ it('drops declarations, the manifest itself, and — without source maps — the maps', () => {
const keeps = shipsToBrowser(false, DIST);
+ expect(keeps(at('index.d.ts'))).toBe(false);
+ expect(keeps(at('chunks.json'))).toBe(false);
+ expect(keeps(at('index.js.map'))).toBe(false);
+ expect(shipsToBrowser(true, DIST)(at('index.js.map'))).toBe(true);
+ expect(shipsToBrowser(true, DIST)(at('index.wechat.js.map'))).toBe(false);
+ });
- it('keeps exactly the top-level files the import map names', () => {
- const named = Object.values(IMPORT_MAP.imports)
- .map((t) => t.replace('./sdk/', ''))
- .filter((t) => !t.includes('/'));
- for (const f of named) expect(keeps(at(f)), f).toBe(true);
- });
-
- it.each([
- 'index.node.js', 'index.wechat.js', 'index.wechat.cjs.js', 'index.wechat.lean.js',
- 'index.minigame.js', 'index.native.js', 'index.native.bundled.js', 'index.bundled.js',
- 'open-data.js',
- ])('drops %s — a browser page can never load it', (f) => {
- expect(keeps(at(f))).toBe(false);
- });
-
- it('keeps a subpath entry, which lives in its own directory', () => {
- for (const f of ['spine/index.js', 'physics/index.js', 'douyin/index.js']) {
- expect(keeps(at(f)), f).toBe(true);
- }
- });
-
- it('keeps the shared chunks, which are not entries and are named by nothing', () => {
- expect(keeps(at('shared/webAppFactory.js'))).toBe(true);
- });
-
- it('drops declarations and, without source maps, the maps', () => {
- expect(keeps(at('index.d.ts'))).toBe(false);
- expect(keeps(at('index.js.map'))).toBe(false);
- expect(shipsToBrowser(true, DIST)(at('index.js.map'))).toBe(true);
- expect(shipsToBrowser(true, DIST)(at('index.wechat.js.map'))).toBe(false);
- });
+ it('refuses a dist with no manifest rather than falling back to shipping it all', () => {
+ const bare = mkdtempSync(path.join(tmpdir(), 'bare-'));
+ expect(() => shipsToBrowser(false, bare)).toThrow(/chunks\.json/);
+ rmSync(bare, { recursive: true, force: true });
+ });
});
diff --git a/pipeline/tests/target-support.test.ts b/pipeline/tests/target-support.test.ts
index 50455628c..df1fa9b4b 100644
--- a/pipeline/tests/target-support.test.ts
+++ b/pipeline/tests/target-support.test.ts
@@ -19,6 +19,7 @@ import {
collectSubsystems, subsystemGapWarnings, targetGaps, SUBSYSTEM_CMAKE_FLAG, type Subsystem,
} from '../src/project/targetSupport';
import { exportGame } from '../src/export/exportGame';
+import { writeFakeSdkDist } from './fixtures/fakeSdkDist';
const HERE = path.dirname(fileURLToPath(import.meta.url));
const REPO = path.resolve(HERE, '..', '..');
@@ -124,8 +125,7 @@ describe('exportGame warns about content the target cannot render', () => {
],
}));
writeFileSync(path.join(root, 'scenes', 'main.esscene.meta'), meta(SCN, 'scene'));
- mkdirSync(path.join(root, '_sdk'), { recursive: true });
- writeFileSync(path.join(root, '_sdk', 'index.js'), 'export const x = 1;');
+ writeFakeSdkDist(path.join(root, '_sdk'));
mkdirSync(path.join(root, '_wasm'), { recursive: true });
writeFileSync(path.join(root, '_wasm', 'esengine.js'), 'export default () => {};');
});