javascriptruby-on-rails-4v8therubyracer

using parallel array assignment with therubyracer


while calling V8::Context#load, therubyracer complains

Unexpected token [ at /home/dm/contra/app/assets/javascripts/libfigure/figure.js:120:10

That ends up being var [ who in the middle of this function:

function allemande_orbit_view(move,pvs) {
    var who = pvs[0]
    var [ who, dir, inner_angle, outer_angle, beats] = pvs
    var [swho,sdir,sinner_angle,souter_angle,sbeats] = parameter_strings(move, pvs)
...

It's complaing about using a destructuring array assignment, like this:

var [a,b] = [5,6]

I see that later versions of V8 support this ( Array destructuring assignment not working in v8 with harmony option in Node.js ), but if I put gem 'libv8', '~> 5.1', '>= 5.1.281.59.1' in my Gemfile, then bundler tells me to buss off:

Bundler could not find compatible versions for gem "libv8":
  In Gemfile:
    libv8 (>= 5.1.281.59.1, ~> 5.1)

    therubyracer was resolved to 0.12.2, which depends on
      libv8 (~> 3.16.14.0)

I look at therubyracer github page, and see the last update a year ago, and only then for v8 4.5, and it looks like it was not going well.

Sooo.... I think I'm hosed on upgrading V8, right?

Anyone know how to pass the --harmony_restructuring flag to the existing V8?


Solution

  • libv8 maintainer here.

    Unfortunately therubyracer is incompatible with versions of V8 greater than 3.16 at this point.

    If you are using it just as a JS runtime for asset compilation you should consider switching to the brand new mini_racer instead.

    As a side note, you should consider asking the maintainers of a project directly first, through their issue tracker for example, before shooting a question in SO. Your question probably would have remained unanswered had I not been by chance looking for recent questions about libv8 here.