-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scala.js packaging should produce NoModule by default #338
Comments
This better aligns with the defaults users coming from sbt land or going to sbt where Scalajs will default to NoModule. This also allows a JS file produced by package to more easily be incuded in an html file if no further linking is required. Closes VirtusLab#338
I think I went for common-js by default so that the generated files can be run straightaway with As the failing tests in #342 show, no-module creates issues when depending on munit for example, that seems to require file system-related APIs (which it gets via the So I'm shared about making no-module the default. |
Isn't that an MUnit issue (scalameta/munit#114, scalameta/munit#247), which was fixed in scalameta/munit#376, part of v0.7.27? |
I'm actually curious, what is the most common use case, running the created script with node, or trying to include it in a webpage?
Gotcha, for a bit of context I think if someone is trying this out and reading through https://scala-cli.virtuslab.org/docs/guides/scala-js and trying to follow the ScalaJS docs will get tripped up on this. Since they'll probably think that they can just include the generated file in their I have no issue passing |
The scripts generated for NoModule are also supposed to run straightaway with Node.js. This is how they are |
Ahh ok, that's even better then. |
This better aligns with the defaults users coming from sbt land or going to sbt where Scalajs will default to NoModule. This also allows a JS file produced by package to more easily be incuded in an html file if no further linking is required. Closes #338
TL;DR: when packaging scala-cli and scalajs plugin have different defaults:
scala-cli defaults to CommonJS module type:
scala-cli/modules/build/src/main/scala/scala/build/options/ScalaJsOptions.scala
Line 37 in a62e63e
Whereas Scala.js when used as SBT plugin defaults to NoModule: https://github.com/scala-js/scala-js/blob/9f7012281eda7185f64e9c3824cf316f2b761081/linker-interface/shared/src/main/scala/org/scalajs/linker/interface/StandardConfig.scala#L73
Current default means you can't run the packaged script in the browser without altering configuration.
Stems from a Discord discusion
The text was updated successfully, but these errors were encountered: