Open ptrdom opened 2 years ago
There is a really old unmerged PR that solves this - https://github.com/scalacenter/scalajs-bundler/pull/408.
@ptrdom I am similarly getting an error due to loc
in WebpackError
being optional as well. I think this was caused by the JS library weeknumber
(1.2.1) having some funny errors with loc
(the line number of the error) missing because I didn't have this happen until I added it as a dependency.
According to the docs, WebPack only mentions message
and refers to all other fields as "various" (does that mean they "vary" in existence and should be optional?):
https://webpack.js.org/api/stats/#errors-and-warnings
My error is resolved with this addition to your PR:
final case class WebpackError(moduleName: Option[String], message: String, loc: Option[String])
@evbo Good eye, I did not spot that in docs. I will implement your suggestion. Maybe adding the stack trace would be a good idea too.
I am currently hitting this issue when upgrading to the new version with webpack 5. Indeed, there are warnings without a moduleName
as already mentioned. Is anything blocking the linked PR?
@cornerman I don't mean to speak for everyone, as I know webpack is still one of the most popular bundlers, but Vite has sort of taken the bundling world by storm! I think many people using Scalajs use Vite, and hence scalajs-bundler might not be getting as much love as it used to.
I know this may be off-topic or counter-productive, but if you can bite the bullet, I migrated to Vite within a day for a fairly large project. And I'm never looking back...
Sjs did an amazing job presenting, so it's a breeze :) https://www.youtube.com/watch?v=dv7fPmgFTNA
I hope this helps...
@evbo Thanks for sharing your good experience with vite and the video. I want to look into vite, but did not find the time yet.
For now updating to webpack 5 seemed a bit faster. My current workaround is using ignoreWarning
in my webpack config.
fullOptJS::webpack
threw the following error for https://github.com/ptrdom/akka-http-slinky-endpoints4s:JSON output was:
Seems like
moduleName
not a mandatory field for warnings in Webpack 5. Relatively simple change. https://github.com/scalacenter/scalajs-bundler/blob/d083e6df3fe2ac795ae16ba69696039bf85f85a3/sbt-scalajs-bundler/src/main/scala/scalajsbundler/Stats.scala#L55