-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Bug]: bundler hard code navigator
in mqtt.esm
#1905
Comments
navigator
navigator
in mqtt.esm
Would you like to submit a PR to fix this issue? |
After investigation, the issue is because of Line 31 in 11bb9bd
from Lines 20 to 33 in 11bb9bd
If I remove that line, navigator is untouched, and so it works as expected, but I guess I cannot PR that because of #1789. |
Wondering if we can have a different solution for wechat, maybe if they add a navigator polifilly before importing mqtt it could work? |
So if I understand correctly, you're not against a PR that removes out-of-the-box support for WeChat? Here is what I propose: Advantage/Disadvantage: Let me know if you think it is valuable for the project, or any other idea; I would be happy to make a PR that would allow to easily support all runtime/envs that have native WebSocket support. |
Yeah I'm not, they already have to import some polifilly: https://github.com/mqttjs/MQTT.js#wechat-and-ali-mini-program-support I'm ok with all implementatins that do not break existing things (except the one about wechat I mentioned above) |
MQTTjs Version
5.8.0
Broker
mosquitto
Environment
Browser
Description
The variable
navigator
, used to determine some env, like tkiki.js #1895, is replaced by a content determined at bundle time, namely:P={deviceMemory:8,hardwareConcurrency:8,language:"en-US"}
if you look atmqtt/dist/mqtt.esm
. And because of that, it is impossible to determine the runtime using this technique (thus the WebSocket lib choice is wrong).Minimal Reproduction
mqtt/dist/mqtt.esm
txiki.js
and see that the code from feat: add compatibility with txiki.js #1895,navigator.userAgent==="txiki.js"
has been transformed inP.userAgent==="txiki.js"
P=
and see that the value assigned isP={deviceMemory:8,hardwareConcurrency:8,language:"en-US"}
console.log(P)&&
beforeP.userAgent==="txiki.js"
Debug logs
The text was updated successfully, but these errors were encountered: