Closed orryoracle closed 4 years ago
Ahh, sorry - yes, I believe this is a bug in the Esprima minifier which minifies modules by default. A few months ago I updated but it looks like it's still buggy :(
The easy solution is just to add --config MODULE_MINIFICATION_LEVEL=
to the command-line, which should disable module minification. --config MODULE_MINIFICATION_LEVEL=TERSER
may also help.
I'll leave the issue open and will see if I can update the minifier, however it may be it makes more sense just to remove it and switch to Terser
--config MODULE_MINIFICATION_LEVEL=TERSER works - thanks!
Actually, --config MODULE_MINIFICATION_LEVEL=TERSER
throws error and import modules unminified (which works I guess):
Terser errors in WifiManager - sending unminified code. DefaultsError:
minifyFnis not a supported option
Looks like not only modules are affected. I'm getting unexpected results with this code:
const photoresistor = Pin(B1);
E.on('init', () => {
photoresistor.mode('analog');
});
setInterval(() => {
analogWrite(LED1, analogRead(photoresistor), { soft: true });
}, 300);
It doesn't produce any errors but LED keeps blinking. I was expecting LED to stay lit, just like it does when I upload the same code with Chrome App.
So what command line are you using for the upload? and please can you post the output after adding -o out.js
to the command line?
I'm using VSCode with the Espruino tools to develop using Espruino WiFi.
Function calls using arrow function such as:
setTimeout(()=>{ console.log('foo')},1000);
Works in main file, but throws syntax error when used in modules and then used in main file:
>Uncaught SyntaxError: Got ';' expected ',' at line 1 col 34 setTimeout(()=>console.log('foo');,1000),exports.foo=10;
(with ^ pointing at semicolon before
,1000
)Am I missing anything in flags etc when calling
espruino
?