scalacenter / scalajs-bundler

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

Don't enable ScalaJSWeb #288

Closed Atry closed 5 years ago

Atry commented 5 years ago

ScalaJSWeb plug-in will create a source mapping to hash path source file (https://github.com/vmunier/sbt-web-scalajs/blob/1e48af8b505867e12cfcfd212cf4180c87c82ca9/src/main/scala/webscalajs/ScalaJSWeb.scala#L23). Unfortunately, the source file is copied to target/web/public/main instead of client/target/scala-2.12/scalajs-bundler/main, which is not accessible from "source-map-loader".

As a result, a warning of NonErrorEmittedError will be thrown by webpack.

We should disable ScalaJSWeb to avoid the warning.

julienrf commented 5 years ago

This is not the right way to fix the problem. The ScalaJSWeb plugin is used to make the bundle available as an sbt-web asset. If the current implementation doesn’t work correctly we should fix it, but not remove the feature.

Atry commented 5 years ago

The ScalaJSWeb plugin is used to make the bundle available as an sbt-web asset.

Not really. What is used to make sbt-web an asset is WebScalaJS, not ScalaJSWeb. The only feature of ScalaJSWeb is setting-up source mapping, which conflicts with scalajs-bundler.

julienrf commented 5 years ago

Oh, I see. But disabling ScalaJSWeb means that source maps won’t work anymore… We should check if it is possible to get everything working.

Atry commented 5 years ago

But disabling ScalaJSWeb means that source maps won’t work anymore…

In fact the source mapping file is generated properly as long as ScalaJSWeb is disabled.

julienrf commented 5 years ago

Interesting, thanks for the investigation. Could you add a sentence about that (the docs currently say to follow the “normal” installation instructions of scalajs-web)? And also can you fix the other places where the ScalaJSWeb plugin is used?

Atry commented 5 years ago

Tests are updated in another PR https://github.com/scalacenter/scalajs-bundler/pull/289

julienrf commented 5 years ago

Thanks!

Atry commented 5 years ago

Another workaround for conflicts between ScalaJSWeb and ScalaJSBundlerPlugin is to set webpackBundlingMode := BundlingMode.LibraryOnly(), since ScalaJSBundlerPlugin does not change Scala.js source mapping in LibraryOnly mode.