Sha256: 3baf79219839431594604a45eaac940d927b36ffcd29c1d599a47fa8786cb5b9

Contents?: true

Size: 915 Bytes

Versions: 5

Compression:

Stored size: 915 Bytes

Contents

module Kernel
  module_function

  # We cannot decorate with prepend + super because Kernel has already been
  # included in Object, and changes in ancestors don't get propagated into
  # already existing ancestor chains.
  alias_method :zeitwerk_original_require, :require

  # @param path [String]
  # @return [Boolean]
  def require(path)
    if loader = Zeitwerk::Registry.loader_for(path)
      if `Opal.modules.hasOwnProperty(path)`
        zeitwerk_original_require(path).tap do |required|
          loader.on_file_autoloaded(path) if required
        end
      else
        loader.on_dir_autoloaded(path)
      end
    else
      zeitwerk_original_require(path).tap do |required|
        if required
          realpath = $LOADED_FEATURES.last
          if loader = Zeitwerk::Registry.loader_for(realpath)
            loader.on_file_autoloaded(realpath)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opal-zeitwerk-0.2.2 opal/zeitwerk/kernel.rb
opal-zeitwerk-0.2.1 opal/zeitwerk/kernel.rb
opal-zeitwerk-0.2.0 opal/zeitwerk/kernel.rb
opal-zeitwerk-0.1.0 opal/zeitwerk/kernel.rb
opal-zeitwerk-0.0.4 opal/zeitwerk/kernel.rb