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(export): a mini-game package whose content uses no particles, post-processing or tilemaps ships a lite engine

yhh3162290d69fc
diff --git a/.github/actions/editor-host/action.yml b/.github/actions/editor-host/action.yml
index f97ec58ad..e629bbd5f 100644
--- a/.github/actions/editor-host/action.yml
+++ b/.github/actions/editor-host/action.yml
@@ -21,6 +21,12 @@ runs:
name: wasm-wechat
path: build/wasm/wechat/
+ - name: Download lite wechat wasm artifact
+ uses: actions/download-artifact@v8
+ with:
+ name: wasm-wechat-lite
+ path: build/wasm/wechat-lite/
+
- name: Download wechat GLX wasm artifact
uses: actions/download-artifact@v8
with:
@@ -34,10 +40,11 @@ runs:
- name: Stage wasm for the editor host
shell: bash
run: |
- mkdir -p desktop/public/wasm desktop/public/wasm-wechat desktop/public/wasm-wechat-glx
+ mkdir -p desktop/public/wasm desktop/public/wasm-wechat desktop/public/wasm-wechat-glx desktop/public/wasm-wechat-lite
cp build/wasm/web/* desktop/public/wasm/
cp build/wasm/wechat/* desktop/public/wasm-wechat/
cp build/wasm/wechat-glx/* desktop/public/wasm-wechat-glx/
+ cp build/wasm/wechat-lite/* desktop/public/wasm-wechat-lite/
- name: Build editor renderer bundle
shell: bash
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f8d22c1cf..85f417184 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -55,6 +55,11 @@ jobs:
with:
name: wasm-wechat
path: build/wasm/wechat/
+ - name: Download this commit's lite WeChat runtime
+ uses: actions/download-artifact@v8
+ with:
+ name: wasm-wechat-lite
+ path: build/wasm/wechat-lite/
- name: Download this commit's compatibility mini-game runtime
uses: actions/download-artifact@v8
with:
@@ -252,6 +257,15 @@ jobs:
path: build/wasm/wechat/
retention-days: 3
+ # The engine without particles, post-processing and tilemaps, which a package whose content uses none of them ships
+ # (pipeline/src/export/liteEngine.ts). Without it the size gate judges the full engine against the 4 MB limit.
+ - name: Upload lite wechat wasm artifact
+ uses: actions/upload-artifact@v7
+ with:
+ name: wasm-wechat-lite
+ path: build/wasm/wechat-lite/
+ retention-days: 3
+
- name: Upload compatibility mini-game wasm artifact
uses: actions/upload-artifact@v7
with:
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index fdafb9947..a84e104ba 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -85,6 +85,13 @@ jobs:
path: build/wasm/wechat/
retention-days: 3
+ - name: Upload lite wechat wasm artifact
+ uses: actions/upload-artifact@v7
+ with:
+ name: wasm-wechat-lite
+ path: build/wasm/wechat-lite/
+ retention-days: 3
+
- name: Upload wechat GLX wasm artifact
uses: actions/upload-artifact@v7
with:
diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml
index 7bcddacdc..689e268d6 100644
--- a/.github/workflows/release-desktop.yml
+++ b/.github/workflows/release-desktop.yml
@@ -126,6 +126,7 @@ jobs:
desktop/public/wasm
desktop/public/wasm-wechat
desktop/public/wasm-wechat-glx
+ desktop/public/wasm-wechat-lite
desktop/public/wasm-quickgame
retention-days: 3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 29956f757..6168cea75 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@ published separately; it ships inside the editor.
### Changed
+- **A lite engine for mini-games.** A WeChat or Douyin package whose scenes and scripts use no particle emitter, post-process volume or tilemap now ships a lite engine, the same engine without those three subsystems and about 200 KB smaller, so a UI-only game has room under the 4 MB main-package limit. It is chosen from the same evidence as the lean SDK entry plus a scan of the project's scripts; any mention of one of the three carries the full engine. Build it with `node build-tools/cli.js build -t wechat-lite` (`-t all` includes it).
- **Post-process effects are optional groups.** The post-process effects' shaders are now three optional groups, esengine/fx-basic, esengine/fx-atmosphere and esengine/fx-lighting: a package carries a group when a PostProcessVolume names one of its effects (or a Weather or TimeOfDay component is in the content), and a game with no volumes ships none of them (about 180 KB less in a UI-only mini-game). An effect a script adds by code needs its group imported (`esengine/fx-basic` and the others) or the module set to Include; the editor and a non-lean entry carry all three.
- **Timelines are an optional module.** Timelines are now an optional module, esengine/timeline: a package carries the timeline runtime and its loader when a scene has a TimelinePlayer, the content has an .estimeline, or a script imports the subpath, and a game with none of them ships neither. The API is unchanged and still reachable from `esengine`.
- **Terrain and Foliage are optional modules.** Terrain and Foliage are now optional modules, esengine/terrain and esengine/foliage: a package carries them when a scene has a Terrain or Foliage component or a script imports the subpath, and a game with neither ships none of them (about 33 KB less in a UI-only mini-game). The API is unchanged and still reachable from `esengine`; the export installs the module for a scene that uses either component.
diff --git a/build-tools/build.config.js b/build-tools/build.config.js
index 2a4d1003e..3428ed203 100644
--- a/build-tools/build.config.js
+++ b/build-tools/build.config.js
@@ -18,6 +18,7 @@ export default {
web: { cmakeOpt: '-O2', wasmOpt: '-O2' },
wechat: { cmakeOpt: '-O2', wasmOpt: '-O2' },
'wechat-glx': { cmakeOpt: '-O2', wasmOpt: '-O2' },
+ 'wechat-lite': { cmakeOpt: '-O2', wasmOpt: '-O2' },
quickgame: { cmakeOpt: '-O2', wasmOpt: '-O2' },
},
@@ -43,6 +44,19 @@ export default {
'sdk/esengine.wxgame.wasm': 'wasm/wechat/esengine.wxgame.wasm',
},
},
+ // The WeChat engine without the particle, post-process and tilemap subsystems, for a package whose content uses none
+ // of them: the same binary otherwise, ~200 KB smaller against a 4 MB main package. The export picks it from the same
+ // evidence it picks the engine's lean entry by (pipeline/src/export/liteEngine.ts).
+ 'wechat-lite': {
+ buildDir: 'build/cmake/wxgame-lite',
+ cmakeFlags: ['-DES_BUILD_WXGAME=ON', '-DES_BUILD_TESTS=OFF', '-DES_ENABLE_PARTICLES=OFF',
+ '-DES_ENABLE_POSTPROCESS=OFF', '-DES_ENABLE_TILEMAP=OFF'],
+ targets: ['esengine_wxgame'],
+ outputs: {
+ 'sdk/esengine.wxgame.js': 'wasm/wechat-lite/esengine.wxgame.js',
+ 'sdk/esengine.wxgame.wasm': 'wasm/wechat-lite/esengine.wxgame.wasm',
+ },
+ },
// The WeChat engine with EmscriptenGLX linked in, for a project that turns it
// on: WeChat publishes the library for emsdk 4.0.10, so this one target
// builds with that emsdk (build-tools/toolchain/glx.js).
@@ -262,6 +276,7 @@ export default {
// would otherwise overwrite the web modules in desktop/public/wasm.
'build/wasm/wechat': 'desktop/public/wasm-wechat',
'build/wasm/wechat-glx': 'desktop/public/wasm-wechat-glx',
+ 'build/wasm/wechat-lite': 'desktop/public/wasm-wechat-lite',
'build/wasm/quickgame': 'desktop/public/wasm-quickgame',
},
sdk: {
diff --git a/build-tools/cli.js b/build-tools/cli.js
index 9368a91a3..63cf37dc7 100644
--- a/build-tools/cli.js
+++ b/build-tools/cli.js
@@ -28,7 +28,7 @@ program
program
.command('build')
.description('Build ESEngine')
- .option('-t, --target <target>', 'Build target (web, wechat, spine, spine21, spine38, spine41, spine43, dragonbones, physics, physics-wechat, spine-wechat, dragonbones-wechat, basis, basis-wechat, sdk, all)', 'web')
+ .option('-t, --target <target>', 'Build target (web, wechat, wechat-lite, spine, spine21, spine38, spine41, spine43, dragonbones, physics, physics-wechat, spine-wechat, dragonbones-wechat, basis, basis-wechat, sdk, all)', 'web')
.option('-d, --debug', 'Debug build', false)
.option('-r, --release', 'Release build (default)', true)
.option('-c, --clean', 'Clean before build', false)
diff --git a/desktop b/desktop
index 9ee7501ff..23489b7e2 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit 9ee7501ff9c5a503c86d0b9b313b951a59f3f781
+Subproject commit 23489b7e26313f147c71dca6947e7465b273d6b5
diff --git a/docs/astro/src/content/docs/publishing/overview.mdx b/docs/astro/src/content/docs/publishing/overview.mdx
index 4a8c877f7..8faf00350 100644
--- a/docs/astro/src/content/docs/publishing/overview.mdx
+++ b/docs/astro/src/content/docs/publishing/overview.mdx
@@ -411,6 +411,11 @@ import { Tilemap } from 'esengine/tilemap';
One subsystem has no subpath yet: a project using **Video** takes the whole engine, with
every optional subsystem in it. Nothing else changes — the API is identical either way.
+The same goes for the engine binary on WeChat and Douyin. When no scene or prefab has a particle emitter, a post-process volume or a
+tilemap, and no script mentions them, the package carries the **lite engine**: the same engine without those three subsystems, about
+200 KB smaller against the 4 MB main package. A single mention in a script (`ParticleEmitter`, `PostProcess…`, `Tilemap…`) is enough to carry
+the full one, as is naming `esengine/tilemap` as **Include** in Project Settings; a doubt always ships everything.
+
### Limits
Where a platform publishes a limit, the build is judged against it and the meter says
diff --git a/docs/astro/src/content/docs/zh-cn/publishing/overview.mdx b/docs/astro/src/content/docs/zh-cn/publishing/overview.mdx
index eaa37127f..73c699ea2 100644
--- a/docs/astro/src/content/docs/zh-cn/publishing/overview.mdx
+++ b/docs/astro/src/content/docs/zh-cn/publishing/overview.mdx
@@ -329,6 +329,10 @@ import { Tilemap } from 'esengine/tilemap';
只有一个子系统暂时没有子路径:用到 **Video** 的项目会拿整份引擎,包含全部可选子系统。其他
什么都不变——两种情况下 API 完全一样。
+微信和抖音上的引擎二进制也是同样的道理。当没有任何场景或预制体里有粒子发射器、后处理体积或瓦片地图,脚本里也没有提到它们时,包里带的是
+**精简引擎**:同一个引擎去掉这三个子系统,在 4 MB 主包限制下小约 200 KB。脚本里只要出现一次(`ParticleEmitter`、`PostProcess…`、`Tilemap…`)就会带完整版,
+在项目设置里把 `esengine/tilemap` 设为**包含**也一样;拿不准时总是全带。
+
### 上限
凡是平台公布了上限的目标,构建都会被对照判定,并且会说明是哪一条、数字从哪来——原文引用,好让你去核对该平台当前的文档,而不是相信我们:
diff --git a/pipeline/src/export/exportMiniGame.ts b/pipeline/src/export/exportMiniGame.ts
index 50e742ea6..b8fc5ff76 100644
--- a/pipeline/src/export/exportMiniGame.ts
+++ b/pipeline/src/export/exportMiniGame.ts
@@ -31,6 +31,7 @@ import type { DebugChannelConfig } from 'esengine';
import { packagedDebugChannel } from './debugChannel';
import { packagedHotUpdate } from './hotUpdateConfig';
import { loadEsbuild } from '../bundle/esbuildRuntime';
+import { liteEngineAnswer, scriptsMentionOmitted } from './liteEngine';
import type { ProjectFeatures, ProjectPackaging } from '../project/format';
import {
DEFAULT_RUNTIME_CONFIG, packagedRuntimeFields, withAudioLoadTypes, type RuntimeProjectConfig,
@@ -328,10 +329,16 @@ export async function exportMiniGame(profile: MiniGameExportProfile, opts: {
+ 'build it with `node build-tools/cli.js build -t wechat-glx`, or turn EmscriptenGLX off in Project Settings → WeChat');
return { ok: false, platform: profile.id, outDir: absOut, included: 0, warnings, errors };
}
- /** The engine's own files come from the GLX runtime when the project asked for it. */
+ // The engine without particles, post-processing and tilemaps, beside the full one: used when the content says it needs none
+ // (decided once the content has been read, below, and before any engine file is staged).
+ const liteDir = `${opts.wasmDir.replace(/[\/]+$/, '')}-lite`;
+ let lite = false;
+ /** The engine's own files come from the GLX runtime when the project asked for it, or the lite one when it can. */
const runtimeFile = (name: string): string => {
const fromGlx = path.join(glxDir, name);
- return glx && existsSync(fromGlx) ? fromGlx : path.join(opts.wasmDir, name);
+ if (glx && existsSync(fromGlx)) return fromGlx;
+ const fromLite = path.join(liteDir, name);
+ return lite && existsSync(fromLite) ? fromLite : path.join(opts.wasmDir, name);
};
const engineGlueFile = profile.engineGlueCandidates
.find((f) => existsSync(runtimeFile(f)));
@@ -533,6 +540,13 @@ export async function exportMiniGame(profile: MiniGameExportProfile, opts: {
choices: moduleChoices(opts.features, opts.modulesByPlatform?.[profile.id]),
debugChannel: !!debugChannel,
});
+ // The lite engine, when this vendor has one and nothing in the content or the scripts reaches what it leaves out.
+ lite = !glx && liteEngineAnswer({
+ subsystems: usedSubsystems.keys(),
+ scriptsMention: await scriptsMentionOmitted(opts.root, opts.scriptsEntry),
+ choices: moduleChoices(opts.features, opts.modulesByPlatform?.[profile.id]),
+ }) && profile.engineGlueCandidates.some((f) => existsSync(path.join(liteDir, f)));
+ if (lite) progress({ phase: 'Choosing engine', detail: 'lite (no particles, post-processing or tilemaps in the content)' });
// A package missing half a scene, with nothing saying which half, is worse than
// one that refuses to be made.
for (const r of plan.refused) {
diff --git a/pipeline/src/export/liteEngine.ts b/pipeline/src/export/liteEngine.ts
new file mode 100644
index 000000000..b51e80419
--- /dev/null
+++ b/pipeline/src/export/liteEngine.ts
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file liteEngine.ts — whether a mini-game package can carry the engine without the subsystems it never uses.
+ *
+ * The engine core compiles particles, post-processing and tilemaps in or out (`ES_ENABLE_*`), and a package whose content
+ * uses none of them does not need the ~200 KB they cost against a 4 MB main package. The evidence is the one the lean SDK
+ * entry is chosen by — the components its scenes and prefabs carry — plus the project's own scripts, because a script can
+ * add an emitter or a volume to a world no scene mentioned. A guess that said "unused" would be a particle effect that
+ * silently never draws, so every doubt answers "carry them".
+ */
+import { readdir, readFile } from 'node:fs/promises';
+import path from 'node:path';
+import type { Subsystem } from '../project/targetSupport';
+import type { ModuleChoice } from '../project/format';
+
+/** The subsystems the lite engine is built without. */
+export const LITE_OMITS: readonly Subsystem[] = ['particles', 'postprocess', 'tilemap'];
+
+/** What a script says when it uses one of them. Broad on purpose: a comment that names one only costs the saving. */
+const SCRIPT_MENTIONS = /\b(ParticleEmitter|ParticleForceField|Particle|ParticlePlugin|PostProcess\w*|Tilemap\w*|TilemapLayer|Tilemaps)\b|esengine\/tilemap/;
+
+const SCRIPT_EXT = /\.(?:[cm]?[jt]sx?)$/;
+const SKIP_DIRS = new Set(['node_modules', '.git', '.esengine', 'dist', 'build', 'out']);
+const MAX_FILES = 4000;
+
+/** Whether any of the project's script sources mentions a subsystem the lite engine leaves out. */
+export async function scriptsMentionOmitted(root: string, scriptsEntry?: string): Promise<boolean> {
+ let seen = 0;
+ const walk = async (dir: string): Promise<boolean> => {
+ let entries;
+ try { entries = await readdir(dir, { withFileTypes: true }); } catch { return false; }
+ for (const e of entries) {
+ if (e.isDirectory()) {
+ if (SKIP_DIRS.has(e.name)) continue;
+ if (await walk(path.join(dir, e.name))) return true;
+ } else if (SCRIPT_EXT.test(e.name) && !e.name.endsWith('.d.ts')) {
+ if (++seen > MAX_FILES) return true; // too many to say: carry everything
+ try {
+ if (SCRIPT_MENTIONS.test(await readFile(path.join(dir, e.name), 'utf8'))) return true;
+ } catch { return true; }
+ }
+ }
+ return false;
+ };
+ if (await walk(path.join(root, 'src'))) return true;
+ if (scriptsEntry) {
+ const entryDir = path.dirname(path.join(root, scriptsEntry));
+ if (path.resolve(entryDir) !== path.resolve(root, 'src') && await walk(entryDir)) return true;
+ }
+ return false;
+}
+
+/**
+ * Whether this package takes the lite engine. Carries everything when any scene or prefab uses an omitted subsystem, when a
+ * script mentions one, or when the project asked for tilemaps by name.
+ */
+export function liteEngineAnswer(evidence: {
+ subsystems: Iterable<Subsystem>;
+ scriptsMention: boolean;
+ choices?: Readonly<Record<string, ModuleChoice>>;
+}): boolean {
+ if (evidence.scriptsMention) return false;
+ if (evidence.choices?.['esengine/tilemap'] === 'include') return false;
+ const used = new Set(evidence.subsystems);
+ return !LITE_OMITS.some((s) => used.has(s));
+}
diff --git a/pipeline/tests/export-wechat.test.ts b/pipeline/tests/export-wechat.test.ts
index 79a192b80..107f28902 100644
--- a/pipeline/tests/export-wechat.test.ts
+++ b/pipeline/tests/export-wechat.test.ts
@@ -734,6 +734,49 @@ describe('exportGame (wechat)', () => {
expect(missing.errors.join('\n')).toContain('build -t wechat-glx');
}, 60_000);
+ // The lite engine is the plain one without particles, post-processing and tilemaps, and it is only right for content
+ // that reaches none of them — by a component in a scene or by a word in a script.
+ it('ships the lite engine only when nothing in the content or the scripts reaches what it leaves out', async () => {
+ const base = path.join(root, '_wxwasm-l');
+ for (const [dir, bytes] of [[base, 'plainbytes'], [`${base}-lite`, 'litebytes']] as const) {
+ mkdirSync(dir, { recursive: true });
+ writeFileSync(path.join(dir, 'esengine.js'), 'module.exports = () => Promise.resolve({});');
+ writeFileSync(path.join(dir, 'esengine.wasm'), bytes);
+ }
+ const scene = path.join(root, 'scenes', 'main.esscene');
+ const script = path.join(root, 'src', 'main.ts');
+ const sceneText = readFileSync(scene, 'utf8');
+ const scriptText = readFileSync(script, 'utf8');
+ const shipped = async (name: string): Promise<string> => {
+ const o = path.join(root, name);
+ const res = await exportGame({
+ root, entryScene: 'scenes/main.esscene', hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,
+ scriptsEntry: 'src/main.ts', sdkDistDir: path.join(root, '_sdk'), wasmDir: base, outDir: o,
+ platform: 'wechat', miniGameAppid: 'wxTEST0123456789',
+ runtime: runtimeConfigOf({ designResolution: { width: 1280, height: 720 } }),
+ });
+ expect(res.ok).toBe(true);
+ return readFileSync(path.join(o, 'wasm', 'esengine.wasm'), 'utf8');
+ };
+ try {
+ expect(await shipped('dist-wx-lite-a')).toBe('litebytes');
+
+ const withEmitter = JSON.parse(sceneText);
+ withEmitter.entities.push({ id: 1, components: [{ type: 'ParticleEmitter', data: {} }] });
+ writeFileSync(scene, JSON.stringify(withEmitter));
+ expect(await shipped('dist-wx-lite-b')).toBe('plainbytes');
+
+ writeFileSync(scene, sceneText);
+ writeFileSync(script, `${scriptText}
+// builds a PostProcessVolume at run time
+`);
+ expect(await shipped('dist-wx-lite-c')).toBe('plainbytes');
+ } finally {
+ writeFileSync(scene, sceneText);
+ writeFileSync(script, scriptText);
+ }
+ }, 120_000);
+
// Moving the binary out of the 4MB main package means four things must agree:
// where it lands, what the loader is told, what game.json declares, and that
// the entry asks the host for the 分包 before the engine is instantiated.
diff --git a/pipeline/tests/lite-engine.test.ts b/pipeline/tests/lite-engine.test.ts
new file mode 100644
index 000000000..913bf0f1b
--- /dev/null
+++ b/pipeline/tests/lite-engine.test.ts
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file When a package may take the engine without particles, post-processing and tilemaps.
+ *
+ * The failure this guards is a silent one: a particle effect that never draws because the engine that shipped has no
+ * particles. So the answer is "lite" only when nothing reaches them, and every doubt carries everything.
+ */
+import { describe, it, expect } from 'vitest';
+import { mkdtemp, mkdir, writeFile } from 'node:fs/promises';
+import { tmpdir } from 'node:os';
+import path from 'node:path';
+import { liteEngineAnswer, scriptsMentionOmitted } from '../src/export/liteEngine';
+
+describe('the lite engine', () => {
+ it('is for content that uses none of what it leaves out', () => {
+ expect(liteEngineAnswer({ subsystems: ['text', 'physics'], scriptsMention: false })).toBe(true);
+ for (const s of ['particles', 'postprocess', 'tilemap'] as const) {
+ expect(liteEngineAnswer({ subsystems: [s], scriptsMention: false })).toBe(false);
+ }
+ });
+
+ it('is not for a script that mentions one, or a project that asked for tilemaps', () => {
+ expect(liteEngineAnswer({ subsystems: [], scriptsMention: true })).toBe(false);
+ expect(liteEngineAnswer({ subsystems: [], scriptsMention: false, choices: { 'esengine/tilemap': 'include' } })).toBe(false);
+ expect(liteEngineAnswer({ subsystems: [], scriptsMention: false, choices: { 'esengine/tilemap': 'exclude' } })).toBe(true);
+ });
+
+ it('reads the scripts for the names of what it leaves out', async () => {
+ const root = await mkdtemp(path.join(tmpdir(), 'estella-lite-'));
+ await mkdir(path.join(root, 'src', 'game'), { recursive: true });
+ await writeFile(path.join(root, 'src', 'main.ts'), "import { Sprite } from 'esengine';\n");
+ expect(await scriptsMentionOmitted(root)).toBe(false);
+ await writeFile(path.join(root, 'src', 'game', 'fx.ts'), 'world.insert(e, ParticleEmitter, {});\n');
+ expect(await scriptsMentionOmitted(root)).toBe(true);
+ });
+});
diff --git a/sdk/src/postprocess/PostProcessAPI.ts b/sdk/src/postprocess/PostProcessAPI.ts
index 5edcce6e7..ac7eb2041 100644
--- a/sdk/src/postprocess/PostProcessAPI.ts
+++ b/sdk/src/postprocess/PostProcessAPI.ts
@@ -73,12 +73,17 @@ export function initPostProcessAPI(engine: NonNullable<EngineApi>): void {
if (!hdrPtr && typeof heap._malloc === 'function') hdrPtr = heap._malloc(4 * 4);
}
+/** A core built without ES_ENABLE_POSTPROCESS (the lite mini-game engine) has none of these entry points: no chain, nothing to ask. */
+function hasPostProcessCore(core: PostProcessCore): boolean {
+ return typeof core.postprocess_isInitialized === 'function';
+}
+
/** @internal Wired by the engine plugins — not part of the public API. */
export function shutdownPostProcessAPI(): void {
// Per-App state dies with its App; here we only tear down the shared module.
if (module) {
try {
- if (module.postprocess_isInitialized()) module.postprocess_shutdown();
+ if (hasPostProcessCore(module) && module.postprocess_isInitialized()) module.postprocess_shutdown();
} catch (e) {
handleWasmError(e, 'PostProcess.shutdown');
}
@@ -292,7 +297,7 @@ export class PostProcessAPI {
}
isInitialized(): boolean {
- if (!module) return false;
+ if (!module || !hasPostProcessCore(module)) return false;
try {
return module.postprocess_isInitialized();
} catch (e) {
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index b8ba39248..acf5a1628 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -2533,6 +2533,8 @@ export const NOTED = {
{"note":"Timelines are now an optional module, esengine/timeline: a package carries the timeline runtime and its loader when a scene has a TimelinePlayer, the content has an .estimeline, or a script imports the subpath, and a game with none of them ships neither."},
"feat(sdk): post-process effect shaders come in three optional groups, so a package carries only the effects its content uses":
{"note":"The post-process effects' shaders are now three optional groups, esengine/fx-basic, esengine/fx-atmosphere and esengine/fx-lighting: a package carries a group when a PostProcessVolume names one of its effects (or a Weather or TimeOfDay component is in the content), and a game with no volumes ships none of them (about 180 KB less in a UI-only mini-game)."},
+ "feat(export): a mini-game package whose content uses no particles, post-processing or tilemaps ships a lite engine":
+ {"note":"A WeChat or Douyin package whose scenes and scripts use no particle emitter, post-process volume or tilemap now ships a lite engine, the same engine without those three subsystems and about 200 KB smaller, so a UI-only game has room under the 4 MB main-package limit."},
"chore(tools): the gates run in parallel with --jobs, and the reds a full run gathered are cleared":
{"internal":"tooling for the static gates, and fixes to checks that had drifted from the code they guard"},
"fix(render): a wire narrower than a pixel is no longer painted over by the sky in dashes":
diff --git a/tools/verify-golden.mjs b/tools/verify-golden.mjs
index 4dce00e63..91dd93acf 100644
--- a/tools/verify-golden.mjs
+++ b/tools/verify-golden.mjs
@@ -363,6 +363,10 @@ function readSizeVerdicts(reportPath) {
for (const key of new Set(pairs.map((p) => JSON.stringify(ENGINE_OF(p.target))))) {
const { dir, variant } = JSON.parse(key);
requireCurrentEngine(ROOT, dir, process.argv, variant);
+ // A package picks the lite engine from the directory beside the WeChat one when its content allows, so that binary is
+ // judged too — a stale one boots, fails its ABI handshake and reads as the game being broken.
+ const lite = `${dir}-lite`;
+ if (variant === 'wechat' && existsSync(lite)) requireCurrentEngine(ROOT, lite, process.argv, 'wechat-lite');
}
const results = [];