-
• #2
Here's the code before minifying.
;(function(){ var WIFI_NAME = "XXXXXX"; var WIFI_PASS = "XXXXXX"; var MQTT_HOST = "192.168.1.145"; var mqtt, wifi; mqtt = __non_webpack_require__("MQTT"); wifi = __non_webpack_require__("EspruinoWiFi"); var client = mqtt.create(MQTT_HOST); client.on('connected', function() { client.subscribe("root/branch"); }); client.on('publish', function(pub) { console.log("topic: "+pub.topic); console.log("message: "+pub.message); }); wifi.connect(WIFI_NAME, { password: WIFI_PASS }, function(err) { if (err) { console.log("Connection error: "+err); return; } console.log("Connected!"); client.connect(); }); })();
-
• #3
Here's the output that I get when I run the minified code from terminal:
=undefined Connected! Uncaught Error: Field or method "connect" does not already exist, and can't create it on undefined at line 1 col 86 ...g("Connected!"),void client.connect()) ^ in function called from system
If I paste the unminified code into the web IDE, it works.
-
• #4
Looks like an issue with
void
only parsing an ID, not the whole expression - I just created a bug for it: https://github.com/espruino/Espruino/issues/1079Bit busy now but it should be an easy fix.
Here's some code that webpack and uglify produced, but Espruino web IDE says it has a lot of problems. I don't see what's wrong with it though.