-
-
Notifications
You must be signed in to change notification settings - Fork 360
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 forkWorkingDir
in ScalaJSModule
(run
, test
, ...)
#1036
Comments
Mill supports changing the working directory for forked tests and in general forked runs. This is controlled via the |
forkWorkingDir
in ScalaJSModule (run
, test
, ...)
forkWorkingDir
in ScalaJSModule (run
, test
, ...)forkWorkingDir
in ScalaJSModule
(run
, test
, ...)
My first approach to solve #2144 was to create a `Custom` `JsEnvConfig` which would take a `className` 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](https://github.com/exoego/scala-js-env-jsdom-nodejs)'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 it manually in scratch but I needed to have a global `package.json` Pull request: #2147
I can send a PR if I'm told how to do it |
I think, you need to add a working dir parameter to |
I started writing a longer comment but tldr this requires a breaking change to scalajs-js-envs. But I just realized that it may not be necessary for my use case. The original problem was how to get Node to use a generated But I realized that I was probably doing it wrong, setting it to the directory containing So maybe I can get ScalaJS tests to run without bundling that way. |
Can you elaborate on this? Why needs it a change in an upstream dependency? This issue is about defining the working (or start) directory of the node.js process. Everything else seems unrelated to this issue.
The motivation is to have two modules which for whatever reasons should not share the same node.js setup. So instead of the project root directory ( |
Because Mill doesn't actually call Node itself. That's the responsibility of the JSEnv. Here is some of the longer reply I was writing:
|
That seems to have worked! nafg/mill-bundler#2 |
Interesting. As JsEnv seem to be designed around the idea to keep some "global state" of the JS environment in the current running JVM, we probably need to spawn a new JVM process from the new working directory, and call the JsEnv API from this process. |
Working with multiple node.js subprojects, it is needed to have different installation directories that carry their own
node_modules
folder.Currently it is not possible to change set the pwd for a subproject, so tests always run by using the root project directory as pwd.
This is probably something that can be useful on a more general level than the
ScalaJSModule
since it can be useful for Scala and Java projects too.The text was updated successfully, but these errors were encountered: