scalacenter / scalajs-bundler

https://scalacenter.github.io/scalajs-bundler
Other
236 stars 101 forks source link

What is the significance of stats failing and how to prevent? #338

Closed evbo closed 2 years ago

evbo commented 4 years ago

Webpack appears to correctly build an electron app that I can run with electron, but at the very end I see the message:

[info] Writing scalajs.webpack.config.js
[error] Error parsing webpack stats output
[error] /assets: JsonValidationError(List(error.path.missing),WrappedArray())
[error] /time: JsonValidationError(List(error.path.missing),WrappedArray())

I see in the change log this is expected if any std output gets generated: https://github.com/scalacenter/scalajs-bundler/blob/08cd66ba26716301c09cae5853b42a7cc31e1c05/manual/src/ornate/changelog.md

So is it a concern? Any thoughts on how I can silence std output to avoid this error?

cquiroz commented 4 years ago

the plugin will read the stats produced by webpack to identify the assets it built. The error maybe an indication that the format changed. What version of webpack are you using?

evbo commented 4 years ago

Sorry should have included that:

Plugins: addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.1") addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.17.0")

Settings: version in webpack := "4.39.1", version in startWebpackDevServer := "3.7.2",

I also just tried these versions and I get the same error:

version in webpack := "4.43.0", version in startWebpackDevServer := "3.11.0",

thanks for the quick response. Just to clearly emphasize, this is only an issue for electron, whereby the best practice (no official documentation on this that I could find) seems to be configuring a multi-compiler like so: https://github.com/tarunlalwani/electron-webpack-typescript-boilerplate/blob/master/webpack.config.js https://www.sitepen.com/blog/getting-started-with-electron-typescript-react-and-webpack/

If I just make a conventional config, an object not an array of objects, I do not see any errors.

evbo commented 3 years ago

Any ideas how to debug this issue? One unfortunate side effect is that the exit code causes jenkins builds to fail even though the build is actually successful.

Thanks

evbo commented 3 years ago

Here's an example of it failing (now with bundler: 0.20.0 and same webpack as before). Even though I had a legitimate error with a JSImport referencing a ".conf" file that should have been a ".json" file, the error seems to be getting swallowed by this instead (no errors were shown prior in the build):

[info] Thanks for using Webpack! [info] Please consider donating to our Open Collective [info] to help us maintain this package. [info] Donate: https://opencollective.com/webpack/donate [error] npm notice created a lockfile as package-lock.json. You should commit this file. [error] npm WARN optional SKIPPING OPTIONAL DEPENDENCY: dmg-license@^1.0.8 (node_modules/dmg-builder/node_modules/dmg-license): [error] npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for dmg-license@1.0.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) [error] npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/chokidar/node_modules/fsevents): [error] npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) [error] npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/watchpack-chokidar2/node_modules/chokidar/node_modules/fsevents): [error] npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) [error] npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/webpack-dev-server/node_modules/chokidar/node_modules/fsevents): [error] npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) [error] npm WARN optional SKIPPING OPTIONAL DEPENDENCY: iconv-corefoundation@^1.1.6 (node_modules/dmg-license/node_modules/iconv-corefoundation): [error] npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for iconv-corefoundation@1.1.6: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) [error] npm WARN stylis-rule-sheet@0.0.10 requires a peer of stylis@^3.5.0 but none is installed. You must install peer dependencies yourself. [info] added 1336 packages from 783 contributors and audited 1346 packages in 245.049s [info] 99 packages are looking for funding [info] run npm fund for details [info] found 5 vulnerabilities (2 low, 2 moderate, 1 high) [info] run npm audit fix to fix them, or npm audit for details [info] Writing scalajs.webpack.config.js [info] Bundling the application with its NPM dependencies [error] Error parsing webpack stats output [error] /assets: JsonValidationError(List(error.path.missing),WrappedArray()) [error] /time: JsonValidationError(List(error.path.missing),WrappedArray()) [error] java.lang.RuntimeException: Non-zero exit code: 2 [error] at scala.sys.package$.error(package.scala:30) [error] at scalajsbundler.Webpack$.$anonfun$run$2(Webpack.scala:295) [error] at scala.util.Either.fold(Either.scala:192) [error] at scalajsbundler.Webpack$.run(Webpack.scala:295) [error] at scalajsbundler.Webpack$.bundle(Webpack.scala:189) [error] at scalajsbundler.sbtplugin.WebpackTasks$.$anonfun$webpack$2(WebpackTasks.scala:52) [error] at sbt.util.FileFunction$.$anonfun$cached$1(FileFunction.scala:80) [error] at sbt.util.FileFunction$.$anonfun$cached$4(FileFunction.scala:153) [error] at sbt.util.Difference.apply(Tracked.scala:414) [error] at sbt.util.Difference.apply(Tracked.scala:394) [error] at sbt.util.FileFunction$.$anonfun$cached$3(FileFunction.scala:149) [error] at sbt.util.Difference.apply(Tracked.scala:414) [error] at sbt.util.Difference.apply(Tracked.scala:389) [error] at sbt.util.FileFunction$.$anonfun$cached$2(FileFunction.scala:148) [error] at scalajsbundler.sbtplugin.WebpackTasks$.$anonfun$webpack$1(WebpackTasks.scala:55) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:49) [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62) [error] at sbt.std.Transform$$anon$4.work(Transform.scala:68) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:282) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23) [error] at sbt.Execute.work(Execute.scala:291) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:282) [error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265) [error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:64) [error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [error] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [error] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [error] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [error] at java.base/java.lang.Thread.run(Thread.java:834) [error] (client / Compile / fullOptJS / webpack) Non-zero exit code: 2 [error] Total time: 322 s (05:22), completed Jul 5, 2021, 11:27:36 PM

evbo commented 3 years ago

as a debugging tool, running webpack manually will at least show the true underlying issue.

(cd client/target/scala-2.13/scalajs-bundler/main/ && node node_modules/webpack/bin/webpack --bail --profile --config webpack-fullopt.config.js)

So this could very well be a bug with scalajs bundler handling stats output incorrectly

evbo commented 2 years ago

This appears to be a duplicate of: https://github.com/scalacenter/scalajs-bundler/pull/408