File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
sbt-plugin/src/main/scala/org/scalajs/sbtplugin Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -366,6 +366,26 @@ private[sbtplugin] object ScalaJSPluginInternal {
366366 val classpath = Attributed .data(fullClasspath.value)
367367 val log = streams.value.log
368368 val tlog = sbtLogger2ToolsLogger(log)
369+ val config = configuration.value.name
370+
371+ /* #4610 Warn if `-Xplugin:scalajs-compiler.jar` (Scala 2) or
372+ * `-scalajs` (Scala 3) is missing from the `scalacOptions`.
373+ * This feature is not automatically tested.
374+ */
375+ def warnMissingScalacOption (thingMissing : String ): Unit = {
376+ log.warn(
377+ s " $thingMissing was missing from ` $config / scalacOptions`, but it is required to produce Scala.js IR. " )
378+ log.warn(" Linking, running and/or testing will probably go wrong." )
379+ log.warn(" The most likely cause is that you used `scalacOptions := ...` instead of using `++=`." )
380+ }
381+ val scalacOpts = scalacOptions.value
382+ if (scalaVersion.value.startsWith(" 2." )) {
383+ if (! scalacOpts.exists(opt => opt.startsWith(" -Xplugin:" ) && opt.contains(" scalajs-compiler" )))
384+ warnMissingScalacOption(" The `scalajs-compiler.jar` compiler plugin" )
385+ } else {
386+ if (! scalacOpts.contains(" -scalajs" ))
387+ warnMissingScalacOption(" The `-scalajs` flag" )
388+ }
369389
370390 val (irFiles, paths) = enhanceIRVersionNotSupportedException {
371391 tlog.time(" Update IR cache" ) {
You can’t perform that action at this time.
0 commit comments