Search code examples
npmscala.jsscalajs-bundler

scalajs-bundler: which compiled file should be included in HTML?


I'm trying to handle my JS dependencies with scalajs-bundler for my Scala.js project. It successfully downloads my dependency (d3.js), but I don't know how to include my code and the dependency in my HTML file.

I tried every files I found on target/scala-2.12/ but it didn't work.

  • with target/scala-2.12/*-jsdeps.js it doesn't run my main method.
  • with target/scala-2.12/scalajs-bundler/main/*-fastopt.js I get ReferenceError: exports is not defined in Firefox.

I don't want to use a facade, this is a short-term project and I plan to use js.Dynamic.

A side question: can I still use source maps with scalajs-bundler ?

Thanks.


Solution

  • Ok, the problem was that the final bundle file *-fastopt-bundle.js (the one to include) was missing, and apparently it was because webpack was silently unable to run because npm packages are referring to node (and not nodejs) in their shebang.

    So the solution was to install nodejs-legacy on Ubuntu.