2

I would like to run javascript code in my ruby program. But it is very slow, so I would try to use bun.sh instead of nodejs as a runtime in execjs.

How can I achieve that ?


I tried this:

require 'execjs'
require "execjs/external_runtime"

PATH_TO_JS = File.join(__dir__, "/katex.min.js")
BUN = ExternalRuntime.new(
      name:        "Bun",
      command:     ["bun run"],
      #runner_path: ExecJS.root + "/support/node_runner.js",
      encoding:    'UTF-8'
)
KATEX = BUN.compile(open(PATH_TO_JS).read)

But I got this error:

project.rb:10:in `<top (required)>': uninitialized constant ExternalRuntime (NameError)

Thank you for your help

Jan Černý
  • 1,268
  • 2
  • 17
  • 31

1 Answers1

1

It must be under ExecJS::ExternalRuntime

Steven Barragán
  • 1,144
  • 1
  • 11
  • 21