Opal 0.11.0: Parser gem, Safe navigator (&.), Random seed support, Constant lookup

Hello everyone!

I'm very happy to announce that after more than a year in the making Opal v0.11.0 has finally been released!

This version is probably the last one before 1.0, it's packed with great new features, a ton of fixes and a complete reimplementation of the parser.

Notable Changes since Opal v0.10.0

Renewed parser

The new parser is much stricter, so expect some code that was happily parsed to be rejected. The good news is your code will be even closer to the standard, and the parser's error messages are generally better and will tell you exactly where the syntax error is.

Constant lookup

The constant lookup system has been rewritten and now the algorithm is closer to what MRI does while still taking advantage of an aggressive cache.

Sprockets extraction

Opal::Server was relying on Sprockets which is now extracted to the resurrected opal-sprockets gem and can be found under Opal::Sprockets::Server.

The opal gem still provides a basic server which can be accessed as Opal::SimpleServer. The simple server uses the internal Opal::Builder instead of Sprockets and has kept the same API where possible.

Headless Chrome

Headless Chrome is the new standard, while phantomjs has been officially abandoned.

Opal v0.11.0 replaced the phantomjs CLI runner with chrome. While there's no plan to restore support for phantomjs if your app really needs it please contact the core team on GitHub or Gitter, if there's enough interest we'll do our best to extract and publish phantomjs runner code as an external gem.

Dynamic requires

Pre-compiling Ruby into JavaScript doesn't go along well with dynamic calls to require, but Opal goes out of its way to infer the required path (e.g. it parses calls to File.expand_path and resolves them at compile time).

Previously whenever a call to require couldn't be resolved it ended in raising an exception and blocked the compilation, often unnecessarily forcing the user to add the requested path to stubs (see the Opal::Config documentation).

With Opal v0.11.0 calls to require that cannot be resolved at compile time will just be ignored and will raise a LoadError at runtime if the given path still isn't found. This is closer to what happens under MRI. It's still possible to revert back to the old behavior by settings Opal::Config.dynamic_require_severity = :error (see the relevant code in opal/config.rb).

Read the Changelog for further details

As always, Opal 0.10 includes many bug fixes and improvements to the internals of the Opal libraries, so be sure to read the changelog for further details.


As always, huge thanks to the many contributors who helped with this release.