Skip to content

Commit

Permalink
Refactor webpack stats module names in warning and error to optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrdom committed May 14, 2022
1 parent ccdf997 commit 8170f89
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions sbt-scalajs-bundler/src/main/scala/scalajsbundler/Stats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ object Stats {

}

final case class WebpackError(moduleName: String, message: String, loc: String)
final case class WebpackError(moduleName: Option[String], message: String, loc: String)

final case class WebpackWarning(moduleName: String, message: String)
final case class WebpackWarning(moduleName: Option[String], message: String)

final case class WebpackStats(
version: String,
Expand Down Expand Up @@ -115,13 +115,13 @@ object Stats {
)(Asset.apply _)

implicit val errorReads: Reads[WebpackError] = (
(JsPath \ "moduleName").read[String] and
(JsPath \ "moduleName").readNullable[String] and
(JsPath \ "message").read[String] and
(JsPath \ "loc").read[String]
)(WebpackError.apply _)

implicit val warningReads: Reads[WebpackWarning] = (
(JsPath \ "moduleName").read[String] and
(JsPath \ "moduleName").readNullable[String] and
(JsPath \ "message").read[String]
)(WebpackWarning.apply _)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,12 @@ object Webpack {
logger.info("")
// Filtering is a workaround for #111
p.warnings.filterNot(_.message.contains("https://raw.githubusercontent.com")).foreach { warning =>
logger.warn(s"WARNING in ${warning.moduleName}")
logger.warn(s"WARNING${warning.moduleName.map("in "+_).getOrElse("")}")
logger.warn(warning.message)
logger.warn("\n")
}
p.errors.foreach { error =>
logger.error(s"ERROR in ${error.moduleName} ${error.loc}")
logger.error(s"ERROR${error.moduleName.map("in "+_).getOrElse("")} ${error.loc}")
logger.error(error.message)
logger.error("\n")
}
Expand All @@ -277,6 +277,7 @@ object Webpack {
val webpackBin = workingDir / "node_modules" / "webpack" / "bin" / "webpack"
val params = nodeArgs ++ Seq(webpackBin.absolutePath, "--profile", "--json") ++ args
val cmd = "node" +: params
log.debug(s"Running command [${cmd.mkString(" ")}]")
Commands.run(cmd, workingDir, log, jsonOutput(cmd, log))
.fold(
sys.error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package example

object Main {
def main(args: Array[String]): Unit = {
println("yarn-interactive main")
println("webpack-stats main")
}
}

0 comments on commit 8170f89

Please sign in to comment.