scalacenter / scalajs-bundler

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

installJsdom may installs jsdom outside of the target directory #416

Open unarist opened 2 years ago

unarist commented 2 years ago

installJsdom seems to install jsdom into target.value / "scalajs-bundler-jsdom". https://github.com/scalacenter/scalajs-bundler/blob/716c9213b339f97dc384404cb4e269656965a83e/sbt-scalajs-bundler/src/main/scala/scalajsbundler/sbtplugin/ScalaJSBundlerPlugin.scala#L606-L608

However, it may install into other directory if:

This behavior unexpectedly edits other file which is not related to Scala project. Also, simultaneous installJsdom execution from sbt projects sometimes fails due to writing same node_modules directory.

For a workaround, I'm thinking about overriding installJsdom task.

Reproducing steps

  1. Prepare sbt project with following files
  2. Run npm init -y to create empty package.json
  3. Run sbt test
  4. ... then I expected there is no node_modules directory in the root directory, but it exists

/project/plugins.sbt

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0")

/build.sbt

scalaVersion := "2.12.11"
enablePlugins(ScalaJSBundlerPlugin)
Test / requireJsDomEnv := true