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 headless package is the package the dialog makes

esengine4bb8c401a756
diff --git a/desktop/electron/cookAssets.ts b/desktop/electron/cookAssets.ts
index 0c401888a..5bcfdbf89 100644
--- a/desktop/electron/cookAssets.ts
+++ b/desktop/electron/cookAssets.ts
@@ -245,6 +245,13 @@ export interface CookResult {
/** uuids present in the project but unreachable — culled from the build. */
unused: string[];
warnings: string[];
+ /**
+ * Assets the game REACHES that could not be produced, as `<path>: <why>`. Each
+ * one is a hole in the package: the scene still references it and the runtime
+ * fetches a path nothing staged. Kept apart from `warnings` because it is the
+ * one cook outcome a caller must not ship.
+ */
+ failed: string[];
}
/**
@@ -270,6 +277,7 @@ export async function cookAssets(
const platform = opts.platform;
const { index } = await scanAssetDatabase(root, { write: false, adopt: false });
const warnings: string[] = [];
+ const failed: string[] = [];
// Second gate: nothing reaches it while the scanner drops these upstream, but
// this is where bytes become an artifact someone else runs. Warns rather than
// dropping silently — an asset missing from a build has to say why.
@@ -624,7 +632,9 @@ export async function cookAssets(
});
}
} catch (err) {
- warnings.push(`copy failed ${entry.path}: ${err instanceof Error ? err.message : String(err)}`);
+ const why = err instanceof Error ? err.message : String(err);
+ warnings.push(`copy failed ${entry.path}: ${why}`);
+ failed.push(`${entry.path}: ${why}`);
}
}
manifestEntries.sort((a, b) => a.path.localeCompare(b.path));
@@ -637,5 +647,8 @@ export async function cookAssets(
const unused = index.entries.filter((e) => !reachable.has(e.uuid)).map((e) => e.uuid);
const includedPaths = [...reachable].map((uuid) => byUuid.get(uuid)?.path).filter((p): p is string => p !== undefined);
- return { ok: true, outDir: absOut, manifestPath, included: [...reachable], includedPaths, unused, warnings };
+ return {
+ ok: failed.length === 0,
+ outDir: absOut, manifestPath, included: [...reachable], includedPaths, unused, warnings, failed,
+ };
}
diff --git a/desktop/electron/exportGame.ts b/desktop/electron/exportGame.ts
index 34452b275..da1cb8eb4 100644
--- a/desktop/electron/exportGame.ts
+++ b/desktop/electron/exportGame.ts
@@ -593,6 +593,9 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>
const projectModules = await loadProjectModules(opts.root, platform);
const cook = await cookAssets(opts.root, { entryScenes: scenes.map((s) => s.path), outDir: payloadDir, contentAddressed: opts.contentAddressed ?? true, compressTextures: opts.compressTextures, compressAudio: opts.compressAudio, atlasTextures: opts.atlasTextures, transcodeVideo, platform });
warnings.push(...cook.warnings);
+ // An asset the game reaches and the cook could not produce is a hole, not a
+ // note: the scene still references it and the runtime 404s at boot.
+ for (const f of cook.failed) errors.push(`asset not packaged — ${f}`);
warnings.push(...await unsupportedContentWarnings(opts.root, cook.includedPaths, platform));
progress({ phase: 'Cooking assets', detail: `${cook.included.length} reachable` });
diff --git a/desktop/scripts/export-project.mjs b/desktop/scripts/export-project.mjs
index 62b334f08..d3da177a3 100644
--- a/desktop/scripts/export-project.mjs
+++ b/desktop/scripts/export-project.mjs
@@ -88,7 +88,11 @@ async function loadExportGame() {
await esbuild.build({
entryPoints: [path.join(DESKTOP, 'electron', 'exportGame.ts')],
outfile, bundle: true, format: 'esm', platform: 'node', target: 'node20',
- external: ['esbuild', 'electron', 'sharp'], logLevel: 'error',
+ // The Basis encoder finds its own .cjs/.wasm through `import.meta.url`,
+ // so inlining it makes it look beside the BUNDLE. External keeps the
+ // specifier, and the temp dir is as deep under desktop/ as electron/ is.
+ external: ['esbuild', 'electron', 'sharp', '../../build-tools/basis/encoder.mjs'],
+ logLevel: 'error',
banner: {
js: "import { createRequire as __esCreateRequire } from 'node:module';\n"
+ `const require = __esCreateRequire('${fileUrl(path.join(DESKTOP, 'package.json'))}');\n`,
@@ -198,7 +202,7 @@ const wasmDir = platform === 'wechat'
]) ?? path.join(DESKTOP, 'public', 'wasm')
: path.join(DESKTOP, 'public', 'wasm');
-const { resolveOrientation, parseManifest, runtimeConfigOf } = await loadProjectFormat();
+const { resolveOrientation, parseManifest, runtimeConfigOf, cookOptionsOf } = await loadProjectFormat();
// PARSED, not read by hand: the parser normalizes legacy platform ids and drops
// values that could not be judged against, and a budget read straight off the JSON
// here would be the orientation bug again with a different field.
@@ -222,6 +226,9 @@ try {
// it a headless package ships every setting at its default while claiming
// to be the package the dialog makes.
runtime: runtimeConfigOf(manifest),
+ // Same bargain, one field over: the cook flags are ALSO the project's
+ // own, and passing none of them shipped every automated package raw.
+ ...cookOptionsOf(manifest),
androidTemplate: platform === 'android' ? templateDir : null,
desktopTemplates,
desktopChannel: opts['steam-appid'] ? 'steam' : undefined,
diff --git a/desktop/src/components/BuildDialog.tsx b/desktop/src/components/BuildDialog.tsx
index 16ddff97c..e397a0df0 100644
--- a/desktop/src/components/BuildDialog.tsx
+++ b/desktop/src/components/BuildDialog.tsx
@@ -47,6 +47,7 @@ import { Group as SettingsGroup, groupByGroup } from '@/components/SettingsRow';
import { settingsRegistry } from '@/settings/registry';
import { useSettings } from '@/store/settingsStore';
import { ProjectStore } from '@/project/ProjectStore';
+import { cookOptionsOf } from '@/project/runtimeConfig';
import { AssetRegistry } from '@/project/AssetRegistry';
import { useEditorStore } from '@/store/editorStore';
import { t } from '@/i18n';
@@ -531,9 +532,9 @@ export function BuildDialog() {
// Awaited, not fired-and-forgotten: the export resolves the network from the
// manifest, so a race here would package for the previous one.
if (platform === 'playable') await ProjectStore.setPlatformPackaging('playable', { network: adNetwork });
- // 'auto' → honor each asset's Import Settings (the cook then reads per-asset
- // texture/audio compression + Max Size); 'skip' → ship everything raw.
- const compress = assetCompression === 'auto';
+ // What 'auto' / 'skip' MEANS is one function, shared with the headless
+ // export: deriving it here on its own is how the two came to disagree.
+ const cook = cookOptionsOf({ packaging: { assetCompression } });
// Live build log (UE-style): each export phase streams over IPC.
const unsub = window.estella.project?.onExportProgress?.((p) =>
setLog((l) => [...l, p.detail ? `${p.phase} — ${p.detail}` : p.phase]),
@@ -544,9 +545,7 @@ export function BuildDialog() {
outDir,
minify: config === 'shipping',
sourcemap: def.sourceMaps && sourceMaps,
- compressTextures: compress,
- atlasTextures: compress,
- compressAudio: compress,
+ ...cook,
})) as Result | null;
if (!res) {
setResult({ ok: false, outDir, included: 0, warnings: [], errors: [t('build.noProjectOpen')] });
diff --git a/desktop/src/project/runtimeConfig.ts b/desktop/src/project/runtimeConfig.ts
index 5d7327bc8..3f5eef0f6 100644
--- a/desktop/src/project/runtimeConfig.ts
+++ b/desktop/src/project/runtimeConfig.ts
@@ -187,6 +187,24 @@ function isDefaultPhysics(config: PhysicsPluginConfig): boolean {
return JSON.stringify(config) === JSON.stringify(DEFAULT_PHYSICS_CONFIG);
}
+/** What the cook does to a project's assets, as three flags it takes. */
+export interface CookOptions {
+ compressTextures: boolean;
+ compressAudio: boolean;
+ atlasTextures: boolean;
+}
+
+/**
+ * The cook flags a project's `assetCompression` means. One derivation for the
+ * same reason {@link runtimeConfigOf} is one: the Build dialog derived these
+ * itself and the headless export passed none of them, so every automated
+ * package shipped raw — verifying a build configuration no user ships.
+ */
+export function cookOptionsOf(manifest: Pick<ProjectManifest, 'packaging'>): CookOptions {
+ const on = (manifest.packaging?.assetCompression ?? 'auto') === 'auto';
+ return { compressTextures: on, compressAudio: on, atlasTextures: on };
+}
+
/** The effective settings of a project with nothing declared — every default. */
export const DEFAULT_RUNTIME_CONFIG: RuntimeProjectConfig = runtimeConfigOf({});