EnriqCG / rcon-srcds

A zero-dependency Typescript library for the Source/Minecraft RCON Protocol
https://www.npmjs.com/package/rcon-srcds
MIT License
60 stars 20 forks source link

Fix Rcon is not a constructor #27

Open nickdnk opened 6 months ago

nickdnk commented 6 months ago

Hello

This fixes https://github.com/EnriqCG/rcon-srcds/issues/13 which just broke my system (again).

I'm not very well-versed in node or modules, but I know this makes the package work as a module and prevents the above error, probably without breaking anything else, as I left the normal export default in there.

nickdnk commented 6 months ago

To clarify, the JS output from tsc simply becomes this, which seems to work fine.

// rcon.js
exports.default = RCON;
module.exports = RCON;

I'm using the package like this. All other dependencies in the project work fine using the import statement, just like the readme for this package tells me to do.

// package.json
{
  "type": "module",
  "dependencies": {
    "typescript": "^5.1.6",
    "rcon-srcds": "^2.1.0"
  }
}
// app.ts
import RCON from "rcon-srcds";

new RCON({...});

// error

For TypeScript I'm using "target": "ES2022" and "module": "ES2022"

EnriqCG commented 6 months ago

At first glance, this does not look like it's gonna be an issue. I want to make sure this works properly though, so I'll verify it before merging.

ari-party commented 4 months ago

I have published Nico's branch to @robertsspaceindustries/rcon-srcds until it is merged and published.