Skip to content

Commit f692f19

Browse files
committed
Fix DENO_V8_FLAGS override and add warning for --js-module-kind + Wasm
- runDeno: append --experimental-wasm-exnref to existing DENO_V8_FLAGS instead of silently replacing user-defined flags; log when flag is set - ScalaJsOptions.linkerConfig: warn when Wasm overrides user-specified --js-module-kind (forced to ESModule by Wasm backend)
1 parent 82e5136 commit f692f19

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,18 @@ object Runner {
367367
.map(_.toString)
368368
.toRight(DenoNotFoundError()))
369369
val denoFlags = Seq("run", "--allow-read")
370+
val wasmFlag = "--experimental-wasm-exnref"
370371
val extraEnv =
371-
if (emitWasm && denoNeedsWasmFlag) Map("DENO_V8_FLAGS" -> "--experimental-wasm-exnref")
372-
else Map.empty
372+
if (emitWasm && denoNeedsWasmFlag) {
373+
// Append to any existing DENO_V8_FLAGS rather than replacing them.
374+
val existing = sys.env.get("DENO_V8_FLAGS").filter(_.nonEmpty)
375+
val merged = existing.fold(wasmFlag)(f => s"$f $wasmFlag")
376+
logger.log(
377+
s"Wasm: setting DENO_V8_FLAGS=$merged (required for Wasm exception handling)"
378+
)
379+
Map("DENO_V8_FLAGS" -> merged)
380+
}
381+
else Map.empty[String, String]
373382

374383
if (allowExecve && Execve.available()) {
375384
val command = Seq(denoPath) ++ denoFlags ++ Seq(entrypoint.getAbsolutePath) ++ args

modules/options/src/main/scala/scala/build/options/ScalaJsOptions.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ final case class ScalaJsOptions(
155155
esVersion = esVersion(logger)
156156
)
157157

158+
if (jsEmitWasm && moduleKindStr.isDefined)
159+
logger.message(
160+
s"[${Console.YELLOW}warn${Console.RESET}] Wasm mode forces ES module output; --js-module-kind is ignored"
161+
)
158162
ScalaJsLinkerConfig(
159163
moduleKind =
160164
if (jsEmitWasm) ScalaJsLinkerConfig.ModuleKind.ESModule else moduleKind(logger),

0 commit comments

Comments
 (0)