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

Support ES6 and beyond #186

Open
KRISACHAN opened this issue Mar 27, 2020 · 16 comments
Open

Support ES6 and beyond #186

KRISACHAN opened this issue Mar 27, 2020 · 16 comments

Comments

@KRISACHAN
Copy link

...
I saw the lib, acorn.js's version just 0.4.1 ....
If I use the high version ecmascript code , for example :

for (let i of [1, 2, 3]) {
console.log(i)
}

It will throw an error ...

The last version of acorn.js is 7.1.0 ,but Js-Interpreter only 0.x

Too terrible

@KRISACHAN KRISACHAN reopened this Mar 27, 2020
@cpcallen
Copy link
Collaborator

The limiting factor is not Acorn (though updating it might not be a bad idea anyway), but that JS Intrpreter itself only understands ES5.1. So being able to parse for ... of loops wouldn't help, because the interpreter still wouldn't know how to execute them.

Nevertheless, since no one seems to have opened a "please support ES6" issue yet, I'll repurpose your report accordingly.

@cpcallen cpcallen changed the title Why not upgrade acorn.js Support ES6 and beyon Mar 27, 2020
@cpcallen cpcallen changed the title Support ES6 and beyon Support ES6 and beyond Mar 27, 2020
@KRISACHAN
Copy link
Author

KRISACHAN commented Mar 27, 2020

Thank you for your answer
I try to repackage with [email protected] just now .

Link here:
https://github.com/KRISACHAN/acorn_interpreter.bundle.js

I don't know if it's a good idea .
:)

Happy Weekend !

@cpcallen
Copy link
Collaborator

I try to repackage with [email protected] just now.

Just make sure you specify the appropriate options to Acorn so that it will parse ES5 only.

@sag1v
Copy link

sag1v commented Mar 28, 2020

@cpcallen
Supporting ES6+ features would be awesome, this is the only "deal breaker" for me of using the lib.
Is it something you are considering doing?

@cpcallen
Copy link
Collaborator

Is it something you are considering doing?

This is a question for @NeilFraser—but I suspect the answer is no, because this will eventually be part of the roadmap of another project (which is actually funded, unlike this one), so in a few years we will have a much better solution.

In the mean time, I would suggest using an ES6->5 transpiler. I have heard that Babel can do this.

@sag1v
Copy link

sag1v commented Mar 28, 2020

Thanks @cpcallen. Actually my use case for this library is to create a JavaScript "visualiser" (similar to devtools), not sure babel can help with this as it will change that actual code i want to visualise.

@analog-hors
Copy link

Same here, I have tried using source maps to correct this, but they don't seem to come out correctly.

@NeilFraser
Copy link
Owner

NeilFraser commented Apr 9, 2020 via email

@sag1v
Copy link

sag1v commented Apr 12, 2020

@KSean222 What do you mean by

... using source maps to correct this...

@analog-hors
Copy link

analog-hors commented Apr 12, 2020

@sag1v https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map
Babel can generate source maps when converting to ES5.

@sag1v
Copy link

sag1v commented Apr 13, 2020

https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map
Babel can generate source maps when converting to ES5.

Yeah i know, but how do you think it to sync them? Sounds interesting

@analog-hors
Copy link

I tried using https://github.com/mozilla/source-map @sag1v

@cheapsteak
Copy link

Is it something you are considering doing?

This is a question for @NeilFraser—but I suspect the answer is no, because this will eventually be part of the roadmap of another project (which is actually funded, unlike this one), so in a few years we will have a much better solution.

In the mean time, I would suggest using an ES6->5 transpiler. I have heard that Babel can do this.

What is the name of the funded project?

@cpcallen
Copy link
Collaborator

cpcallen commented Sep 2, 2020

What is the name of the funded project?

Code City. But do note: "will eventually be part of the roadmap"—in its present form Code City is actually a less-complete JavaScript implementation than JS Interpreter is.

@bendavis78
Copy link

I'm very interested in this, as it would be useful for creating a client-side step debugger for Theia IDE.

In theory, how much work are we talking to make this happen? Would it require a major re-write of the interpreter? Or is it just adding ES-6 specific features?

@cpcallen
Copy link
Collaborator

@bendavis78: It would be a considerable amount of work. ES6 is quite a bit larger language than ES5.1, and ES2020 is even more so. I don't think it necessarily requires a throw-it-away-and-start-from-scratch rewrite: it could certainly be done incrementally—but by the time it was done very little of the original code base will remain.

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

No branches or pull requests

7 participants