Sha256: 933cd48d9987c8819f63a9f898622a7a9895845edc92efa98255c19a0690ea42

Contents?: true

Size: 719 Bytes

Versions: 1

Compression:

Stored size: 719 Bytes

Contents

require_relative "mode"

class CrapMode < Mode
  def write
    notify
    File.write(file_path, process(untar))
  rescue Mode::NoEntryPointError
    puts "\e[31mNo entry point found for file #{@version["name"]}\e[0m"
  end

  private

  def notify
    super

    puts "\e[36mPackage #{@version["name"]} has no module defined and will be written in compatibility mode."
    puts "If that doesn't work, you should consider opening a pull request to add ES module support."
    puts "The package repository is here: #{@version.dig("repository", "url")}\e[0m"
  end

  def process(str)
    %(
      var module = { exports: {} };
      (function(){#{str}}).call(window);
      export default module.exports;
    )
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grundler-0.1.0 lib/grundler/crap_mode.rb