-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support using with ESM in browser #223
Comments
Thanks for bringing this to our attention. We want to add support for ESM, but I don't have a date for when that will get added. Please continue to upvote if this is something that you want. |
Maybe, monkey patch the dependency by using an alias inside webpack/vite configuration? |
Would it be accurate to say this is an issue with mqtt-js and not the SDK? What is under SDK/CRT control that can help address this? |
The SDK can replace the dependency on non ESM packages like the mqtt one |
That is a very significant ask =/ That being said, we're not super happy with the state of mqtt-js at the moment. Haven't seen a reasonable alternative yet. Preliminary discussions about implementing a pure-JS client ourselves but that's a lot of time for uncertain payoff. |
In the mean-time we have gotten proper Websocket API support on API Gateway which provides a better alternative for our use-case. So if you need real-time updates from your IoT devices, I encourage you to look into that instead. |
As @bretambrose said, for ESM to work with this sdk it would need to work with mqtt-js. The changes need to be made in that repo. Because of this I'm going to close this feature request. |
|
@jmklix mqtt.js seems to have been updated, see mqttjs/MQTT.js#1269 |
Currently there are no examples for using the project in the browser, so I created a minimal example that creates a connection in a web application bundled using Vite.js, which uses ES modules.
This does not work, for example because the library depends on
globals
.This can be addressed by defining it (see this bug report):
However then
mqtt-packet/constants.js
is loaded, which depends on the Node.js API. ESM and browser friendly alternative exists: https://www.npmjs.com/package/u8-mqtt-packetI understand this is a bigger task, so I wanted people to have an issue to upvote.
The text was updated successfully, but these errors were encountered: