cool-easter-32542
02/22/2024, 9:41 PMnodejs subsystem or directly into the package_json target.
When using yarn as the package manager, env vars can be very useful because almost all of the yarn settings can be set through env vars prefixed with YARN_, in replacement of having a .yarnrc.yml file.
From yarn docs:
Finally, note that most settings can also be defined through environment variables
(at least for the simpler ones; arrays and objects aren't supported yet).
To do this, just prefix the names and write them in snake case:
YARN_CACHE_FOLDER will set the cache folder (such values will overwrite any
that might have been defined in the RC files - use them sparingly).
https://v3.yarnpkg.com/configuration/yarnrc
Describe the solution you'd like
Allow passing extra env vars either through nodejs subsystem and/or the package_json target.
On pants.toml file:
[nodejs]
package_manager_extra_env_vars={"YARN_NODE_LINKER": "node-modules"}
and/or at the BUILD file:
package_json(
extra_env_vars={"YARN_NODE_LINKER": "node-modules"},
)
Describe alternatives you've considered
Creating a .yarnrc.yml file and using the files target to have this file on sandbox during the yarn install works. It does however require some additional steps to set those yarn settings and also only addresses the yarn package manager.
.yarnrc.yml
nodeLinker: node-modules
BUILD
files(
name="package_config",
sources=[".yarnrc.yml"],
)
package_json(
dependencies=[":package_config"],
)
pantsbuild/pants