Is there any standard way to use Scala.js application as a libriary in CommonJS environment? And if not, can I patch generated js file for that purpose?
Put this in your build file:
scalaJSModuleKind := ModuleKind.CommonJSModule
Put this in your build file (explanation see below):
scalaJSOutputWrapper := ("var __ScalaJSEnv = { exportsNamespace: exports };", "")
You can tell Scala.js where to send the stuff it exports. To make a CommonJS module, simply prepend this:
var __ScalaJSEnv = {
exportsNamespace: exports
};
to the .js
file produced by fastOptJS
/fullOptJS
.
Please upgrade :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With