LoginSignup
0
0

More than 1 year has passed since last update.

Opal::Builder を使ってコンパイルする際に source map も生成する

Last updated at Posted at 2022-05-04

cli_runners/compiler.rb を参考にしました。Opal のバージョンは v1.5.0 です。

require "opal"

builder = Opal::Builder.new
builder.build("./sample.rb")
compiled_source = builder.to_s
compiled_source += "\n" + builder.source_map.to_data_uri_comment

File.write("sample.js", compiled_source)

ちなみに、 opal コマンドを使って opal -c sample.rb のようにコンパイルした場合はデフォルトで source map を生成してくれます( --no-source-map オプションで無効化できる)。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0