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

Ecma v6 #274

Closed
Jugolo opened this issue Mar 1, 2016 · 13 comments
Closed

Ecma v6 #274

Jugolo opened this issue Mar 1, 2016 · 13 comments

Comments

@Jugolo
Copy link
Contributor

Jugolo commented Mar 1, 2016

Will jint support ecma version6?

@sebastienros
Copy link
Owner

Eventually. It's been a very popular question/request so I think it should be worth considering, even more that the current implementation looks quite complete and bug free. The new spec is about to be released in the next weeks, so why not start on it.

The plan could be to add support for specific features one by one and release as they are ready. The parser and object model could be done as a whole first, the same way I did for ES5, then tackle each ES6 feature. Could even be a common effort.

I also need to find a good test suite to validate the features.

@Jugolo
Copy link
Contributor Author

Jugolo commented Mar 2, 2016

Create will see if i can get some time to make puæl requst :)

@dested
Copy link

dested commented Mar 21, 2016

To achieve support for this I am passing the typescript source into jint, and passing my source into that. Its actually not as slow as I anticipated, and I have es6 support (as well as typescript!)

Some pseudocode

var typescript = File.ReadAllText("js/typescript/typescript.js");
var mc = engine.Execute(typescript);
var tsc = mc.GetValue("ts");
var cc = tsc.AsObject().Get("transpile");
var c = cc.Invoke(YOURACTUALSOURCECODESTRING).AsString();
var result = engine.Execute(c);

@sebastienros
Copy link
Owner

Thought about it but had never tried, that's awesome. We could even imagine a mode where Jint would load typescript automatically to execute Ecma2015. With just an option.

Or something like:

var engine = new Engine();
var result = engine.Execute(someScript, Version.Ecma2015);

On the first call of this option, we just need to load TypeScript from a resource file. It would be reused across the engine calls, and would not impact the current perf as this would be injected on demand.

@dested
Copy link

dested commented Mar 22, 2016

I have done it with a fair amount of success. The initial transpile hit is rough, but post that the code it produces is clean and performant. Could be an interesting flag, you just need to keep up with the typescript versions which is ever changing.

@sebastienros
Copy link
Owner

Some news on ES6 side. For the past few months I have been actively working of implementing support for ES6. This is a huge work be I made some progress.

The plan is this:

  • Port the ES6 version of the Esprima parser to C#, like I had done for ES5 which is currently used in Jint.
  • Update Jint 2 to use the new ES6 parser instead, and deprecate the old parser.
  • Implement each ES6 feature in parallel.

The new parser will probably be released as a separate package, just to ensure that one can use it by itself, to do crazy stuff with JS manipulation.

Good news is that as of this morning I have a complete ES6 parser. It is not in a packageable form yet, but all the unit tests from Esprima are working. It includes syntax errors and range/location information.
Once the parser is integrated, everyone will be able to help on implementing the new features, and benefit from it.

@sebastienros
Copy link
Owner

It's on github now: https://github.com/sebastienros/esprima-dotnet

@sebastienros
Copy link
Owner

Annoucement #343

@Jugolo
Copy link
Contributor Author

Jugolo commented Oct 30, 2016

Create :) thanks :)

@nixonad
Copy link

nixonad commented Mar 8, 2018

@dested : I tried the suggested code to import typescript and use the transpiler.
I get this "Message: Esprima.ParserException : Line 27': Duplicate proto fields are not allowed in object literals" when executing the typescript.js file (version 2.6.2)

Anyone else using typescript like this?

@gentledepp
Copy link
Contributor

@dested could you provide some demo project?

In general: I like the idea of having typescript-support in Jint.
However, I do believe that it is not its main focus.

So maybe there should be something like an additional jing-typescript package

E.g.

  • jint
  • jint.typescript (depends on jint, typescript)

@dested
Copy link

dested commented Jan 17, 2019

@gentledepp

This was mid 2016, I was using TypeScript 1.6, I haven't tried it on later versions. The code worked something like this

var typescript = File.ReadAllText("js/typescript/typescript.js");
var typescriptProgram = engine.Execute(typescript);
var tsc = typescriptProgram.GetValue("ts");
var transpileFunc = tsc.AsObject().Get("transpile");
var jsOuput = transpileFunc.Invoke(typeScriptProgram).AsString();
var jsProgram= engine.Execute(jsOuput);

@lahma
Copy link
Collaborator

lahma commented Apr 22, 2020

Please follow #343 for updates, things are progressing and updates are sent there.

@lahma lahma closed this as completed Apr 22, 2020
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

6 participants