EnriqCG / rcon-srcds

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

Convert export to default export #11

Closed c43721 closed 3 years ago

c43721 commented 3 years ago

Reason for this change is because of the following:

import Rcon from 'rcon-srcds';

// Results in TypeError: rcon_srcds_1.default is not a constructor

However, if we use the alternative syntax to import everything as a constant:


import * as Rcon from 'rcon-srcds';

// Results in This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.

Changes:

// Old
export = RCON

// New
export default RCON

With the default export, everything works as expected.

EnriqCG commented 3 years ago

Default export in an ECMAScript2017+ context makes sense. This module was originally written in 2018 in plain JS, and export = RCON was the normal convention 🤷‍♂️.

This is a very welcome change. Thanks, @c43721.

EnriqCG commented 3 years ago

Release v.2.0.1 has been published to NPM including changes in this PR.

c43721 commented 3 years ago

Awesome! I'll change over my backend to use this package now.