question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support using with ESM in browser

See original GitHub issue

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):

<script>
  // @see https://github.com/aws/aws-sdk-js/issues/3673#issuecomment-855205181
  var global = global || window;
</script>

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-packet

I understand this is a bigger task, so I wanted people to have an issue to upvote.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:16
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
jmklixcommented, Mar 21, 2022

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.

0reactions
bretambrosecommented, Dec 15, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"ESM" | Can I use... Support tables for HTML5, CSS3, etc
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
Using ES Modules in the Browser Today - SitePoint
The Current ES Modules Landscape ... Safari, Chrome, Firefox and Edge all support the ES6 Modules import syntax. Here's what they look like....
Read more >
How to use ESM on the web and in Node.js - ByteofDev
Today, Chrome, Safari, and Firefox fully support ESM, so you should not have any problem running it in modern browsers.
Read more >
JavaScript modules (ESM) now supported by major browsers
JavaScript modules (ESM) now supported by major browsers ... Using ECMAScript modules from ES6 / ES2015 has been a daily for many developers...
Read more >
Life with ESM | CSS-Tricks
ESM, meaning ES Modules, meaning JavaScript Modules. Like, import and friends. Browsers support it these days. There is plenty of nuance, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found