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.

build(sdk): a clean SDK build is three seconds, not eighteen

esengine014fed613b8d
diff --git a/build-tools/tasks/sdk.js b/build-tools/tasks/sdk.js
index ecaeab7ca..baf84e3af 100644
--- a/build-tools/tasks/sdk.js
+++ b/build-tools/tasks/sdk.js
@@ -44,8 +44,8 @@ export async function buildSdk(options = {}) {
const sdkSrcDir = path.join(sdkDir, 'src');
// The bundle is a function of the sources AND the build configuration,
- // so rollup/tsconfig/package edits must bust the cache too.
- const configFiles = ['rollup.config.js', 'tsconfig.json', 'package.json']
+ // so bundler/tsconfig/package edits must bust the cache too.
+ const configFiles = ['rolldown.config.js', 'rollup.config.js', 'tsconfig.json', 'package.json']
.map((f) => path.join(sdkDir, f));
currentHash = `${await hashDirectory(sdkSrcDir, /\.ts$/)}:${await hashFiles(configFiles)}`;
@@ -150,26 +150,6 @@ async function copyDistOutputs(sdkDir, outputDir) {
}
}
-export async function buildSdkDirect(format = 'all') {
- logger.step(`Building SDK (${format})...`);
-
- const sdkDir = config.paths.sdk;
- const outputDir = path.join(config.paths.output, 'sdk');
-
- await mkdir(outputDir, { recursive: true });
-
- const args = ['rollup', '-c'];
- if (format !== 'all') {
- args.push('--environment', `FORMAT:${format}`);
- }
-
- await runCommand('npx', args, { cwd: sdkDir });
-
- await copyDistOutputs(sdkDir, outputDir);
-
- logger.success(`SDK (${format}): Build complete`);
-}
-
export async function cleanSdk() {
const sdkDistDir = path.join(config.paths.sdk, 'dist');
const outputSdkDir = path.join(config.paths.output, 'sdk');
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 984133377..1c4bb67f6 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -139,6 +139,9 @@ importers:
rimraf:
specifier: ^5.0.5
version: 5.0.10
+ rolldown:
+ specifier: 1.2.1
+ version: 1.2.1
rollup:
specifier: ^4.9.0
version: 4.57.1
@@ -308,12 +311,21 @@ packages:
'@emnapi/[email protected]':
resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==}
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-AZypUeJ/yByuxyS7BlSNRDOMLMlROYtjYdIAuBmJssVz1UJDSeYxLrdizhXCFYhedC5bqd/ASy8EuNXbVVXp9g==}
+
'@emnapi/[email protected]':
resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==}
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-hFPAhMUjJD9BSyCANEISPOogeXC9Zo9ZQl7L6vKnaVsMkCtzznaW/naYypeyl0Gv5rYfWYsZbpixTMpjDJzQeA==}
+
'@emnapi/[email protected]':
resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==}
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-9DsSk+o5NBX0CCJT8s0EROGSGxjR/tKu6aBTaVyq+SjAEQH4XcdcRxPBRzsBLizTTJ49MJjF+jgu3qnO9GLQcQ==}
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==}
engines: {node: '>=12'}
@@ -672,6 +684,13 @@ packages:
'@emnapi/core': ^1.7.1
'@emnapi/runtime': ^1.7.1
+ '@napi-rs/[email protected]':
+ resolution: {integrity: sha512-JfB4kuJQjaoHuCTseIINHtHWeJnvgEcxjwA5t/Y00ZgaOO1Crz3fjT/p8kT28zA/Caz7oiUMn3d6H2yOVCVwuw==}
+ engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0}
+ peerDependencies:
+ '@emnapi/core': ^1.7.1 || ^2.0.0-alpha.3
+ '@emnapi/runtime': ^1.7.1 || ^2.0.0-alpha.3
+
resolution: {integrity: sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==}
engines: {node: '>= 16'}
@@ -683,6 +702,9 @@ packages:
'@oxc-project/[email protected]':
resolution: {integrity: sha512-KzkdCd6Uxqnf6l3HOw1xfatAlUURA0g14cvBYFyJ5SaNOQbOUvBr9PKArcPcrNIeRsBdgcUzOGrhKveVpvOIGA==}
+ '@oxc-project/[email protected]':
+ resolution: {integrity: sha512-7W+2q5AKQVU36fkaryontrHn3YDt1RyUYXatw9i5H8ocYe2sPKSFB6eS8WNPeRKiN1qAWWZUPm7gwFzJGrccqQ==}
+
'@peculiar/[email protected]':
resolution: {integrity: sha512-7YT0U/ze0tF2QOBbE15gKZwy5tvgGyLRiRHLzhlbOpf7BT032oBSd0haZqXn5W6l26WLlu3dyxzjM+2638/z2Q==}
@@ -710,30 +732,60 @@ packages:
cpu: [arm64]
os: [android]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-02hOeOSryYxVrOIphmLAsqnCJWxwlzFk+pEt/N/i6OgT3lShHO7xGCU5cpgchRDHboAEbSjzgGh+O/u1GswQmA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [android]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-PcAhP+ynjURNyy8SKGl5DQP94aGuB/7JrXJb/t7P+hanXvQVMWzUvRRhBAcg/lNRadBhoUPqSoP4xw5tR/KBEA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [darwin]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-fMsTOnN0OjFm3CyppWPitKnc8UlliVARUULW6cfU6AIqjdtgmSFWSk9vecHzZduv/yMWIHDlRhM1e8Iff9uAfA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [darwin]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-9YpfeUvSE2RS7wysJ81uOZkXJz7f7Q55H2Gvp3VEw/EsahqDtrphrZ0EwDLK5vvKOzaCrBsjF8JmnMLcUt78Gg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [darwin]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-1wjKdz/XLGKHaTNHjQveQ/B23TKx4ItAqm1JbyVuvNPc4Ze0Fb48s49TAd/2zcplPl8okE/UbTgmlVfwT7eFeQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [darwin]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-yB1IlAsSNHncV6SCTL27/MVGR5htvQsoGxIv5KMGXALp+Ll1wYsn+x98M9MW7qa+NdSbvrrY7ANI4wLJ0n1e6g==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [freebsd]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-Fa0jHR07E7YBN4vOEsbVf2briYNsuOowfLJaXULZM0ldMlaCaj2LJgLMbMe4iacRyZmvR8efFhgR9wKuGclQUg==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [freebsd]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-Yi30IVAAfLUCy2MseFjbB1jAMDl1VMCAas5StnYp8da9+CKvMd2H2cbEjWcw5NPaPqzvYkVIaF1nNUG+b7u/sw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [linux]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-pzkgu1SSHGgRRyRZ4fbmSgmajbVt+epaLP99NDjFft69v/ypfTi6swBMiVdh2EkQ0OSnHE1lZDM7DRGkyAzUpA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm]
+ os: [linux]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-jsO7R8To+AdlYgUmN5sHSCZbfhtMBkO0WUx8iORQnPcMMdgr7qM2DQmMwgabs3GhNztdmoKkMKQFHD6DTMCIQw==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -741,6 +793,13 @@ packages:
os: [linux]
libc: [glibc]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-QI5SEDY8cbiYWHx0VO4vIc3UlS6a32vXHjU8Qy/17adEmZIPuByJg13UEvo9c/UCiUkdcVWY83C+b+JrwnNyUg==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [linux]
+ libc: [glibc]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-VWkUHwWriDciit80wleYwKILoR/KMvxh/IdwS/paX+ZgpuRpCrKLUdadJbc0NpBEiyhpYawsJ73j9aCvOH+f7Q==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -748,6 +807,13 @@ packages:
os: [linux]
libc: [musl]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-Sm41FyCeXqmYcERoYOCbGIL5hNfd8w9LQ7Y61Bev48HkcjaJqV/iiVOaiDxjVTRMS+QKrZmD8cfPt4uMVnvM+A==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [linux]
+ libc: [musl]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-5f1laC0SlIR0yDbFCd8acUhvJIag6N3zC5P7oUPN6wX0aOma+uKJ0wBDH5aq7I1PVI2ttTlhJwzwRIBnLiSGEg==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -755,6 +821,13 @@ packages:
os: [linux]
libc: [glibc]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-2x+WhXTGl9yJYPbltW/BSEPTVz9OIWQyER4N+gJEDWkkn904eRcBzELqh/Hf7K0w/ubGbKNMv0ZC+94QK/IFEg==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [ppc64]
+ os: [linux]
+ libc: [glibc]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-Iq4ko0r4XsgbrF/LunNgHtAGLRRVE2kXonAXQ/MV0mC6jQpMOhW1SvtZja2EhC/kd05++bP78dsqBeIQyYJ6Yg==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -762,6 +835,13 @@ packages:
os: [linux]
libc: [glibc]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-eEjmQpuRQayHPWWnywaWHkFT3ToPbP3RYy42VVd/B9aBGDA+Ol25EIWHxKQST3IiWJjikCWUF7KtbfqwZrzVwQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [s390x]
+ os: [linux]
+ libc: [glibc]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-B8m6tD5+/N5FeNQFbKlLA/2yVq9ycQP1SeedyEYYKWBNR3ZQbkvIUcNnDNM03lO1l5F2roiiFJGgvoLLyZXtSg==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -769,6 +849,13 @@ packages:
os: [linux]
libc: [glibc]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-/Orga1fZYkLc/56jBICcHrKchl8Z2UKdDSr3LG9ToWO1lQ6a4Livk9Xz+9WN91zsz5QR3XQz2NNoSDEvP6qadw==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [linux]
+ libc: [glibc]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-pSdpdUJHkuCxun9LE7jvgUB9qsRgaiyNNCX7m/AvHTcq67AiT/Yhoxvw5zPfhrM8k/BfP8ce/hMOpthKDpEUow==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -776,29 +863,58 @@ packages:
os: [linux]
libc: [musl]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-xxBJRL+0q0Kce7orznGWLuylHDY65vuARXZRpX+hPdv+DqK2c3NlCsVA98tlWzWNEE7yPqA/1NQ5nnCrj49Y5A==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [linux]
+ libc: [musl]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-OXXS3RKJgX2uLwM+gYyuH5omcH8fL1LJs96pZGgtetVCahON57+d4SJHzTgZiOjxgGkSnpXpOsWuPDGAKAigEg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [openharmony]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-M6AdXIXw3s+/8XpKMzdGDEXGS1S7kwUsy+rcTIUIOx5Ge4nXKCtAFHFV9YKkXvGcC5WMoTjAteLzlsQROVI0Yw==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [openharmony]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-JTtb8BWFynicNSoPrehsCzBtOKjZ6jhMiPFEmOiuXg1Fl8dn2KHQob+GuPSGR0dryQa1PQJbzjF3dqO/whhjLg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [wasm32]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-/TX0SoRGojHzSAHpfVBbavRVSazg5U3h3Y3VXfcc0cdugq6kxdqw8LPGFiPr+/7gE/60zRcsOY2Vi9b9eT0jww==}
+ engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0}
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-gEdFFEN70A/jxb2svrWsN3aDL7OUtmvlOy+6fa2jxG8K0wQ1ZbdeLGnidov6Yu5/733dI5ySfzFlQ/cb0bSz1g==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [win32]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-EvRrivJieyHG+AO9lleZWgq+g0+S7oV2C51yuqlcyU/R9net+sI4Pj0F+lUoP2bEr6TWX3SqFaaS0SzfLxSzkw==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [win32]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-eXB7CHuaQdqmJcc3koCNtNPmT/bj2gc999kUFgBxG8Ac0NdgXc4rkCHhqrgrhN3zddvvvrgzj1e90SuSfmyIXA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [win32]
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-Z4eCmn5QJ/5+azF9knpLWKfVd9aidn0mAe9TpJgvBLId9Ax3t0+JVxBmT25Bv7NBbVW1TZyKjQjQReouMeH5UQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [win32]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==}
@@ -1004,6 +1120,9 @@ packages:
resolution: {integrity: sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==}
+ '@tybys/[email protected]':
+ resolution: {integrity: sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==}
+
resolution: {integrity: sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==}
@@ -2849,6 +2968,11 @@ packages:
engines: {node: ^20.19.0 || >=22.12.0}
hasBin: true
+ resolution: {integrity: sha512-4FKJhg8d3OiyQOA6Q1Q0hoFFpW9/OoX+VsHzpECsdsIZoOArrAK90gl59YK/Z+gnDel45bgJZK03ozH/9bCqEw==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ hasBin: true
+
resolution: {integrity: sha512-d0UrqxYd8KyZ6i3M2Nx7WOMy708qsV/7fTHMHxCMCBOAe3V/U7OMPu5GkX8hC+cmkHhzGnfeYongl1IgiooddA==}
engines: {node: '>=16'}
@@ -3703,16 +3827,32 @@ snapshots:
tslib: 2.8.1
optional: true
+ '@emnapi/[email protected]':
+ dependencies:
+ '@emnapi/wasi-threads': 2.0.1
+ tslib: 2.8.1
+ optional: true
+
'@emnapi/[email protected]':
dependencies:
tslib: 2.8.1
optional: true
+ '@emnapi/[email protected]':
+ dependencies:
+ tslib: 2.8.1
+ optional: true
+
'@emnapi/[email protected]':
dependencies:
tslib: 2.8.1
optional: true
+ '@emnapi/[email protected]':
+ dependencies:
+ tslib: 2.8.1
+ optional: true
+
'@esbuild/[email protected]':
optional: true
@@ -3944,12 +4084,21 @@ snapshots:
'@tybys/wasm-util': 0.10.2
optional: true
+ dependencies:
+ '@emnapi/core': 2.0.0-alpha.3
+ '@emnapi/runtime': 2.0.0-alpha.3
+ '@tybys/wasm-util': 0.10.3
+ optional: true
+
'@noble/[email protected]': {}
'@noble/[email protected]': {}
'@oxc-project/[email protected]': {}
+ '@oxc-project/[email protected]': {}
+
'@peculiar/[email protected]':
dependencies:
'@peculiar/utils': 2.0.3
@@ -3980,39 +4129,75 @@ snapshots:
'@rolldown/[email protected]':
optional: true
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]':
optional: true
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]':
optional: true
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]':
optional: true
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]':
optional: true
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]':
optional: true
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]':
optional: true
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]':
optional: true
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]':
optional: true
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]':
optional: true
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]':
optional: true
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]':
optional: true
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]':
dependencies:
'@emnapi/core': 1.10.0
@@ -4020,12 +4205,25 @@ snapshots:
'@napi-rs/wasm-runtime': 1.1.5(@emnapi/[email protected])(@emnapi/[email protected])
optional: true
+ '@rolldown/[email protected]':
+ dependencies:
+ '@emnapi/core': 2.0.0-alpha.3
+ '@emnapi/runtime': 2.0.0-alpha.3
+ '@napi-rs/wasm-runtime': 1.2.2(@emnapi/[email protected])(@emnapi/[email protected])
+ optional: true
+
'@rolldown/[email protected]':
optional: true
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]':
optional: true
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]': {}
@@ -4160,6 +4358,11 @@ snapshots:
tslib: 2.8.1
optional: true
+ '@tybys/[email protected]':
+ dependencies:
+ tslib: 2.8.1
+ optional: true
+
dependencies:
'@types/http-cache-semantics': 4.2.0
@@ -6236,6 +6439,27 @@ snapshots:
'@rolldown/binding-win32-arm64-msvc': 1.0.3
'@rolldown/binding-win32-x64-msvc': 1.0.3
+ dependencies:
+ '@oxc-project/types': 0.142.0
+ '@rolldown/pluginutils': 1.0.1
+ optionalDependencies:
+ '@rolldown/binding-android-arm64': 1.2.1
+ '@rolldown/binding-darwin-arm64': 1.2.1
+ '@rolldown/binding-darwin-x64': 1.2.1
+ '@rolldown/binding-freebsd-x64': 1.2.1
+ '@rolldown/binding-linux-arm-gnueabihf': 1.2.1
+ '@rolldown/binding-linux-arm64-gnu': 1.2.1
+ '@rolldown/binding-linux-arm64-musl': 1.2.1
+ '@rolldown/binding-linux-ppc64-gnu': 1.2.1
+ '@rolldown/binding-linux-s390x-gnu': 1.2.1
+ '@rolldown/binding-linux-x64-gnu': 1.2.1
+ '@rolldown/binding-linux-x64-musl': 1.2.1
+ '@rolldown/binding-openharmony-arm64': 1.2.1
+ '@rolldown/binding-wasm32-wasi': 1.2.1
+ '@rolldown/binding-win32-arm64-msvc': 1.2.1
+ '@rolldown/binding-win32-x64-msvc': 1.2.1
+
dependencies:
magic-string: 0.30.21
diff --git a/sdk/package.json b/sdk/package.json
index f2c7955ae..9f30737e1 100644
--- a/sdk/package.json
+++ b/sdk/package.json
@@ -54,8 +54,8 @@
"dist"
],
"scripts": {
- "build": "rollup -c",
- "watch": "rollup -c -w",
+ "build": "rolldown -c && rollup -c",
+ "watch": "rolldown -c -w",
"clean": "rimraf dist",
"api:check": "node ../tools/api-surface.mjs --check",
"api:update": "node ../tools/api-surface.mjs --update",
@@ -85,6 +85,7 @@
"happy-dom": "^15.11.0",
"minigame-api-typings": "^3.8.16",
"rimraf": "^5.0.5",
+ "rolldown": "1.2.1",
"rollup": "^4.9.0",
"rollup-plugin-dts": "^6.1.0",
"tslib": "^2.6.2",
diff --git a/sdk/rolldown.config.js b/sdk/rolldown.config.js
new file mode 100644
index 000000000..e96fc9d59
--- /dev/null
+++ b/sdk/rolldown.config.js
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+import { defineConfig } from 'rolldown';
+
+const ENTRY_FILES = ['/index.ts', '/index.wechat.ts', '/index.minigame.ts', '/index.node.ts', '/index.native.ts'];
+const treeshake = {
+ moduleSideEffects: (id) => ENTRY_FILES.some(e => id.endsWith(e)),
+};
+
+// OXC's minifier drops annotation comments unconditionally — rolldown 1.2.1
+// exposes no knob for it — which would strip the `@vite-ignore` markers that our
+// runtime-computed dynamic imports need to stay opaque to a downstream bundler.
+// Legal comments it does keep, so smuggle the marker through disguised as one and
+// swap it back after minification. Both substitutions are length-preserving, which
+// keeps every sourcemap in the chain valid without regenerating it.
+const VITE_IGNORE_RE = /\/\*\s*@vite-ignore\s*\*\//g;
+const SMUGGLED = '/*! @vite-ignore*/';
+const RESTORED = '/* @vite-ignore*/';
+
+function preserveViteIgnore() {
+ let smuggled = 0;
+ let restored = 0;
+ return {
+ name: 'preserve-vite-ignore',
+ renderChunk(code) {
+ const marked = code.replace(VITE_IGNORE_RE, () => (smuggled++, SMUGGLED));
+ return marked === code ? null : { code: marked, map: null };
+ },
+ generateBundle(_options, bundle) {
+ for (const chunk of Object.values(bundle)) {
+ if (chunk.type !== 'chunk' || !chunk.code.includes(SMUGGLED)) continue;
+ chunk.code = chunk.code.replaceAll(SMUGGLED, () => (restored++, RESTORED));
+ }
+ // A silent drop here would only surface as a downstream bundler warning in
+ // someone else's project, so fail the build instead.
+ if (restored !== smuggled) {
+ this.error(`preserve-vite-ignore: smuggled ${smuggled} marker(s) past the minifier but recovered ${restored} — the minifier is no longer preserving legal comments.`);
+ }
+ },
+ };
+}
+
+const minify = { compress: true, mangle: true, codegen: { removeWhitespace: true, legalComments: 'inline' } };
+
+export default defineConfig([
+ {
+ // ONE code-split graph for every ESM entry a bundler can combine:
+ // `esengine` (web or wechat) and the `esengine/*` subpaths must resolve
+ // into the SAME shared chunks, or a game bundle that imports both gets
+ // two copies of the core — and identity-keyed resources (Res(Spine))
+ // split-brain: the runtime inserts into one copy, systems read the other.
+ input: {
+ 'index': 'src/index.ts',
+ 'index.wechat': 'src/index.wechat.ts',
+ 'index.minigame': 'src/index.minigame.ts',
+ 'index.native': 'src/index.native.ts',
+ 'physics/index': 'src/physics/index.ts',
+ 'spine/index': 'src/spine/index.ts',
+ 'dragonbones/index': 'src/dragonbones/index.ts',
+ 'wasm': 'src/wasm.ts',
+ },
+ output: {
+ dir: 'dist',
+ format: 'esm',
+ sourcemap: true,
+ chunkFileNames: 'shared/[name].js',
+ minify,
+ },
+ plugins: [preserveViteIgnore()],
+ treeshake,
+ },
+ {
+ input: 'src/index.ts',
+ output: { file: 'dist/index.bundled.js', format: 'esm', sourcemap: true, minify },
+ plugins: [preserveViteIgnore()],
+ treeshake,
+ },
+ {
+ input: 'src/index.wechat.ts',
+ output: { file: 'dist/index.wechat.cjs.js', format: 'cjs', sourcemap: true, minify },
+ plugins: [preserveViteIgnore()],
+ treeshake,
+ },
+ {
+ // Single-file IIFE for embedded JS engines (QuickJS on the native host):
+ // no imports, no code-splitting — one script that installs `ESEngine` as a
+ // global the game script uses (ESEngine.createNativeWorld(globalThis), …).
+ // The native (embedded-Dawn) analog of index.wechat.cjs.js.
+ input: 'src/index.native.ts',
+ output: { file: 'dist/index.native.bundled.js', format: 'iife', name: 'ESEngine', sourcemap: false, minify },
+ plugins: [preserveViteIgnore()],
+ treeshake,
+ },
+ {
+ input: 'src/index.node.ts',
+ output: { file: 'dist/index.node.js', format: 'esm', sourcemap: true, minify },
+ external: (id) => id.startsWith('node:'),
+ plugins: [preserveViteIgnore()],
+ treeshake,
+ },
+]);
diff --git a/sdk/rollup.config.js b/sdk/rollup.config.js
index 05d52319f..a038e9ac5 100644
--- a/sdk/rollup.config.js
+++ b/sdk/rollup.config.js
@@ -1,75 +1,12 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
-import typescript from '@rollup/plugin-typescript';
-import terser from '@rollup/plugin-terser';
+// Types only — the JS bundles are built by rolldown (see rolldown.config.js).
+// The `.d.ts` rollup stays on tsc-backed rollup-plugin-dts: it costs ~10% of the
+// build and switching generators would need `isolatedDeclarations` across the
+// whole source tree, with nothing in CI comparing the emitted types.
import dts from 'rollup-plugin-dts';
-const ENTRY_FILES = ['/index.ts', '/index.wechat.ts', '/index.minigame.ts', '/index.node.ts', '/index.native.ts'];
-const treeshake = {
- moduleSideEffects: (id) => ENTRY_FILES.some(e => id.endsWith(e)),
-};
-
-const esmBuilds = [
- {
- // ONE code-split graph for every ESM entry a bundler can combine:
- // `esengine` (web or wechat) and the `esengine/*` subpaths must resolve
- // into the SAME shared chunks, or a game bundle that imports both gets
- // two copies of the core — and identity-keyed resources (Res(Spine))
- // split-brain: the runtime inserts into one copy, systems read the other.
- input: {
- 'index': 'src/index.ts',
- 'index.wechat': 'src/index.wechat.ts',
- 'index.minigame': 'src/index.minigame.ts',
- 'index.native': 'src/index.native.ts',
- 'physics/index': 'src/physics/index.ts',
- 'spine/index': 'src/spine/index.ts',
- 'dragonbones/index': 'src/dragonbones/index.ts',
- 'wasm': 'src/wasm.ts',
- },
- output: {
- dir: 'dist',
- format: 'esm',
- sourcemap: true,
- chunkFileNames: 'shared/[name].js',
- },
- plugins: [
- typescript({ tsconfig: './tsconfig.json', declaration: false }),
- terser({ format: { comments: (_, comment) => comment.value.includes('@vite-ignore') } }),
- ],
- treeshake,
- },
- {
- input: 'src/index.ts',
- output: { file: 'dist/index.bundled.js', format: 'esm', sourcemap: true },
- plugins: [typescript({ tsconfig: './tsconfig.json', declaration: false }), terser({ format: { comments: (_, comment) => comment.value.includes('@vite-ignore') } })],
- treeshake,
- },
- {
- input: 'src/index.wechat.ts',
- output: { file: 'dist/index.wechat.cjs.js', format: 'cjs', sourcemap: true },
- plugins: [typescript({ tsconfig: './tsconfig.json', declaration: false }), terser({ format: { comments: (_, comment) => comment.value.includes('@vite-ignore') } })],
- treeshake,
- },
- {
- // Single-file IIFE for embedded JS engines (QuickJS on the native host):
- // no imports, no code-splitting — one script that installs `ESEngine` as a
- // global the game script uses (ESEngine.createNativeWorld(globalThis), …).
- // The native (embedded-Dawn) analog of index.wechat.cjs.js.
- input: 'src/index.native.ts',
- output: { file: 'dist/index.native.bundled.js', format: 'iife', name: 'ESEngine', sourcemap: false },
- plugins: [typescript({ tsconfig: './tsconfig.json', declaration: false }), terser({ format: { comments: (_, comment) => comment.value.includes('@vite-ignore') } })],
- treeshake,
- },
- {
- input: 'src/index.node.ts',
- output: { file: 'dist/index.node.js', format: 'esm', sourcemap: true },
- external: (id) => id.startsWith('node:'),
- plugins: [typescript({ tsconfig: './tsconfig.json', declaration: false }), terser({ format: { comments: (_, comment) => comment.value.includes('@vite-ignore') } })],
- treeshake,
- },
-];
-
-const dtsBuilds = [
+export default [
{
input: {
'index': 'src/index.ts',
@@ -90,5 +27,3 @@ const dtsBuilds = [
plugins: [dts()],
},
];
-
-export default [...esmBuilds, ...dtsBuilds];