Opal 1.7, Ruby 3.2, --watch

We're excited to announce the release of Opal v1.7! This release includes support for Ruby 3.2 and the ability to watch file changes with the --watch flag.

Ruby 3.2 Support

Opal v1.7 adds support for Ruby 3.2, the latest version of the Ruby programming language. This means that you can use most of the new features and improvements in Ruby 3.2 when writing your Opal code.

Watching File Changes with the --watch Flag

Opal v1.7 introduces the --watch flag, which allows you to automatically recompile your code whenever a file is changed. This is especially useful when working on larger projects, as it saves you the time and effort of manually recompiling your code every time you make a change.

To use the --watch flag, simply pass it as an argument when running the opal command. For example:

opal --output=main.js --watch -c main.rb

This will start the Opal compiler and watch for any changes to the main.rb file. When a change is detected, the compiler will automatically recompile the code.

We hope these new features will make it easier for you to write and debug your Opal code. As always, please report any issues or feedback on the Opal GitHub repository.

If you work on macOS be sure to install v1.7.1 that includes a fix for reading the most updated content of watched files.

New runners

Support was added for running code in Deno, Firefox, and Safari, if any of those is available on your box you can try them out by passing --runner with safari, firefox, or deno.

Example:

$ # Remember to enable "Allow Remote Automation" in Safari's Develop menu
$ opal:master ⤑ bin/opal --runner=safari -ropal/platform -e "puts 'Hello from Webkit, heir of Konqueror!'"                                                     ~/C/opal
Connecting to localhost:9444...
Connecting to localhost:9444...
Connecting to localhost:9444...
Hello from Webkit, heir of Konqueror!

Resources