-
-
Notifications
You must be signed in to change notification settings - Fork 347
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
Support exoego fork of JsDom JsEnv #2147
Conversation
Thank so much! I think @sjrd mentioned that there's a jsenv for using selenium. And in some ticket it was implied that users writing their own jsenv was a normal use case. |
Supporting custom jsEnvs is harder and the only solution I have at the moment is clunky, which makes me prefer to support them in the core repository. |
I've just noticed the scala-js-env-selenium which EDIT: The selenium jsEnv has multiple parameters and it's not as easy as I thought to support. So I will not add it to this PR. |
@@ -50,6 +50,21 @@ trait ScalaJSModule extends scalalib.ScalaModule { outer => | |||
) | |||
} | |||
|
|||
def scalaJSJsEnvIvyDeps: Target[Agg[Dep]] = T { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very happy with this change which will speed up downloading dependencies in Scala.js builds, since now Mill downloads only the dependency you need instead of downloading all of them :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one. I like that change too.
Would it be possible to add an additional Custom
config, which requires the user to define the dependency as well as the executable and the parameters? That way, we don't need to change whenever a user wants to play with a new JsEnv
. It might be not as safe, tested and convenient as the supported types, but also don't stand in the way.
I tried but the problem is that |
This means we need to provide some factory function which is actually creating the Here is an idea. Maybe, we can delegate to some factory on the freshly build classpath. E.g. the user implements an factory ( In Mill, we then need the correct dependency and the class name of the factory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I'll merge as is. Thank you!
Potential generic support for other JsEnv
s can be discussed and implemented independently.
My first approach to solve #2144 was to create a
Custom
JsEnvConfig
which would take aclassName
and then the implementation would instantiate that class with java reflection. It worked fine but didn't support parameters or builders used by the JsEnv to create itself.Since there aren't many custom
JsEnv
s out there (the only one I know is exoego's fork of jsdom-nodejs, I'm proposing of supporting it officially in Mill.This PR also changes the worker classpath to only download and load the jsEnv dependencies that are needed. This skips downloading artifacts and loading classes for jsEnvs that aren't used, like this new one for people not using it, or the deprecated phantom jsEnv.
Testing this properly means installing
jsdom
which can only be done in the root because of #1036 (to my understanding). I tested in manually in scratch but I needed to have a globalpackage.json