hytopia 0.10.11-prerelease-5 → 0.10.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 +69 -19
- package/package.json +2 -3
- package/server.mjs +2 -2
package/bin/scripts.js
CHANGED
@@ -6,6 +6,7 @@ import fs from 'fs';
|
|
6
6
|
import path from 'path';
|
7
7
|
import readline from 'readline';
|
8
8
|
import { fileURLToPath } from 'url';
|
9
|
+
import * as esbuild from 'esbuild';
|
9
10
|
|
10
11
|
// Store command-line flags
|
11
12
|
const flags = {};
|
@@ -67,7 +68,20 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
67
68
|
async function build() {
|
68
69
|
console.log('🔧 Building project...');
|
69
70
|
|
70
|
-
|
71
|
+
await esbuild.build({
|
72
|
+
entryPoints: ['index.ts'],
|
73
|
+
outfile: './index.mjs',
|
74
|
+
bundle: true,
|
75
|
+
format: 'esm',
|
76
|
+
platform: 'node',
|
77
|
+
target: 'node24',
|
78
|
+
sourcemap: 'inline',
|
79
|
+
mainFields: ['module', 'main'],
|
80
|
+
conditions: ['import', 'node'],
|
81
|
+
banner: {
|
82
|
+
js: 'import { createRequire as __cr } from "module"; import { fileURLToPath } from "url"; import { dirname } from "path"; const require = __cr(import.meta.url); const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename);'
|
83
|
+
}
|
84
|
+
});
|
71
85
|
}
|
72
86
|
|
73
87
|
/**
|
@@ -75,25 +89,61 @@ async function build() {
|
|
75
89
|
* and watches for changes.
|
76
90
|
*/
|
77
91
|
function start() {
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
92
|
+
(async () => {
|
93
|
+
let child = null;
|
94
|
+
let restartTimer = null;
|
95
|
+
|
96
|
+
const stopNode = () => {
|
97
|
+
if (child && !child.killed) {
|
98
|
+
try { child.kill(); } catch {}
|
99
|
+
}
|
100
|
+
};
|
101
|
+
|
102
|
+
const restartNode = () => {
|
103
|
+
stopNode();
|
104
|
+
child = spawn(process.execPath, ['--enable-source-maps', 'index.mjs'], { stdio: 'inherit', shell: false });
|
105
|
+
};
|
106
|
+
|
107
|
+
const ctx = await esbuild.context({
|
108
|
+
entryPoints: ['index.ts'],
|
109
|
+
outfile: './index.mjs',
|
110
|
+
bundle: true,
|
111
|
+
format: 'esm',
|
112
|
+
platform: 'node',
|
113
|
+
target: 'node24',
|
114
|
+
sourcemap: 'inline',
|
115
|
+
external: [ 'mediasoup' ], // prevent pathing issues in dev env, prod sets the bin path so no issue bundling in prod build/package.
|
116
|
+
mainFields: ['module', 'main'],
|
117
|
+
conditions: ['import', 'node'],
|
118
|
+
banner: {
|
119
|
+
js: 'import { createRequire as __cr } from "module"; import { fileURLToPath } from "url"; import { dirname } from "path"; const require = __cr(import.meta.url); const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename);'
|
120
|
+
},
|
121
|
+
plugins: [{
|
122
|
+
name: 'restart-after-build',
|
123
|
+
setup(build) {
|
124
|
+
build.onStart(() => {
|
125
|
+
if (restartTimer) { clearTimeout(restartTimer); restartTimer = null; }
|
126
|
+
});
|
127
|
+
build.onEnd((result) => {
|
128
|
+
if (result.errors?.length) return;
|
129
|
+
restartTimer = setTimeout(restartNode, 150);
|
130
|
+
});
|
131
|
+
}
|
132
|
+
}]
|
133
|
+
});
|
134
|
+
|
135
|
+
await ctx.watch();
|
136
|
+
|
137
|
+
const cleanup = async () => {
|
138
|
+
if (restartTimer) clearTimeout(restartTimer);
|
139
|
+
stopNode();
|
140
|
+
try { await ctx.dispose(); } catch {}
|
141
|
+
process.exit(0);
|
142
|
+
};
|
93
143
|
|
94
|
-
|
95
|
-
|
96
|
-
|
144
|
+
process.on('SIGINT', cleanup);
|
145
|
+
process.on('SIGTERM', cleanup);
|
146
|
+
})();
|
97
147
|
}
|
98
148
|
|
99
149
|
/**
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hytopia",
|
3
|
-
"version": "0.10.11
|
3
|
+
"version": "0.10.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
6
|
"main": "./server.mjs",
|
@@ -58,8 +58,7 @@
|
|
58
58
|
"dependencies": {
|
59
59
|
"@gltf-transform/cli": "^4.2.1",
|
60
60
|
"archiver": "^7.0.1",
|
61
|
-
"
|
62
|
-
"nodemon": "^3.1.10",
|
61
|
+
"esbuild": "^0.25.9",
|
63
62
|
"ws": "^8.18.2"
|
64
63
|
},
|
65
64
|
"optionalDependencies": {
|