Sha256: dc1cc6d2e0ed89b9ba19c1581c74e9c371286a8919f502436bd367b5c907fb74
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true module Proscenium class Middleware class Esbuild < Base class CompileError < StandardError attr_reader :detail def initialize(detail) @detail = ActiveSupport::HashWithIndifferentAccess.new(Oj.load(detail, mode: :strict)) super "#{@detail[:text]} in #{@detail[:location][:file]}:#{@detail[:location][:line]}" end end def attempt benchmark :esbuild do render_response build("#{cli} --root #{root} #{path}") end rescue CompileError => e render_response "export default #{e.detail.to_json}" do |response| response['X-Proscenium-Middleware'] = 'Esbuild::CompileError' end end private def path @request.path[1..] end def cli if ENV['PROSCENIUM_TEST'] 'deno run -q --import-map import_map.json -A lib/proscenium/compilers/esbuild.js' else Gem.bin_path 'proscenium', 'esbuild' end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems