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/gameplay or esengine/replication installs them under a bundler that treats chunks as pure

yhhdbcb15494aa2
diff --git a/sdk/src/gameplay/entry.ts b/sdk/src/gameplay/entry.ts
new file mode 100644
index 000000000..82dfaafe7
--- /dev/null
+++ b/sdk/src/gameplay/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/gameplay` entry: the barrel, and the call that installs it.
+ *
+ * The call is here and not in `./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 { registerGameplaySupport } from './gameplaySupport';
+
+registerGameplaySupport();
diff --git a/sdk/src/gameplay/index.ts b/sdk/src/gameplay/index.ts
index 73c78155f..3eab2d1c5 100644
--- a/sdk/src/gameplay/index.ts
+++ b/sdk/src/gameplay/index.ts
@@ -73,12 +73,6 @@ export {
updateCameras,
} from './GameplayPlugin';
-
-// Importing this subpath INSTALLS the gameplay runtime — see spine/index.ts.
-import { registerGameplaySupport } from './gameplaySupport';
-
-registerGameplaySupport();
-
export {
gridCellAt,
gridCellCentre,
diff --git a/sdk/src/net/replication/entry.ts b/sdk/src/net/replication/entry.ts
new file mode 100644
index 000000000..6e95863ba
--- /dev/null
+++ b/sdk/src/net/replication/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/replication` entry: the barrel, and the call that installs it.
+ *
+ * The call is here and not in `./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 { registerReplicationSupport } from './replicationSupport';
+
+registerReplicationSupport();
diff --git a/sdk/src/net/replication/index.ts b/sdk/src/net/replication/index.ts
index 491bfdf46..758679f97 100644
--- a/sdk/src/net/replication/index.ts
+++ b/sdk/src/net/replication/index.ts
@@ -65,11 +65,6 @@ export {
type NetRoleKind,
} from './ReplicationPlugin';
-// Importing this subpath INSTALLS replication — see spine/index.ts.
-import { registerReplicationSupport } from './replicationSupport';
-
-registerReplicationSupport();
-
// The channel and the transports a game drives replication over: they chunk
// with the protocol, so this is where a package pays for them.
export {
diff --git a/sdk/tests/replication-e2e-ws.test.ts b/sdk/tests/replication-e2e-ws.test.ts
index 37ab0dc17..60ffdaa0e 100644
--- a/sdk/tests/replication-e2e-ws.test.ts
+++ b/sdk/tests/replication-e2e-ws.test.ts
@@ -18,6 +18,8 @@ import { loadWasmModule, HAS_WASM } from './helpers/loadWasm';
import { GameSocket } from '../src/net/GameSocket';
import type { ReliableOrderedTransport } from '../src/net/NetChannel';
import { replicationPlugin, Net, Replicated } from '../src/net/replication';
+// The subpath's entry is what installs replication into an app; the barrel above is only its names.
+import '../src/net/replication/entry';
import { setPlatform } from '../src/platform/base';
import { nodeAdapter } from '../src/platform/node';