Skip to content

Commit 7899c1e

Browse files
committed
Add logging for implicit Wasm behaviors; rebase on upstream main
- Log when --experimental-wasm-exnref is injected in runJs (Node.js < 25) - Log when Wasm mode enables ES module output in Run.scala - Improve comment in Wasm.scala directive to reference AmbiguousPlatformError for --wasm + --platform native conflict detection
1 parent 4799827 commit 7899c1e

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

  • modules
    • build/src/main/scala/scala/build/internal
    • cli/src/main/scala/scala/cli/commands/run
    • directives/src/main/scala/scala/build/preprocessing/directives

modules/build/src/main/scala/scala/build/internal/Runner.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ object Runner {
283283
.map(_.toString)
284284
.toRight(NodeNotFoundError()))
285285
val nodeFlags = if (emitWasm && nodeNeedsWasmFlag) List("--experimental-wasm-exnref") else Nil
286+
if (emitWasm && nodeFlags.nonEmpty)
287+
logger.log(
288+
s"Wasm: adding ${nodeFlags.mkString(" ")} (required for Wasm exception handling on Node.js < 25)"
289+
)
286290
if !jsDom && allowExecve && Execve.available() then {
287291
val command = Seq(nodePath) ++ nodeFlags ++ Seq(entrypoint.getAbsolutePath) ++ args
288292

modules/cli/src/main/scala/scala/cli/commands/run/Run.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ object Run extends ScalaCommand[RunOptions] with BuildCommandHelpers {
480480
if jsOpts.jsEmitWasm then {
481481
val runtime = jsOpts.wasmRuntime
482482
val esModule = true // Wasm backend uses ES modules
483+
logger.log("Wasm mode enabled: using ES module output on JS platform")
483484
scratchDirOpt.foreach(os.makeDir.all(_))
484485
val jsDest = os.temp(
485486
dir = scratchDirOpt.orNull,

modules/directives/src/main/scala/scala/build/preprocessing/directives/Wasm.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ final case class Wasm(
3737
}
3838
parsedRuntime.map { runtime =>
3939
val wasmEnabled = wasm.getOrElse(false) || wasmRuntime.isDefined
40-
// When Wasm is enabled, force Platform.JS (Scala.js Wasm backend requires JS compilation)
40+
// Scala.js Wasm backend requires JS platform. When --platform native is also
41+
// specified alongside --wasm, an AmbiguousPlatformError is raised in platform resolution.
4142
val scalaOptions =
4243
if (wasmEnabled)
4344
ScalaOptions(platform = Some(Positioned.none(Platform.JS)))

0 commit comments

Comments
 (0)