1
0
Fork 0
mirror of https://github.com/rubyjs/mini_racer synced 2023-03-27 23:21:28 -04:00
mini_racer/examples/source-map-support/renderer.rb

13 lines
445 B
Ruby
Raw Normal View History

require 'mini_racer'
ctx = MiniRacer::Context.new
# Make sure we pass the filename option so source-map-support can map properly
ctx.eval(File.read('./dist/main.js'), filename: 'main.js')
# Expose a function to retrieve the source map
ctx.attach('readSourceMap', proc { |filename| File.read("./dist/#{filename}.map")} )
# This will actually cause the error, and we will have a pretty backtrace!
ctx.eval('this.webpackLib.renderComponent()')