Bug: load
cannot be invoked on a path unless require
has been called on it first
#2629
Labels
load
cannot be invoked on a path unless require
has been called on it first
#2629
Describe the bug
I cannot use
load
to load files from a gem unless I have calledrequire
on them first. This differs from Ruby behavior where I can callload
on any Ruby file the first time.Opal version: 1.8.2
To Reproduce
Code like this does not work if the file hasn't been required.
For example, if I replace the contents of this file https://github.com/AndyObtiva/sample-glimmer-dsl-web-rails7-app/blob/master/app/assets/opal/sample_selector.rb with the code below, it does not work:
It fails with an error:
If I do this, it works:
Like updating the example above with this code:
This breaks Ruby expectations because in Ruby, I can load a file the very first time without having required the file first. This enables me to build an app that dynamically loads files based on user choices. I use this approach in desktop sample runner apps, and I tried using the same approach in this Opal app: https://github.com/AndyObtiva/sample-glimmer-dsl-web-rails7-app . Right now, because of the error I get, I am forced to track if a file has been required first, and if not required, then I call
require
the first time. Afterwards, I callload
on subsequent times.I think this needs to be fixed to give us the same behavior we expect from Ruby.
The text was updated successfully, but these errors were encountered: