We are happy to announce that Opal 1.6 and Opal-RSpec 1.0 are out!
Opal-RSpec is an Opal port of RSpec, a well known Ruby testing tool, allowing you to easily test your Ruby applications in browser and in Node, just like you can do so with MRI.
This release of Opal is focused primarily on improving upon MRI compatibility. We now fully support freezing and also we now have a new robust and hackable control flow instruction handling implementation (think:
return...). Also, Windows support has been improved and Opal gained a parallel compile support - significantly improving compile times on multicore systems. In addition, the
await subsystem is no longer experimental.
Try it now on opalrb.com/try, or get started instantly with no further steps required (except for installing Ruby):
gem install opal # Try either of the following examples: opal -e 'puts "Hello world!"' opal -ce 'puts "Hello world!"' > hello_world.js; node hello_world.js opal -OcEe 'puts "Hello world!"' # Or run it in a web browser: bundle init bundle add opal-browser puma bundle add rack -v '< 3' bundle exec opal -Rserver -qopal-browser -rbrowser -e '$document.write("Hello world!")'
One of those features is freezing. Thanks to @janbiedermann, we now have a robust freezing system across the codebase, using carefully crafted
We have working proof-of-concept patches to make mutable strings work, but they still need some time to mature...
Robust control flow instructions system (aka closure tracking)
Most of the time Opal gets control flow instructions (namely:
retry) correctly. Many Ruby gems can work with Opal verbatim, perhaps just needing easy adjustments due to our lack of mutable strings. But sometimes, for unknown reasons, we can get a
break wrong and have no easy answer why a Gem doesn't work. Well, no more.
Introducing closure tracking: we did a refactor of our codebase, moving (unifying and heavily improving) all the control flow instructions logic in a single 250 line file. Doing this, allowed us to easily close 4 old issues and get many more MSpec Ruby Specs passing.
We are aware that this is still not perfect and perhaps we haven't covered some edge cases. But the simplification of the code will easily allow us to improve upon those in the future.
If you update your code to Opal 1.6, you may encounter some issues if you relied on old behavior
For those of you, that use Windows as your development platform, we have prepared a lot of bugfixes to support all the development tools we provide. Also the compiler and generated source maps treat Windows line endings correctly. We also now run full test suites on Windows machines to ensure Opal remains fully working on Windows in the future.
There will be a significant performance improvement for code or DSLs that use a lot of blocks.
Parallel compilation (aka prefork)
In this release we introduce parallel compilation for
Opal::Builder, which will cause our Ruby process to fork a number (3/4 of your CPU core count by default) of processes that will compile every file of your application in parallel.
Until recently, it used to be a big problem with Opal, that compile times were slow. Because a large part of the Opal core and standard libraries are also written in Ruby, those are also needed to be compiled with your application. We used to do most of our Opal application development using Sprockets, which supported caching (albeit with some unfortunate bugs and caveats...) and since Opal 1.3 we have a robust caching support everywhere, without needing Sprockets.
Truth be told, Sprockets is now moving to maintenance mode and so is Opal-Sprockets (we are still committed to supporting it, because we understand it's widely used in production). In the meantime we are focusing on
opal CLI command, but also
Opal-RSpec has been updated to now use the latest RSpec version. A huge part of Opal-RSpec has been rewritten. We now support diffs and provide a source fragment. We also now have a robust support for async tests - either using promises, or using await facility of Opal. This also means there's a slight incompatibility, because we need to use
PromiseV1 (which as of yet is still a default
We have decided to break compatibility with anything lesser than Opal v1.6 - if you still depend on an older Opal version, you can keep using Opal-RSpec v0.8 and we will still accept patches for this version.
Please take a look at the README to take note of other incompatible changes since v0.8.
As always this version brings a lot of other bug fixes and small improvements, please have a look at the full changelog. If you want to know more, have questions, or want to start contributing, please join the Slack channel and ask around, we're always happy to welcome new people to the community!