{"SyntaxError: Expected an expression but found 'class' instead"}
When i am trying to execute a file of javascript, i am getting following error as it is containing a class. for other files which only contains functions it is not giving any errors, only for the file with javascript class it is throwing exception. here is the exception: {"SyntaxError: Expected an expression but found 'class' instead"} and here is my code:
var scriptEngine = new ScriptEngine();
scriptEngine.EnableDebugging = true;
string console = "";
scriptEngine.ExecuteFile(@"SQLProJSQueryFormatter.js");
Anybody can help??
See https://github.com/paulbartrum/jurassic/blob/master/README.md
class is a part of ECMAScript 6 that isn't supported yet.
Your best bet is to transpile your script to ECMA 5.
Hi, do you have any experience with transpiling? I tried to get this project working in jurassic: https://github.com/jpknoll/mjml-aspnetcore
It takes around 20ms to compile a small template and I thougt jurassic might be faster than a node service, but Just failed to get it transpile. Babel just doe not convert arrow functions.
Not exactly. I've only done stuff with compiling TypeScript.
The TypeScript compiler can handle arrow functions, but I'm not sure what it does if you give it a .js file instead of a .ts file as the input. However there is an --allowJs flag to let you do this, so maybe it would work?