# frozen_string_literal: true module SewingKit module Webpack class Manifest class Base def initialize @metadata = nil end # :nodoc: def asset_dependencies(entrypoint_name) metadata['entrypoints'][entrypoint_name] end def clear_cache! @metadata = nil end def manifest metadata['assets'] end def load_metadata_from_node begin stdout, * = Open3.capture3('node_modules/.bin/sewing-kit', 'manifest', "--mode=#{mode}") rescue => e raise NodeSewingKitNotRunnable.new(mode, e) end begin JSON.parse(stdout) rescue => e raise ManifestParseError, e end end protected def mode ENV['NODE_ENV'] || Rails.env.to_s || 'production' end end end end end