Skip to content
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

{"SyntaxError: Expected an expression but found 'class' instead"} #175

Open
sepehrbg opened this issue Mar 19, 2020 · 3 comments
Open

{"SyntaxError: Expected an expression but found 'class' instead"} #175

sepehrbg opened this issue Mar 19, 2020 · 3 comments

Comments

@sepehrbg
Copy link

sepehrbg commented Mar 19, 2020

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

@eaglemc
Copy link

eaglemc commented Mar 29, 2020

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.

@SebastianStehle
Copy link

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.

@eaglemc
Copy link

eaglemc commented Jun 9, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants