hytopia 0.10.0-prerelease-9 → 0.10.0-prerelease-11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/scripts.js CHANGED
@@ -69,6 +69,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
69
69
  * @example
70
70
  */
71
71
  async function build() {
72
+ logDivider();
73
+ console.log('🔧 Building project...');
72
74
  await esbuild.build({
73
75
  entryPoints: ['index.ts'],
74
76
  outfile: './index.mjs',
@@ -87,7 +89,6 @@ async function build() {
87
89
  function start() {
88
90
  (async () => {
89
91
  let child = null;
90
- let restartTimer = null;
91
92
 
92
93
  const stopNode = () => {
93
94
  if (child && !child.killed) {
@@ -95,14 +96,9 @@ function start() {
95
96
  }
96
97
  };
97
98
 
98
- const startNode = () => {
99
+ const spawnNode = () => {
99
100
  stopNode();
100
- child = spawn(process.execPath, ['index.mjs'], { stdio: 'inherit', shell: false });
101
- };
102
-
103
- const scheduleRestart = () => {
104
- if (restartTimer) clearTimeout(restartTimer);
105
- restartTimer = setTimeout(startNode, 100);
101
+ child = spawn(process.execPath, ['--watch', 'index.mjs'], { stdio: 'inherit', shell: false });
106
102
  };
107
103
 
108
104
  const ctx = await esbuild.context({
@@ -113,22 +109,15 @@ function start() {
113
109
  platform: 'node',
114
110
  target: 'node24',
115
111
  sourcemap: 'inline',
116
- plugins: [{
117
- name: 'restart-on-end',
118
- setup(build) {
119
- build.onEnd((result) => {
120
- if (!result.errors?.length) scheduleRestart();
121
- });
122
- }
123
- }]
124
112
  });
125
113
 
126
- await ctx.rebuild();
127
- startNode();
114
+ // Start watching (per esbuild, this performs an initial build before resolving)
128
115
  await ctx.watch();
129
116
 
117
+ // Run node with native --watch to auto-restart on output changes
118
+ spawnNode();
119
+
130
120
  const cleanup = async () => {
131
- if (restartTimer) clearTimeout(restartTimer);
132
121
  stopNode();
133
122
  try { await ctx.dispose(); } catch {}
134
123
  process.exit(0);
@@ -401,7 +390,7 @@ function initCursorLocalMcp() {
401
390
  * @example
402
391
  * `hytopia package`
403
392
  */
404
- function packageProject() {
393
+ async function packageProject() {
405
394
  const sourceDir = process.cwd();
406
395
  const projectName = path.basename(sourceDir);
407
396
  const packageJsonPath = path.join(sourceDir, 'package.json');
@@ -473,6 +462,9 @@ function packageProject() {
473
462
 
474
463
  console.log(`📦 Packaging project "${projectName}"...`);
475
464
 
465
+ // Build the project
466
+ await build();
467
+
476
468
  // Create a file to stream archive data to
477
469
  const output = fs.createWriteStream(outputFile);
478
470
  const archive = archiver('zip', {
@@ -686,6 +678,7 @@ function displayHelp() {
686
678
  console.log('Commands:');
687
679
  console.log(' help, -h, --help Show this help');
688
680
  console.log(' version, -v, --version Show CLI version');
681
+ console.log(' build Build the project (Generates ESM index.js)');
689
682
  console.log(' start Start a HYTOPIA project server (Node.js & watch)');
690
683
  console.log(' init [--template NAME] Initialize a new project');
691
684
  console.log(' init-mcp Setup MCP integrations');
@@ -4,10 +4,10 @@
4
4
  import fs from 'fs';
5
5
 
6
6
  const sdkPackage = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
7
- const server = fs.readFileSync('./server.js', 'utf8');
7
+ const server = fs.readFileSync('./server.mjs', 'utf8');
8
8
 
9
9
  if (!server.includes('__DEV_SDK_VERSION__')) {
10
- throw new Error('__DEV_SDK_VERSION__ not found in server.js. Please create a fresh build before publishing! You can do this by running: cd ../server && bun run build.');
10
+ throw new Error('__DEV_SDK_VERSION__ not found in server.mjs. Please create a fresh build before publishing! You can do this by running: cd ../server && npm run build.');
11
11
  }
12
12
 
13
- fs.writeFileSync('./server.js', server.replace(/__DEV_SDK_VERSION__/g, sdkPackage.version));
13
+ fs.writeFileSync('./server.mjs', server.replace(/__DEV_SDK_VERSION__/g, sdkPackage.version));
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.10.0-prerelease-9",
3
+ "version": "0.10.0-prerelease-11",
4
4
  "description": "The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.",
5
5
  "type": "module",
6
- "main": "./server.js",
6
+ "main": "./server.mjs",
7
7
  "exports": {
8
8
  ".": {
9
9
  "types": "./server.d.ts",
10
- "default": "./server.js"
10
+ "default": "./server.mjs"
11
11
  }
12
12
  },
13
13
  "bin": {