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
Ian Ker-Seymer 723958f4da Add example of using source-map-support (#130)
* Add example of using source-map-support

* Address PR comments
2019-03-12 16:03:08 +11:00

12 lines
445 B
Ruby

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()')