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(sdk): importing esengine/ai, tilemap, logic, worldgen, rig2d or dragonbones installs them under a bundler that treats chunks as pure

yhh27223ce7f1d5
diff --git a/sdk/rolldown.config.js b/sdk/rolldown.config.js
index c26630200..2754ca609 100644
--- a/sdk/rolldown.config.js
+++ b/sdk/rolldown.config.js
@@ -102,28 +102,28 @@ export default defineConfig([
'physics/index': 'src/physics/index.ts',
'physics3d/index': 'src/physics3d/index.ts',
'spine/index': 'src/spine/index.ts',
- 'tilemap/index': 'src/tilemap/index.ts',
+ 'tilemap/index': 'src/tilemap/entry.ts',
'terrain/index': 'src/terrain/index.ts',
'timeline/index': 'src/timeline/entry.ts',
'fx-basic/index': 'src/postprocess/fxBasic.ts',
'fx-atmosphere/index': 'src/postprocess/fxAtmosphere.ts',
'fx-lighting/index': 'src/postprocess/fxLighting.ts',
'foliage/index': 'src/foliage/index.ts',
- 'worldgen/index': 'src/worldgen/index.ts',
+ 'worldgen/index': 'src/worldgen/entry.ts',
'water/index': 'src/water/index.ts',
'spline/index': 'src/spline/index.ts',
'voxel/index': 'src/voxel/index.ts',
- 'rig2d/index': 'src/rig2d/index.ts',
+ 'rig2d/index': 'src/rig2d/entry.ts',
'imported-scene/index': 'src/imported-scene/index.ts',
'skeletal-animation/index': 'src/skeletal-animation/index.ts',
'character-shaders/index': 'src/character/index.ts',
- 'logic/index': 'src/logic/index.ts',
+ 'logic/index': 'src/logic/entry.ts',
'debug-channel/index': 'src/debug-channel/index.ts',
- 'ai/index': 'src/ai/index.ts',
+ 'ai/index': 'src/ai/entry.ts',
'net/replication/index': 'src/net/replication/index.ts',
'net/session/index': 'src/net/session/index.ts',
'gameplay/index': 'src/gameplay/index.ts',
- 'dragonbones/index': 'src/dragonbones/index.ts',
+ 'dragonbones/index': 'src/dragonbones/entry.ts',
'douyin/index': 'src/platform/douyin/index.ts',
'kuaishou/index': 'src/platform/kuaishou/index.ts',
'bilibili/index': 'src/platform/bilibili/index.ts',
diff --git a/sdk/rollup.config.js b/sdk/rollup.config.js
index 12815565f..0c97fa0e2 100644
--- a/sdk/rollup.config.js
+++ b/sdk/rollup.config.js
@@ -24,28 +24,28 @@ export default [
'huawei/index': 'src/platform/huawei/index.ts',
'openpaas/index': 'src/openpaas/index.ts',
'spine/index': 'src/spine/index.ts',
- 'tilemap/index': 'src/tilemap/index.ts',
+ 'tilemap/index': 'src/tilemap/entry.ts',
'terrain/index': 'src/terrain/index.ts',
'timeline/index': 'src/timeline/entry.ts',
'fx-basic/index': 'src/postprocess/fxBasic.ts',
'fx-atmosphere/index': 'src/postprocess/fxAtmosphere.ts',
'fx-lighting/index': 'src/postprocess/fxLighting.ts',
'foliage/index': 'src/foliage/index.ts',
- 'worldgen/index': 'src/worldgen/index.ts',
+ 'worldgen/index': 'src/worldgen/entry.ts',
'water/index': 'src/water/index.ts',
'spline/index': 'src/spline/index.ts',
'voxel/index': 'src/voxel/index.ts',
- 'rig2d/index': 'src/rig2d/index.ts',
+ 'rig2d/index': 'src/rig2d/entry.ts',
'imported-scene/index': 'src/imported-scene/index.ts',
'skeletal-animation/index': 'src/skeletal-animation/index.ts',
'character-shaders/index': 'src/character/index.ts',
- 'logic/index': 'src/logic/index.ts',
+ 'logic/index': 'src/logic/entry.ts',
'debug-channel/index': 'src/debug-channel/index.ts',
- 'ai/index': 'src/ai/index.ts',
+ 'ai/index': 'src/ai/entry.ts',
'net/replication/index': 'src/net/replication/index.ts',
'net/session/index': 'src/net/session/index.ts',
'gameplay/index': 'src/gameplay/index.ts',
- 'dragonbones/index': 'src/dragonbones/index.ts',
+ 'dragonbones/index': 'src/dragonbones/entry.ts',
'wasm': 'src/wasm.ts',
},
output: {
diff --git a/sdk/src/ai/entry.ts b/sdk/src/ai/entry.ts
new file mode 100644
index 000000000..00505a533
--- /dev/null
+++ b/sdk/src/ai/entry.ts
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file entry.ts — the `esengine/ai` entry: the barrel, and the call that installs it.
+ *
+ * The call is here and not at the end of `./index` because other modules import that barrel, and a barrel other modules
+ * import is merged into a shared chunk — where a bundler that treats chunks as side-effect free drops a top-level call.
+ * An entry module's own statements are kept. See timeline/entry.ts.
+ */
+export * from './index';
+
+import { registerAiSupport } from './aiSupport';
+
+registerAiSupport();
diff --git a/sdk/src/ai/index.ts b/sdk/src/ai/index.ts
index c4f381b07..ae50ff720 100644
--- a/sdk/src/ai/index.ts
+++ b/sdk/src/ai/index.ts
@@ -63,8 +63,3 @@ export {
// Perception: sight/FOV sensing into a Perception component (read by FSM/BT).
export * from './perception';
-
-// Importing this subpath INSTALLS gameplay AI — see spine/index.ts.
-import { registerAiSupport } from './aiSupport';
-
-registerAiSupport();
diff --git a/sdk/src/dragonbones/entry.ts b/sdk/src/dragonbones/entry.ts
new file mode 100644
index 000000000..03e484aba
--- /dev/null
+++ b/sdk/src/dragonbones/entry.ts
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file entry.ts — the `esengine/dragonbones` entry: the barrel, and the call that installs it.
+ *
+ * The call is here and not at the end of `./index` because other modules import that barrel, and a barrel other modules
+ * import is merged into a shared chunk — where a bundler that treats chunks as side-effect free drops a top-level call.
+ * An entry module's own statements are kept. See timeline/entry.ts.
+ */
+export * from './index';
+
+import { registerDragonBonesSupport } from './dragonBonesSupport';
+
+registerDragonBonesSupport();
diff --git a/sdk/src/dragonbones/index.ts b/sdk/src/dragonbones/index.ts
index f2d02e9d7..931538dbf 100644
--- a/sdk/src/dragonbones/index.ts
+++ b/sdk/src/dragonbones/index.ts
@@ -22,8 +22,3 @@ export {
} from './loadDragonBonesScene';
export type { DragonBonesAssetInfo } from './loadDragonBonesScene';
export type { RuntimeAssetSource } from '../runtime/runtimeAssets';
-
-// Importing this subpath INSTALLS DragonBones — see spine/index.ts.
-import { registerDragonBonesSupport } from './dragonBonesSupport';
-
-registerDragonBonesSupport();
diff --git a/sdk/src/logic/entry.ts b/sdk/src/logic/entry.ts
new file mode 100644
index 000000000..9068275fd
--- /dev/null
+++ b/sdk/src/logic/entry.ts
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file entry.ts — the `esengine/logic` entry: the barrel, and the call that installs it.
+ *
+ * The call is here and not at the end of `./index` because other modules import that barrel, and a barrel other modules
+ * import is merged into a shared chunk — where a bundler that treats chunks as side-effect free drops a top-level call.
+ * An entry module's own statements are kept. See timeline/entry.ts.
+ */
+export * from './index';
+
+import { registerScriptGraphSupport } from './logicSupport';
+
+registerScriptGraphSupport();
diff --git a/sdk/src/logic/index.ts b/sdk/src/logic/index.ts
index dc197794b..242848447 100644
--- a/sdk/src/logic/index.ts
+++ b/sdk/src/logic/index.ts
@@ -100,8 +100,3 @@ export {
renameScriptGraphPort,
retypeScriptGraphPort,
} from './graphOps';
-
-// Importing this subpath INSTALLS script graphs — see spine/index.ts.
-import { registerScriptGraphSupport } from './logicSupport';
-
-registerScriptGraphSupport();
diff --git a/sdk/src/rig2d/entry.ts b/sdk/src/rig2d/entry.ts
new file mode 100644
index 000000000..320c12e36
--- /dev/null
+++ b/sdk/src/rig2d/entry.ts
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file entry.ts — the `esengine/rig2d` entry: the barrel, and the call that installs it.
+ *
+ * The call is here and not at the end of `./index` because other modules import that barrel, and a barrel other modules
+ * import is merged into a shared chunk — where a bundler that treats chunks as side-effect free drops a top-level call.
+ * An entry module's own statements are kept. See timeline/entry.ts.
+ */
+export * from './index';
+
+import { registerRig2DSupport } from './rig2dSupport';
+
+registerRig2DSupport();
diff --git a/sdk/src/rig2d/index.ts b/sdk/src/rig2d/index.ts
index aee51a86e..d5b2d8834 100644
--- a/sdk/src/rig2d/index.ts
+++ b/sdk/src/rig2d/index.ts
@@ -19,8 +19,3 @@ export {
type Bone2DData, type IK2DData, type BoneConstraint2DData,
} from './rig2dPlugin';
export { spawnRig, rigPrefab, type SpawnedRig } from './spawnRig';
-
-// Importing this subpath INSTALLS the constraints — see tilemap/index.ts.
-import { registerRig2DSupport } from './rig2dSupport';
-
-registerRig2DSupport();
diff --git a/sdk/src/tilemap/entry.ts b/sdk/src/tilemap/entry.ts
new file mode 100644
index 000000000..72186f216
--- /dev/null
+++ b/sdk/src/tilemap/entry.ts
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file entry.ts — the `esengine/tilemap` entry: the barrel, and the call that installs it.
+ *
+ * The call is here and not at the end of `./index` because other modules import that barrel, and a barrel other modules
+ * import is merged into a shared chunk — where a bundler that treats chunks as side-effect free drops a top-level call.
+ * An entry module's own statements are kept. See timeline/entry.ts.
+ */
+export * from './index';
+
+import { registerTilemapSupport } from './tilemapSupport';
+
+registerTilemapSupport();
diff --git a/sdk/src/tilemap/index.ts b/sdk/src/tilemap/index.ts
index 0d53fb0ad..c281feae5 100644
--- a/sdk/src/tilemap/index.ts
+++ b/sdk/src/tilemap/index.ts
@@ -73,8 +73,3 @@ export {
navGridFromTilemapLayer,
type BuildNavGridOptions,
} from './navGridFromTilemap';
-
-// Importing this subpath INSTALLS tilemaps — see spine/index.ts.
-import { registerTilemapSupport } from './tilemapSupport';
-
-registerTilemapSupport();
diff --git a/sdk/src/worldgen/entry.ts b/sdk/src/worldgen/entry.ts
new file mode 100644
index 000000000..aaf39ede0
--- /dev/null
+++ b/sdk/src/worldgen/entry.ts
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file entry.ts — the `esengine/worldgen` entry: the barrel, and the call that installs it.
+ *
+ * The call is here and not at the end of `./index` because other modules import that barrel, and a barrel other modules
+ * import is merged into a shared chunk — where a bundler that treats chunks as side-effect free drops a top-level call.
+ * An entry module's own statements are kept. See timeline/entry.ts.
+ */
+export * from './index';
+
+import { registerWorldGenSupport } from './worldgenSupport';
+
+registerWorldGenSupport();
diff --git a/sdk/src/worldgen/index.ts b/sdk/src/worldgen/index.ts
index 343f9330b..6b898490e 100644
--- a/sdk/src/worldgen/index.ts
+++ b/sdk/src/worldgen/index.ts
@@ -20,8 +20,3 @@ export {
} from './fields';
export { PlanetFace, FaceZones, planetFaces, faceHalf, faceUnit, type PlaneFrame } from './planetSurface';
-
-// Importing this subpath INSTALLS generated worlds — see tilemap/index.ts. Their ground is the terrain's when the scene has one.
-import { registerWorldGenSupport } from './worldgenSupport';
-
-registerWorldGenSupport();
diff --git a/tools/lib/sdkProgram.mjs b/tools/lib/sdkProgram.mjs
index dd0073b1c..1c8892eab 100644
--- a/tools/lib/sdkProgram.mjs
+++ b/tools/lib/sdkProgram.mjs
@@ -57,25 +57,25 @@ export const ENTRIES = {
'physics': 'src/physics/index.ts',
'physics3d': 'src/physics3d/index.ts',
'spine': 'src/spine/index.ts',
- 'dragonbones': 'src/dragonbones/index.ts',
- 'tilemap': 'src/tilemap/index.ts',
+ 'dragonbones': 'src/dragonbones/entry.ts',
+ 'tilemap': 'src/tilemap/entry.ts',
'terrain': 'src/terrain/index.ts',
'timeline': 'src/timeline/entry.ts',
'fx-basic': 'src/postprocess/fxBasic.ts',
'fx-atmosphere': 'src/postprocess/fxAtmosphere.ts',
'fx-lighting': 'src/postprocess/fxLighting.ts',
'foliage': 'src/foliage/index.ts',
- 'worldgen': 'src/worldgen/index.ts',
+ 'worldgen': 'src/worldgen/entry.ts',
'water': 'src/water/index.ts',
'spline': 'src/spline/index.ts',
'voxel': 'src/voxel/index.ts',
- 'rig2d': 'src/rig2d/index.ts',
+ 'rig2d': 'src/rig2d/entry.ts',
'imported-scene': 'src/imported-scene/index.ts',
'skeletal-animation': 'src/skeletal-animation/index.ts',
'character-shaders': 'src/character/index.ts',
- 'logic': 'src/logic/index.ts',
+ 'logic': 'src/logic/entry.ts',
'debug-channel': 'src/debug-channel/index.ts',
- 'ai': 'src/ai/index.ts',
+ 'ai': 'src/ai/entry.ts',
'replication': 'src/net/replication/index.ts',
'session': 'src/net/session/index.ts',
'gameplay': 'src/gameplay/index.ts',