@colyseus/monitor 0.16.2 → 0.16.3
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/build/index.js +1 -4
- package/build/index.js.map +2 -2
- package/build/index.mjs +1 -4
- package/build/index.mjs.map +2 -2
- package/build/static/bundle.js +1 -1
- package/build/static/bundle.js.map +1 -1
- package/build.mjs +29 -7
- package/package.json +1 -1
- package/src-backend/index.ts +2 -4
package/build.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import path from 'path';
|
|
|
2
2
|
import glob from 'fast-glob';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import ts from "typescript";
|
|
5
|
+
import fs from "fs";
|
|
5
6
|
import esbuild from "esbuild";
|
|
6
7
|
|
|
7
8
|
// we need to change up how __dirname is used for ES6 purposes
|
|
@@ -71,14 +72,35 @@ async function main() {
|
|
|
71
72
|
sourcemap: "external",
|
|
72
73
|
platform: "node",
|
|
73
74
|
outExtension: { '.js': '.mjs', },
|
|
74
|
-
plugins: [
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
build
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
plugins: [
|
|
76
|
+
{
|
|
77
|
+
name: 'add-mjs',
|
|
78
|
+
setup(build) {
|
|
79
|
+
build.onResolve({ filter: /.*/ }, (args) => {
|
|
80
|
+
if (args.importer) return { path: args.path.replace(/^\.(.*)\.js$/, '.$1.mjs'), external: true }
|
|
81
|
+
})
|
|
82
|
+
},
|
|
80
83
|
},
|
|
81
|
-
|
|
84
|
+
{
|
|
85
|
+
//
|
|
86
|
+
// WORKAROUND FOR __dirname usage in ESM
|
|
87
|
+
// TODO: need to have a better appraoch for ESM + CJS builds...
|
|
88
|
+
//
|
|
89
|
+
name: 'dirname',
|
|
90
|
+
setup(build) {
|
|
91
|
+
build.onLoad({ filter: /.*/ }, ({ path: filePath }) => {
|
|
92
|
+
let contents = fs.readFileSync(filePath, "utf8");
|
|
93
|
+
const loader = path.extname(filePath).substring(1);
|
|
94
|
+
contents = contents.replace("__dirname", `path.dirname(fileURLToPath(import.meta.url))`)
|
|
95
|
+
return {
|
|
96
|
+
contents,
|
|
97
|
+
loader,
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
]
|
|
82
104
|
});
|
|
83
105
|
|
|
84
106
|
// emit .d.ts files
|
package/package.json
CHANGED
package/src-backend/index.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
3
|
+
import { fileURLToPath } from 'url'; // required for ESM support. (esbuild uses it)
|
|
4
4
|
|
|
5
5
|
import { getAPI } from './api.js';
|
|
6
6
|
import './ext/Room.js';
|
|
7
7
|
|
|
8
8
|
// __dirname is not available in ESM
|
|
9
|
-
|
|
10
|
-
const getDirname = () => (typeof __dirname !== 'undefined') ? __dirname : path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
-
const frontendDirectory = path.resolve(getDirname(), "..", "build", "static");
|
|
9
|
+
const frontendDirectory = path.resolve(__dirname, "..", "build", "static");
|
|
12
10
|
|
|
13
11
|
export interface MonitorOptions {
|
|
14
12
|
columns: Array<
|