scalajs-bundler icon indicating copy to clipboard operation
scalajs-bundler copied to clipboard

Providing `nodeExecCommand` setting

Open ptrdom opened this issue 3 years ago • 4 comments

This is somewhat related to https://github.com/scalacenter/scalajs-bundler/issues/418 - instead of directly supporting some node version manager, we could expose a setting that would allow users to set a node executable, similar to how sbt-native-packager does it with dockerExecCommand. Then users of scalajs-bundler could wire in for example https://github.com/jasongin/nvs by setting nodeExecCommand to nvs exec <ver>.

How does this sound @sjrd?

ptrdom avatar May 26 '22 17:05 ptrdom

This is something that can be done with a custom NodeJSEnv.Config:

import org.scalajs.jsenv.nodejs.NodeJSEnv

jsEnv := {
  new NodeJSEnv(NodeJSEnv.Config()
    .withExecutable("nvs")
    .withArgs(List("exec", ver)))
}

sjrd avatar May 31 '22 19:05 sjrd

When suggesting this I mainly had interactions with Webpack in mind:

  • https://github.com/scalacenter/scalajs-bundler/blob/d083e6df3fe2ac795ae16ba69696039bf85f85a3/sbt-scalajs-bundler/src/main/scala/scalajsbundler/Webpack.scala#L285
  • https://github.com/scalacenter/scalajs-bundler/blob/d083e6df3fe2ac795ae16ba69696039bf85f85a3/sbt-scalajs-bundler/src/main/scala/scalajsbundler/WebpackDevServer.scala#L54 It is not possible to intercept node executable used for them.

ptrdom avatar May 31 '22 19:05 ptrdom

Wouldn't that be possible to do in user space using #420, then?

sjrd avatar Jun 02 '22 09:06 sjrd

No, because that PR does not expose these bundler related node invocations that I have linked above. New setting is the only way. Do not see a problem here - it is a beneficial change that is easily backwards compatible.

ptrdom avatar Jun 02 '22 17:06 ptrdom