Paper.js: Support ES 2015 in Paperscript

Created on 20 Oct 2016  Â·  13Comments  Â·  Source: paperjs/paper.js

Paper.js currently uses Acorn 0.5.0, which only parses ES5. ES 2015 support would be awesome! I'm sending a pull request to update.

paper-script feature

Most helpful comment

As of 0ec06e7353f6119401aed87d9a3678756ce8dea0, this now works:

screen shot 2017-03-11 at 20 55 28

All 13 comments

Update! Made a fork and updated Acorn. It largely worked but we ran into some unexpected issues that I _think_ might be from acorn. Made an issue with them. It really looks like an off by one error.

Interesting. I am weary of including a newer Acorn at the moment as it has increased in size a lot... But I guess there's no avoiding that in the longer term? Another option could also be to prioritize an already loaded version of Acorn over the one that's internally bundled?

That's an interesting idea. If you could pass a parser into paper that might solve the problem. Is Esprima smaller than acorn? I imagine both grew because of ES2015.

We started with Esprima, but Acorn.js used to be much smaller than Esprima. Not sure where they stand now. Will investigate! This passing in of a newer Acorn should be fairly simple to achieve... I will look into it.

Linking to PR #1185 that I didn't see until now.

So I am working on this now, and it is fairly easy to implement. The only issue I am seeing is that for versions of Acorn.js v0.10.0 and above, we need to pass the preserveParens option to it in order to have the same results as with v0.5.0 (see #1275).

That's a non-standard option, and Esprima doesn't offer it, so I think we're now locked to Acorn.js, which is fine with me.

So since 5dafc67278db68e4154a7895bf4c26c944a1ed7b, you can now work with external versions of Acorn.js. In NodeJS, it needs to simply be present in node_modules and will be preferred over the bundled version. In browsers, you can either have it present in the global scope as acorn object, or load it through any mechanism that works with calls to require('acorn'), just like on NodeJS.

This should suffice?

This seems massively useful! What would it take to get the sketch editor to use a different parser?

Thanks,
-Zeke

On Mar 10, 2017, 9:58 AM -0600, Jürg Lehni notifications@github.com, wrote:

So since 5dafc67, you can now work with external versions of Acorn.js. In NodeJS, it needs to simply be present in node_modules and will be used. In browsers, you can either have it present in the global scope as acorn object, or load it through any mechanism that works with calls to require('acorn'), just like on NodeJS. This should suffice?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

At the moment, that's not possible. But with a very simple change, all it would take is to request the file at the beginning of your script, e.g.:

include('https://cdnjs.cloudflare.com/ajax/libs/acorn/4.0.11/acorn.js');

I will think about this.

As of 0ec06e7353f6119401aed87d9a3678756ce8dea0, this now works:

screen shot 2017-03-11 at 20 55 28

That's very helpful, thank you!

On Mar 11, 2017, 1:56 PM -0600, Jürg Lehni notifications@github.com, wrote:
>

As of 0ec06e7 (https://github.com/paperjs/paper.js/commit/0ec06e7353f6119401aed87d9a3678756ce8dea0), this now works:

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub (https://github.com/paperjs/paper.js/issues/1183#issuecomment-285895627), or mute the thread (https://github.com/notifications/unsubscribe-auth/AA6u6fNZ8Ijbhc8LEnP-3Gbvzx8Duvcuks5rkvxQgaJpZM4KchiR).

v0.11.0 has just been released, and sketch.paperjs.org update accordingly:

This now just works!

Amazing!!!!

Zeke

On Apr 19, 2017, 4:20 PM -0500, Jürg Lehni notifications@github.com, wrote:

v0.11.0 has just been released, and sketch.paperjs.org update accordingly.
This now just works
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sansumbrella picture sansumbrella  Â·  3Comments

kaelumania picture kaelumania  Â·  6Comments

hapticdata picture hapticdata  Â·  5Comments

JohnMcLear picture JohnMcLear  Â·  5Comments

eljefedelrodeodeljefe picture eljefedelrodeodeljefe  Â·  5Comments