Sha256: df3a2f279e691a6ebb3d94f1bca4b1095dc071da2fc1c764fe6a708b794e9a04
Contents?: true
Size: 1.06 KB
Versions: 6
Compression:
Stored size: 1.06 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' ].join(' ') else Gem.bin_path 'proscenium', 'esbuild' end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems