Description
I'm seeking input on an idea for moving this repo forward.
My team at Microsoft uses MQTT to communicate with the Azure IoTHub service. __MQTT.js does an excellent job here, but, frankly, it's starting to show its age. It was written when the node.js ecosystem was less mature, and it has evolved as the ecosystem changed. Many (but not all) of these "evolutionary steps" were bolted-on pieces of technology that "added a little more to MQTT.js". The result is code that does what it needs to do, but it’s hard to understand and even harder to change.
@YoDaMa and @vishnureddy17 looked at this problem and started to build an updated version of this library from the ground up. This is a noble pursuit. It’s also extremely easy to underestimate how difficult it is. While MQTT, the transport, is relatively simple, libraries with thousands of dependents, like MQTT.js, are not so simple. The thousands of dependents, or customers, or users, or whatever you want to call yourselves are what make MQTT.js powerful. "Rebuilding from the ground up" means "moving forward by moving away from these customers." I personally do not like this idea.
Instead, we should take the time and take a large evolutionary step to bring the existing MQTT.js code "into the modern age." We should call this MQTT.js version 5.0.0, with the major version change from 4 to 5 showing that this is a breaking change. But we should only break things when there is a clear advantage. Changes in API or behavior from version 4.7.3 to version 5 should be justified and documented. Customers who want to "play it safe" can use semantic versioning rules in package.json to make sure they do not get version 5. Other customers who want to "follow along" shouldn’t need to make major changes, but we cannot guarantee this.
We should convert this code to typescript. I have done this as a POC (proof-of-concept). The extra type information has shown me so many places where the code is sloppy and could be tightened up, especially around options and client properties and callback signatures. You can see my POC here
We should also start using prettier and eslint on the code. I hate arguing about "what format is correct" for pretty-printers. I love being able to write code without worrying about formatting because I know it will get automatically formatted. Unfortunately, this means that every line of code gets changed, and merges from "pre-prettier" code into "post-prettier" code gets ugly. I wish I knew a way to avoid this.
We should start publishing commonjs and ECMAScript side-by-side if we can. It's too bad that there is still a distinction here, but I think we can make both sides happy without picking a side.
We need to make sure the browserified packages still work, but I assume they will change. I'm less clear on details here, but I assume that webpack and ECMAScript is the way that people want to go. I could be wrong, and we have options here.
If we can do these things, then the code will be ready for some interesting changes. I have a ton of ideas and opinions here, but I do not want to cloud the discussion just yet. :)
I'm curious to hear what people think. Some of the things I have said here are strong beliefs. Others just seem like the right path.
Tagging an arbitrary list of active/recent contributors to get your attention. Apologies for the spam.
@mcollina, @vishnureddy17, @YoDaMa, @redboltz, @scarry1992, @radekg, @ysfscream, @sublimator, @RangerMauve, @4rzael, @anhldbk, @bkp7, @nosovk, @robertsLando, @ogis-yamazaki, @ryanwinter, @anthonyvercolano