feat: granular --unstable-* flags (#20968)

This commit adds granular `--unstable-*` flags:
- "--unstable-broadcast-channel"
- "--unstable-ffi"
- "--unstable-fs"
- "--unstable-http"
- "--unstable-kv"
- "--unstable-net"
- "--unstable-worker-options"
- "--unstable-cron"

These flags are meant to replace a "catch-all" flag - "--unstable", that
gives a binary control whether unstable features are enabled or not. The
downside of this flag that allowing eg. Deno KV API also enables the FFI
API (though the latter is still gated with a permission).

These flags can also be specified in `deno.json` file under `unstable`
key.

Currently, "--unstable" flag works the same way - I will open a follow
up PR that will print a warning when using "--unstable" and suggest to use
concrete "--unstable-*" flag instead. We plan to phase out "--unstable"
completely in Deno 2.
This commit is contained in:
Bartek Iwańczuk 2023-11-01 23:15:08 +01:00 committed by GitHub
parent 42c426e769
commit 24c3c96958
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 266 additions and 27 deletions

View file

@ -723,7 +723,14 @@ impl CliOptions {
}
pub fn ts_type_lib_window(&self) -> TsTypeLib {
if self.flags.unstable {
if self.flags.unstable
|| !self.flags.unstable_features.is_empty()
|| self
.maybe_config_file
.as_ref()
.map(|f| !f.json.unstable.is_empty())
.unwrap_or(false)
{
TsTypeLib::UnstableDenoWindow
} else {
TsTypeLib::DenoWindow
@ -1264,6 +1271,17 @@ impl CliOptions {
.unwrap_or(false)
}
pub fn unstable_features(&self) -> Vec<String> {
let mut from_config_file = self
.maybe_config_file()
.as_ref()
.map(|c| c.json.unstable.clone())
.unwrap_or_default();
from_config_file.extend_from_slice(&self.flags.unstable_features);
from_config_file
}
pub fn v8_flags(&self) -> &Vec<String> {
&self.flags.v8_flags
}