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.

chore: enable bulk-memory and nontrapping-float-to-int in wasm-opt

esengine2a3c22899c79
diff --git a/build-tools/tasks/wasm.js b/build-tools/tasks/wasm.js
index 6ce115e0c..58a17c96f 100644
--- a/build-tools/tasks/wasm.js
+++ b/build-tools/tasks/wasm.js
@@ -154,7 +154,7 @@ async function optimizeWasmFiles(buildDir, outputs, optLevel = '-O2') {
try {
const before = (await stat(wasmPath)).size;
- await runCommand('wasm-opt', [optLevel, '-o', wasmPath, wasmPath], { silent: true });
+ await runCommand('wasm-opt', [optLevel, '--enable-bulk-memory', '--enable-nontrapping-float-to-int', '-o', wasmPath, wasmPath], { silent: true });
const after = (await stat(wasmPath)).size;
const reduction = ((1 - after / before) * 100).toFixed(1);
logger.debug(`wasm-opt ${optLevel}: ${src} ${(before / 1024).toFixed(0)}KB → ${(after / 1024).toFixed(0)}KB (-${reduction}%)`);