Closed edmellum closed 3 years ago
Hi @edmellum.
Thank you for the contribution!
Regarding the environment variable, do you know how this interacts with Cargo for the non-web parts of the workspace? For example, if the workspace has other crates being built in parallel while the bundler is running, I'm worried that changing the environment variable might change the target directory Cargo uses for those other crates.
The previous approach spawned a new process with Command
, so conveniently the environment variables were scoped only to that process. I suspect that Cargo is going to run our build.rs script in its own process so it could be fine, but I haven't found any docs confirming this. Do you maybe have any insights on this, and any knock on effects we should be aware of?
Cheers, Justin
Thanks for the great review, I appreciate it a lot! 😄
Considering build.rs is compiled into its own executable and specifically given certain environment variables, I don't think anything is allowed to leak.
I've taken a cursory glance at the cargo source starting at where I believe the custom build script executable is built into a Command to run and it looks to me like there should be no leakage, although there is a bit of code between std::process::Command and where the build script executable is run, following it isn't too hard and I didn't spot anything strange.
Fixes #1
I tried using
extra_options
to pass--target-dir
to cargo but it fails with wasm_bindgen which is why the environment variable is set.