feat(unstable): add DENO_NODE_CONDITIONS env var (#29848)
Some checks are pending
ci / build libs (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions

Follow up to https://github.com/denoland/deno/pull/29586 that
adds a `DENO_NODE_CONDITIONS` env var that allows to
specify conditional exports when the user can't control
CLI flags passed to the command (eg. on Deploy).
This commit is contained in:
Bartek Iwańczuk 2025-06-25 09:16:11 +02:00 committed by GitHub
parent 864a6f5774
commit bff09506bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 0 deletions

View file

@ -4577,6 +4577,7 @@ fn lock_args() -> [Arg; 3] {
fn node_conditions_arg() -> Arg {
Arg::new("unstable-node-conditions")
.long("unstable-node-conditions")
.help("Use this argument to specify custom conditions for npm package exports. You can also use DENO_NODE_CONDITIONS env var.")
.use_value_delimiter(true)
.action(ArgAction::Append)
}

View file

@ -548,6 +548,14 @@ fn resolve_flags_and_init(
load_env_variables_from_env_file(flags.env_file.as_ref(), flags.log_level);
flags.unstable_config.fill_with_env();
if flags.node_conditions.is_empty() {
if let Ok(conditions) = std::env::var("DENO_NODE_CONDITIONS") {
flags.node_conditions = conditions
.split(",")
.map(|c| c.trim().to_string())
.collect();
}
}
let otel_config = flags.otel_config();
init_logging(flags.log_level, Some(otel_config.clone()));

View file

@ -13,6 +13,14 @@
"args": "run --unstable-node-conditions react-server -A main.js",
"output": "condition.out",
"exitCode": 1
},
{
"args": "run -A main.js",
"envs": {
"DENO_NODE_CONDITIONS": "react-server"
},
"output": "condition.out",
"exitCode": 1
}
]
}