scalacenter / scalajs-bundler

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

scalajs-bundler does not respect ^x.y.z in version of webpack #285

Open exoego opened 5 years ago

exoego commented 5 years ago

scalajs-bundler supports npm version syntax (e.g. ^x.y.z) in npm*Dependencies like

# This works
npmDevDependencies in Compile ++= Seq(
    "terser-webpack-plugin" -> "^1.2.1",
    "webpack-merge" -> "^4.2.1",
)

scalajs-bundler has a configuration to set webpack and webpack-dev-server versions like

# This works
version in webpack := "4.29.3",
version in startWebpackDevServer := "3.1.14",

However, it raises error if npm version syntax ^x.y.z used.

# This does not work...
version in webpack := "^4.29.3",
version in startWebpackDevServer := "^3.1.14",

with the following error stack trace

[error] java.lang.RuntimeException: No webpack version defined
[error]     at scala.sys.package$.error(package.scala:26)
[error]     at scalajsbundler.PackageJson$.write(PackageJson.scala:49)
[error]     at scalajsbundler.sbtplugin.PackageJsonTasks$.$anonfun$writePackageJson$2(PackageJsonTasks.scala:66)
[error]     at scalajsbundler.util.Caching$.cached(Caching.scala:15)
[error]     at scalajsbundler.sbtplugin.PackageJsonTasks$.writePackageJson(PackageJsonTasks.scala:54)
[error]     at scalajsbundler.sbtplugin.ScalaJSBundlerPlugin$.$anonfun$perConfigSettings$8(ScalaJSBundlerPlugin.scala:657)
[error]     at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error]     at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error]     at sbt.std.Transform$$anon$4.work(System.scala:67)
[error]     at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error]     at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]     at sbt.Execute.work(Execute.scala:278)
[error]     at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error]     at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error]     at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error]     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]     at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
[error]     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
[error]     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error]     at java.base/java.lang.Thread.run(Thread.java:844)
[error] (server / Compile / scalaJSBundlerPackageJson) No webpack version defined

Since webpack and webpack-dev-server is resolved by npm, I think it is better scalajs-bundler also support npm version syntax.