Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devCommands is still too strict: It misses ~ #52

Closed
nafg opened this issue Nov 27, 2019 · 7 comments · Fixed by #57
Closed

devCommands is still too strict: It misses ~ #52

nafg opened this issue Nov 27, 2019 · 7 comments · Fixed by #57

Comments

@nafg
Copy link

nafg commented Nov 27, 2019

The fix for #27 is a step in the right direction I suppose, but it still misses one case.

If I do ~myproject/reStart everything is fine because it will split on '/' and get "reStart". However if I do project myproject; ~reStart it doesn't do the right thing because it returns "~reStart" which doesn't match.

@nafg
Copy link
Author

nafg commented Nov 27, 2019

Actually if a command starts with ~ arguably it should trigger dev mode no matter what the command is.

@nafg
Copy link
Author

nafg commented Nov 27, 2019

It would be interesting to have a setting that instead of a list of strings, was a function that could examine the current command and use its own logic.

@nafg
Copy link
Author

nafg commented Nov 27, 2019

Weirdly, if I have Global / onChangedBuildSource := ReloadOnSourceChanges and I run sbt ~myproject/reStart, at first webscalajs.CrossSbtUtils.executedCommandKey.value returns reStart but after changing a build file, causing sbt to reload, it returns ~.

(sbt 1.3.4)

@vmunier
Copy link
Owner

vmunier commented Dec 15, 2019

Hi,

It would be interesting to have a setting that instead of a list of strings, was a function that could examine the current command and use its own logic.

Agreed, such a setting would be useful. At the moment, you can configure isDevMode in scalaJSPipeline and provide your own logic. You could read from an environment variable for instance: isDevMode in scalaJSPipeline := !sys.env.get("SCALAJS_PROD").contains("true")

I think parsing the SBT command line to know whether fastOptJS or fullOptJS should be run is too fragile. As you pointed out, there are cases that are not handled well: the current parsing code fails to detect ~reStart or project myproject; reStart as dev commands.

state.value.history.currentOption.flatMap(_.commandLine.takeWhile(c => !c.isWhitespace).split(Array('/', ':')).lastOption).getOrElse("")

I am thinking of removing devCommands completely and let the user define an environment variable or SBT setting to configure the build on whether fastOpsJS (default) or fullOptJS should be run.
That would be a breaking change and it's forcing the user to reload SBT to be able to switch between fastOpsJS or fullOptJS, but the behaviour is more predictable.

@sjrd
Copy link
Contributor

sjrd commented Dec 15, 2019

or SBT setting to configure the build on whether fastOpsJS (default) or fullOptJS should be run.

Also known as scalaJSStage, defined in the core sbt-scalajs. 😉

@vmunier
Copy link
Owner

vmunier commented Apr 26, 2020

Hi everyone, I've just opened a PR, which uses the scalaJSStage setting from the Scala.js projects to know whether to run fastOptJS or fullOptJS: #57. Any feedback welcome!

@vmunier vmunier mentioned this issue Jun 2, 2020
@vmunier
Copy link
Owner

vmunier commented Jun 2, 2020

sbt-web-scalajs v1.1.0 now relies on scalaJSStage to know whether fastOptJS or fullOptJS should be run.

@vmunier vmunier closed this as completed Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants