Questions tagged [opalrb]

Opal is a Ruby to JavaScript source-to-source compiler. It comes packed with the Ruby corelib you know and love. It is both fast as a runtime and small in its footprint.

Opal is a Ruby to JavaScript compiler. It is source-to-source, making it fast as a runtime. Opal includes a compiler (which can be run in any browser), a corelib and runtime implementation. The corelib/runtime is also very small.

Opal is hosted on github, discussed on Gitter, has a Freenode IRC channel at #opal and is on twitter @opalrb.

More documentation can be found in the docs.

92 questions
1
vote
1 answer

Are threads coming to opal?

So, I read here, that we don't have access to threads from javascript. But thats not really true, is it? We do have some sort of thread support from javascript (with workers?). It's not going to be impossible. Is this the issue or am I…
Moon4u
  • 127
  • 1
  • 8
1
vote
1 answer

Constants in OpalRB

I'm wondering about something in a project of mine with OpalRB (the Ruby-to-JavaScript compiler): when you make a constant in Opal, like so: ONE = 1 ... is that essentially the same thing as saying this is JavaScript?: const ONE = 1; The reason…
GDP2
  • 1,948
  • 2
  • 22
  • 38
1
vote
1 answer

Is there a way to show the Ruby line numbers in javascript generated by Opal

For debugging purposes I would like to see the corresponding Ruby Source position in the javascript file generated by Opal. Is there a simple way to achive this? I tried # config.ru require 'bundler' Bundler.require run Opal::Server.new { |s| …
Bernhard
  • 686
  • 8
  • 20
1
vote
2 answers

OpalRB Ignore compile directive

I'm building an application that will be hosted both as a stand-alone app as well as running within the web browser. This means that certain classes should be implemented differently (but used in the same way). Example: If OPAL_RB require…
mikabytes
  • 1,818
  • 2
  • 18
  • 30
0
votes
1 answer

Opal ruby Rake task failing with error FrozenError: can't modify frozen Array

In my web application I am trying to use Opal to program Javascript. ruby-3.1.2 opal-1.7.3 opal-jquery 0.4.6 I am using guard-rake to automatically compile any changes made to my opal files. Following are the relevant code…
Jignesh Gohel
  • 6,236
  • 6
  • 53
  • 89
0
votes
1 answer

Why does `require 'native'` throw an exception in opalrb?

I'm taking baby steps with opalrb, here is my main.rb: require 'native' def main puts "hi from the main function in main.rb" end def demoButton outputDiv = Element.find('output').get(0) puts outputDiv.methods.sort end It's included…
Vasiliy Sharapov
  • 997
  • 1
  • 8
  • 27
0
votes
1 answer

How can I parse a URL in Opal?

Let's say I have a URL that I want to parse, including the query string: https://www.example.com/foo?bar=1&a[]=x&a[]=y I would expect to be able to obtain a hash of the query string like: { "bar" => "1", "a" => ["x", "y"] } How can I parse this…
Benjamin Oakes
  • 12,262
  • 12
  • 65
  • 83
0
votes
1 answer

What's the point of using Opal?

Opal looks like nice library, but I'm not sure if there is real use for it. How do you use it? Or is it just a curiosity?
Łukasz Cupak
  • 46
  • 1
  • 5
0
votes
1 answer

how can get proc content using Opalrb parser

I need to get the content of a proc send to js by Opal ruby. I am only using the static version of Opal, Opal-native, opal-parser. how can I proceed ? def parse_proc params #### how can I get proc content? end def touch(&proc) parse_proc…
0
votes
1 answer

Could not setup webrick https server + sinatra + opalrb(sprockets)

I want to make my simple sinatra application with OpalRb Sprockets works over webrick https. But it doesn't work. For each generated opal js file returns 404 : [22/Oct/2019:17:48:17 HDT] "GET…
0
votes
1 answer

I get an JS error Opal.const_get_relative is not a function when compiling ruby into js

I have a Ruby function translated into JS by Opal that has always worked fine, but suddenly it does not work anymore. The JS console gives me this error message Opal.const_get_relative is not a function The original Ruby code is…
andreheijstek
  • 71
  • 1
  • 9
0
votes
1 answer

UTF8 String With Accents In Opal

I'm trying to use a UTF8 string with accents in Opal. Ruby Code: test = "Français" puts test $document['#test'].inner_html = test Compiled JavaScript : test = "Fran\xC3\xA7ais"; self.$puts(test); return (($a = [test]), $b =…
elphoton
  • 1
  • 1
0
votes
0 answers

Rails is generating an error when loading Opal Javascript on actual server but not on local test server

I am using Opal to convert Ruby into Javascript on a Rails server, and everything works perfectly on the test server on my local machine in both development and production modes. However, when the files are uploaded to the actual server, an…
Ontonator
  • 319
  • 3
  • 17
0
votes
1 answer

How do I import a JavaScript or JSX based component into React.rb so it is accessible in ruby?

Using the example given for React-Bootstrap and react.rb works perfectly but I am trying to get a NPN component called React-TimeAgo working and I am lost. This is what I have done: In index.js (for Webpack to import it into the webpack…
BarrieH
  • 373
  • 3
  • 11
0
votes
1 answer

How do I tell Rails not to pre-render components?

When using React.rb how do I keep Rails from prerendering the components?
Ken Stipek
  • 1,512
  • 8
  • 12