-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: switch to esbuild * chore: change module imports to relative so esbuild can find them
- Loading branch information
Showing
304 changed files
with
11,402 additions
and
3,161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin"; | ||
import fs from "node:fs"; | ||
import esbuild from "esbuild"; | ||
import { createRequire } from "node:module"; | ||
|
||
const require = createRequire(import.meta.url); | ||
|
||
const nativeNodeModulesPlugin = { | ||
name: "native-node-modules", | ||
setup(build) { | ||
// If a ".node" file is imported within a module in the "file" namespace, resolve | ||
// it to an absolute path and put it into the "node-file" virtual namespace. | ||
build.onResolve({ filter: /\.node$/, namespace: "file" }, (args) => ({ | ||
path: require.resolve(args.path, { paths: [args.resolveDir] }), | ||
namespace: "node-file", | ||
})); | ||
|
||
// Files in the "node-file" virtual namespace call "require()" on the | ||
// path from esbuild of the ".node" file in the output directory. | ||
build.onLoad({ filter: /.*/, namespace: "node-file" }, (args) => ({ | ||
contents: ` | ||
import path from ${JSON.stringify(args.path)} | ||
try { module.exports = require(path) } | ||
catch {} | ||
`, | ||
})); | ||
|
||
// If a ".node" file is imported within a module in the "node-file" namespace, put | ||
// it in the "file" namespace where esbuild's default loading behavior will handle | ||
// it. It is already an absolute path since we resolved it to one above. | ||
build.onResolve( | ||
{ filter: /\.node$/, namespace: "node-file" }, | ||
(args) => ({ | ||
path: args.path, | ||
namespace: "file", | ||
}), | ||
); | ||
|
||
// Tell esbuild's default loading behavior to use the "file" loader for | ||
// these ".node" files. | ||
let opts = build.initialOptions; | ||
opts.loader = opts.loader || {}; | ||
opts.loader[".node"] = "file"; | ||
}, | ||
}; | ||
|
||
esbuild | ||
.build({ | ||
sourcemap: "external", // Source map generation must be turned on | ||
platform: "node", | ||
outdir: "dist", | ||
entryPoints: ["apps/main/server.ts"], | ||
format: "esm", | ||
metafile: true, | ||
bundle: true, | ||
packages: "external", | ||
banner: { | ||
js: "import * as path from 'node:path';import { createRequire } from 'module';import { fileURLToPath } from 'node:url';const require = createRequire(import.meta.url);const __dirname = path.dirname(fileURLToPath(import.meta.url));", | ||
}, | ||
plugins: [ | ||
nativeNodeModulesPlugin, | ||
// Put the Sentry esbuild plugin after all other plugins | ||
sentryEsbuildPlugin({ | ||
authToken: process.env.SENTRY_AUTH_TOKEN, | ||
org: "drazisilcom", | ||
project: "rusty-motors-server", | ||
}), | ||
], | ||
}) | ||
.then((result) => { | ||
fs.writeFileSync("meta.json", JSON.stringify(result.metafile)); | ||
}) | ||
.catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,19 @@ | |
"name": "rusty-motors", | ||
"version": "1.0.1", | ||
"description": "This is a game server, being written from scratch, for a very old and long dead game. The owners of said game have shown no interest in bringing it back, but even so all names of their IP have been avoided to prevent issues.", | ||
"main": "index.js", | ||
"type": "module", | ||
"exports": { | ||
".": "./dist/index.js" | ||
}, | ||
"scripts": { | ||
"test": "tsc && eslint --fix . && prettier --write . && node --openssl-legacy-provider node_modules/vitest/vitest.mjs run --coverage packages thebeast", | ||
"start": "pnpm --filter @rustymotors/server start" | ||
"lint": "tsc", | ||
"build": "node build.mjs", | ||
"start": "node --openssl-legacy-provider --env-file=.env dist/server.js", | ||
"dev:rsc": "tsc --watch --preserveWatchOutput", | ||
"dev:node": "node --watch dist/apps/main/server.js", | ||
"dev:esbuild": "pnpm run build --watch", | ||
"dev": "run-p dev:*", | ||
"test": "eslint --fix . && prettier --write . && node --openssl-legacy-provider node_modules/vitest/vitest.mjs run --coverage packages thebeast" | ||
}, | ||
"author": "Molly Crendraven <[email protected]>", | ||
"license": "AGPL-3.0", | ||
|
@@ -16,24 +24,33 @@ | |
"url": "[email protected]:drazisil/mcos.git" | ||
}, | ||
"devDependencies": { | ||
"@sentry/node": "^7.108.0", | ||
"@sentry/profiling-node": "^7.108.0", | ||
"@slonik/migrator": "0.12.0", | ||
"@types/node": "20.11.30", | ||
"@vitest/coverage-v8": "1.4.0", | ||
"esbuild": "^0.20.2", | ||
"eslint": "8.57.0", | ||
"eslint-config-prettier": "9.1.0", | ||
"eslint-plugin-prettier": "5.1.3", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "3.2.5", | ||
"typescript": "5.4.3", | ||
"vitest": "1.4.0" | ||
}, | ||
"dependencies": { | ||
"@fastify/sensible": "^5.5.0", | ||
"@rustymotors/database": "workspace:^", | ||
"@rustymotors/shared": "workspace:^", | ||
"@rustymotors/shared-packets": "workspace:^", | ||
"@sentry/node": "^7.102.0", | ||
"@sentry/profiling-node": "^7.104.0", | ||
"@sentry/esbuild-plugin": "^2.16.0", | ||
"fastify": "^4.25.2", | ||
"pino": "^8.18.0", | ||
"pino-pretty": "^11.0.0", | ||
"short-unique-id": "^5.0.3", | ||
"slonik": "37", | ||
"tsx": "^4.7.1" | ||
"tsx": "^4.7.1", | ||
"zod": "^3.22.4" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { SubThread } from "../shared/index.js"; | ||
import { Gateway } from "../gateway/src/GatewayServer.js"; | ||
import type { TServerLogger } from "../shared/index.js"; | ||
/** | ||
* @module ConsoleThread | ||
*/ | ||
/** | ||
* Console thread | ||
*/ | ||
export declare class ConsoleThread extends SubThread { | ||
parentThread: Gateway; | ||
/** | ||
* @param {object} options | ||
* @param {Gateway} options.parentThread The parent thread | ||
* @param {ServerLogger} options.log The logger | ||
*/ | ||
constructor({ | ||
parentThread, | ||
log, | ||
}: { | ||
parentThread: Gateway; | ||
log: TServerLogger; | ||
}); | ||
/** @param {import("../interfaces/index.js").KeypressEvent} key */ | ||
handleKeypressEvent( | ||
key: import("../interfaces/index.js").KeypressEvent, | ||
): void; | ||
init(): void; | ||
run(): void; | ||
stop(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.