lib/es6_tilt.rb in es6_tilt-0.0.7 vs lib/es6_tilt.rb in es6_tilt-0.1.0

- old
+ new

@@ -1,18 +1,27 @@ require 'tilt' -require 'babel/transpiler' require 'sprockets' +require 'tempfile' module ES6Tilt class ES6Transformer< Tilt::Template self.default_mime_type = 'application/javascript' def prepare end def evaluate(scope, locals, &block) - output = Babel::Transpiler.transform(data) - output["code"] + + location = File.dirname(file) + compacted = Tempfile.new('compacted', location) + + `#{Rails.root.join('node_modules','.bin')}/rollup -f iife --no-indent -c #{Rails.root}/rollup.config.js -n #{File.basename(file).camelize} -- #{file} > #{compacted.path}` + + output = compacted.read + + compacted.close + compacted.unlink + output end end end Sprockets.register_engine('.es6', ES6Tilt::ES6Transformer)